diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 6433e0d640d..a2559c77401 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -7,7 +7,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::Applicability; -use syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID}; +use syntax::ast::{LitKind, DUMMY_NODE_ID}; use syntax::source_map::{dummy_spanned, Span, DUMMY_SP}; /// **What it does:** Checks for boolean expressions that can be written more @@ -72,7 +72,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool { _: &'tcx FnDecl, body: &'tcx Body, _: Span, - _: NodeId, + _: HirId, ) { NonminimalBoolVisitor { cx }.visit_body(body) } diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 76b342089bc..da86734cac1 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -6,7 +6,7 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass}; use rustc::ty; use rustc::{declare_tool_lint, lint_array}; -use syntax::ast::{Attribute, NodeId}; +use syntax::ast::Attribute; use syntax::source_map::Span; use crate::utils::{in_macro, is_allowed, match_type, paths, span_help_and_lint, LimitStack}; @@ -123,9 +123,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity { _: &'tcx FnDecl, body: &'tcx Body, span: Span, - node_id: NodeId, + hir_id: HirId, ) { - let def_id = cx.tcx.hir().local_def_id(node_id); + let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id); if !cx.tcx.has_attr(def_id, "test") { self.check(cx, body, span); } diff --git a/clippy_lints/src/enum_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index 4806736682f..35fef9e3af4 100644 --- a/clippy_lints/src/enum_glob_use.rs +++ b/clippy_lints/src/enum_glob_use.rs @@ -5,7 +5,6 @@ use rustc::hir::def::Def; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; -use syntax::ast::NodeId; use syntax::source_map::Span; /// **What it does:** Checks for `use Enum::*`. @@ -39,7 +38,7 @@ impl LintPass for EnumGlobUse { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse { - fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) { + fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: HirId) { // only check top level `use` statements for item in &m.item_ids { self.lint_item(cx, cx.tcx.hir().expect_item(item.id)); diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index a276579b1b5..a39ee6d18ee 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -66,11 +66,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { _: &'tcx FnDecl, body: &'tcx Body, _: Span, - node_id: NodeId, + hir_id: HirId, ) { // If the method is an impl for a trait, don't warn - let parent_id = cx.tcx.hir().get_parent(node_id); - let parent_node = cx.tcx.hir().find(parent_id); + let parent_id = cx.tcx.hir().get_parent_item(hir_id); + let parent_node = cx.tcx.hir().find_by_hir_id(parent_id); if let Some(Node::Item(item)) = parent_node { if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { @@ -84,7 +84,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { too_large_for_stack: self.too_large_for_stack, }; - let fn_def_id = cx.tcx.hir().local_def_id(node_id); + let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id); let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id); ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body); diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index b6e0480d986..7ea01ad5ec9 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -112,9 +112,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { decl: &'tcx hir::FnDecl, body: &'tcx hir::Body, span: Span, - nodeid: ast::NodeId, + hir_id: hir::HirId, ) { - let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(nodeid)) { + let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_hir_id( + cx.tcx.hir().get_parent_node_by_hir_id(hir_id)) + { matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _)) } else { false @@ -146,6 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { } } + let nodeid = cx.tcx.hir().hir_to_node_id(hir_id); self.check_raw_ptr(cx, unsafety, decl, body, nodeid); self.check_line_number(cx, span); } diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 72d95a0763a..8bbcce20984 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -1,9 +1,9 @@ use crate::utils::{in_macro, is_expn_of, snippet_opt, span_lint_and_then}; -use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl, MatchSource}; +use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl, HirId, MatchSource}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; -use syntax::{ast::NodeId, source_map::Span}; +use syntax::source_map::Span; /// **What it does:** Checks for missing return statements at the end of a block. /// @@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { _: &'tcx FnDecl, body: &'tcx Body, span: Span, - _: NodeId, + _: HirId, ) { let def_id = cx.tcx.hir().body_owner_def_id(body.id()); let mir = cx.tcx.optimized_mir(def_id); diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 018fdb08316..d045eaefbdb 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -1,5 +1,4 @@ use crate::consts::{constant, Constant}; -use crate::reexport::*; use crate::utils::sugg::Sugg; use crate::utils::{ get_item_name, get_parent_expr, implements_trait, in_constant, in_macro, is_integer_literal, iter_input_pats, @@ -256,7 +255,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { decl: &'tcx FnDecl, body: &'tcx Body, _: Span, - _: NodeId, + _: HirId, ) { if let FnKind::Closure(_) = k { // Does not apply to closures diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 9228c586bbf..00a3de0632f 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -1,11 +1,10 @@ use crate::utils::{is_entrypoint_fn, span_lint}; use rustc::hir; use rustc::hir::intravisit::FnKind; -use rustc::hir::{Body, Constness, FnDecl}; +use rustc::hir::{Body, Constness, FnDecl, HirId}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_mir::transform::qualify_min_const_fn::is_min_const_fn; -use syntax::ast::NodeId; use syntax_pos::Span; /// **What it does:** @@ -79,9 +78,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn { _: &FnDecl, _: &Body, span: Span, - node_id: NodeId, + hir_id: HirId, ) { - let def_id = cx.tcx.hir().local_def_id(node_id); + let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id); if is_entrypoint_fn(cx, def_id) { return; diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 2f71facb2cd..d77d95a9fff 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -81,7 +81,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { decl: &'tcx FnDecl, body: &'tcx Body, span: Span, - node_id: NodeId, + hir_id: HirId, ) { if in_macro(span) { return; @@ -103,7 +103,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(node_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_by_hir_id( + cx.tcx.hir().get_parent_node_by_hir_id(hir_id)) + { if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { @@ -122,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { let sized_trait = need!(cx.tcx.lang_items().sized_trait()); - let fn_def_id = cx.tcx.hir().local_def_id(node_id); + let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id); let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec()) .filter(|p| !p.is_global()) diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 5c994d8a2bc..0fd10d7796c 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -5,7 +5,7 @@ use crate::utils::{ use if_chain::if_chain; use matches::matches; use rustc::hir::intravisit::FnKind; -use rustc::hir::{def_id, Body, FnDecl}; +use rustc::hir::{def_id, Body, FnDecl, HirId}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::mir::{ self, traversal, @@ -17,7 +17,6 @@ use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use std::convert::TryFrom; use syntax::{ - ast::NodeId, source_map::{BytePos, Span}, }; @@ -88,7 +87,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone { _: &'tcx FnDecl, body: &'tcx Body, _: Span, - _: NodeId, + _: HirId, ) { let def_id = cx.tcx.hir().body_owner_def_id(body.id()); let mir = cx.tcx.optimized_mir(def_id); diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 9adac2f6d7f..40e76c2c089 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { decl: &'tcx FnDecl, body: &'tcx Body, _: Span, - _: NodeId, + _: HirId, ) { if in_external_macro(cx.sess(), body.value.span) { return; diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index 4e3bb7d329e..5174af9f7f4 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -13,7 +13,6 @@ use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use rustc_target::abi::LayoutOf; use rustc_target::spec::abi::Abi; -use syntax::ast::NodeId; use syntax_pos::Span; /// **What it does:** Checks for functions taking arguments by reference, where @@ -165,7 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { decl: &'tcx FnDecl, _body: &'tcx Body, span: Span, - node_id: NodeId, + hir_id: HirId, ) { if in_macro(span) { return; @@ -187,7 +186,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(node_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_by_hir_id( + cx.tcx.hir().get_parent_node_by_hir_id(hir_id)) + { if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { @@ -195,7 +196,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { } } - let fn_def_id = cx.tcx.hir().local_def_id(node_id); + let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id); let fn_sig = cx.tcx.fn_sig(fn_def_id); let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 7455f7d68fd..ff1eb459128 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -1,7 +1,6 @@ #![allow(clippy::default_hash_types)] use crate::consts::{constant, Constant}; -use crate::reexport::*; use crate::utils::paths; use crate::utils::{ clip, comparisons, differing_macro_contexts, higher, in_constant, in_macro, int_bits, last_path_segment, @@ -175,9 +174,19 @@ impl LintPass for TypePass { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass { - fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: NodeId) { + fn check_fn( + &mut self, + cx: &LateContext<'_, '_>, + _: FnKind<'_>, + decl: &FnDecl, + _: &Body, + _: Span, + id: HirId, + ) { // skip trait implementations, see #605 - if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent(id)) { + if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_hir_id( + cx.tcx.hir().get_parent_item(id)) + { if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { return; } @@ -1336,7 +1345,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass { decl: &'tcx FnDecl, _: &'tcx Body, _: Span, - _: NodeId, + _: HirId, ) { self.check_fndecl(cx, decl); } diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index 29d76a05118..57aa8810df0 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -4,7 +4,6 @@ use rustc::hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visit use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_data_structures::fx::FxHashMap; -use syntax::ast; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; @@ -53,7 +52,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel { decl: &'tcx hir::FnDecl, body: &'tcx hir::Body, span: Span, - fn_id: ast::NodeId, + fn_id: hir::HirId, ) { if in_macro(span) { return; diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 196715f77d7..c2288aed2d6 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -5,7 +5,6 @@ use rustc::{declare_tool_lint, lint_array}; use crate::utils::{in_macro, match_type, paths, span_lint_and_then, usage::is_potentially_mutated}; use rustc::hir::intravisit::*; use rustc::hir::*; -use syntax::ast::NodeId; use syntax::source_map::Span; /// **What it does:** Checks for calls of `unwrap[_err]()` that cannot fail. @@ -198,7 +197,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { decl: &'tcx FnDecl, body: &'tcx Body, span: Span, - fn_id: NodeId, + fn_id: HirId, ) { if in_macro(span) { return; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 4e2d4de8518..6cb57a4bcf1 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -8,7 +8,7 @@ use rustc::hir::{BindingAnnotation, Expr, ExprKind, Pat, PatKind, QPath, Stmt, S use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_data_structures::fx::FxHashMap; -use syntax::ast::{Attribute, LitKind, DUMMY_NODE_ID}; +use syntax::ast::{Attribute, LitKind}; /// **What it does:** Generates clippy code that detects the offending pattern /// @@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { return; } prelude(); - PrintVisitor::new("var").visit_variant(var, generics, DUMMY_NODE_ID); + PrintVisitor::new("var").visit_variant(var, generics, hir::DUMMY_HIR_ID); done(); }