@@ -1971,6 +1971,9 @@ bitflags! {
19711971 const NO_VARIANT_FLAGS = 0 ;
19721972 /// Indicates whether the field list of this variant is `#[non_exhaustive]`.
19731973 const IS_FIELD_LIST_NON_EXHAUSTIVE = 1 << 0 ;
1974+ /// Indicates whether this variant was obtained as part of recovering from
1975+ /// a syntactic error. May be incomplete or bogus.
1976+ const IS_RECOVERED = 1 << 1 ;
19741977 }
19751978}
19761979
@@ -1994,9 +1997,6 @@ pub struct VariantDef {
19941997 pub ctor_kind : CtorKind ,
19951998 /// Flags of the variant (e.g. is field list non-exhaustive)?
19961999 flags : VariantFlags ,
1997- /// Variant is obtained as part of recovering from a syntactic error.
1998- /// May be incomplete or bogus.
1999- pub recovered : bool ,
20002000}
20012001
20022002impl < ' tcx > VariantDef {
@@ -2039,6 +2039,10 @@ impl<'tcx> VariantDef {
20392039 flags |= VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE ;
20402040 }
20412041
2042+ if recovered {
2043+ flags |= VariantFlags :: IS_RECOVERED ;
2044+ }
2045+
20422046 VariantDef {
20432047 def_id : variant_did. unwrap_or ( parent_did) ,
20442048 ctor_def_id,
@@ -2047,7 +2051,6 @@ impl<'tcx> VariantDef {
20472051 fields,
20482052 ctor_kind,
20492053 flags,
2050- recovered,
20512054 }
20522055 }
20532056
@@ -2057,6 +2060,12 @@ impl<'tcx> VariantDef {
20572060 self . flags . intersects ( VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE )
20582061 }
20592062
2063+ /// Was this variant obtained as part of recovering from a syntactic error?
2064+ #[ inline]
2065+ pub fn is_recovered ( & self ) -> bool {
2066+ self . flags . intersects ( VariantFlags :: IS_RECOVERED )
2067+ }
2068+
20602069 /// `repr(transparent)` structs can have a single non-ZST field, this function returns that
20612070 /// field.
20622071 pub fn transparent_newtype_field ( & self , tcx : TyCtxt < ' tcx > ) -> Option < & FieldDef > {
0 commit comments