This commit is contained in:
Matthias Krüger 2018-12-08 01:56:03 +01:00 committed by Philipp Hansch
parent 26602ddff4
commit f13d23de41
No known key found for this signature in database
GPG Key ID: B6FA06A6E0E2665B
46 changed files with 140 additions and 140 deletions

View File

@ -121,11 +121,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
}
fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
let body_owner = cx.tcx.hir.body_owner(body.id());
let body_owner = cx.tcx.hir().body_owner(body.id());
match cx.tcx.hir.body_owner_kind(body_owner) {
match cx.tcx.hir().body_owner_kind(body_owner) {
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const => {
let body_span = cx.tcx.hir.span(body_owner);
let body_span = cx.tcx.hir().span(body_owner);
if let Some(span) = self.const_span {
if span.contains(body_span) {
@ -139,8 +139,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
}
fn check_body_post(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
let body_owner = cx.tcx.hir.body_owner(body.id());
let body_span = cx.tcx.hir.span(body_owner);
let body_owner = cx.tcx.hir().body_owner(body.id());
let body_span = cx.tcx.hir().span(body_owner);
if let Some(span) = self.const_span {
if span.contains(body_span) {

View File

@ -144,12 +144,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
return; // useless if the trait doesn't exist
};
// check that we are not inside an `impl AssignOp` of this exact operation
let parent_fn = cx.tcx.hir.get_parent(e.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
let parent_fn = cx.tcx.hir().get_parent(e.id);
let parent_impl = cx.tcx.hir().get_parent(parent_fn);
// the crate node is the only one that is not in the map
if_chain! {
if parent_impl != ast::CRATE_NODE_ID;
if let hir::Node::Item(item) = cx.tcx.hir.get(parent_impl);
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) =
item.node;
if trait_ref.path.def.def_id() == trait_id;

View File

@ -354,7 +354,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
fn is_relevant_item(tcx: TyCtxt<'_, '_, '_>, item: &Item) -> bool {
if let ItemKind::Fn(_, _, _, eid) = item.node {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value)
} else {
true
}
@ -362,7 +362,7 @@ fn is_relevant_item(tcx: TyCtxt<'_, '_, '_>, item: &Item) -> bool {
fn is_relevant_impl(tcx: TyCtxt<'_, '_, '_>, item: &ImplItem) -> bool {
match item.node {
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value),
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value),
_ => false,
}
}
@ -371,7 +371,7 @@ fn is_relevant_trait(tcx: TyCtxt<'_, '_, '_>, item: &TraitItem) -> bool {
match item.node {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value)
},
_ => false,
}

View File

@ -68,7 +68,7 @@ struct ExVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
let body = self.cx.tcx.hir.body(eid);
let body = self.cx.tcx.hir().body(eid);
let ex = &body.value;
if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro(body.value.span) {
self.found_block = Some(ex);

View File

@ -60,7 +60,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
if filter_args.len() == 2;
if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].node;
then {
let body = cx.tcx.hir.body(body_id);
let body = cx.tcx.hir().body(body_id);
if_chain! {
if body.arguments.len() == 1;
if let Some(argname) = get_pat_name(&body.arguments[0].pat);

View File

@ -49,7 +49,7 @@ impl LintPass for CopyIterator {
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(item.id));
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
span_note_and_lint(

View File

@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity {
span: Span,
node_id: NodeId,
) {
let def_id = cx.tcx.hir.local_def_id(node_id);
let def_id = cx.tcx.hir().local_def_id(node_id);
if !cx.tcx.has_attr(def_id, "test") {
self.check(cx, body, span);
}

View File

@ -82,7 +82,7 @@ impl LintPass for Derive {
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(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
@ -129,9 +129,9 @@ fn check_hash_peq<'a, 'tcx>(
cx, DERIVE_HASH_XOR_EQ, span,
mess,
|db| {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(impl_id) {
if let Some(node_id) = cx.tcx.hir().as_local_node_id(impl_id) {
db.span_note(
cx.tcx.hir.span(node_id),
cx.tcx.hir().span(node_id),
"`PartialEq` implemented here"
);
}

View File

@ -43,7 +43,7 @@ impl LintPass for EmptyEnum {
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(item.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");

View File

@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
let variant = &var.node;
if let Some(ref anon_const) = variant.disr_expr {
let param_env = ty::ParamEnv::empty();
let def_id = cx.tcx.hir.body_owner_def_id(anon_const.body);
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
let instance = ty::Instance::new(def_id, substs);
let c_id = GlobalId {

View File

@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) {
// only check top level `use` statements
for item in &m.item_ids {
self.lint_item(cx, cx.tcx.hir.expect_item(item.id));
self.lint_item(cx, cx.tcx.hir().expect_item(item.id));
}
}
}

View File

@ -74,8 +74,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
node_id: NodeId,
) {
// If the method is an impl for a trait, don't warn
let parent_id = cx.tcx.hir.get_parent(node_id);
let parent_node = cx.tcx.hir.find(parent_id);
let parent_id = cx.tcx.hir().get_parent(node_id);
let parent_node = cx.tcx.hir().find(parent_id);
if let Some(Node::Item(item)) = parent_node {
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
too_large_for_stack: self.too_large_for_stack,
};
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
let fn_def_id = cx.tcx.hir().local_def_id(node_id);
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body);
@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
span_lint(
cx,
BOXED_LOCAL,
cx.tcx.hir.span(node),
cx.tcx.hir().span(node),
"local variable doesn't need to be boxed here",
);
}
@ -115,7 +115,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
}
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;
let map = &self.cx.tcx.hir();
if map.is_argument(consume_pat.id) {
// Skip closure arguments
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.id)) {

View File

@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
if let ExprKind::Closure(_, ref decl, eid, _, _) = expr.node {
let body = cx.tcx.hir.body(eid);
let body = cx.tcx.hir().body(eid);
let ex = &body.value;
if let ExprKind::Call(ref caller, ref args) = ex.node {
if args.len() != decl.inputs.len() {

View File

@ -191,7 +191,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
///
/// When such a read is found, the lint is triggered.
fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
let map = &vis.cx.tcx.hir;
let map = &vis.cx.tcx.hir();
let mut cur_id = vis.write_expr.id;
loop {
let parent_id = map.get_parent_node(cur_id);

View File

@ -48,7 +48,7 @@ impl LintPass for FallibleImplFrom {
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(item.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);
@ -106,11 +106,11 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
if_chain! {
if impl_item.ident.name == "from";
if let ImplItemKind::Method(_, body_id) =
cx.tcx.hir.impl_item(impl_item.id).node;
cx.tcx.hir().impl_item(impl_item.id).node;
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 body = cx.tcx.hir().body(body_id);
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.node_id);
let mut fpu = FindPanicUnwrap {
tcx: cx.tcx,
tables: cx.tcx.typeck_tables_of(impl_item_def_id),

View File

@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
span: Span,
nodeid: ast::NodeId,
) {
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(nodeid)) {
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
} else {
false
@ -138,7 +138,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}
if let hir::TraitMethod::Provided(eid) = *eid {
let body = cx.tcx.hir.body(eid);
let body = cx.tcx.hir().body(eid);
self.check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.id);
}
}

View File

@ -119,7 +119,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
_: Span,
_: NodeId,
) {
let def_id = cx.tcx.hir.body_owner_def_id(body.id());
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
let mir = cx.tcx.optimized_mir(def_id);
// checking return type through MIR, HIR is not able to determine inferred closure return types

View File

@ -165,7 +165,7 @@ fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr) -> Finiteness {
}
if method.ident.name == "flat_map" && args.len() == 2 {
if let ExprKind::Closure(_, _, body_id, _, _) = args[1].node {
let body = cx.tcx.hir.body(body_id);
let body = cx.tcx.hir().body(body_id);
return is_infinite(cx, &body.value);
}
}

View File

@ -59,7 +59,7 @@ impl LintPass for LargeEnumVariant {
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(item.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");

View File

@ -137,7 +137,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
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(item.id.node_id);
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
}
} else {
@ -156,7 +156,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
if cx.access_levels.is_exported(visited_trait.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(visited_trait.id);
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
let is_empty_method_found = current_and_super_traits
@ -188,7 +188,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
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(item.id.node_id);
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
}
} else {
@ -208,7 +208,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
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);
let def_id = cx.tcx.hir().local_def_id(item.id);
let ty = cx.tcx.type_of(def_id);
span_lint(

View File

@ -204,7 +204,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
let mut checker = BodyLifetimeChecker {
lifetimes_used_in_body: false,
};
checker.visit_expr(&cx.tcx.hir.body(body_id).value);
checker.visit_expr(&cx.tcx.hir().body(body_id).value);
if checker.lifetimes_used_in_body {
return false;
}
@ -324,7 +324,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
GenericArg::Type(_) => false,
})
{
let hir_id = self.cx.tcx.hir.node_to_hir_id(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);
@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
self.collect_anonymous_lifetimes(path, ty);
},
TyKind::Def(item, _) => {
if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir.expect_item(item.id).node {
if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir().expect_item(item.id).node {
for bound in &exist_ty.bounds {
if let GenericBound::Outlives(_) = *bound {
self.record(&None);

View File

@ -1111,8 +1111,8 @@ fn check_for_loop_range<'a, 'tcx>(
// ensure that the indexed variable was declared before the loop, see #601
if let Some(indexed_extent) = indexed_extent {
let parent_id = cx.tcx.hir.get_parent(expr.id);
let parent_def_id = cx.tcx.hir.local_def_id(parent_id);
let parent_id = cx.tcx.hir().get_parent(expr.id);
let parent_def_id = cx.tcx.hir().local_def_id(parent_id);
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id);
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
@ -1464,7 +1464,7 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(
// For each candidate, check the parent block to see if
// it's initialized to zero at the start of the loop.
let map = &cx.tcx.hir;
let map = &cx.tcx.hir();
let parent_scope = map
.get_enclosing_scope(expr.id)
.and_then(|id| map.get_enclosing_scope(id));
@ -1636,7 +1636,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
then {
let def = cx.tables.qpath_def(qpath, bound.hir_id);
if let Def::Local(node_id) = def {
let node_str = cx.tcx.hir.get(node_id);
let node_str = cx.tcx.hir().get(node_id);
if_chain! {
if let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, _, _, _) = pat.node;
@ -1772,10 +1772,10 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
match def {
Def::Local(node_id) | Def::Upvar(node_id, ..) => {
let hir_id = self.cx.tcx.hir.node_to_hir_id(node_id);
let hir_id = self.cx.tcx.hir().node_to_hir_id(node_id);
let parent_id = self.cx.tcx.hir.get_parent(expr.id);
let parent_def_id = self.cx.tcx.hir.local_def_id(parent_id);
let parent_id = self.cx.tcx.hir().get_parent(expr.id);
let parent_def_id = self.cx.tcx.hir().local_def_id(parent_id);
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
if indexed_indirectly {
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent));
@ -2186,7 +2186,7 @@ fn is_conditional(expr: &Expr) -> bool {
fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> bool {
if_chain! {
if let Some(loop_block) = get_enclosing_block(cx, match_expr.id);
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(loop_block.id));
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(loop_block.id));
then {
return is_loop_nested(cx, loop_expr, iter_expr)
}
@ -2202,11 +2202,11 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
return true;
};
loop {
let parent = cx.tcx.hir.get_parent_node(id);
let parent = cx.tcx.hir().get_parent_node(id);
if parent == id {
return false;
}
match cx.tcx.hir.find(parent) {
match cx.tcx.hir().find(parent) {
Some(Node::Expr(expr)) => match expr.node {
ExprKind::Loop(..) | ExprKind::While(..) => {
return true;

View File

@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let ty = cx.tables.expr_ty(&args[0]);
if match_type(cx, ty, &paths::OPTION) || match_trait_method(cx, e, &paths::ITERATOR);
if let hir::ExprKind::Closure(_, _, body_id, _, _) = args[1].node;
let closure_body = cx.tcx.hir.body(body_id);
let closure_body = cx.tcx.hir().body(body_id);
let closure_expr = remove_blocks(&closure_body.value);
then {
match closure_body.arguments[0].pat.node {

View File

@ -161,7 +161,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr) ->
fn unit_closure<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr) -> Option<(&'tcx hir::Arg, &'a hir::Expr)> {
if let hir::ExprKind::Closure(_, ref decl, inner_expr_id, _, _) = expr.node {
let body = cx.tcx.hir.body(inner_expr_id);
let body = cx.tcx.hir().body(inner_expr_id);
let body_expr = &body.value;
if_chain! {

View File

@ -911,14 +911,14 @@ 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(implitem.id);
let item = cx.tcx.hir().expect_item(parent);
let def_id = cx.tcx.hir().local_def_id(item.id);
let ty = cx.tcx.type_of(def_id);
if_chain! {
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
if let Some(first_arg_ty) = sig.decl.inputs.get(0);
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next();
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) {
@ -1086,7 +1086,7 @@ fn lint_or_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Spa
}
// don't lint for constant values
let owner_def = cx.tcx.hir.get_parent_did(arg.id);
let owner_def = cx.tcx.hir().get_parent_did(arg.id);
let promotable = cx.tcx.rvalue_promotable_map(owner_def).contains(&arg.hir_id.local_id);
if promotable {
return;
@ -1334,8 +1334,8 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) {
// x.clone() might have dereferenced x, possibly through Deref impls
if cx.tables.expr_ty(arg) != ty {
let parent = cx.tcx.hir.get_parent_node(expr.id);
match cx.tcx.hir.get(parent) {
let parent = cx.tcx.hir().get_parent_node(expr.id);
match cx.tcx.hir().get(parent) {
hir::Node::Expr(parent) => match parent.node {
// &*x is a nop, &x.clone() is not
hir::ExprKind::AddrOf(..) |
@ -1496,7 +1496,7 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args:
if_chain! {
// Extract the body of the closure passed to fold
if let hir::ExprKind::Closure(_, _, body_id, _, _) = fold_args[2].node;
let closure_body = cx.tcx.hir.body(body_id);
let closure_body = cx.tcx.hir().body(body_id);
let closure_expr = remove_blocks(&closure_body.value);
// Check if the closure body is of the form `acc <op> some_expr(x)`

View File

@ -26,7 +26,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 body = cx.tcx.hir().body(body_id);
let arg_id = body.arguments[0].pat.id;
let mutates_arg = match mutated_variables(&body.value, cx) {
Some(used_mutably) => used_mutably.contains(&arg_id),

View File

@ -612,7 +612,7 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
/// Test whether `def` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext<'_, '_>, def: &def::Def) -> bool {
match *def {
def::Def::Local(id) | def::Def::Upvar(id, _, _) => !in_macro(cx.tcx.hir.span(id)),
def::Def::Local(id) | def::Def::Upvar(id, _, _) => !in_macro(cx.tcx.hir().span(id)),
_ => false,
}
}

View File

@ -142,8 +142,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
hir::ItemKind::Fn(..) => {
// ignore main()
if it.name == "main" {
let def_id = cx.tcx.hir.local_def_id(it.id);
let def_key = cx.tcx.hir.def_key(def_id);
let def_id = cx.tcx.hir().local_def_id(it.id);
let def_key = cx.tcx.hir().def_key(def_id);
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
return;
}
@ -180,7 +180,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(impl_item.id);
match cx.tcx.associated_item(def_id).container {
ty::TraitContainer(_) => return,
ty::ImplContainer(cid) => {

View File

@ -123,7 +123,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
// note: we need to check if the trait is exported so we can't use
// `LateLintPass::check_trait_item` here.
for tit in trait_items {
let tit_ = cx.tcx.hir.trait_item(tit.id);
let tit_ = cx.tcx.hir().trait_item(tit.id);
match tit_.node {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Method(..) => {
@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
// 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(tit.id.node_id);
check_missing_inline_attrs(cx, &item.attrs, item.span, desc);
}
},
@ -171,14 +171,14 @@ 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(impl_item.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),
};
if let Some(trait_def_id) = trait_def_id {
if let Some(n) = cx.tcx.hir.as_local_node_id(trait_def_id) {
if let Some(n) = cx.tcx.hir().as_local_node_id(trait_def_id) {
if !cx.access_levels.is_exported(n) {
// If a trait is being implemented for an item, and the
// trait is not exported, we don't need #[inline]

View File

@ -107,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
}
// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(node_id)) {
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..))
{
@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
let sized_trait = need!(cx.tcx.lang_items().sized_trait());
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
let fn_def_id = cx.tcx.hir().local_def_id(node_id);
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec())
.filter(|p| !p.is_global())
@ -220,7 +220,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
// Dereference suggestion
let sugg = |db: &mut DiagnosticBuilder<'_>| {
if let ty::Adt(def, ..) = ty.sty {
if let Some(span) = cx.tcx.hir.span_if_local(def.did) {
if let Some(span) = cx.tcx.hir().span_if_local(def.did) {
if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
db.span_help(span, "consider marking this type as Copy");
}
@ -355,14 +355,14 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
if let mc::Categorization::Local(vid) = cmt.cat {
let mut id = matched_pat.id;
loop {
let parent = self.cx.tcx.hir.get_parent_node(id);
let parent = self.cx.tcx.hir().get_parent_node(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(id) {
match node {
Node::Expr(e) => {
// `match` and `if let`

View File

@ -107,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.node {
for assoc_item in items {
if let hir::AssociatedItemKind::Method { has_self: false } = assoc_item.kind {
let impl_item = cx.tcx.hir.impl_item(assoc_item.id);
let impl_item = cx.tcx.hir().impl_item(assoc_item.id);
if in_external_macro(cx.sess(), impl_item.span) {
return;
}
@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
return;
}
if sig.decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
let self_did = cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id));
let self_did = cx.tcx.hir().local_def_id(cx.tcx.hir().get_parent(id));
let self_ty = cx.tcx.type_of(self_did);
if_chain! {
if same_tys(cx, self_ty, return_ty(cx, id));
@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
let mut impls = NodeSet::default();
cx.tcx.for_each_impl(default_trait_id, |d| {
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) {
if let Some(node_id) = cx.tcx.hir().as_local_node_id(ty_def.did) {
impls.insert(node_id);
}
}
@ -157,7 +157,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
if let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def();
if self_def.did.is_local();
then {
let self_id = cx.tcx.hir.local_def_id_to_node_id(self_def.did.to_local());
let self_id = cx.tcx.hir().local_def_id_to_node_id(self_def.did.to_local());
if impling_types.contains(&self_id) {
return;
}

View File

@ -182,8 +182,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_node_id = cx.tcx.hir().get_parent_node(impl_item.id);
let item = cx.tcx.hir().expect_item(item_node_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);
@ -217,11 +217,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
let mut dereferenced_expr = expr;
let mut needs_check_adjustment = true;
loop {
let parent_id = cx.tcx.hir.get_parent_node(cur_expr.id);
let parent_id = cx.tcx.hir().get_parent_node(cur_expr.id);
if parent_id == cur_expr.id {
break;
}
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir.find(parent_id) {
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find(parent_id) {
match &parent_expr.node {
ExprKind::AddrOf(..) => {
// `&e` => `e` must be referenced

View File

@ -122,7 +122,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
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)) {
if let Some(Node::Item(it)) = cx.tcx.hir().find(cx.tcx.hir().get_parent(item.id)) {
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
return; // ignore trait impls
}
@ -157,7 +157,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
}
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);
let fn_def_id = cx.tcx.hir().local_def_id(fn_id);
let sig = cx.tcx.fn_sig(fn_def_id);
let fn_ty = sig.skip_binder();

View File

@ -93,7 +93,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
_: Span,
_: NodeId,
) {
let def_id = cx.tcx.hir.body_owner_def_id(body.id());
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
let mir = cx.tcx.optimized_mir(def_id);
for (bb, bbdata) in mir.basic_blocks().iter_enumerated() {

View File

@ -371,7 +371,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
TyKind::Slice(ref sty) => check_ty(cx, sty, bindings),
TyKind::Array(ref fty, ref anon_const) => {
check_ty(cx, fty, bindings);
check_expr(cx, &cx.tcx.hir.body(anon_const.body).value, bindings);
check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings);
},
TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => {
check_ty(cx, mty, bindings)
@ -381,7 +381,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
check_ty(cx, t, bindings)
}
},
TyKind::Typeof(ref anon_const) => check_expr(cx, &cx.tcx.hir.body(anon_const.body).value, bindings),
TyKind::Typeof(ref anon_const) => check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings),
_ => (),
}
}

View File

@ -82,9 +82,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
}
// Check if the binary expression is part of another bi/unary expression
// as a child node
let mut parent_expr = cx.tcx.hir.get_parent_node(expr.id);
let mut parent_expr = cx.tcx.hir().get_parent_node(expr.id);
while parent_expr != ast::CRATE_NODE_ID {
if let hir::Node::Expr(e) = cx.tcx.hir.get(parent_expr) {
if let hir::Node::Expr(e) = cx.tcx.hir().get(parent_expr) {
match e.node {
hir::ExprKind::Binary(..)
| hir::ExprKind::Unary(hir::UnOp::UnNot, _)
@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
_ => {},
}
}
parent_expr = cx.tcx.hir.get_parent_node(parent_expr);
parent_expr = cx.tcx.hir().get_parent_node(parent_expr);
}
// as a parent node
let mut visitor = BinaryExprVisitor { in_binary_expr: false };
@ -182,12 +182,12 @@ fn check_binop<'a>(
}
// Get the actually implemented trait
let parent_fn = cx.tcx.hir.get_parent(expr.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
let parent_fn = cx.tcx.hir().get_parent(expr.id);
let parent_impl = cx.tcx.hir().get_parent(parent_fn);
if_chain! {
if parent_impl != ast::CRATE_NODE_ID;
if let hir::Node::Item(item) = cx.tcx.hir.get(parent_impl);
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node;
if let Some(idx) = trait_ids.iter().position(|&tid| tid == trait_ref.path.def.def_id());
if binop != expected_ops[idx];

View File

@ -82,11 +82,11 @@ impl<'a, 'tcx> TriviallyCopyPassByRef {
}
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(item.id.node_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(item.id.node_id) {
Some(b) => b,
None => return,
};
@ -192,7 +192,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
}
// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(node_id)) {
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..))
{
@ -200,7 +200,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
}
}
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
let fn_def_id = cx.tcx.hir().local_def_id(node_id);
let fn_sig = cx.tcx.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);

View File

@ -154,7 +154,7 @@ impl LintPass for TypePass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: NodeId) {
// skip trait implementations, see #605
if let Some(hir::Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) {
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent(id)) {
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
return;
}
@ -203,7 +203,7 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str])
GenericArg::Lifetime(_) => None,
});
if let TyKind::Path(ref qpath) = ty.node;
if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(ty.id)));
if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir().node_to_hir_id(ty.id)));
if match_def_path(cx.tcx, did, path);
then {
return true;
@ -223,7 +223,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
}
match ast_ty.node {
TyKind::Path(ref qpath) if !is_local => {
let hir_id = cx.tcx.hir.node_to_hir_id(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() {
@ -317,7 +317,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) {
match mut_ty.ty.node {
TyKind::Path(ref qpath) => {
let hir_id = cx.tcx.hir.node_to_hir_id(mut_ty.ty.id);
let hir_id = cx.tcx.hir().node_to_hir_id(mut_ty.ty.id);
let def = cx.tables.qpath_def(qpath, hir_id);
if_chain! {
if let Some(def_id) = opt_def_id(def);
@ -545,7 +545,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg {
ExprKind::Call(_, ref args) | ExprKind::MethodCall(_, _, ref args) => {
for arg in args {
if is_unit(cx.tables.expr_ty(arg)) && !is_unit_literal(arg) {
let map = &cx.tcx.hir;
let map = &cx.tcx.hir();
// apparently stuff in the desugaring of `?` can trigger this
// so check for that here
// only the calls to `Try::from_error` is marked as desugared,
@ -1930,7 +1930,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
});
let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
for item in items.iter().map(|item| cx.tcx.hir.impl_item(item.id)) {
for item in items.iter().map(|item| cx.tcx.hir().impl_item(item.id)) {
ctr_vis.visit_impl_item(item);
}
@ -1949,7 +1949,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
}
},
ItemKind::Fn(ref decl, .., ref generics, body_id) => {
let body = cx.tcx.hir.body(body_id);
let body = cx.tcx.hir().body(body_id);
for ty in &decl.inputs {
let mut vis = ImplicitHasherTypeVisitor::new(cx);
@ -2157,6 +2157,6 @@ impl<'a, 'b, 'tcx: 'a + 'b> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir)
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -93,6 +93,6 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.hir)
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -185,7 +185,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir)
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
}
}

View File

@ -135,7 +135,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(impl_item.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);
@ -190,18 +190,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
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(item.id);
let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);
if let Some(impl_trait_ref) = impl_trait_ref {
for impl_item_ref in refs {
let impl_item = cx.tcx.hir.impl_item(impl_item_ref.id);
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
if let ImplItemKind::Method(MethodSig{ decl: impl_decl, .. }, impl_body_id)
= &impl_item.node {
let item_type = cx.tcx.type_of(impl_def_id);
check_trait_method_impl_decl(cx, item_type, impl_item, impl_decl, &impl_trait_ref);
let body = cx.tcx.hir.body(*impl_body_id);
let body = cx.tcx.hir().body(*impl_body_id);
visitor.visit_body(body);
} else {
visitor.visit_impl_item(impl_item);
@ -209,7 +209,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
}
} else {
for impl_item_ref in refs {
let impl_item = cx.tcx.hir.impl_item(impl_item_ref.id);
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
visitor.visit_impl_item(impl_item);
}
}
@ -238,6 +238,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.hir)
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -145,9 +145,9 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
},
(&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => {
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id.body).value);
let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id.body).value);
let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
self.eq_expr(le, re) && ll == rl
},
@ -287,11 +287,11 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
self.tables = self.cx.tcx.body_tables(ll_id.body);
let ll = celcx.expr(&self.cx.tcx.hir.body(ll_id.body).value);
let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
self.tables = self.cx.tcx.body_tables(rl_id.body);
let rl = celcx.expr(&self.cx.tcx.hir.body(rl_id.body).value);
let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
let eq_ty = self.eq_ty(lt, rt);
self.tables = full_table;
@ -484,7 +484,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
CaptureClause::CaptureByRef => 1,
}
.hash(&mut self.s);
self.hash_expr(&self.cx.tcx.hir.body(eid).value);
self.hash_expr(&self.cx.tcx.hir().body(eid).value);
},
ExprKind::Field(ref e, ref f) => {
let c: fn(_, _) -> _ = ExprKind::Field;
@ -551,7 +551,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(e);
let full_table = self.tables;
self.tables = self.cx.tcx.body_tables(l_id.body);
self.hash_expr(&self.cx.tcx.hir.body(l_id.body).value);
self.hash_expr(&self.cx.tcx.hir().body(l_id.body).value);
self.tables = full_table;
},
ExprKind::Ret(ref e) => {

View File

@ -74,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
match item.node {
hir::ImplItemKind::Const(_, body_id) => {
println!("associated constant");
print_expr(cx, &cx.tcx.hir.body(body_id).value, 1);
print_expr(cx, &cx.tcx.hir().body(body_id).value, 1);
},
hir::ImplItemKind::Method(..) => println!("method"),
hir::ImplItemKind::Type(_) => println!("associated type"),
@ -345,13 +345,13 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
println!("{}value:", ind);
print_expr(cx, val, indent + 1);
println!("{}repeat count:", ind);
print_expr(cx, &cx.tcx.hir.body(anon_const.body).value, indent + 1);
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
},
}
}
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(item.id);
println!("item `{}`", item.name);
match item.vis.node {
hir::VisibilityKind::Public => println!("public"),
@ -364,7 +364,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(item.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 {

View File

@ -166,8 +166,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
output: &mut self.registered_lints,
cx,
};
let body_id = cx.tcx.hir.body_owned_by(impl_item_refs[0].id.node_id);
collector.visit_expr(&cx.tcx.hir.body(body_id).value);
let body_id = cx.tcx.hir().body_owned_by(impl_item_refs[0].id.node_id);
collector.visit_expr(&cx.tcx.hir().body(body_id).value);
}
}
}
@ -236,7 +236,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.hir)
NestedVisitorMap::All(&self.cx.tcx.hir())
}
}

View File

@ -62,8 +62,8 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
}
pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
let parent_id = cx.tcx.hir.get_parent(id);
match cx.tcx.hir.body_owner_kind(parent_id) {
let parent_id = cx.tcx.hir().get_parent(id);
match cx.tcx.hir().body_owner_kind(parent_id) {
hir::BodyOwnerKind::Fn => false,
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true,
}
@ -331,8 +331,8 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option<Vec<&'a
/// Get the name of the item the expression is in, if available.
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
let parent_id = cx.tcx.hir.get_parent(expr.id);
match cx.tcx.hir.find(parent_id) {
let parent_id = cx.tcx.hir().get_parent(expr.id);
match cx.tcx.hir().find(parent_id) {
Some(Node::Item(&Item { ref name, .. })) => Some(*name),
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
Some(ident.name)
@ -520,7 +520,7 @@ fn trim_multiline_inner(s: Cow<'_, str>, ignore_first: bool, ch: char) -> Cow<'_
/// Get a parent expressions if any this is useful to constrain a lint.
pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c Expr> {
let map = &cx.tcx.hir;
let map = &cx.tcx.hir();
let node_id: NodeId = e.id;
let parent_id: NodeId = map.get_parent_node(node_id);
if node_id == parent_id {
@ -536,7 +536,7 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c
}
pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeId) -> Option<&'tcx Block> {
let map = &cx.tcx.hir;
let map = &cx.tcx.hir();
let enclosing_node = map
.get_enclosing_scope(node)
.and_then(|enclosing_id| map.find(enclosing_id));
@ -550,7 +550,7 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI
| Node::ImplItem(&ImplItem {
node: ImplItemKind::Method(_, eid),
..
}) => match cx.tcx.hir.body(eid).value.node {
}) => match cx.tcx.hir().body(eid).value.node {
ExprKind::Block(ref block, _) => Some(block),
_ => None,
},
@ -836,7 +836,7 @@ 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);
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
cx.tcx.erase_late_bound_regions(&ret_ty)
}
@ -1117,7 +1117,7 @@ pub fn without_block_comments(lines: Vec<&str>) -> Vec<&str> {
}
pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_, '_, '_>, node: NodeId) -> bool {
let map = &tcx.hir;
let map = &tcx.hir();
let mut prev_enclosing_node = None;
let mut enclosing_node = node;
while Some(enclosing_node) != prev_enclosing_node {

View File

@ -21,7 +21,7 @@ pub fn get_spans(
idx: usize,
replacements: &'static [(&'static str, &'static str)],
) -> Option<Vec<(Span, Cow<'static, str>)>> {
if let Some(body) = opt_body_id.map(|id| cx.tcx.hir.body(id)) {
if let Some(body) = opt_body_id.map(|id| cx.tcx.hir().body(id)) {
get_binding_name(&body.arguments[idx]).map_or_else(
|| Some(vec![]),
|name| extract_clone_suggestions(cx, name, replacements, body),