Skip to content

Commit f634106

Browse files
committed
resolve: Regroup lifetime rib kinds to account for their purpose
1 parent e94ec30 commit f634106

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

Diff for: compiler/rustc_resolve/src/late.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,14 @@ enum LifetimeUseSet {
224224

225225
#[derive(Copy, Clone, Debug)]
226226
enum LifetimeRibKind {
227-
/// This rib acts as a barrier to forbid reference to lifetimes of a parent item.
228-
Item,
229-
227+
// -- Ribs introducing named lifetimes
228+
//
230229
/// This rib declares generic parameters.
230+
/// Only for this kind the `LifetimeRib::bindings` field can be non-empty.
231231
Generics { binder: NodeId, span: Span, kind: LifetimeBinderKind },
232232

233-
/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
234-
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
235-
/// lifetimes in const generics. See issue #74052 for discussion.
236-
ConstGeneric,
237-
238-
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
239-
/// This function will emit an error if `generic_const_exprs` is not enabled, the body identified by
240-
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
241-
AnonConst,
242-
233+
// -- Ribs introducing unnamed lifetimes
234+
//
243235
/// Create a new anonymous lifetime parameter and reference it.
244236
///
245237
/// If `report_in_path`, report an error when encountering lifetime elision in a path:
@@ -256,16 +248,31 @@ enum LifetimeRibKind {
256248
/// ```
257249
AnonymousCreateParameter { binder: NodeId, report_in_path: bool },
258250

251+
/// Replace all anonymous lifetimes by provided lifetime.
252+
Elided(LifetimeRes),
253+
254+
// -- Barrier ribs that stop lifetime lookup, or continue it but produce an error later.
255+
//
259256
/// Give a hard error when either `&` or `'_` is written. Used to
260257
/// rule out things like `where T: Foo<'_>`. Does not imply an
261258
/// error on default object bounds (e.g., `Box<dyn Foo>`).
262259
AnonymousReportError,
263260

264-
/// Replace all anonymous lifetimes by provided lifetime.
265-
Elided(LifetimeRes),
266-
267261
/// Signal we cannot find which should be the anonymous lifetime.
268262
ElisionFailure,
263+
264+
/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
265+
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
266+
/// lifetimes in const generics. See issue #74052 for discussion.
267+
ConstGeneric,
268+
269+
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
270+
/// This function will emit an error if `generic_const_exprs` is not enabled, the body
271+
/// identified by `body_id` is an anonymous constant and `lifetime_ref` is non-static.
272+
AnonConst,
273+
274+
/// This rib acts as a barrier to forbid reference to lifetimes of a parent item.
275+
Item,
269276
}
270277

271278
#[derive(Copy, Clone, Debug)]

0 commit comments

Comments
 (0)