@@ -1183,6 +1183,8 @@ pub struct VariantDef {
1183
1183
pub discr : VariantDiscr ,
1184
1184
/// Fields of this variant.
1185
1185
pub fields : IndexVec < FieldIdx , FieldDef > ,
1186
+ /// The error guarantees from parser, if any.
1187
+ tainted : Option < ErrorGuaranteed > ,
1186
1188
/// Flags of the variant (e.g. is field list non-exhaustive)?
1187
1189
flags : VariantFlags ,
1188
1190
}
@@ -1212,7 +1214,7 @@ impl VariantDef {
1212
1214
fields : IndexVec < FieldIdx , FieldDef > ,
1213
1215
adt_kind : AdtKind ,
1214
1216
parent_did : DefId ,
1215
- recovered : bool ,
1217
+ recover_tainted : Option < ErrorGuaranteed > ,
1216
1218
is_field_list_non_exhaustive : bool ,
1217
1219
has_unnamed_fields : bool ,
1218
1220
) -> Self {
@@ -1227,15 +1229,23 @@ impl VariantDef {
1227
1229
flags |= VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE ;
1228
1230
}
1229
1231
1230
- if recovered {
1232
+ if recover_tainted . is_some ( ) {
1231
1233
flags |= VariantFlags :: IS_RECOVERED ;
1232
1234
}
1233
1235
1234
1236
if has_unnamed_fields {
1235
1237
flags |= VariantFlags :: HAS_UNNAMED_FIELDS ;
1236
1238
}
1237
1239
1238
- VariantDef { def_id : variant_did. unwrap_or ( parent_did) , ctor, name, discr, fields, flags }
1240
+ VariantDef {
1241
+ def_id : variant_did. unwrap_or ( parent_did) ,
1242
+ ctor,
1243
+ name,
1244
+ discr,
1245
+ fields,
1246
+ flags,
1247
+ tainted : recover_tainted,
1248
+ }
1239
1249
}
1240
1250
1241
1251
/// Is this field list non-exhaustive?
@@ -1244,12 +1254,6 @@ impl VariantDef {
1244
1254
self . flags . intersects ( VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE )
1245
1255
}
1246
1256
1247
- /// Was this variant obtained as part of recovering from a syntactic error?
1248
- #[ inline]
1249
- pub fn is_recovered ( & self ) -> bool {
1250
- self . flags . intersects ( VariantFlags :: IS_RECOVERED )
1251
- }
1252
-
1253
1257
/// Does this variant contains unnamed fields
1254
1258
#[ inline]
1255
1259
pub fn has_unnamed_fields ( & self ) -> bool {
@@ -1261,6 +1265,11 @@ impl VariantDef {
1261
1265
Ident :: new ( self . name , tcx. def_ident_span ( self . def_id ) . unwrap ( ) )
1262
1266
}
1263
1267
1268
+ /// Was this variant obtained as part of recovering from a syntactic error?
1269
+ pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
1270
+ self . tainted
1271
+ }
1272
+
1264
1273
#[ inline]
1265
1274
pub fn ctor_kind ( & self ) -> Option < CtorKind > {
1266
1275
self . ctor . map ( |( kind, _) | kind)
@@ -1308,8 +1317,24 @@ impl PartialEq for VariantDef {
1308
1317
// definition of `VariantDef` changes, a compile-error will be produced,
1309
1318
// reminding us to revisit this assumption.
1310
1319
1311
- let Self { def_id : lhs_def_id, ctor : _, name : _, discr : _, fields : _, flags : _ } = & self ;
1312
- let Self { def_id : rhs_def_id, ctor : _, name : _, discr : _, fields : _, flags : _ } = other;
1320
+ let Self {
1321
+ def_id : lhs_def_id,
1322
+ ctor : _,
1323
+ name : _,
1324
+ discr : _,
1325
+ fields : _,
1326
+ flags : _,
1327
+ tainted : _,
1328
+ } = & self ;
1329
+ let Self {
1330
+ def_id : rhs_def_id,
1331
+ ctor : _,
1332
+ name : _,
1333
+ discr : _,
1334
+ fields : _,
1335
+ flags : _,
1336
+ tainted : _,
1337
+ } = other;
1313
1338
1314
1339
let res = lhs_def_id == rhs_def_id;
1315
1340
@@ -1339,7 +1364,7 @@ impl Hash for VariantDef {
1339
1364
// of `VariantDef` changes, a compile-error will be produced, reminding
1340
1365
// us to revisit this assumption.
1341
1366
1342
- let Self { def_id, ctor : _, name : _, discr : _, fields : _, flags : _ } = & self ;
1367
+ let Self { def_id, ctor : _, name : _, discr : _, fields : _, flags : _, tainted : _ } = & self ;
1343
1368
def_id. hash ( s)
1344
1369
}
1345
1370
}
0 commit comments