Rollup merge of #35353 - poveda-ruiz:master, r=jonathandturner

Updated E0081 to new format

Part of #35233. r? @jonathandturner
This commit is contained in:
Eduard-Mihai Burtescu 2016-08-06 15:01:21 +03:00 committed by GitHub
commit b9c5fa4023
2 changed files with 14 additions and 8 deletions

View File

@ -1251,8 +1251,9 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
let mut err = struct_span_err!(ccx.tcx.sess, v.span, E0081,
"discriminant value `{}` already exists", disr_vals[i]);
let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap();
span_note!(&mut err, ccx.tcx.map.span(variant_i_node_id),
"conflicting discriminant here");
err.span_label(ccx.tcx.map.span(variant_i_node_id),
&format!("first use of `{}`", disr_vals[i]));
err.span_label(v.span , &format!("enum already has `{}`", disr_vals[i]));
err.emit();
}
disr_vals.push(current_disr_val);

View File

@ -12,13 +12,18 @@ const N: isize = 1;
enum Foo {
A = 1,
B = 1, //~ ERROR discriminant value `1isize` already exists
//~^^ NOTE conflicting
//~^ NOTE first use
//~| NOTE first use
//~| NOTE first use
B = 1, //~ ERROR discriminant value
//~^ NOTE enum already
C = 0,
D, //~ ERROR discriminant value `1isize` already exists
//~^^^^^ NOTE conflicting
E = N, //~ ERROR discriminant value `1isize` already exists
//~^^^^^^^ NOTE conflicting
D, //~ ERROR discriminant value
//~^ NOTE enum already
E = N, //~ ERROR discriminant value
//~^ NOTE enum already
}
fn main() {}