Skip to content

Commit 879ea99

Browse files
committed
---
yaml --- r: 68564 b: refs/heads/auto c: 0bd67f6 h: refs/heads/master v: v3
1 parent c27fbc1 commit 879ea99

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: d324014c6cd2919333c330b5ae49739f287540b6
17+
refs/heads/auto: 0bd67f68913288af7cb26cca796842e9c8514521
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/middle/resolve.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,6 +3846,27 @@ impl Resolver {
38463846
generics: &Generics,
38473847
fields: &[@struct_field],
38483848
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+
38493870
// If applicable, create a rib for the type parameters.
38503871
do self.with_type_parameter_rib(HasTypeParameters
38513872
(generics, id, 0,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

0 commit comments

Comments
 (0)