resolve: Regroup lifetime rib kinds to account for their purpose

This commit is contained in:
Vadim Petrochenkov 2022-10-10 18:31:08 +04:00
parent e94ec30dc4
commit f634106591

View File

@ -224,22 +224,14 @@ enum LifetimeUseSet {
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
enum LifetimeRibKind { enum LifetimeRibKind {
/// This rib acts as a barrier to forbid reference to lifetimes of a parent item. // -- Ribs introducing named lifetimes
Item, //
/// This rib declares generic parameters. /// This rib declares generic parameters.
/// Only for this kind the `LifetimeRib::bindings` field can be non-empty.
Generics { binder: NodeId, span: Span, kind: LifetimeBinderKind }, Generics { binder: NodeId, span: Span, kind: LifetimeBinderKind },
/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const // -- Ribs introducing unnamed lifetimes
/// generics. We are disallowing this until we can decide on how we want to handle non-'static //
/// lifetimes in const generics. See issue #74052 for discussion.
ConstGeneric,
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
/// This function will emit an error if `generic_const_exprs` is not enabled, the body identified by
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
AnonConst,
/// Create a new anonymous lifetime parameter and reference it. /// Create a new anonymous lifetime parameter and reference it.
/// ///
/// If `report_in_path`, report an error when encountering lifetime elision in a path: /// If `report_in_path`, report an error when encountering lifetime elision in a path:
@ -256,16 +248,31 @@ enum LifetimeRibKind {
/// ``` /// ```
AnonymousCreateParameter { binder: NodeId, report_in_path: bool }, AnonymousCreateParameter { binder: NodeId, report_in_path: bool },
/// Replace all anonymous lifetimes by provided lifetime.
Elided(LifetimeRes),
// -- Barrier ribs that stop lifetime lookup, or continue it but produce an error later.
//
/// Give a hard error when either `&` or `'_` is written. Used to /// Give a hard error when either `&` or `'_` is written. Used to
/// rule out things like `where T: Foo<'_>`. Does not imply an /// rule out things like `where T: Foo<'_>`. Does not imply an
/// error on default object bounds (e.g., `Box<dyn Foo>`). /// error on default object bounds (e.g., `Box<dyn Foo>`).
AnonymousReportError, AnonymousReportError,
/// Replace all anonymous lifetimes by provided lifetime.
Elided(LifetimeRes),
/// Signal we cannot find which should be the anonymous lifetime. /// Signal we cannot find which should be the anonymous lifetime.
ElisionFailure, ElisionFailure,
/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
/// lifetimes in const generics. See issue #74052 for discussion.
ConstGeneric,
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
/// This function will emit an error if `generic_const_exprs` is not enabled, the body
/// identified by `body_id` is an anonymous constant and `lifetime_ref` is non-static.
AnonConst,
/// This rib acts as a barrier to forbid reference to lifetimes of a parent item.
Item,
} }
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]