use crate::reexport::*;
+use matches::matches;
use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
use rustc::hir::def::Def;
use rustc::hir::*;
use rustc::hir::intravisit::*;
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
- if let ItemFn(ref decl, _, ref generics, id) = item.node {
+ if let ItemKind::Fn(ref decl, _, ref generics, id) = item.node {
check_fn_inner(cx, decl, Some(id), generics, item.span);
}
}
fn visit_ty(&mut self, ty: &'tcx Ty) {
match ty.node {
- TyRptr(ref lt, _) if lt.is_elided() => {
+ TyKind::Rptr(ref lt, _) if lt.is_elided() => {
self.record(&None);
},
- TyPath(ref path) => {
- self.collect_anonymous_lifetimes(path, ty);
- },
- TyImplTraitExistential(exist_ty_id, _, _) => {
- if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(exist_ty_id.id).node {
- for bound in &exist_ty.bounds {
- if let GenericBound::Outlives(_) = *bound {
- self.record(&None);
+ TyKind::Path(ref path) => {
+ if let QPath::Resolved(_, ref path) = *path {
+ if let Def::Existential(def_id) = path.def {
+ let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();
+ if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
+ for bound in &exist_ty.bounds {
+ if let GenericBound::Outlives(_) = *bound {
+ self.record(&None);
+ }
+ }
+ } else {
+ unreachable!()
}
+ walk_ty(self, ty);
+ return;
}
}
+ self.collect_anonymous_lifetimes(path, ty);
}
- TyTraitObject(ref bounds, ref lt) => {
+ TyKind::TraitObject(ref bounds, ref lt) => {
if !lt.is_elided() {
self.abort = true;
}