Skip to content

Commit 287dcb7

Browse files
committed
auto merge of #15262 : zecozephyr/rust/15620, r=luqmana
Fixes #15260
2 parents 2735c7b + 6821a18 commit 287dcb7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/librustc/middle/typeck/check/_match.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
318318
for field in fields.iter() {
319319
match field_map.find_mut(&field.ident.name) {
320320
Some(&(_, true)) => {
321+
// Check the pattern anyway, so that attempts to look
322+
// up its type won't fail
323+
check_pat(pcx, &*field.pat, ty::mk_err());
321324
tcx.sess.span_err(span,
322325
format!("field `{}` bound twice in pattern",
323326
token::get_ident(field.ident)).as_slice());

src/test/compile-fail/issue-15260.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo {
12+
a: uint,
13+
}
14+
15+
fn main(){
16+
let Foo {a: _, a: _} = Foo {a: 29};
17+
//~^ ERROR field `a` bound twice in pattern
18+
}
19+

0 commit comments

Comments
 (0)