@@ -1114,7 +1114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1114
1114
tcx. sess . struct_span_err ( pat. span , "`..` cannot be used in union patterns" ) . emit ( ) ;
1115
1115
}
1116
1116
} else if !etc && !unmentioned_fields. is_empty ( ) {
1117
- unmentioned_err = Some ( self . error_unmentioned_fields ( pat. span , & unmentioned_fields) ) ;
1117
+ unmentioned_err = Some ( self . error_unmentioned_fields ( pat, & unmentioned_fields) ) ;
1118
1118
}
1119
1119
match ( inexistent_fields_err, unmentioned_err) {
1120
1120
( Some ( mut i) , Some ( mut u) ) => {
@@ -1237,13 +1237,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1237
1237
if tcx. sess . teach ( & err. get_code ( ) . unwrap ( ) ) {
1238
1238
err. note (
1239
1239
"This error indicates that a struct pattern attempted to \
1240
- extract a non-existent field from a struct. Struct fields \
1241
- are identified by the name used before the colon : so struct \
1242
- patterns should resemble the declaration of the struct type \
1243
- being matched.\n \n \
1244
- If you are using shorthand field patterns but want to refer \
1245
- to the struct field by a different name, you should rename \
1246
- it explicitly.",
1240
+ extract a non-existent field from a struct. Struct fields \
1241
+ are identified by the name used before the colon : so struct \
1242
+ patterns should resemble the declaration of the struct type \
1243
+ being matched.\n \n \
1244
+ If you are using shorthand field patterns but want to refer \
1245
+ to the struct field by a different name, you should rename \
1246
+ it explicitly.",
1247
1247
) ;
1248
1248
}
1249
1249
err
@@ -1299,7 +1299,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1299
1299
1300
1300
fn error_unmentioned_fields (
1301
1301
& self ,
1302
- span : Span ,
1302
+ pat : & Pat < ' _ > ,
1303
1303
unmentioned_fields : & [ Ident ] ,
1304
1304
) -> DiagnosticBuilder < ' tcx > {
1305
1305
let field_names = if unmentioned_fields. len ( ) == 1 {
@@ -1312,23 +1312,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1312
1312
. join ( ", " ) ;
1313
1313
format ! ( "fields {}" , fields)
1314
1314
} ;
1315
- let mut diag = struct_span_err ! (
1315
+ let mut err = struct_span_err ! (
1316
1316
self . tcx. sess,
1317
- span,
1317
+ pat . span,
1318
1318
E0027 ,
1319
1319
"pattern does not mention {}" ,
1320
1320
field_names
1321
1321
) ;
1322
- diag . span_label ( span, format ! ( "missing {}" , field_names) ) ;
1323
- if self . tcx . sess . teach ( & diag . get_code ( ) . unwrap ( ) ) {
1324
- diag . note (
1322
+ err . span_label ( pat . span , format ! ( "missing {}" , field_names) ) ;
1323
+ if self . tcx . sess . teach ( & err . get_code ( ) . unwrap ( ) ) {
1324
+ err . note (
1325
1325
"This error indicates that a pattern for a struct fails to specify a \
1326
- sub-pattern for every one of the struct's fields. Ensure that each field \
1327
- from the struct's definition is mentioned in the pattern, or use `..` to \
1328
- ignore unwanted fields.",
1326
+ sub-pattern for every one of the struct's fields. Ensure that each field \
1327
+ from the struct's definition is mentioned in the pattern, or use `..` to \
1328
+ ignore unwanted fields.",
1329
1329
) ;
1330
1330
}
1331
- diag
1331
+ err
1332
1332
}
1333
1333
1334
1334
fn check_pat_box (
0 commit comments