Rollup merge of #36757 - KiChjang:E0025-format, r=jonathandturner
Update E0025 to new error format Part of #35233. Fixes #35198. r? @jonathandturner
This commit is contained in:
commit
224e882878
@ -675,14 +675,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
for &Spanned { node: ref field, span } in fields {
|
for &Spanned { node: ref field, span } in fields {
|
||||||
let field_ty = match used_fields.entry(field.name) {
|
let field_ty = match used_fields.entry(field.name) {
|
||||||
Occupied(occupied) => {
|
Occupied(occupied) => {
|
||||||
let mut err = struct_span_err!(tcx.sess, span, E0025,
|
struct_span_err!(tcx.sess, span, E0025,
|
||||||
"field `{}` bound multiple times \
|
"field `{}` bound multiple times \
|
||||||
in the pattern",
|
in the pattern",
|
||||||
field.name);
|
field.name)
|
||||||
span_note!(&mut err, *occupied.get(),
|
.span_label(span,
|
||||||
"field `{}` previously bound here",
|
&format!("multiple uses of `{}` in pattern", field.name))
|
||||||
field.name);
|
.span_label(*occupied.get(), &format!("first use of `{}`", field.name))
|
||||||
err.emit();
|
.emit();
|
||||||
tcx.types.err
|
tcx.types.err
|
||||||
}
|
}
|
||||||
Vacant(vacant) => {
|
Vacant(vacant) => {
|
||||||
|
@ -15,5 +15,8 @@ struct Foo {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = Foo { a:1, b:2 };
|
let x = Foo { a:1, b:2 };
|
||||||
let Foo { a: x, a: y, b: 0 } = x; //~ ERROR E0025
|
let Foo { a: x, a: y, b: 0 } = x;
|
||||||
|
//~^ ERROR field `a` bound multiple times in the pattern
|
||||||
|
//~| NOTE multiple uses of `a` in pattern
|
||||||
|
//~| NOTE first use of `a`
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,28 @@ struct Foo {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let Foo {
|
let Foo {
|
||||||
a: _, //~ NOTE field `a` previously bound here
|
a: _, //~ NOTE first use of `a`
|
||||||
a: _ //~ ERROR field `a` bound multiple times in the pattern
|
a: _
|
||||||
|
//~^ ERROR field `a` bound multiple times in the pattern
|
||||||
|
//~| NOTE multiple uses of `a` in pattern
|
||||||
} = Foo { a: 29 };
|
} = Foo { a: 29 };
|
||||||
|
|
||||||
let Foo {
|
let Foo {
|
||||||
a, //~ NOTE field `a` previously bound here
|
a, //~ NOTE first use of `a`
|
||||||
a: _ //~ ERROR field `a` bound multiple times in the pattern
|
a: _
|
||||||
|
//~^ ERROR field `a` bound multiple times in the pattern
|
||||||
|
//~| NOTE multiple uses of `a` in pattern
|
||||||
} = Foo { a: 29 };
|
} = Foo { a: 29 };
|
||||||
|
|
||||||
let Foo {
|
let Foo {
|
||||||
a, //~ NOTE field `a` previously bound here
|
a,
|
||||||
//~^ NOTE field `a` previously bound here
|
//~^ NOTE first use of `a`
|
||||||
a: _, //~ ERROR field `a` bound multiple times in the pattern
|
//~| NOTE first use of `a`
|
||||||
a: x //~ ERROR field `a` bound multiple times in the pattern
|
a: _,
|
||||||
|
//~^ ERROR field `a` bound multiple times in the pattern
|
||||||
|
//~| NOTE multiple uses of `a` in pattern
|
||||||
|
a: x
|
||||||
|
//~^ ERROR field `a` bound multiple times in the pattern
|
||||||
|
//~| NOTE multiple uses of `a` in pattern
|
||||||
} = Foo { a: 29 };
|
} = Foo { a: 29 };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user