This commit is contained in:
Oliver Schneider 2017-08-15 11:10:49 +02:00
parent 3ab06c1f77
commit f3ae929b2d
27 changed files with 60 additions and 57 deletions

View File

@ -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

View File

@ -318,7 +318,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u128> {
}
},
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) {

View File

@ -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);

View File

@ -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<Constant> {
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<Constant> {
fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option<Constant> {
let def = self.tables.qpath_def(qpath, id);
match def {
Def::Const(def_id) |

View File

@ -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);

View File

@ -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];

View File

@ -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 {

View File

@ -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]));

View File

@ -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,

View File

@ -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,

View File

@ -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);

View File

@ -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<NodeId> {
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",

View File

@ -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]);

View File

@ -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,

View File

@ -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)

View File

@ -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 {

View File

@ -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())
},

View File

@ -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<Vec<&'a Exp
},
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(..) |

View File

@ -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,

View File

@ -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");

View File

@ -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);

View File

@ -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 {

View File

@ -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]);

View File

@ -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(),

View File

@ -159,7 +159,7 @@ pub fn vec_macro<'e>(cx: &LateContext, expr: &'e hir::Expr) -> Option<VecArgs<'e
let hir::ExprPath(ref path) = fun.node,
is_expn_of(fun.span, "vec").is_some(),
], {
let fun_def = resolve_node(cx, path, fun.id);
let fun_def = resolve_node(cx, path, fun.hir_id);
return if match_def_path(cx.tcx, fun_def.def_id(), &paths::VEC_FROM_ELEM) && args.len() == 2 {
// `vec![elem; size]` case
Some(VecArgs::Repeat(&args[0], &args[1]))

View File

@ -145,7 +145,7 @@ fn has_attr(attrs: &[Attribute]) -> 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);

View File

@ -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))