From 8212b4e24a7564eeaa8c61d008fb24f7ec5e334a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 27 Feb 2019 10:39:33 +0100 Subject: [PATCH] enable rust-lang/rust#58754 --- clippy_lints/src/functions.rs | 10 +++++----- clippy_lints/src/methods/mod.rs | 11 ++++++----- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_inline.rs | 5 +++-- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/non_copy_const.rs | 4 ++-- clippy_lints/src/ptr.rs | 14 +++++++------- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/utils/diagnostics.rs | 6 ++---- clippy_lints/src/utils/mod.rs | 7 +++---- 10 files changed, 31 insertions(+), 32 deletions(-) diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 3b15f2760c15..1a9089b55d77 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -150,8 +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_raw_ptr(cx, unsafety, decl, body, hir_id); self.check_line_number(cx, span, body); } @@ -164,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { 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 @@ impl<'a, 'tcx> Functions { 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)) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index dd75c8aff37b..78781bc626c6 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -906,9 +906,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { 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; @@ -916,7 +916,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { 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 && @@ -963,7 +964,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } 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() { diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 9fd67e2fcbfd..e9efac1cd349 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -162,7 +162,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { 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) => { diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 754215799e58..40370506fd92 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -146,7 +146,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { } // 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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { 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), diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index ce8b1db505ee..fe992d3cf22c 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { 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() { diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 3bc46f53308f..34a4a7eb2f72 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -177,8 +177,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { 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); diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index cddb1c7106d3..e930aae1040b 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -10,7 +10,6 @@ use rustc::ty; 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 @@ impl LintPass for PointerPass { 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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { } 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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { } #[allow(clippy::too_many_lines)] -fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option) { - 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) { + 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(); diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 94f98a17e4f7..9d394a15bd5e 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -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); diff --git a/clippy_lints/src/utils/diagnostics.rs b/clippy_lints/src/utils/diagnostics.rs index 5aaf2f9f7cc7..6d04ce70bc43 100644 --- a/clippy_lints/src/utils/diagnostics.rs +++ b/clippy_lints/src/utils/diagnostics.rs @@ -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); } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index ee148ce35588..bcb0989fb1d3 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -753,8 +753,8 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option { } /// 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) } @@ -929,8 +929,7 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> { /// /// 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 {