@@ -1183,6 +1183,8 @@ pub struct VariantDef {
11831183 pub discr : VariantDiscr ,
11841184 /// Fields of this variant.
11851185 pub fields : IndexVec < FieldIdx , FieldDef > ,
1186+ /// The error guarantees from parser, if any.
1187+ tainted : Option < ErrorGuaranteed > ,
11861188 /// Flags of the variant (e.g. is field list non-exhaustive)?
11871189 flags : VariantFlags ,
11881190}
@@ -1212,7 +1214,7 @@ impl VariantDef {
12121214 fields : IndexVec < FieldIdx , FieldDef > ,
12131215 adt_kind : AdtKind ,
12141216 parent_did : DefId ,
1215- recovered : bool ,
1217+ recover_tainted : Option < ErrorGuaranteed > ,
12161218 is_field_list_non_exhaustive : bool ,
12171219 has_unnamed_fields : bool ,
12181220 ) -> Self {
@@ -1227,15 +1229,23 @@ impl VariantDef {
12271229 flags |= VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE ;
12281230 }
12291231
1230- if recovered {
1232+ if recover_tainted . is_some ( ) {
12311233 flags |= VariantFlags :: IS_RECOVERED ;
12321234 }
12331235
12341236 if has_unnamed_fields {
12351237 flags |= VariantFlags :: HAS_UNNAMED_FIELDS ;
12361238 }
12371239
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+ }
12391249 }
12401250
12411251 /// Is this field list non-exhaustive?
@@ -1244,12 +1254,6 @@ impl VariantDef {
12441254 self . flags . intersects ( VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE )
12451255 }
12461256
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-
12531257 /// Does this variant contains unnamed fields
12541258 #[ inline]
12551259 pub fn has_unnamed_fields ( & self ) -> bool {
@@ -1261,6 +1265,11 @@ impl VariantDef {
12611265 Ident :: new ( self . name , tcx. def_ident_span ( self . def_id ) . unwrap ( ) )
12621266 }
12631267
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+
12641273 #[ inline]
12651274 pub fn ctor_kind ( & self ) -> Option < CtorKind > {
12661275 self . ctor . map ( |( kind, _) | kind)
@@ -1308,8 +1317,24 @@ impl PartialEq for VariantDef {
13081317 // definition of `VariantDef` changes, a compile-error will be produced,
13091318 // reminding us to revisit this assumption.
13101319
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;
13131338
13141339 let res = lhs_def_id == rhs_def_id;
13151340
@@ -1339,7 +1364,7 @@ impl Hash for VariantDef {
13391364 // of `VariantDef` changes, a compile-error will be produced, reminding
13401365 // us to revisit this assumption.
13411366
1342- let Self { def_id, ctor : _, name : _, discr : _, fields : _, flags : _ } = & self ;
1367+ let Self { def_id, ctor : _, name : _, discr : _, fields : _, flags : _, tainted : _ } = & self ;
13431368 def_id. hash ( s)
13441369 }
13451370}
0 commit comments