X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Futils%2Finternal_lints.rs;h=226817c8e51f0f140835f9c3f2fb09926b303cd6;hb=b109e1033476390f95c728d674909ef90f0ff0ca;hp=1de0975ab4216bf7db678d2b22fe3a3c7369ce77;hpb=1e1b4e26ea4bf842edbda888eecfc40c02b60d73;p=rust.git diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 1de0975ab42..226817c8e51 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,9 +1,11 @@ use rustc::lint::*; +use rustc::{declare_lint, lint_array}; use rustc::hir::*; +use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use crate::utils::{match_qpath, paths, span_lint}; use syntax::symbol::LocalInternedString; -use syntax::ast::{Crate as AstCrate, ItemKind, Name, NodeId}; +use syntax::ast::{Crate as AstCrate, ItemKind, Name}; use syntax::codemap::Span; use std::collections::{HashMap, HashSet}; @@ -62,7 +64,7 @@ fn get_lints(&self) -> LintArray { } impl EarlyLintPass for Clippy { - fn check_crate(&mut self, cx: &EarlyContext, krate: &AstCrate) { + fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &AstCrate) { if let Some(utils) = krate .module .items @@ -78,7 +80,7 @@ fn check_crate(&mut self, cx: &EarlyContext, krate: &AstCrate) { if let ItemKind::Mod(ref paths_mod) = paths.node { let mut last_name: Option = None; for item in &paths_mod.items { - let name = item.ident.name.as_str(); + let name = item.ident.as_str(); if let Some(ref last_name) = last_name { if **last_name > *name { span_lint( @@ -117,15 +119,17 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemStatic(ref ty, MutImmutable, body_id) = item.node { + if let hir::ItemKind::Static(ref ty, MutImmutable, body_id) = item.node { if is_lint_ref_type(ty) { self.declared_lints.insert(item.name, item.span); - } else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name == "ARRAY" { - let mut collector = LintCollector { - output: &mut self.registered_lints, - cx, - }; - collector.visit_expr(&cx.tcx.hir.body(body_id).value); + } else if is_lint_array_type(ty) && item.name == "ARRAY" { + if let VisibilityKind::Inherited = item.vis.node { + let mut collector = LintCollector { + output: &mut self.registered_lints, + cx, + }; + collector.visit_expr(&cx.tcx.hir.body(body_id).value); + } } } } @@ -160,7 +164,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate) { fn is_lint_ref_type(ty: &Ty) -> bool { - if let TyRptr( + if let TyKind::Rptr( _, MutTy { ty: ref inner, @@ -168,7 +172,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool { }, ) = ty.node { - if let TyPath(ref path) = inner.node { + if let TyKind::Path(ref path) = inner.node { return match_qpath(path, &paths::LINT); } } @@ -177,7 +181,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool { fn is_lint_array_type(ty: &Ty) -> bool { - if let TyPath(ref path) = ty.node { + if let TyKind::Path(ref path) = ty.node { match_qpath(path, &paths::LINT_ARRAY) } else { false @@ -194,9 +198,9 @@ fn visit_expr(&mut self, expr: &'tcx Expr) { walk_expr(self, expr); } - fn visit_path(&mut self, path: &'tcx Path, _: NodeId) { + fn visit_path(&mut self, path: &'tcx Path, _: HirId) { if path.segments.len() == 1 { - self.output.insert(path.segments[0].name); + self.output.insert(path.segments[0].ident.name); } } fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {