hir::ItemUse(..) |
hir::ItemMod(..) |
hir::ItemDefaultImpl(..) |
- hir::ItemForeignMod(..) => {
+ hir::ItemForeignMod(..) |
+ hir::ItemGlobalAsm(..) => {
// These sorts of items have no lifetime parameters at all.
intravisit::walk_item(self, item);
}
self.resolve_elided_lifetimes(slice::ref_slice(lifetime_ref));
return;
}
- if lifetime_ref.name == keywords::StaticLifetime.name() {
+ if lifetime_ref.is_static() {
self.insert_lifetime(lifetime_ref, Region::Static);
return;
}
let lifetime_i = &lifetimes[i];
for lifetime in lifetimes {
- if lifetime.lifetime.name == keywords::StaticLifetime.name() {
+ if lifetime.lifetime.is_static() {
let lifetime = lifetime.lifetime;
let mut err = struct_span_err!(self.sess, lifetime.span, E0262,
"invalid lifetime parameter name: `{}`", lifetime.name);
self.check_lifetime_def_for_shadowing(old_scope, &lifetime_i.lifetime);
for bound in &lifetime_i.bounds {
- self.resolve_lifetime_ref(bound);
+ if !bound.is_static() {
+ self.resolve_lifetime_ref(bound);
+ } else {
+ self.insert_lifetime(bound, Region::Static);
+ self.sess.struct_span_warn(lifetime_i.lifetime.span.to(bound.span),
+ &format!("unnecessary lifetime parameter `{}`", lifetime_i.lifetime.name))
+ .help(&format!("you can use the `'static` lifetime directly, in place \
+ of `{}`", lifetime_i.lifetime.name))
+ .emit();
+ }
}
}
}