diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 6433e0d640d5..a2559c774011 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 76b342089bc5..da86734cac1e 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 4806736682f1..35fef9e3af4e 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 a276579b1b5b..a39ee6d18eea 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 b6e0480d986b..53703ef9bce2 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -112,9 +112,13 @@ 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 +150,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 72d95a0763ae..8bbcce209847 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 018fdb083162..d045eaefbdb9 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 9228c586bbfd..00a3de0632f8 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 2f71facb2cd3..fb78dd01f5e5 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,11 @@ 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 +126,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 5c994d8a2bc9..a80fd311c3dd 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, @@ -16,10 +16,7 @@ use rustc::ty; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use std::convert::TryFrom; -use syntax::{ - ast::NodeId, - source_map::{BytePos, Span}, -}; +use syntax::source_map::{BytePos, Span}; macro_rules! unwrap_or_continue { ($x:expr) => { @@ -88,7 +85,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 9adac2f6d7fa..40e76c2c089b 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 4e3bb7d329e1..59e6bcedbe54 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,11 @@ 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 +198,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 7455f7d68fd0..dc1119595022 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,9 @@ 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 +1335,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 29d76a051186..57aa8810df02 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 196715f77d77..c2288aed2d6b 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 4e2d4de85188..6cb57a4bcf19 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(); }