Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0124 to the new error format #35318

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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