File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
14
14
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
15
15
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
16
16
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17
- refs/heads/auto: d324014c6cd2919333c330b5ae49739f287540b6
17
+ refs/heads/auto: 0bd67f68913288af7cb26cca796842e9c8514521
18
18
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
19
19
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
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