File tree 2 files changed +22
-0
lines changed
librustc/middle/typeck/check
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -318,6 +318,9 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
318
318
for field in fields. iter ( ) {
319
319
match field_map. find_mut ( & field. ident . name ) {
320
320
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 ( ) ) ;
321
324
tcx. sess . span_err ( span,
322
325
format ! ( "field `{}` bound twice in pattern" ,
323
326
token:: get_ident( field. ident) ) . as_slice ( ) ) ;
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments