@@ -1971,6 +1971,9 @@ bitflags! {
1971
1971
const NO_VARIANT_FLAGS = 0 ;
1972
1972
/// Indicates whether the field list of this variant is `#[non_exhaustive]`.
1973
1973
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 ;
1974
1977
}
1975
1978
}
1976
1979
@@ -1994,9 +1997,6 @@ pub struct VariantDef {
1994
1997
pub ctor_kind : CtorKind ,
1995
1998
/// Flags of the variant (e.g. is field list non-exhaustive)?
1996
1999
flags : VariantFlags ,
1997
- /// Variant is obtained as part of recovering from a syntactic error.
1998
- /// May be incomplete or bogus.
1999
- pub recovered : bool ,
2000
2000
}
2001
2001
2002
2002
impl < ' tcx > VariantDef {
@@ -2039,6 +2039,10 @@ impl<'tcx> VariantDef {
2039
2039
flags |= VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE ;
2040
2040
}
2041
2041
2042
+ if recovered {
2043
+ flags |= VariantFlags :: IS_RECOVERED ;
2044
+ }
2045
+
2042
2046
VariantDef {
2043
2047
def_id : variant_did. unwrap_or ( parent_did) ,
2044
2048
ctor_def_id,
@@ -2047,7 +2051,6 @@ impl<'tcx> VariantDef {
2047
2051
fields,
2048
2052
ctor_kind,
2049
2053
flags,
2050
- recovered,
2051
2054
}
2052
2055
}
2053
2056
@@ -2057,6 +2060,12 @@ impl<'tcx> VariantDef {
2057
2060
self . flags . intersects ( VariantFlags :: IS_FIELD_LIST_NON_EXHAUSTIVE )
2058
2061
}
2059
2062
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
+
2060
2069
/// `repr(transparent)` structs can have a single non-ZST field, this function returns that
2061
2070
/// field.
2062
2071
pub fn transparent_newtype_field ( & self , tcx : TyCtxt < ' tcx > ) -> Option < & FieldDef > {
0 commit comments