Skip to content

Commit 0a3766a

Browse files
author
Jonathan Turner
authored
Rollup merge of #35504 - razielgn:updated-e0026-to-new-format, r=jonathandturner
Updated E0026 to new format. Part of #35233. Fixes #35497. r? @jonathandturner
2 parents a72891e + ee38609 commit 0a3766a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/librustc_typeck/check/_match.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
695695
field_map.get(&field.name)
696696
.map(|f| self.field_ty(span, f, substs))
697697
.unwrap_or_else(|| {
698-
span_err!(tcx.sess, span, E0026,
699-
"struct `{}` does not have a field named `{}`",
700-
tcx.item_path_str(variant.did),
701-
field.name);
698+
struct_span_err!(tcx.sess, span, E0026,
699+
"struct `{}` does not have a field named `{}`",
700+
tcx.item_path_str(variant.did),
701+
field.name)
702+
.span_label(span,
703+
&format!("struct `{}` does not have field `{}`",
704+
tcx.item_path_str(variant.did),
705+
field.name))
706+
.emit();
707+
702708
tcx.types.err
703709
})
704710
}

src/test/compile-fail/E0026.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct Thing {
1616
fn main() {
1717
let thing = Thing { x: 0, y: 0 };
1818
match thing {
19-
Thing { x, y, z } => {} //~ ERROR E0026
19+
Thing { x, y, z } => {}
20+
//~^ ERROR struct `Thing` does not have a field named `z` [E0026]
21+
//~| NOTE struct `Thing` does not have field `z`
2022
}
2123
}

0 commit comments

Comments
 (0)