Skip to content

Commit

Permalink
Rollup merge of #35318 - sciyoshi:update-e0124, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0124 to the new error format

Part of #35233. This resolves #35255.

r? @jonathandturner
  • Loading branch information
steveklabnik authored Aug 4, 2016
2 parents 59a2293 + a0bdb17 commit 60c1910
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,11 +1010,12 @@ fn convert_struct_variant<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let fid = ccx.tcx.map.local_def_id(f.id);
let dup_span = seen_fields.get(&f.name).cloned();
if let Some(prev_span) = dup_span {
let mut err = struct_span_err!(ccx.tcx.sess, f.span, E0124,
"field `{}` is already declared",
f.name);
span_note!(&mut err, prev_span, "previously declared here");
err.emit();
struct_span_err!(ccx.tcx.sess, f.span, E0124,
"field `{}` is already declared",
f.name)
.span_label(f.span, &"field already declared")
.span_label(prev_span, &format!("`{}` first declared here", f.name))
.emit();
} else {
seen_fields.insert(f.name, f.span);
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0124.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
// except according to those terms.

struct Foo {
field1: i32, //~ NOTE `field1` first declared here
field1: i32,
field1: i32, //~ ERROR E0124
//~^ ERROR field `field1` is already declared [E0124]
//~| NOTE field already declared
}

fn main() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/struct-fields-decl-dupe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
// except according to those terms.

struct BuildData {
foo: isize, //~ NOTE `foo` first declared here
foo: isize,
foo: isize, //~ ERROR field `foo` is already declared
//~^ ERROR field `foo` is already declared [E0124]
//~| NOTE field already declared
}

fn main() {
Expand Down

0 comments on commit 60c1910

Please sign in to comment.