use rustc::lint::*;
use syntax::codemap::Span;
use rustc_front::intravisit::{Visitor, walk_ty, walk_ty_param_bound};
-use rustc::middle::def::Def::{DefTy, DefTrait};
+use rustc::middle::def::Def::{DefTy, DefTrait, DefStruct};
use std::collections::HashSet;
use utils::{in_external_macro, span_lint};
let last_path_segment = path.segments.last().map(|s| &s.parameters);
if let Some(&AngleBracketedParameters(ref params)) = last_path_segment {
if params.lifetimes.is_empty() {
- let def = self.cx.tcx.def_map.borrow().get(&ty.id).map(|r| r.full_def());
- match def {
- Some(DefTy(def_id, _)) => {
- if let Some(ty_def) = self.cx.tcx.adt_defs.borrow().get(&def_id) {
- let scheme = ty_def.type_scheme(self.cx.tcx);
- for _ in scheme.generics.regions.as_slice() {
+ if let Some(def) = self.cx.tcx.def_map.borrow().get(&ty.id).map(|r| r.full_def()) {
+ match def {
+ DefTy(def_id, _) | DefStruct(def_id) => {
+ let type_scheme = self.cx.tcx.lookup_item_type(def_id);
+ for _ in type_scheme.generics.regions.as_slice() {
self.record(&None);
}
- }
- }
- Some(DefTrait(def_id)) => {
- let trait_def = self.cx.tcx.trait_defs.borrow()[&def_id];
- for _ in &trait_def.generics.regions {
- self.record(&None);
- }
+ },
+ DefTrait(def_id) => {
+ let trait_def = self.cx.tcx.trait_defs.borrow()[&def_id];
+ for _ in &trait_def.generics.regions {
+ self.record(&None);
+ }
+ },
+ _ => {}
}
- _ => {}
}
}
}
// unambiguous if we elided the lifetime
fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given
+type FooAlias<'a> = Foo<'a>;
+
+fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given
+
+// no warning, two input lifetimes (named on the reference, anonymous on Foo)
+fn alias_with_lt2<'a>(_foo: &'a FooAlias) -> &'a str { unimplemented!() }
+
+// no warning, two input lifetimes (anonymous on the reference, named on Foo)
+fn alias_with_lt3<'a>(_foo: &FooAlias<'a> ) -> &'a str { unimplemented!() }
+
+// no warning, two input lifetimes
+fn alias_with_lt4<'a, 'b>(_foo: &'a FooAlias<'b> ) -> &'a str { unimplemented!() }
+
fn main() {
}