Replace LifetimeRes::Anonymous by LifetimeRes::Infer.

This commit is contained in:
Camille GILLOT 2022-06-13 08:22:06 +02:00
parent ab63591f00
commit 10be0dd8df
9 changed files with 51 additions and 105 deletions

View file

@ -738,11 +738,8 @@ pub enum LifetimeRes {
binder: NodeId,
},
/// This variant is used for anonymous lifetimes that we did not resolve during
/// late resolution. Shifting the work to the HIR lifetime resolver.
Anonymous {
/// Id of the introducing place. See `Param`.
binder: NodeId,
},
/// late resolution. Those lifetimes will be inferred by typechecking.
Infer,
/// Explicit `'static` lifetime.
Static,
/// Resolution failure.

View file

@ -108,7 +108,8 @@ pub enum LifetimeName {
Error,
/// User wrote an anonymous lifetime, either `'_` or nothing.
Underscore,
/// The semantics of this lifetime should be inferred by typechecking code.
Infer,
/// User wrote `'static`.
Static,
@ -118,7 +119,7 @@ impl LifetimeName {
pub fn ident(&self) -> Ident {
match *self {
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Error => Ident::empty(),
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
LifetimeName::Infer => Ident::with_dummy_span(kw::UnderscoreLifetime),
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
LifetimeName::Param(_, param_name) => param_name.ident(),
}
@ -127,7 +128,7 @@ impl LifetimeName {
pub fn is_anonymous(&self) -> bool {
match *self {
LifetimeName::ImplicitObjectLifetimeDefault
| LifetimeName::Underscore
| LifetimeName::Infer
| LifetimeName::Param(_, ParamName::Fresh)
| LifetimeName::Error => true,
LifetimeName::Static | LifetimeName::Param(..) => false,
@ -136,7 +137,7 @@ impl LifetimeName {
pub fn is_elided(&self) -> bool {
match self {
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Underscore => true,
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,
// It might seem surprising that `Fresh` counts as
// *not* elided -- but this is because, as far as the code

View file

@ -497,7 +497,7 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime
| LifetimeName::Static
| LifetimeName::Error
| LifetimeName::ImplicitObjectLifetimeDefault
| LifetimeName::Underscore => {}
| LifetimeName::Infer => {}
}
}