From f3ae929b2ddbf15048e0912974f63c6b799ee643 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 11:10:49 +0200 Subject: [PATCH] Rustup --- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/booleans.rs | 3 ++- clippy_lints/src/consts.rs | 6 +++--- clippy_lints/src/cyclomatic_complexity.rs | 4 ++-- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 4 ++-- clippy_lints/src/format.rs | 4 ++-- clippy_lints/src/functions.rs | 4 ++-- clippy_lints/src/let_if_seq.rs | 4 ++-- clippy_lints/src/lifetimes.rs | 3 ++- clippy_lints/src/loops.rs | 12 ++++++------ clippy_lints/src/mem_forget.rs | 2 +- clippy_lints/src/methods.rs | 2 +- clippy_lints/src/minmax.rs | 2 +- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/mut_reference.rs | 4 ++-- clippy_lints/src/no_effect.rs | 4 ++-- clippy_lints/src/panic.rs | 2 +- clippy_lints/src/print.rs | 6 +++--- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/shadow.rs | 4 ++-- clippy_lints/src/transmute.rs | 2 +- clippy_lints/src/types.rs | 9 +++++---- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/inspector.rs | 4 ++-- clippy_lints/src/utils/mod.rs | 20 ++++++++++---------- 27 files changed, 60 insertions(+), 57 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index a52c4d90aab..86d72226601 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -215,7 +215,7 @@ fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool ExprBreak(_, None) => false, ExprCall(ref path_expr, _) => { if let ExprPath(ref qpath) = path_expr.node { - let fun_id = tables.qpath_def(qpath, path_expr.id).def_id(); + let fun_id = tables.qpath_def(qpath, path_expr.hir_id).def_id(); !match_def_path(tcx, fun_id, &paths::BEGIN_PANIC) } else { true diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index f711a3680a7..6e5a18240cb 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -318,7 +318,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option { } }, ExprPath(ref qpath) => { - let def = cx.tables.qpath_def(qpath, lit.id); + let def = cx.tables.qpath_def(qpath, lit.hir_id); if let Def::Const(def_id) = def { lookup_const_by_id(cx.tcx, cx.param_env.and((def_id, Substs::empty()))).and_then(|(l, _ty)| { let body = if let Some(id) = cx.tcx.hir.as_local_node_id(l) { diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 4c67b260046..7c7dbe80883 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -122,6 +122,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { let mk_expr = |op| { Expr { id: DUMMY_NODE_ID, + hir_id: DUMMY_HIR_ID, span: DUMMY_SP, attrs: ThinVec::new(), node: ExprBinary(dummy_spanned(op), lhs.clone(), rhs.clone()), @@ -411,7 +412,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { match e.node { ExprBinary(binop, _, _) if binop.node == BiOr || binop.node == BiAnd => self.bool_expr(e), ExprUnary(UnNot, ref inner) => { - if self.cx.tables.node_types[&inner.id].is_bool() { + if self.cx.tables.node_types()[inner.hir_id].is_bool() { self.bool_expr(e); } else { walk_expr(self, e); diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 095fcf06e09..2a6fa051d2f 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -12,7 +12,7 @@ use std::cmp::PartialOrd; use std::hash::{Hash, Hasher}; use std::mem; use std::rc::Rc; -use syntax::ast::{FloatTy, LitKind, StrStyle, NodeId}; +use syntax::ast::{FloatTy, LitKind, StrStyle}; use syntax::ptr::P; #[derive(Debug, Copy, Clone)] @@ -249,7 +249,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { /// simple constant folding: Insert an expression, get a constant or none. fn expr(&mut self, e: &Expr) -> Option { match e.node { - ExprPath(ref qpath) => self.fetch_path(qpath, e.id), + ExprPath(ref qpath) => self.fetch_path(qpath, e.hir_id), ExprBlock(ref block) => self.block(block), ExprIf(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, otherwise), ExprLit(ref lit) => Some(lit_to_constant(&lit.node, self.tcx, self.tables.expr_ty(e))), @@ -284,7 +284,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { } /// lookup a possibly constant expression from a ExprPath - fn fetch_path(&mut self, qpath: &QPath, id: NodeId) -> Option { + fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option { let def = self.tables.qpath_def(qpath, id); match def { Def::Const(def_id) | diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index f2ee62995a0..c7593a195ff 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -71,7 +71,7 @@ impl CyclomaticComplexity { returns, .. } = helper; - let ret_ty = cx.tables.node_id_to_type(expr.id); + let ret_ty = cx.tables.node_id_to_type(expr.hir_id); let ret_adjust = if match_type(cx, ret_ty, &paths::RESULT) { returns } else { @@ -160,7 +160,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> { }, ExprCall(ref callee, _) => { walk_expr(self, e); - let ty = self.cx.tables.node_id_to_type(callee.id); + let ty = self.cx.tables.node_id_to_type(callee.hir_id); match ty.sty { ty::TyFnDef(..) | ty::TyFnPtr(_) => { let sig = ty.fn_sig(self.cx.tcx); diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index b02333b89a0..dfa8ddbab6c 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -120,7 +120,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprPath(ref qpath) = path.node, args.len() == 1, ], { - let def_id = cx.tables.qpath_def(qpath, path.id).def_id(); + let def_id = cx.tables.qpath_def(qpath, path.hir_id).def_id(); let lint; let msg; let arg = &args[0]; diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 81109761ca7..549b621812d 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence { if let ExprPath(ref qpath) = lhs.node { if let QPath::Resolved(_, ref path) = *qpath { if path.segments.len() == 1 { - let var = cx.tables.qpath_def(qpath, lhs.id).def_id(); + let var = cx.tables.qpath_def(qpath, lhs.hir_id).def_id(); let mut visitor = ReadVisitor { cx: cx, var: var, @@ -304,7 +304,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> { match expr.node { ExprPath(ref qpath) => { if let QPath::Resolved(None, ref path) = *qpath { - if path.segments.len() == 1 && self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var { + if path.segments.len() == 1 && self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var { if is_in_assignment_position(self.cx, expr) { // This is a write, not a read. } else { diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 16dced95760..fb2e04a3662 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if_let_chain!{[ let ExprPath(ref qpath) = fun.node, args.len() == 2, - match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::FMT_ARGUMENTS_NEWV1), + match_def_path(cx.tcx, resolve_node(cx, qpath, fun.hir_id).def_id(), &paths::FMT_ARGUMENTS_NEWV1), // ensure the format string is `"{..}"` with only one argument and no text check_static_str(cx, &args[0]), // ensure the format argument is `{}` ie. Display with no fancy option @@ -130,7 +130,7 @@ fn check_arg_is_display(cx: &LateContext, expr: &Expr) -> bool { let ExprCall(_, ref args) = exprs[0].node, args.len() == 2, let ExprPath(ref qpath) = args[1].node, - match_def_path(cx.tcx, resolve_node(cx, qpath, args[1].id).def_id(), &paths::DISPLAY_FMT_METHOD), + match_def_path(cx.tcx, resolve_node(cx, qpath, args[1].hir_id).def_id(), &paths::DISPLAY_FMT_METHOD), ], { let ty = walk_ptrs_ty(cx.tables.pat_ty(&pat[0])); diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index e45ab558089..1bb8780ea4a 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -187,7 +187,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { } }, hir::ExprMethodCall(_, _, ref args) => { - let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id(); + let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id(); let base_type = self.cx.tcx.type_of(def_id); if type_is_unsafe_function(self.cx, base_type) { @@ -210,7 +210,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> { fn check_arg(&self, ptr: &hir::Expr) { if let hir::ExprPath(ref qpath) = ptr.node { - let def = self.cx.tables.qpath_def(qpath, ptr.id); + let def = self.cx.tables.qpath_def(qpath, ptr.hir_id); if self.ptrs.contains(&def.def_id()) { span_lint( self.cx, diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index ecd18424bd8..64ba8adafe2 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -139,7 +139,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { if_let_chain! {[ let hir::ExprPath(ref qpath) = expr.node, - self.id == self.cx.tables.qpath_def(qpath, expr.id).def_id(), + self.id == self.cx.tables.qpath_def(qpath, expr.hir_id).def_id(), ], { self.used = true; return; @@ -162,7 +162,7 @@ fn check_assign<'a, 'tcx>( let hir::StmtSemi(ref expr, _) = expr.node, let hir::ExprAssign(ref var, ref value) = expr.node, let hir::ExprPath(ref qpath) = var.node, - decl == cx.tables.qpath_def(qpath, var.id).def_id(), + decl == cx.tables.qpath_def(qpath, var.hir_id).def_id(), ], { let mut v = UsedVisitor { cx: cx, diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 21b8bf6b5f5..507373fede5 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -284,7 +284,8 @@ impl<'v, 't> RefVisitor<'v, 't> { let last_path_segment = &last_path_segment(qpath).parameters; if let AngleBracketedParameters(ref params) = *last_path_segment { if params.lifetimes.is_empty() { - match self.cx.tables.qpath_def(qpath, ty.id) { + let hir_id = self.cx.tcx.hir.node_to_hir_id(ty.id); + match self.cx.tables.qpath_def(qpath, hir_id) { Def::TyAlias(def_id) | Def::Struct(def_id) => { let generics = self.cx.tcx.generics_of(def_id); diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 25015cb26bb..439a82e41ef 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -801,8 +801,8 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) { lint_iter_method(cx, args, arg, method_name); } } else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) { - let def_id = cx.tables.type_dependent_defs[&arg.id].def_id(); - let substs = cx.tables.node_substs(arg.id); + let def_id = cx.tables.type_dependent_defs()[arg.hir_id].def_id(); + let substs = cx.tables.node_substs(arg.hir_id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs(); @@ -1053,13 +1053,13 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { let QPath::Resolved(None, ref path) = *qpath, path.segments.len() == 1, // our variable! - self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var, + self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var, // the indexed container is referenced by a name let ExprPath(ref seqpath) = seqexpr.node, let QPath::Resolved(None, ref seqvar) = *seqpath, seqvar.segments.len() == 1, ], { - let def = self.cx.tables.qpath_def(seqpath, seqexpr.id); + let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id); match def { Def::Local(..) | Def::Upvar(..) => { let def_id = def.def_id(); @@ -1085,7 +1085,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { let QPath::Resolved(None, ref path) = *qpath, path.segments.len() == 1, ], { - if self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var { + if self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var { // we are not indexing anything, record that self.nonindex = true; } else { @@ -1376,7 +1376,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { fn var_def_id(cx: &LateContext, expr: &Expr) -> Option { if let ExprPath(ref qpath) = expr.node { - let path_res = cx.tables.qpath_def(qpath, expr.id); + let path_res = cx.tables.qpath_def(qpath, expr.hir_id); if let Def::Local(def_id) = path_res { let node_id = cx.tcx.hir.as_local_node_id(def_id).expect( "That DefId should be valid", diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 280b51b2312..edf477720d5 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -32,7 +32,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { if let ExprCall(ref path_expr, ref args) = e.node { if let ExprPath(ref qpath) = path_expr.node { - let def_id = cx.tables.qpath_def(qpath, path_expr.id).def_id(); + let def_id = cx.tables.qpath_def(qpath, path_expr.hir_id).def_id(); if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) { let forgot_ty = cx.tables.expr_ty(&args[0]); diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index c04fdde772f..a50d77f5521 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -898,7 +898,7 @@ fn lint_cstring_as_ptr(cx: &LateContext, expr: &hir::Expr, new: &hir::Expr, unwr let hir::ExprCall(ref fun, ref args) = new.node, args.len() == 1, let hir::ExprPath(ref path) = fun.node, - let Def::Method(did) = cx.tables.qpath_def(path, fun.id), + let Def::Method(did) = cx.tables.qpath_def(path, fun.hir_id), match_def_path(cx.tcx, did, &paths::CSTRING_NEW) ], { span_lint_and_then(cx, TEMPORARY_CSTRING_AS_PTR, expr.span, diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 2c6553e90c9..a86b2b300e5 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -62,7 +62,7 @@ enum MinMax { fn min_max<'a>(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &'a Expr)> { if let ExprCall(ref path, ref args) = expr.node { if let ExprPath(ref qpath) = path.node { - let def_id = cx.tables.qpath_def(qpath, path.id).def_id(); + let def_id = cx.tables.qpath_def(qpath, path.hir_id).def_id(); if match_def_path(cx.tcx, def_id, &paths::CMP_MIN) { fetch_const(cx, args, MinMax::Min) diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 67b0b1e167d..ef42bfe0b02 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -361,7 +361,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { binding != "_result" && // FIXME: #944 is_used(cx, expr) && // don't lint if the declaration is in a macro - non_macro_local(cx, &cx.tables.qpath_def(qpath, expr.id)) + non_macro_local(cx, &cx.tables.qpath_def(qpath, expr.hir_id)) { Some(binding) } else { diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 0c0c8f4061f..6a7b45bfbfb 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -47,8 +47,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed { } }, ExprMethodCall(ref path, _, ref arguments) => { - let def_id = cx.tables.type_dependent_defs[&e.id].def_id(); - let substs = cx.tables.node_substs(e.id); + let def_id = cx.tables.type_dependent_defs()[e.hir_id].def_id(); + let substs = cx.tables.node_substs(e.hir_id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); check_arguments(cx, arguments, method_type, &path.name.as_str()) }, diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index c57df468f7c..782b4033645 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -69,7 +69,7 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool { }, Expr_::ExprCall(ref callee, ref args) => { if let Expr_::ExprPath(ref qpath) = callee.node { - let def = cx.tables.qpath_def(qpath, callee.id); + let def = cx.tables.qpath_def(qpath, callee.hir_id); match def { Def::Struct(..) | Def::Variant(..) | @@ -165,7 +165,7 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option { if let Expr_::ExprPath(ref qpath) = callee.node { - let def = cx.tables.qpath_def(qpath, callee.id); + let def = cx.tables.qpath_def(qpath, callee.hir_id); match def { Def::Struct(..) | Def::Variant(..) | diff --git a/clippy_lints/src/panic.rs b/clippy_lints/src/panic.rs index 9c1c6beec4f..e9e529cfdb4 100644 --- a/clippy_lints/src/panic.rs +++ b/clippy_lints/src/panic.rs @@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprCall(ref fun, ref params) = ex.node, params.len() == 2, let ExprPath(ref qpath) = fun.node, - match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::BEGIN_PANIC), + match_def_path(cx.tcx, resolve_node(cx, qpath, fun.hir_id).def_id(), &paths::BEGIN_PANIC), let ExprLit(ref lit) = params[0].node, is_direct_expn_of(expr.span, "panic").is_some(), let LitKind::Str(ref string, _) = lit.node, diff --git a/clippy_lints/src/print.rs b/clippy_lints/src/print.rs index bf734cc9c0e..4a427fc79bd 100644 --- a/clippy_lints/src/print.rs +++ b/clippy_lints/src/print.rs @@ -73,7 +73,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprCall(ref fun, ref args) = expr.node, let ExprPath(ref qpath) = fun.node, ], { - let fun = resolve_node(cx, qpath, fun.id); + let fun = resolve_node(cx, qpath, fun.hir_id); let fun_id = fun.def_id(); // Search for `std::io::_print(..)` which is unique in a @@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprCall(ref args_fun, ref args_args) = args[0].node, let ExprPath(ref qpath) = args_fun.node, match_def_path(cx.tcx, - resolve_node(cx, qpath, args_fun.id).def_id(), + resolve_node(cx, qpath, args_fun.hir_id).def_id(), &paths::FMT_ARGUMENTS_NEWV1), args_args.len() == 2, let ExprAddrOf(_, ref match_expr) = args_args[1].node, @@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { // `::std::fmt::ArgumentV1::new(__arg0, ::std::fmt::Debug::fmt)` else if args.len() == 2 && match_def_path(cx.tcx, fun_id, &paths::FMT_ARGUMENTV1_NEW) { if let ExprPath(ref qpath) = args[1].node { - let def_id = cx.tables.qpath_def(qpath, args[1].id).def_id(); + let def_id = cx.tables.qpath_def(qpath, args[1].hir_id).def_id(); if match_def_path(cx.tcx, def_id, &paths::DEBUG_FMT_METHOD) && !is_in_debug_impl(cx, expr) && is_expn_of(expr.span, "panic").is_none() { span_lint(cx, USE_DEBUG, args[0].span, "use of `Debug`-based formatting"); diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 4feeb6d0939..4241dd94ac9 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprPath(ref qpath) = fun.node, args.len() == 1, ], { - let def_id = cx.tables.qpath_def(qpath, fun.id).def_id(); + let def_id = cx.tables.qpath_def(qpath, fun.hir_id).def_id(); if match_def_path(cx.tcx, def_id, &paths::REGEX_NEW) || match_def_path(cx.tcx, def_id, &paths::REGEX_BUILDER_NEW) { check_regex(cx, &args[0], true); diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index e80636ca347..b4857f1b613 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -148,7 +148,7 @@ fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: } } -fn is_binding(cx: &LateContext, pat_id: NodeId) -> bool { +fn is_binding(cx: &LateContext, pat_id: HirId) -> bool { let var_ty = cx.tables.node_id_to_type(pat_id); match var_ty.sty { ty::TyAdt(..) => false, @@ -167,7 +167,7 @@ fn check_pat<'a, 'tcx>( match pat.node { PatKind::Binding(_, _, ref ident, ref inner) => { let name = ident.node; - if is_binding(cx, pat.id) { + if is_binding(cx, pat.hir_id) { let mut new_binding = true; for tup in bindings.iter_mut() { if tup.0 == name { diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 13555e3bb05..bcb03c79215 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -88,7 +88,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { if let ExprCall(ref path_expr, ref args) = e.node { if let ExprPath(ref qpath) = path_expr.node { - let def_id = cx.tables.qpath_def(qpath, path_expr.id).def_id(); + let def_id = cx.tables.qpath_def(qpath, path_expr.hir_id).def_id(); if match_def_path(cx.tcx, def_id, &paths::TRANSMUTE) { let from_ty = cx.tables.expr_ty(&args[0]); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 44e33d40a38..ed0027af533 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -149,7 +149,8 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { } match ast_ty.node { TyPath(ref qpath) if !is_local => { - let def = cx.tables.qpath_def(qpath, ast_ty.id); + let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id); + let def = cx.tables.qpath_def(qpath, hir_id); if let Some(def_id) = opt_def_id(def) { if Some(def_id) == cx.tcx.lang_items.owned_box() { let last = last_path_segment(qpath); @@ -157,8 +158,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { let PathParameters::AngleBracketedParameters(ref ag) = last.parameters, let Some(vec) = ag.types.get(0), let TyPath(ref qpath) = vec.node, - let def::Def::Struct(..) = cx.tables.qpath_def(qpath, vec.id), - let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, vec.id)), + let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(vec.id))), match_def_path(cx.tcx, did, &paths::VEC), ], { span_help_and_lint(cx, @@ -202,7 +202,8 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { TyRptr(ref lt, MutTy { ref ty, ref mutbl }) => { match ty.node { TyPath(ref qpath) => { - let def = cx.tables.qpath_def(qpath, ast_ty.id); + let hir_id = cx.tcx.hir.node_to_hir_id(ty.id); + let def = cx.tables.qpath_def(qpath, hir_id); if_let_chain! {[ let Some(def_id) = opt_def_id(def), Some(def_id) == cx.tcx.lang_items.owned_box(), diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 593cbf69f5b..d138892a092 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -159,7 +159,7 @@ pub fn vec_macro<'e>(cx: &LateContext, expr: &'e hir::Expr) -> Option bool { fn print_decl(cx: &LateContext, decl: &hir::Decl) { match decl.node { hir::DeclLocal(ref local) => { - println!("local variable of type {}", cx.tables.node_id_to_type(local.id)); + println!("local variable of type {}", cx.tables.node_id_to_type(local.hir_id)); println!("pattern:"); print_pat(cx, &local.pat, 0); if let Some(ref e) = local.init { @@ -161,7 +161,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) { let ind = " ".repeat(indent); println!("{}+", ind); println!("{}ty: {}", ind, cx.tables.expr_ty(expr)); - println!("{}adjustments: {:?}", ind, cx.tables.adjustments.get(&expr.id)); + println!("{}adjustments: {:?}", ind, cx.tables.adjustments().get(expr.hir_id)); match expr.node { hir::ExprBox(ref e) => { println!("{}Box", ind); diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index bb79fcef909..d62f3963bc3 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -196,7 +196,7 @@ pub fn match_type(cx: &LateContext, ty: Ty, path: &[&str]) -> bool { /// Check if the method call given in `expr` belongs to given type. pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool { - let method_call = cx.tables.type_dependent_defs[&expr.id]; + let method_call = cx.tables.type_dependent_defs()[expr.hir_id]; let trt_id = cx.tcx.impl_of_method(method_call.def_id()); if let Some(trt_id) = trt_id { match_def_path(cx.tcx, trt_id, path) @@ -207,7 +207,7 @@ pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool { /// Check if the method call given in `expr` belongs to given trait. pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool { - let method_call = cx.tables.type_dependent_defs[&expr.id]; + let method_call = cx.tables.type_dependent_defs()[expr.hir_id]; let trt_id = cx.tcx.trait_of_item(method_call.def_id()); if let Some(trt_id) = trt_id { match_def_path(cx.tcx, trt_id, path) @@ -347,8 +347,8 @@ pub fn implements_trait<'a, 'tcx>( }) } -/// Resolve the definition of a node from its `NodeId`. -pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: NodeId) -> def::Def { +/// Resolve the definition of a node from its `HirId`. +pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: HirId) -> def::Def { cx.tables.qpath_def(qpath, id) } @@ -656,7 +656,7 @@ pub fn is_integer_literal(expr: &Expr, value: u128) -> bool { } pub fn is_adjusted(cx: &LateContext, e: &Expr) -> bool { - cx.tables.adjustments.get(&e.id).is_some() + cx.tables.adjustments().get(e.hir_id).is_some() } pub struct LimitStack { @@ -833,9 +833,9 @@ pub fn is_copy<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { /// Return whether a pattern is refutable. pub fn is_refutable(cx: &LateContext, pat: &Pat) -> bool { - fn is_enum_variant(cx: &LateContext, qpath: &QPath, did: NodeId) -> bool { + fn is_enum_variant(cx: &LateContext, qpath: &QPath, id: HirId) -> bool { matches!( - cx.tables.qpath_def(qpath, did), + cx.tables.qpath_def(qpath, id), def::Def::Variant(..) | def::Def::VariantCtor(..) ) } @@ -851,17 +851,17 @@ pub fn is_refutable(cx: &LateContext, pat: &Pat) -> bool { PatKind::Ref(ref pat, _) => is_refutable(cx, pat), PatKind::Lit(..) | PatKind::Range(..) => true, - PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.id), + PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.hir_id), PatKind::Tuple(ref pats, _) => are_refutable(cx, pats.iter().map(|pat| &**pat)), PatKind::Struct(ref qpath, ref fields, _) => { - if is_enum_variant(cx, qpath, pat.id) { + if is_enum_variant(cx, qpath, pat.hir_id) { true } else { are_refutable(cx, fields.iter().map(|field| &*field.node.pat)) } }, PatKind::TupleStruct(ref qpath, ref pats, _) => { - if is_enum_variant(cx, qpath, pat.id) { + if is_enum_variant(cx, qpath, pat.hir_id) { true } else { are_refutable(cx, pats.iter().map(|pat| &**pat))