]> git.lizzy.rs Git - rust.git/commitdiff
enable rust-lang/rust#58754
authorljedrz <ljedrz@gmail.com>
Wed, 27 Feb 2019 09:39:33 +0000 (10:39 +0100)
committerljedrz <ljedrz@gmail.com>
Fri, 1 Mar 2019 18:10:14 +0000 (19:10 +0100)
clippy_lints/src/functions.rs
clippy_lints/src/methods/mod.rs
clippy_lints/src/missing_doc.rs
clippy_lints/src/missing_inline.rs
clippy_lints/src/new_without_default.rs
clippy_lints/src/non_copy_const.rs
clippy_lints/src/ptr.rs
clippy_lints/src/use_self.rs
clippy_lints/src/utils/diagnostics.rs
clippy_lints/src/utils/mod.rs

index 3b15f2760c155d246d7131a4c9b7e303a464735c..1a9089b55d77f000d45b54166d491b7101057450 100644 (file)
@@ -150,8 +150,7 @@ fn check_fn(
             }
         }
 
-        let nodeid = cx.tcx.hir().hir_to_node_id(hir_id);
-        self.check_raw_ptr(cx, unsafety, decl, body, nodeid);
+        self.check_raw_ptr(cx, unsafety, decl, body, hir_id);
         self.check_line_number(cx, span, body);
     }
 
@@ -164,7 +163,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Trai
 
             if let hir::TraitMethod::Provided(eid) = *eid {
                 let body = cx.tcx.hir().body(eid);
-                self.check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.id);
+                self.check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id);
             }
         }
     }
@@ -255,10 +254,11 @@ fn check_raw_ptr(
         unsafety: hir::Unsafety,
         decl: &'tcx hir::FnDecl,
         body: &'tcx hir::Body,
-        nodeid: ast::NodeId,
+        hir_id: hir::HirId,
     ) {
         let expr = &body.value;
-        if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) {
+        let node_id = cx.tcx.hir().hir_to_node_id(hir_id);
+        if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(node_id) {
             let raw_ptrs = iter_input_pats(decl, body)
                 .zip(decl.inputs.iter())
                 .filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
index 8d4bb06e59be63e951034e742295330aab33bdf2..deaf054aec7dd5189606e8d2005b8848da8a5374 100644 (file)
@@ -907,9 +907,9 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
             return;
         }
         let name = implitem.ident.name;
-        let parent = cx.tcx.hir().get_parent(implitem.id);
-        let item = cx.tcx.hir().expect_item(parent);
-        let def_id = cx.tcx.hir().local_def_id(item.id);
+        let parent = cx.tcx.hir().get_parent_item(implitem.hir_id);
+        let item = cx.tcx.hir().expect_item_by_hir_id(parent);
+        let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
         let ty = cx.tcx.type_of(def_id);
         if_chain! {
             if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
@@ -917,7 +917,8 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
             if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
             if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
             then {
-                if cx.access_levels.is_exported(implitem.id) {
+                let node_id = cx.tcx.hir().hir_to_node_id(implitem.hir_id);
+                if cx.access_levels.is_exported(node_id) {
                 // check missing trait implementations
                     for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS {
                         if name == method_name &&
@@ -964,7 +965,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
         }
 
         if let hir::ImplItemKind::Method(_, _) = implitem.node {
-            let ret_ty = return_ty(cx, implitem.id);
+            let ret_ty = return_ty(cx, implitem.hir_id);
 
             // walk the return type and check for Self (this does not check associated types)
             for inner_type in ret_ty.walk() {
index 9fd67e2fcbfdecdceef023fc5bd7c2401ac4db14..e9efac1cd349153b792367c010f30710fbc235d4 100644 (file)
@@ -162,7 +162,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir
 
     fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
         // If the method is an impl for a trait, don't doc.
-        let def_id = cx.tcx.hir().local_def_id(impl_item.id);
+        let def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
         match cx.tcx.associated_item(def_id).container {
             ty::TraitContainer(_) => return,
             ty::ImplContainer(cid) => {
index 754215799e58770cd96ea15adc4b278aa4065388..40370506fd924090ece89b420e8c73c9dda4792f 100644 (file)
@@ -146,7 +146,8 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::
         }
 
         // If the item being implemented is not exported, then we don't need #[inline]
-        if !cx.access_levels.is_exported(impl_item.id) {
+        let node_id = cx.tcx.hir().hir_to_node_id(impl_item.hir_id);
+        if !cx.access_levels.is_exported(node_id) {
             return;
         }
 
@@ -155,7 +156,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::
             hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(_) | hir::ImplItemKind::Existential(_) => return,
         };
 
-        let def_id = cx.tcx.hir().local_def_id(impl_item.id);
+        let def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
         let trait_def_id = match cx.tcx.associated_item(def_id).container {
             TraitContainer(cid) => Some(cid),
             ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
index ce8b1db505ee473a16bc65d8ccaa65b72ad5789f..fe992d3cf22c0f5b46c90b5de126d3c012c2b2c0 100644 (file)
@@ -133,7 +133,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
                             let self_did = cx.tcx.hir().local_def_id_from_hir_id(cx.tcx.hir().get_parent_item(id));
                             let self_ty = cx.tcx.type_of(self_did);
                             if_chain! {
-                                if same_tys(cx, self_ty, return_ty(cx, node_id));
+                                if same_tys(cx, self_ty, return_ty(cx, id));
                                 if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT);
                                 then {
                                     if self.impling_types.is_none() {
index 3bc46f53308f6d0c1c2041d734b22d64db9b559d..34a4a7eb2f72db4a5f79a0590aa81e7435abab75 100644 (file)
@@ -177,8 +177,8 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx Tra
 
     fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
         if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node {
-            let item_node_id = cx.tcx.hir().get_parent_node(impl_item.id);
-            let item = cx.tcx.hir().expect_item(item_node_id);
+            let item_hir_id = cx.tcx.hir().get_parent_node_by_hir_id(impl_item.hir_id);
+            let item = cx.tcx.hir().expect_item_by_hir_id(item_hir_id);
             // ensure the impl is an inherent impl.
             if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node {
                 let ty = hir_ty_to_ty(cx.tcx, hir_ty);
index cddb1c7106d3a7a0530a607a9d770e2a24b3d40e..e930aae1040bd5e3d36d5c6e525521cfa97a6464 100644 (file)
@@ -10,7 +10,6 @@
 use rustc::{declare_tool_lint, lint_array};
 use rustc_errors::Applicability;
 use std::borrow::Cow;
-use syntax::ast::NodeId;
 use syntax::source_map::Span;
 use syntax_pos::MultiSpan;
 
@@ -111,18 +110,19 @@ fn name(&self) -> &'static str {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
     fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
         if let ItemKind::Fn(ref decl, _, _, body_id) = item.node {
-            check_fn(cx, decl, item.id, Some(body_id));
+            check_fn(cx, decl, item.hir_id, Some(body_id));
         }
     }
 
     fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
         if let ImplItemKind::Method(ref sig, body_id) = item.node {
-            if let Some(Node::Item(it)) = cx.tcx.hir().find(cx.tcx.hir().get_parent(item.id)) {
+            let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
+            if let Some(Node::Item(it)) = cx.tcx.hir().find_by_hir_id(parent_item) {
                 if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
                     return; // ignore trait impls
                 }
             }
-            check_fn(cx, &sig.decl, item.id, Some(body_id));
+            check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
         }
     }
 
@@ -133,7 +133,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem
             } else {
                 None
             };
-            check_fn(cx, &sig.decl, item.id, body_id);
+            check_fn(cx, &sig.decl, item.hir_id, body_id);
         }
     }
 
@@ -152,8 +152,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
 }
 
 #[allow(clippy::too_many_lines)]
-fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<BodyId>) {
-    let fn_def_id = cx.tcx.hir().local_def_id(fn_id);
+fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: Option<BodyId>) {
+    let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(fn_id);
     let sig = cx.tcx.fn_sig(fn_def_id);
     let fn_ty = sig.skip_binder();
 
index 94f98a17e4f7461d0edaad9f9888d1a5134fe1d0..9d394a15bd5e27e93a0558ecf9b0d6fadb45a783 100644 (file)
@@ -137,7 +137,7 @@ fn check_trait_method_impl_decl<'a, 'tcx: 'a>(
     let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id);
     let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig);
 
-    let impl_method_def_id = cx.tcx.hir().local_def_id(impl_item.id);
+    let impl_method_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
     let impl_method_sig = cx.tcx.fn_sig(impl_method_def_id);
     let impl_method_sig = cx.tcx.erase_late_bound_regions(&impl_method_sig);
 
index 5aaf2f9f7cc704da2a189ab6970ca20b01296dd2..6d04ce70bc434abbcb1936bb04af3c6fdc9e5ddb 100644 (file)
@@ -135,8 +135,7 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
 }
 
 pub fn span_lint_node(cx: &LateContext<'_, '_>, lint: &'static Lint, node: HirId, sp: Span, msg: &str) {
-    let node_id = cx.tcx.hir().hir_to_node_id(node);
-    DiagnosticWrapper(cx.tcx.struct_span_lint_node(lint, node_id, sp, msg)).docs_link(lint);
+    DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, node, sp, msg)).docs_link(lint);
 }
 
 pub fn span_lint_node_and_then(
@@ -147,8 +146,7 @@ pub fn span_lint_node_and_then(
     msg: &str,
     f: impl FnOnce(&mut DiagnosticBuilder<'_>),
 ) {
-    let node_id = cx.tcx.hir().hir_to_node_id(node);
-    let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_node(lint, node_id, sp, msg));
+    let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, node, sp, msg));
     f(&mut db.0);
     db.docs_link(lint);
 }
index d7ed3191ddbe473caf4ff92634946dfb06fc8786..70ba0592caa314884f6e031a0702ea6a14748df3 100644 (file)
@@ -702,8 +702,8 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
 }
 
 /// Convenience function to get the return type of a function
-pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Ty<'tcx> {
-    let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
+pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
+    let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(fn_item);
     let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
     cx.tcx.erase_late_bound_regions(&ret_ty)
 }
@@ -878,8 +878,7 @@ fn is_err(arm: &Arm) -> bool {
 ///
 /// Useful for skipping long running code when it's unnecessary
 pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: HirId) -> bool {
-    let node_id = cx.tcx.hir().hir_to_node_id(id);
-    cx.tcx.lint_level_at_node(lint, node_id).0 == Level::Allow
+    cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
 }
 
 pub fn get_arg_name(pat: &Pat) -> Option<ast::Name> {