Skip to content

Updated E0081 to new format #35353

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

Merged
merged 2 commits into from Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions src/test/compile-fail/issue-15524.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ const N: isize = 1;

enum Foo {
A = 1,
B = 1, //~ ERROR discriminant value `1isize` already exists
//~^^ NOTE conflicting
B = 1, //~ ERROR discriminant value
//~^ NOTE enum already
//~^^^ NOTE first use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming I'm reading this right, the NOTE first use for these errors should be on a label on line 14 A = 1.

Are the spans you're getting showing up on 15, 18, and 20 instead?

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
//~^^^^^^^ NOTE first use
E = N, //~ ERROR discriminant value
//~^ NOTE enum already
//~^^^^^^^^^^ NOTE first use
}

fn main() {}