mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Refactor checking if a Lifetime
is static
Simply move the test for `keywords::StaticLifetime` into the `Lifetime` impl, to match how elision is checked.
This commit is contained in:
parent
8c4f2c64c6
commit
1ae1a19ba6
@ -100,6 +100,10 @@ impl Lifetime {
|
|||||||
pub fn is_elided(&self) -> bool {
|
pub fn is_elided(&self) -> bool {
|
||||||
self.name == keywords::Invalid.name()
|
self.name == keywords::Invalid.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_static(&self) -> bool {
|
||||||
|
self.name == keywords::StaticLifetime.name()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A lifetime definition, eg `'a: 'b+'c+'d`
|
/// A lifetime definition, eg `'a: 'b+'c+'d`
|
||||||
|
@ -434,7 +434,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||||||
self.resolve_elided_lifetimes(slice::ref_slice(lifetime_ref));
|
self.resolve_elided_lifetimes(slice::ref_slice(lifetime_ref));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if lifetime_ref.name == keywords::StaticLifetime.name() {
|
if lifetime_ref.is_static() {
|
||||||
self.insert_lifetime(lifetime_ref, Region::Static);
|
self.insert_lifetime(lifetime_ref, Region::Static);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1434,7 +1434,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||||||
let lifetime_i = &lifetimes[i];
|
let lifetime_i = &lifetimes[i];
|
||||||
|
|
||||||
for lifetime in lifetimes {
|
for lifetime in lifetimes {
|
||||||
if lifetime.lifetime.name == keywords::StaticLifetime.name() {
|
if lifetime.lifetime.is_static() {
|
||||||
let lifetime = lifetime.lifetime;
|
let lifetime = lifetime.lifetime;
|
||||||
let mut err = struct_span_err!(self.sess, lifetime.span, E0262,
|
let mut err = struct_span_err!(self.sess, lifetime.span, E0262,
|
||||||
"invalid lifetime parameter name: `{}`", lifetime.name);
|
"invalid lifetime parameter name: `{}`", lifetime.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user