]> git.lizzy.rs Git - rust.git/commitdiff
align with rust-lang/rust/#58836
authorljedrz <ljedrz@gmail.com>
Fri, 1 Mar 2019 12:26:06 +0000 (13:26 +0100)
committerljedrz <ljedrz@gmail.com>
Fri, 1 Mar 2019 18:10:14 +0000 (19:10 +0100)
20 files changed:
clippy_lints/src/copy_iterator.rs
clippy_lints/src/derive.rs
clippy_lints/src/empty_enum.rs
clippy_lints/src/escape.rs
clippy_lints/src/fallible_impl_from.rs
clippy_lints/src/large_enum_variant.rs
clippy_lints/src/len_zero.rs
clippy_lints/src/loops.rs
clippy_lints/src/methods/unnecessary_filter_map.rs
clippy_lints/src/missing_doc.rs
clippy_lints/src/missing_inline.rs
clippy_lints/src/needless_borrow.rs
clippy_lints/src/needless_pass_by_value.rs
clippy_lints/src/partialeq_ne_impl.rs
clippy_lints/src/trivially_copy_pass_by_ref.rs
clippy_lints/src/types.rs
clippy_lints/src/use_self.rs
clippy_lints/src/utils/inspector.rs
clippy_lints/src/utils/internal_lints.rs
clippy_lints/src/utils/usage.rs

index 59eef9e39dcebfbea578bd1939704c79681bb825..3fac6e78adbe8f2fc403b5e27e5da26752db6872 100644 (file)
@@ -44,7 +44,7 @@ fn name(&self) -> &'static str {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
     fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
         if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
-            let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.id));
+            let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
 
             if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
                 span_note_and_lint(
index 9580fbbe4c14a3146f9b294aca2e3aafc6d34998..2460a2746e3dba772f413c3ebe56802080c50e19 100644 (file)
@@ -77,7 +77,7 @@ fn name(&self) -> &'static str {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
     fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
         if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
-            let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.id));
+            let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
             let is_automatically_derived = is_automatically_derived(&*item.attrs);
 
             check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
index ab80625f6852d46e1dc1b0bcbc91d21a169fbb25..60d83a98d51e5a94fffea9483abcd896ddc922f0 100644 (file)
@@ -38,7 +38,7 @@ fn name(&self) -> &'static str {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
     fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
-        let did = cx.tcx.hir().local_def_id(item.id);
+        let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
         if let ItemKind::Enum(..) = item.node {
             let ty = cx.tcx.type_of(did);
             let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
index 3f49cbdc0f2c6a419e4df968a45ed5341a1a8ef4..6060d3e7b28e0c6c80664022fbaf3000516f9825 100644 (file)
@@ -6,9 +6,8 @@
 use rustc::middle::mem_categorization::{cmt_, Categorization};
 use rustc::ty::layout::LayoutOf;
 use rustc::ty::{self, Ty};
-use rustc::util::nodemap::NodeSet;
+use rustc::util::nodemap::HirIdSet;
 use rustc::{declare_tool_lint, lint_array};
-use syntax::ast::NodeId;
 use syntax::source_map::Span;
 
 pub struct Pass {
@@ -44,7 +43,7 @@ fn is_non_trait_box(ty: Ty<'_>) -> bool {
 
 struct EscapeDelegate<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,
-    set: NodeSet,
+    set: HirIdSet,
     too_large_for_stack: u64,
 }
 
@@ -80,7 +79,7 @@ fn check_fn(
 
         let mut v = EscapeDelegate {
             cx,
-            set: NodeSet::default(),
+            set: HirIdSet::default(),
             too_large_for_stack: self.too_large_for_stack,
         };
 
@@ -92,7 +91,7 @@ fn check_fn(
             span_lint(
                 cx,
                 BOXED_LOCAL,
-                cx.tcx.hir().span(node),
+                cx.tcx.hir().span_by_hir_id(node),
                 "local variable doesn't need to be boxed here",
             );
         }
@@ -111,13 +110,15 @@ fn consume(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, mode: ConsumeMode) {
     fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {}
     fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) {
         let map = &self.cx.tcx.hir();
-        if map.is_argument(consume_pat.id) {
+        if map.is_argument(map.hir_to_node_id(consume_pat.hir_id)) {
             // Skip closure arguments
-            if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
+            if let Some(Node::Expr(..)) = map.find_by_hir_id(
+                map.get_parent_node_by_hir_id(consume_pat.hir_id))
+            {
                 return;
             }
             if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
-                self.set.insert(consume_pat.id);
+                self.set.insert(consume_pat.hir_id);
             }
             return;
         }
@@ -129,7 +130,7 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) {
                         if let ExprKind::Box(..) = ex.node {
                             if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
                                 // let x = box (...)
-                                self.set.insert(consume_pat.id);
+                                self.set.insert(consume_pat.hir_id);
                             }
                             // TODO Box::new
                             // TODO vec![]
@@ -143,7 +144,7 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) {
             if self.set.contains(&lid) {
                 // let y = x where x is known
                 // remove x, insert y
-                self.set.insert(consume_pat.id);
+                self.set.insert(consume_pat.hir_id);
                 self.set.remove(&lid);
             }
         }
@@ -177,7 +178,7 @@ fn borrow(
             }
         }
     }
-    fn decl_without_init(&mut self, _: NodeId, _: Span) {}
+    fn decl_without_init(&mut self, _: HirId, _: Span) {}
     fn mutate(&mut self, _: HirId, _: Span, _: &cmt_<'tcx>, _: MutateMode) {}
 }
 
index 3669e8998a4c9a1cd6253886dac621b16efc4815..48d4db53d32e28d69df5d57c50ac5b15299e8785 100644 (file)
@@ -43,7 +43,7 @@ fn name(&self) -> &'static str {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
     fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
         // check for `impl From<???> for ..`
-        let impl_def_id = cx.tcx.hir().local_def_id(item.id);
+        let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
         if_chain! {
             if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
             if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
@@ -105,7 +105,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
             then {
                 // check the body for `begin_panic` or `unwrap`
                 let body = cx.tcx.hir().body(body_id);
-                let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.node_id);
+                let impl_item_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.id.hir_id);
                 let mut fpu = FindPanicUnwrap {
                     tcx: cx.tcx,
                     tables: cx.tcx.typeck_tables_of(impl_item_def_id),
index a6d34f2c7a234290b500d5098826d18bb985e8b3..7a1a0e599c1404a00c3831e931eef73db9db7170 100644 (file)
@@ -54,7 +54,7 @@ fn name(&self) -> &'static str {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
     fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
-        let did = cx.tcx.hir().local_def_id(item.id);
+        let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
         if let ItemKind::Enum(ref def, _) = item.node {
             let ty = cx.tcx.type_of(did);
             let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
index 2764cd6ffd9b34a3fdcb187d08bc1b5aae16304c..d66fcee97ecdbb7ad071ddfb8982edaae4c89d92 100644 (file)
@@ -132,7 +132,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &TraitItemRef, name: &str) -> b
         item.ident.name == name
             && if let AssociatedItemKind::Method { has_self } = item.kind {
                 has_self && {
-                    let did = cx.tcx.hir().local_def_id(item.id.node_id);
+                    let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
                     cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
                 }
             } else {
@@ -149,9 +149,11 @@ fn fill_trait_set(traitt: DefId, set: &mut FxHashSet<DefId>, cx: &LateContext<'_
         }
     }
 
-    if cx.access_levels.is_exported(visited_trait.id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
+    let trait_node_id = cx.tcx.hir().hir_to_node_id(visited_trait.hir_id);
+
+    if cx.access_levels.is_exported(trait_node_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
         let mut current_and_super_traits = FxHashSet::default();
-        let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.id);
+        let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
         fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
 
         let is_empty_method_found = current_and_super_traits
@@ -183,7 +185,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bo
         item.ident.name == name
             && if let AssociatedItemKind::Method { has_self } = item.kind {
                 has_self && {
-                    let did = cx.tcx.hir().local_def_id(item.id.node_id);
+                    let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
                     cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
                 }
             } else {
@@ -192,7 +194,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bo
     }
 
     let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
-        if cx.access_levels.is_exported(is_empty.id.node_id) {
+        if cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(is_empty.id.hir_id)) {
             return;
         } else {
             "a private"
@@ -202,8 +204,8 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bo
     };
 
     if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
-        if cx.access_levels.is_exported(i.id.node_id) {
-            let def_id = cx.tcx.hir().local_def_id(item.id);
+        if cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(i.id.hir_id)) {
+            let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
             let ty = cx.tcx.type_of(def_id);
 
             span_lint(
index 73da2467f59c2d64cd03b62581aabde93e2e5183..c8f557d3341e2523b6f7f9281cf8e0a819996d40 100644 (file)
@@ -1562,8 +1562,8 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
 }
 
 struct MutatePairDelegate {
-    node_id_low: Option<NodeId>,
-    node_id_high: Option<NodeId>,
+    hir_id_low: Option<HirId>,
+    hir_id_high: Option<HirId>,
     span_low: Option<Span>,
     span_high: Option<Span>,
 }
@@ -1578,10 +1578,10 @@ fn consume_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: ConsumeMode) {}
     fn borrow(&mut self, _: HirId, sp: Span, cmt: &cmt_<'tcx>, _: ty::Region<'_>, bk: ty::BorrowKind, _: LoanCause) {
         if let ty::BorrowKind::MutBorrow = bk {
             if let Categorization::Local(id) = cmt.cat {
-                if Some(id) == self.node_id_low {
+                if Some(id) == self.hir_id_low {
                     self.span_low = Some(sp)
                 }
-                if Some(id) == self.node_id_high {
+                if Some(id) == self.hir_id_high {
                     self.span_high = Some(sp)
                 }
             }
@@ -1590,16 +1590,16 @@ fn borrow(&mut self, _: HirId, sp: Span, cmt: &cmt_<'tcx>, _: ty::Region<'_>, bk
 
     fn mutate(&mut self, _: HirId, sp: Span, cmt: &cmt_<'tcx>, _: MutateMode) {
         if let Categorization::Local(id) = cmt.cat {
-            if Some(id) == self.node_id_low {
+            if Some(id) == self.hir_id_low {
                 self.span_low = Some(sp)
             }
-            if Some(id) == self.node_id_high {
+            if Some(id) == self.hir_id_high {
                 self.span_high = Some(sp)
             }
         }
     }
 
-    fn decl_without_init(&mut self, _: NodeId, _: Span) {}
+    fn decl_without_init(&mut self, _: HirId, _: Span) {}
 }
 
 impl<'tcx> MutatePairDelegate {
@@ -1635,7 +1635,7 @@ fn mut_warn_with_span(cx: &LateContext<'_, '_>, span: Option<Span>) {
     }
 }
 
-fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId> {
+fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId> {
     if_chain! {
         if let ExprKind::Path(ref qpath) = bound.node;
         if let QPath::Resolved(None, _) = *qpath;
@@ -1648,7 +1648,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
                     if let PatKind::Binding(bind_ann, ..) = pat.node;
                     if let BindingAnnotation::Mutable = bind_ann;
                     then {
-                        return Some(node_id);
+                        return Some(cx.tcx.hir().node_to_hir_id(node_id));
                     }
                 }
             }
@@ -1660,11 +1660,11 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
 fn check_for_mutation(
     cx: &LateContext<'_, '_>,
     body: &Expr,
-    bound_ids: &[Option<NodeId>],
+    bound_ids: &[Option<HirId>],
 ) -> (Option<Span>, Option<Span>) {
     let mut delegate = MutatePairDelegate {
-        node_id_low: bound_ids[0],
-        node_id_high: bound_ids[1],
+        hir_id_low: bound_ids[0],
+        hir_id_high: bound_ids[1],
         span_low: None,
         span_high: None,
     };
@@ -1938,8 +1938,7 @@ fn is_iterator_used_after_while_let<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, it
         past_while_let: false,
         var_used_after_while_let: false,
     };
-    let def_hir_id = cx.tcx.hir().node_to_hir_id(def_id);
-    if let Some(enclosing_block) = get_enclosing_block(cx, def_hir_id) {
+    if let Some(enclosing_block) = get_enclosing_block(cx, def_id) {
         walk_block(&mut visitor, enclosing_block);
     }
     visitor.var_used_after_while_let
@@ -1947,7 +1946,7 @@ fn is_iterator_used_after_while_let<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, it
 
 struct VarUsedAfterLoopVisitor<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,
-    def_id: NodeId,
+    def_id: HirId,
     iter_expr_id: HirId,
     past_while_let: bool,
     var_used_after_while_let: bool,
@@ -2053,7 +2052,7 @@ enum VarState {
 /// Scan a for loop for variables that are incremented exactly once.
 struct IncrementVisitor<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,       // context reference
-    states: FxHashMap<NodeId, VarState>, // incremented variables
+    states: FxHashMap<HirId, VarState>,  // incremented variables
     depth: u32,                          // depth of conditional expressions
     done: bool,
 }
@@ -2108,7 +2107,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
 struct InitializeVisitor<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>, // context reference
     end_expr: &'tcx Expr,          // the for loop. Stop scanning here.
-    var_id: NodeId,
+    var_id: HirId,
     state: VarState,
     name: Option<Name>,
     depth: u32, // depth of conditional expressions
@@ -2119,7 +2118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
     fn visit_stmt(&mut self, stmt: &'tcx Stmt) {
         // Look for declarations of the variable
         if let StmtKind::Local(ref local) = stmt.node {
-            if local.pat.id == self.var_id {
+            if local.pat.hir_id == self.var_id {
                 if let PatKind::Binding(.., ident, _) = local.pat.node {
                     self.name = Some(ident.name);
 
@@ -2191,11 +2190,11 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
     }
 }
 
-fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<NodeId> {
+fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<HirId> {
     if let ExprKind::Path(ref qpath) = expr.node {
         let path_res = cx.tables.qpath_def(qpath, expr.hir_id);
         if let Def::Local(node_id) = path_res {
-            return Some(node_id);
+            return Some(cx.tcx.hir().node_to_hir_id(node_id));
         }
     }
     None
@@ -2376,7 +2375,7 @@ fn check_infinite_loop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, cond: &'tcx Expr, e
 /// All variables definition IDs are collected
 struct VarCollectorVisitor<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,
-    ids: FxHashSet<NodeId>,
+    ids: FxHashSet<HirId>,
     def_ids: FxHashMap<def_id::DefId, bool>,
     skip: bool,
 }
@@ -2390,7 +2389,7 @@ fn insert_def_id(&mut self, ex: &'tcx Expr) {
             then {
                 match def {
                     Def::Local(node_id) | Def::Upvar(node_id, ..) => {
-                        self.ids.insert(node_id);
+                        self.ids.insert(self.cx.tcx.hir().node_to_hir_id(node_id));
                     },
                     Def::Static(def_id, mutable) => {
                         self.def_ids.insert(def_id, mutable);
index 8d90a4388fcbee2ad4f35d42ab806507e2a27d48..c081384db4b82a320f7392b6cb3b143f6524df13 100644 (file)
@@ -5,7 +5,6 @@
 use rustc::hir::def::Def;
 use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
 use rustc::lint::LateContext;
-use syntax::ast;
 
 use if_chain::if_chain;
 
@@ -18,7 +17,7 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr
 
     if let hir::ExprKind::Closure(_, _, body_id, ..) = args[1].node {
         let body = cx.tcx.hir().body(body_id);
-        let arg_id = body.arguments[0].pat.id;
+        let arg_id = body.arguments[0].pat.hir_id;
         let mutates_arg = match mutated_variables(&body.value, cx) {
             Some(used_mutably) => used_mutably.contains(&arg_id),
             None => true,
@@ -56,7 +55,7 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr
 // returns (found_mapping, found_filtering)
 fn check_expression<'a, 'tcx: 'a>(
     cx: &'a LateContext<'a, 'tcx>,
-    arg_id: ast::NodeId,
+    arg_id: hir::HirId,
     expr: &'tcx hir::Expr,
 ) -> (bool, bool) {
     match &expr.node {
@@ -69,7 +68,7 @@ fn check_expression<'a, 'tcx: 'a>(
                             if let hir::ExprKind::Path(path) = &args[0].node;
                             if let Def::Local(ref local) = cx.tables.qpath_def(path, args[0].hir_id);
                             then {
-                                if arg_id == *local {
+                                if arg_id == cx.tcx.hir().node_to_hir_id(*local) {
                                     return (false, false)
                                 }
                             }
@@ -113,7 +112,7 @@ fn check_expression<'a, 'tcx: 'a>(
 
 struct ReturnVisitor<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,
-    arg_id: ast::NodeId,
+    arg_id: hir::HirId,
     // Found a non-None return that isn't Some(input)
     found_mapping: bool,
     // Found a return that isn't Some
@@ -121,7 +120,7 @@ struct ReturnVisitor<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx: 'a> ReturnVisitor<'a, 'tcx> {
-    fn new(cx: &'a LateContext<'a, 'tcx>, arg_id: ast::NodeId) -> ReturnVisitor<'a, 'tcx> {
+    fn new(cx: &'a LateContext<'a, 'tcx>, arg_id: hir::HirId) -> ReturnVisitor<'a, 'tcx> {
         ReturnVisitor {
             cx,
             arg_id,
index e9efac1cd349153b792367c010f30710fbc235d4..8c5c1f65280fc98e40c76749f51aea2b07c7368e 100644 (file)
@@ -124,7 +124,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
             hir::ItemKind::Fn(..) => {
                 // ignore main()
                 if it.ident.name == "main" {
-                    let def_id = cx.tcx.hir().local_def_id(it.id);
+                    let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
                     let def_key = cx.tcx.hir().def_key(def_id);
                     if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
                         return;
index 40370506fd924090ece89b420e8c73c9dda4792f..2a7a211f26cb2d085e29046773a226b25c686e04 100644 (file)
@@ -95,7 +95,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
             return;
         }
 
-        if !cx.access_levels.is_exported(it.id) {
+        if !cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(it.hir_id)) {
             return;
         }
         match it.node {
@@ -115,7 +115,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
                                 // trait method with default body needs inline in case
                                 // an impl is not provided
                                 let desc = "a default trait method";
-                                let item = cx.tcx.hir().expect_trait_item(tit.id.node_id);
+                                let item = cx.tcx.hir().expect_trait_item_by_hir_id(tit.id.hir_id);
                                 check_missing_inline_attrs(cx, &item.attrs, item.span, desc);
                             }
                         },
index 777d2f683f0dab777a5d2fab19f9c52511ccfffe..91e3918731202b8bd9158410ac4b737cc6cdfe52 100644 (file)
@@ -4,13 +4,12 @@
 
 use crate::utils::{in_macro, snippet_opt, span_lint_and_then};
 use if_chain::if_chain;
-use rustc::hir::{BindingAnnotation, Expr, ExprKind, Item, MutImmutable, Pat, PatKind};
+use rustc::hir::{BindingAnnotation, Expr, ExprKind, HirId, Item, MutImmutable, Pat, PatKind};
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
 use rustc::ty;
 use rustc::ty::adjustment::{Adjust, Adjustment};
 use rustc::{declare_tool_lint, lint_array};
 use rustc_errors::Applicability;
-use syntax::ast::NodeId;
 
 /// **What it does:** Checks for address of operations (`&`) that are going to
 /// be dereferenced immediately by the compiler.
@@ -32,7 +31,7 @@
 
 #[derive(Default)]
 pub struct NeedlessBorrow {
-    derived_item: Option<NodeId>,
+    derived_item: Option<HirId>,
 }
 
 impl LintPass for NeedlessBorrow {
@@ -119,13 +118,13 @@ fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
     fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
         if item.attrs.iter().any(|a| a.check_name("automatically_derived")) {
             debug_assert!(self.derived_item.is_none());
-            self.derived_item = Some(item.id);
+            self.derived_item = Some(item.hir_id);
         }
     }
 
     fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
         if let Some(id) = self.derived_item {
-            if item.id == id {
+            if item.hir_id == id {
                 self.derived_item = None;
             }
         }
index 69d04ff7495e7ea43c4f819c6702da6f08d19cfc..43343bcfabf18ffc21f7df514a8fb887f211ebad 100644 (file)
@@ -17,7 +17,6 @@
 use rustc_errors::Applicability;
 use rustc_target::spec::abi::Abi;
 use std::borrow::Cow;
-use syntax::ast::NodeId;
 use syntax::errors::DiagnosticBuilder;
 use syntax_pos::Span;
 
@@ -210,7 +209,7 @@ fn check_fn(
                 if !implements_borrow_trait;
                 if !all_borrowable_trait;
 
-                if let PatKind::Binding(mode, canonical_id, ..) = arg.pat.node;
+                if let PatKind::Binding(mode, _, canonical_id, ..) = arg.pat.node;
                 if !moved_vars.contains(&canonical_id);
                 then {
                     if mode == BindingAnnotation::Mutable || mode == BindingAnnotation::RefMut {
@@ -326,10 +325,10 @@ fn check_fn(
 
 struct MovedVariablesCtxt<'a, 'tcx: 'a> {
     cx: &'a LateContext<'a, 'tcx>,
-    moved_vars: FxHashSet<NodeId>,
+    moved_vars: FxHashSet<HirId>,
     /// Spans which need to be prefixed with `*` for dereferencing the
     /// suggested additional reference.
-    spans_need_deref: FxHashMap<NodeId, FxHashSet<Span>>,
+    spans_need_deref: FxHashMap<HirId, FxHashSet<Span>>,
 }
 
 impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
@@ -353,16 +352,16 @@ fn non_moving_pat(&mut self, matched_pat: &Pat, cmt: &mc::cmt_<'tcx>) {
         let cmt = unwrap_downcast_or_interior(cmt);
 
         if let mc::Categorization::Local(vid) = cmt.cat {
-            let mut id = matched_pat.id;
+            let mut id = matched_pat.hir_id;
             loop {
-                let parent = self.cx.tcx.hir().get_parent_node(id);
+                let parent = self.cx.tcx.hir().get_parent_node_by_hir_id(id);
                 if id == parent {
                     // no parent
                     return;
                 }
                 id = parent;
 
-                if let Some(node) = self.cx.tcx.hir().find(id) {
+                if let Some(node) = self.cx.tcx.hir().find_by_hir_id(id) {
                     match node {
                         Node::Expr(e) => {
                             // `match` and `if let`
@@ -432,7 +431,7 @@ fn borrow(
 
     fn mutate(&mut self, _: HirId, _: Span, _: &mc::cmt_<'tcx>, _: euv::MutateMode) {}
 
-    fn decl_without_init(&mut self, _: NodeId, _: Span) {}
+    fn decl_without_init(&mut self, _: HirId, _: Span) {}
 }
 
 fn unwrap_downcast_or_interior<'a, 'tcx>(mut cmt: &'a mc::cmt_<'tcx>) -> mc::cmt_<'tcx> {
index f57fd22c0707d71f0ae0982a643567df726d0c88..5c532516b94367d20ce4754c091c625a94124d6a 100644 (file)
@@ -51,11 +51,10 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
             then {
                 for impl_item in impl_items {
                     if impl_item.ident.name == "ne" {
-                        let hir_id = cx.tcx.hir().node_to_hir_id(impl_item.id.node_id);
                         span_lint_node(
                             cx,
                             PARTIALEQ_NE_IMPL,
-                            hir_id,
+                            impl_item.id.hir_id,
                             impl_item.span,
                             "re-implementing `PartialEq::ne` is unnecessary",
                         );
index 59e6bcedbe54577603b145e1d54db5d88b5511b1..5c1d637874c60fdb8e1d81397b8600559cc120c4 100644 (file)
@@ -72,11 +72,11 @@ pub fn new(limit: Option<u64>, target: &SessionConfig) -> Self {
     }
 
     fn check_trait_method(&mut self, cx: &LateContext<'_, 'tcx>, item: &TraitItemRef) {
-        let method_def_id = cx.tcx.hir().local_def_id(item.id.node_id);
+        let method_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
         let method_sig = cx.tcx.fn_sig(method_def_id);
         let method_sig = cx.tcx.erase_late_bound_regions(&method_sig);
 
-        let decl = match cx.tcx.hir().fn_decl(item.id.node_id) {
+        let decl = match cx.tcx.hir().fn_decl_by_hir_id(item.id.hir_id) {
             Some(b) => b,
             None => return,
         };
index 7356f957d3111e1dea3dfa78456134e75c2573b7..09f596a10254469c5bc551903a2a30a13135d709 100644 (file)
@@ -2034,7 +2034,7 @@ fn suggestion<'a, 'tcx>(
             }
         }
 
-        if !cx.access_levels.is_exported(item.id) {
+        if !cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(item.hir_id)) {
             return;
         }
 
index 9d394a15bd5e27e93a0558ecf9b0d6fadb45a783..fb7bb1f0d2ae6b9675280a2d0e9aeff2d6d4229b 100644 (file)
@@ -192,7 +192,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
                         item_path,
                         cx,
                     };
-                    let impl_def_id = cx.tcx.hir().local_def_id(item.id);
+                    let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
                     let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);
 
                     if let Some(impl_trait_ref) = impl_trait_ref {
index c83e1c396bca2d06b230168bcd073ef0f07f08c7..4d43c374b722c0ddb44ec228405d84c1a85af83e 100644 (file)
@@ -344,7 +344,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
 }
 
 fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
-    let did = cx.tcx.hir().local_def_id(item.id);
+    let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
     println!("item `{}`", item.ident.name);
     match item.vis.node {
         hir::VisibilityKind::Public => println!("public"),
@@ -357,7 +357,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
     }
     match item.node {
         hir::ItemKind::ExternCrate(ref _renamed_from) => {
-            let def_id = cx.tcx.hir().local_def_id(item.id);
+            let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
             if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(def_id) {
                 let source = cx.tcx.used_crate_source(crate_id);
                 if let Some(ref src) = source.dylib {
index 78950493699a4e9a2932858f40d95393fd61a256..0821ab036b0a464f9cf37df47f152a437c7f3c04 100644 (file)
@@ -164,7 +164,8 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
                         output: &mut self.registered_lints,
                         cx,
                     };
-                    let body_id = cx.tcx.hir().body_owned_by(impl_item_refs[0].id.node_id);
+                    let node_id = cx.tcx.hir().hir_to_node_id(impl_item_refs[0].id.hir_id);
+                    let body_id = cx.tcx.hir().body_owned_by(node_id);
                     collector.visit_expr(&cx.tcx.hir().body(body_id).value);
                 }
             }
index 1f649829f810c772cf89fa3b2d88eb2a979b1fea..f4c89a8caec7e475210d6e53b4eeadc570c9c9a3 100644 (file)
@@ -7,11 +7,10 @@
 use rustc::middle::mem_categorization::Categorization;
 use rustc::ty;
 use rustc_data_structures::fx::FxHashSet;
-use syntax::ast::NodeId;
 use syntax::source_map::Span;
 
 /// Returns a set of mutated local variable ids or None if mutations could not be determined.
-pub fn mutated_variables<'a, 'tcx: 'a>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<NodeId>> {
+pub fn mutated_variables<'a, 'tcx: 'a>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
     let mut delegate = MutVarsDelegate {
         used_mutably: FxHashSet::default(),
         skip: false,
@@ -35,11 +34,11 @@ pub fn is_potentially_mutated<'a, 'tcx: 'a>(
         Def::Local(id) | Def::Upvar(id, ..) => id,
         _ => return true,
     };
-    mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
+    mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&cx.tcx.hir().node_to_hir_id(id)))
 }
 
 struct MutVarsDelegate {
-    used_mutably: FxHashSet<NodeId>,
+    used_mutably: FxHashSet<HirId>,
     skip: bool,
 }
 
@@ -79,5 +78,5 @@ fn mutate(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, _: MutateMode) {
         self.update(&cmt.cat)
     }
 
-    fn decl_without_init(&mut self, _: NodeId, _: Span) {}
+    fn decl_without_init(&mut self, _: HirId, _: Span) {}
 }