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 @@ -3886,6 +3886,27 @@ impl Resolver {
38863886 generics: & Generics ,
38873887 fields: & [ @struct_field] ,
38883888 visitor: ResolveVisitor ) {
3889+ let mut ident_map = HashMap :: new:: < ast:: ident , @struct_field > ( ) ;
3890+ for fields. iter( ) . advance |& field| {
3891+ match field. node. kind {
3892+ named_field( ident, _) => {
3893+ match ident_map. find( & ident) {
3894+ Some ( & prev_field) => {
3895+ let ident_str = self . session. str_of( ident) ;
3896+ self . session. span_err( field. span,
3897+ fmt ! ( "field `%s` is already declared" , ident_str) ) ;
3898+ self . session. span_note( prev_field. span,
3899+ "Previously declared here" ) ;
3900+ } ,
3901+ None => {
3902+ ident_map. insert( ident, field) ;
3903+ }
3904+ }
3905+ }
3906+ _ => ( )
3907+ }
3908+ }
3909+
38893910 // If applicable, create a rib for the type parameters.
38903911 do self. with_type_parameter_rib( HasTypeParameters
38913912 ( 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