Update E0124 to the new error format

This commit is contained in:
Samuel Cormier-Iijima 2016-08-04 15:09:15 -04:00
parent e804a3cf25
commit a0bdb17618
3 changed files with 12 additions and 7 deletions

View File

@ -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);
}

View File

@ -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() {

View File

@ -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() {