Skip to content

Commit fd7314f

Browse files
committed
Update E0025 to new error format
1 parent c276928 commit fd7314f

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

src/librustc_typeck/check/_match.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
675675
for &Spanned { node: ref field, span } in fields {
676676
let field_ty = match used_fields.entry(field.name) {
677677
Occupied(occupied) => {
678-
let mut err = struct_span_err!(tcx.sess, span, E0025,
679-
"field `{}` bound multiple times \
680-
in the pattern",
681-
field.name);
682-
span_note!(&mut err, *occupied.get(),
683-
"field `{}` previously bound here",
684-
field.name);
685-
err.emit();
678+
struct_span_err!(tcx.sess, span, E0025,
679+
"field `{}` bound multiple times \
680+
in the pattern",
681+
field.name)
682+
.span_label(span,
683+
&format!("multiple uses of `{}` in pattern", field.name))
684+
.span_label(*occupied.get(), &format!("first use of `{}`", field.name))
685+
.emit();
686686
tcx.types.err
687687
}
688688
Vacant(vacant) => {

src/test/compile-fail/E0025.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ struct Foo {
1515

1616
fn main() {
1717
let x = Foo { a:1, b:2 };
18-
let Foo { a: x, a: y, b: 0 } = x; //~ ERROR E0025
18+
let Foo { a: x, a: y, b: 0 } = x;
19+
//~^ ERROR field `a` bound multiple times in the pattern
20+
//~| NOTE multiple uses of `a` in pattern
21+
//~| NOTE first use of `a`
1922
}

src/test/compile-fail/issue-15260.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,28 @@ struct Foo {
1414

1515
fn main() {
1616
let Foo {
17-
a: _, //~ NOTE field `a` previously bound here
18-
a: _ //~ ERROR field `a` bound multiple times in the pattern
17+
a: _, //~ NOTE first use of `a`
18+
a: _
19+
//~^ ERROR field `a` bound multiple times in the pattern
20+
//~| NOTE multiple uses of `a` in pattern
1921
} = Foo { a: 29 };
2022

2123
let Foo {
22-
a, //~ NOTE field `a` previously bound here
23-
a: _ //~ ERROR field `a` bound multiple times in the pattern
24+
a, //~ NOTE first use of `a`
25+
a: _
26+
//~^ ERROR field `a` bound multiple times in the pattern
27+
//~| NOTE multiple uses of `a` in pattern
2428
} = Foo { a: 29 };
2529

2630
let Foo {
27-
a, //~ NOTE field `a` previously bound here
28-
//~^ NOTE field `a` previously bound here
29-
a: _, //~ ERROR field `a` bound multiple times in the pattern
30-
a: x //~ ERROR field `a` bound multiple times in the pattern
31+
a,
32+
//~^ NOTE first use of `a`
33+
//~| NOTE first use of `a`
34+
a: _,
35+
//~^ ERROR field `a` bound multiple times in the pattern
36+
//~| NOTE multiple uses of `a` in pattern
37+
a: x
38+
//~^ ERROR field `a` bound multiple times in the pattern
39+
//~| NOTE multiple uses of `a` in pattern
3140
} = Foo { a: 29 };
3241
}

0 commit comments

Comments
 (0)