File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -3846,6 +3846,27 @@ impl Resolver {
3846
3846
generics: & Generics ,
3847
3847
fields: & [ @struct_field] ,
3848
3848
visitor: ResolveVisitor ) {
3849
+ let mut ident_map = HashMap :: new:: < ast:: ident , @struct_field > ( ) ;
3850
+ for fields. iter( ) . advance |& field| {
3851
+ match field. node. kind {
3852
+ named_field( ident, _) => {
3853
+ match ident_map. find( & ident) {
3854
+ Some ( & prev_field) => {
3855
+ let ident_str = self . session. str_of( ident) ;
3856
+ self . session. span_err( field. span,
3857
+ fmt ! ( "field `%s` is already declared" , ident_str) ) ;
3858
+ self . session. span_note( prev_field. span,
3859
+ "Previously declared here" ) ;
3860
+ } ,
3861
+ None => {
3862
+ ident_map. insert( ident, field) ;
3863
+ }
3864
+ }
3865
+ }
3866
+ _ => ( )
3867
+ }
3868
+ }
3869
+
3849
3870
// If applicable, create a rib for the type parameters.
3850
3871
do self. with_type_parameter_rib( HasTypeParameters
3851
3872
( generics, id, 0 ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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 BuildData {
12
+ foo : int ,
13
+ foo : int , //~ ERROR field `foo` is already declared
14
+ }
15
+
16
+ fn main ( ) {
17
+ }
You can’t perform that action at this time.
0 commit comments