1
Fork 0
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) { 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 => { 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 let Some(span) = self.const_span {
if span.contains(body_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) { fn check_body_post(&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());
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 let Some(span) = self.const_span {
if span.contains(body_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 return; // useless if the trait doesn't exist
}; };
// check that we are not inside an `impl AssignOp` of this exact operation // 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_fn = cx.tcx.hir().get_parent(e.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn); let parent_impl = cx.tcx.hir().get_parent(parent_fn);
// the crate node is the only one that is not in the map // the crate node is the only one that is not in the map
if_chain! { if_chain! {
if parent_impl != ast::CRATE_NODE_ID; 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), _, _) = if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) =
item.node; item.node;
if trait_ref.path.def.def_id() == trait_id; 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 { fn is_relevant_item(tcx: TyCtxt<'_, '_, '_>, item: &Item) -> bool {
if let ItemKind::Fn(_, _, _, eid) = item.node { 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 { } else {
true true
} }
@ -362,7 +362,7 @@ fn is_relevant_item(tcx: TyCtxt<'_, '_, '_>, item: &Item) -> bool {
fn is_relevant_impl(tcx: TyCtxt<'_, '_, '_>, item: &ImplItem) -> bool { fn is_relevant_impl(tcx: TyCtxt<'_, '_, '_>, item: &ImplItem) -> bool {
match item.node { 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, _ => false,
} }
} }
@ -371,7 +371,7 @@ fn is_relevant_trait(tcx: TyCtxt<'_, '_, '_>, item: &TraitItem) -> bool {
match item.node { match item.node {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true, TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => { 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, _ => false,
} }

View file

@ -68,7 +68,7 @@ struct ExVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> { impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) { fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprKind::Closure(_, _, eid, _, _) = expr.node { 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; let ex = &body.value;
if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro(body.value.span) { if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro(body.value.span) {
self.found_block = Some(ex); 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 filter_args.len() == 2;
if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].node; if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].node;
then { then {
let body = cx.tcx.hir.body(body_id); let body = cx.tcx.hir().body(body_id);
if_chain! { if_chain! {
if body.arguments.len() == 1; if body.arguments.len() == 1;
if let Some(argname) = get_pat_name(&body.arguments[0].pat); 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { 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) { if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
span_note_and_lint( span_note_and_lint(

View file

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

View file

@ -82,7 +82,7 @@ impl LintPass for Derive {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { 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); let is_automatically_derived = is_automatically_derived(&*item.attrs);
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived); 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, cx, DERIVE_HASH_XOR_EQ, span,
mess, mess,
|db| { |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( db.span_note(
cx.tcx.hir.span(node_id), cx.tcx.hir().span(node_id),
"`PartialEq` implemented here" "`PartialEq` implemented here"
); );
} }

View file

@ -43,7 +43,7 @@ impl LintPass for EmptyEnum {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) { 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 { if let ItemKind::Enum(..) = item.node {
let ty = cx.tcx.type_of(did); let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum"); 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; let variant = &var.node;
if let Some(ref anon_const) = variant.disr_expr { if let Some(ref anon_const) = variant.disr_expr {
let param_env = ty::ParamEnv::empty(); 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 substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
let instance = ty::Instance::new(def_id, substs); let instance = ty::Instance::new(def_id, substs);
let c_id = GlobalId { 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) { fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) {
// only check top level `use` statements // only check top level `use` statements
for item in &m.item_ids { 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, node_id: NodeId,
) { ) {
// If the method is an impl for a trait, don't warn // If the method is an impl for a trait, don't warn
let parent_id = cx.tcx.hir.get_parent(node_id); let parent_id = cx.tcx.hir().get_parent(node_id);
let parent_node = cx.tcx.hir.find(parent_id); let parent_node = cx.tcx.hir().find(parent_id);
if let Some(Node::Item(item)) = parent_node { if let Some(Node::Item(item)) = parent_node {
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.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, 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); 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); 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( span_lint(
cx, cx,
BOXED_LOCAL, BOXED_LOCAL,
cx.tcx.hir.span(node), cx.tcx.hir().span(node),
"local variable doesn't need to be boxed here", "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 matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {}
fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) { 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) { if map.is_argument(consume_pat.id) {
// Skip closure arguments // Skip closure arguments
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.id)) { 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) { fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
if let ExprKind::Closure(_, ref decl, eid, _, _) = expr.node { 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; let ex = &body.value;
if let ExprKind::Call(ref caller, ref args) = ex.node { if let ExprKind::Call(ref caller, ref args) = ex.node {
if args.len() != decl.inputs.len() { 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. /// When such a read is found, the lint is triggered.
fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) { 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; let mut cur_id = vis.write_expr.id;
loop { loop {
let parent_id = map.get_parent_node(cur_id); 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
// check for `impl From<???> for ..` // 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_chain! {
if let hir::ItemKind::Impl(.., ref impl_items) = item.node; if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id); 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_chain! {
if impl_item.ident.name == "from"; if impl_item.ident.name == "from";
if let ImplItemKind::Method(_, body_id) = 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 { then {
// check the body for `begin_panic` or `unwrap` // check the body for `begin_panic` or `unwrap`
let body = cx.tcx.hir.body(body_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 impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.node_id);
let mut fpu = FindPanicUnwrap { let mut fpu = FindPanicUnwrap {
tcx: cx.tcx, tcx: cx.tcx,
tables: cx.tcx.typeck_tables_of(impl_item_def_id), 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, span: Span,
nodeid: ast::NodeId, 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(_), _, _)) matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
} else { } else {
false false
@ -138,7 +138,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
} }
if let hir::TraitMethod::Provided(eid) = *eid { 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); 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, _: Span,
_: NodeId, _: 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); let mir = cx.tcx.optimized_mir(def_id);
// checking return type through MIR, HIR is not able to determine inferred closure return types // 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 method.ident.name == "flat_map" && args.len() == 2 {
if let ExprKind::Closure(_, _, body_id, _, _) = args[1].node { 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); return is_infinite(cx, &body.value);
} }
} }

View file

@ -59,7 +59,7 @@ impl LintPass for LargeEnumVariant {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) { 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 { if let ItemKind::Enum(ref def, _) = item.node {
let ty = cx.tcx.type_of(did); let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum"); 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 item.ident.name == name
&& if let AssociatedItemKind::Method { has_self } = item.kind { && if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && { 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 cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
} }
} else { } 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")) { 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 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); fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
let is_empty_method_found = current_and_super_traits 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 item.ident.name == name
&& if let AssociatedItemKind::Method { has_self } = item.kind { && if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && { 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 cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
} }
} else { } 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 let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(i.id.node_id) { 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); let ty = cx.tcx.type_of(def_id);
span_lint( span_lint(

View file

@ -204,7 +204,7 @@ fn could_use_elision<'a, 'tcx: 'a>(
let mut checker = BodyLifetimeChecker { let mut checker = BodyLifetimeChecker {
lifetimes_used_in_body: false, 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 { if checker.lifetimes_used_in_body {
return false; return false;
} }
@ -324,7 +324,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
GenericArg::Type(_) => false, 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) { match self.cx.tables.qpath_def(qpath, hir_id) {
Def::TyAlias(def_id) | Def::Struct(def_id) => { Def::TyAlias(def_id) | Def::Struct(def_id) => {
let generics = self.cx.tcx.generics_of(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); self.collect_anonymous_lifetimes(path, ty);
}, },
TyKind::Def(item, _) => { 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 { for bound in &exist_ty.bounds {
if let GenericBound::Outlives(_) = *bound { if let GenericBound::Outlives(_) = *bound {
self.record(&None); 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 // ensure that the indexed variable was declared before the loop, see #601
if let Some(indexed_extent) = indexed_extent { if let Some(indexed_extent) = indexed_extent {
let parent_id = cx.tcx.hir.get_parent(expr.id); let parent_id = cx.tcx.hir().get_parent(expr.id);
let parent_def_id = cx.tcx.hir.local_def_id(parent_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 region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_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) { 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 // For each candidate, check the parent block to see if
// it's initialized to zero at the start of the loop. // 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 let parent_scope = map
.get_enclosing_scope(expr.id) .get_enclosing_scope(expr.id)
.and_then(|id| map.get_enclosing_scope(id)); .and_then(|id| map.get_enclosing_scope(id));
@ -1636,7 +1636,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
then { then {
let def = cx.tables.qpath_def(qpath, bound.hir_id); let def = cx.tables.qpath_def(qpath, bound.hir_id);
if let Def::Local(node_id) = def { 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_chain! {
if let Node::Binding(pat) = node_str; if let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, _, _, _) = pat.node; 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); let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
match def { match def {
Def::Local(node_id) | Def::Upvar(node_id, ..) => { 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_id = self.cx.tcx.hir().get_parent(expr.id);
let parent_def_id = self.cx.tcx.hir.local_def_id(parent_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); let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
if indexed_indirectly { if indexed_indirectly {
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent)); 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 { fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> bool {
if_chain! { if_chain! {
if let Some(loop_block) = get_enclosing_block(cx, match_expr.id); 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 { then {
return is_loop_nested(cx, loop_expr, iter_expr) 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; return true;
}; };
loop { loop {
let parent = cx.tcx.hir.get_parent_node(id); let parent = cx.tcx.hir().get_parent_node(id);
if parent == id { if parent == id {
return false; return false;
} }
match cx.tcx.hir.find(parent) { match cx.tcx.hir().find(parent) {
Some(Node::Expr(expr)) => match expr.node { Some(Node::Expr(expr)) => match expr.node {
ExprKind::Loop(..) | ExprKind::While(..) => { ExprKind::Loop(..) | ExprKind::While(..) => {
return true; return true;

View file

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

View file

@ -911,14 +911,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
return; return;
} }
let name = implitem.ident.name; let name = implitem.ident.name;
let parent = cx.tcx.hir.get_parent(implitem.id); let parent = cx.tcx.hir().get_parent(implitem.id);
let item = cx.tcx.hir.expect_item(parent); let item = cx.tcx.hir().expect_item(parent);
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); let ty = cx.tcx.type_of(def_id);
if_chain! { if_chain! {
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node; 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_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; if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
then { then {
if cx.access_levels.is_exported(implitem.id) { 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 // 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); let promotable = cx.tcx.rvalue_promotable_map(owner_def).contains(&arg.hir_id.local_id);
if promotable { if promotable {
return; 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) { if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) {
// x.clone() might have dereferenced x, possibly through Deref impls // x.clone() might have dereferenced x, possibly through Deref impls
if cx.tables.expr_ty(arg) != ty { if cx.tables.expr_ty(arg) != ty {
let parent = cx.tcx.hir.get_parent_node(expr.id); let parent = cx.tcx.hir().get_parent_node(expr.id);
match cx.tcx.hir.get(parent) { match cx.tcx.hir().get(parent) {
hir::Node::Expr(parent) => match parent.node { hir::Node::Expr(parent) => match parent.node {
// &*x is a nop, &x.clone() is not // &*x is a nop, &x.clone() is not
hir::ExprKind::AddrOf(..) | hir::ExprKind::AddrOf(..) |
@ -1496,7 +1496,7 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args:
if_chain! { if_chain! {
// Extract the body of the closure passed to fold // Extract the body of the closure passed to fold
if let hir::ExprKind::Closure(_, _, body_id, _, _) = fold_args[2].node; 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); let closure_expr = remove_blocks(&closure_body.value);
// Check if the closure body is of the form `acc <op> some_expr(x)` // 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 { 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 arg_id = body.arguments[0].pat.id;
let mutates_arg = match mutated_variables(&body.value, cx) { let mutates_arg = match mutated_variables(&body.value, cx) {
Some(used_mutably) => used_mutably.contains(&arg_id), 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. /// Test whether `def` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext<'_, '_>, def: &def::Def) -> bool { fn non_macro_local(cx: &LateContext<'_, '_>, def: &def::Def) -> bool {
match *def { 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, _ => false,
} }
} }

View file

@ -142,8 +142,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
hir::ItemKind::Fn(..) => { hir::ItemKind::Fn(..) => {
// ignore main() // ignore main()
if it.name == "main" { if it.name == "main" {
let def_id = cx.tcx.hir.local_def_id(it.id); let def_id = cx.tcx.hir().local_def_id(it.id);
let def_key = cx.tcx.hir.def_key(def_id); let def_key = cx.tcx.hir().def_key(def_id);
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) { if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
return; 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) { 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. // 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 { match cx.tcx.associated_item(def_id).container {
ty::TraitContainer(_) => return, ty::TraitContainer(_) => return,
ty::ImplContainer(cid) => { 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 // note: we need to check if the trait is exported so we can't use
// `LateLintPass::check_trait_item` here. // `LateLintPass::check_trait_item` here.
for tit in trait_items { 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 { match tit_.node {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {}, hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Method(..) => { hir::TraitItemKind::Method(..) => {
@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
// trait method with default body needs inline in case // trait method with default body needs inline in case
// an impl is not provided // an impl is not provided
let desc = "a default trait method"; 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); 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, 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 { let trait_def_id = match cx.tcx.associated_item(def_id).container {
TraitContainer(cid) => Some(cid), TraitContainer(cid) => Some(cid),
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id), 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(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 !cx.access_levels.is_exported(n) {
// If a trait is being implemented for an item, and the // If a trait is being implemented for an item, and the
// trait is not exported, we don't need #[inline] // 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 // 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(_), _, _) | if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..)) 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 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()) let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec())
.filter(|p| !p.is_global()) .filter(|p| !p.is_global())
@ -220,7 +220,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
// Dereference suggestion // Dereference suggestion
let sugg = |db: &mut DiagnosticBuilder<'_>| { let sugg = |db: &mut DiagnosticBuilder<'_>| {
if let ty::Adt(def, ..) = ty.sty { 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() { if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
db.span_help(span, "consider marking this type as Copy"); 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 { if let mc::Categorization::Local(vid) = cmt.cat {
let mut id = matched_pat.id; let mut id = matched_pat.id;
loop { loop {
let parent = self.cx.tcx.hir.get_parent_node(id); let parent = self.cx.tcx.hir().get_parent_node(id);
if id == parent { if id == parent {
// no parent // no parent
return; return;
} }
id = parent; id = parent;
if let Some(node) = self.cx.tcx.hir.find(id) { if let Some(node) = self.cx.tcx.hir().find(id) {
match node { match node {
Node::Expr(e) => { Node::Expr(e) => {
// `match` and `if let` // `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 { if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.node {
for assoc_item in items { for assoc_item in items {
if let hir::AssociatedItemKind::Method { has_self: false } = assoc_item.kind { 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) { if in_external_macro(cx.sess(), impl_item.span) {
return; return;
} }
@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
return; return;
} }
if sig.decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) { 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); let self_ty = cx.tcx.type_of(self_did);
if_chain! { if_chain! {
if same_tys(cx, self_ty, return_ty(cx, id)); 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(); let mut impls = NodeSet::default();
cx.tcx.for_each_impl(default_trait_id, |d| { 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(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); 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 let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def();
if self_def.did.is_local(); if self_def.did.is_local();
then { 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) { if impling_types.contains(&self_id) {
return; 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) { fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node { if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node {
let item_node_id = cx.tcx.hir.get_parent_node(impl_item.id); 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 = cx.tcx.hir().expect_item(item_node_id);
// ensure the impl is an inherent impl. // ensure the impl is an inherent impl.
if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node { if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node {
let ty = hir_ty_to_ty(cx.tcx, hir_ty); 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 dereferenced_expr = expr;
let mut needs_check_adjustment = true; let mut needs_check_adjustment = true;
loop { 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 { if parent_id == cur_expr.id {
break; 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 { match &parent_expr.node {
ExprKind::AddrOf(..) => { ExprKind::AddrOf(..) => {
// `&e` => `e` must be referenced // `&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) { 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 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 { if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
return; // ignore trait impls 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>) { 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 sig = cx.tcx.fn_sig(fn_def_id);
let fn_ty = sig.skip_binder(); let fn_ty = sig.skip_binder();

View file

@ -93,7 +93,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
_: Span, _: Span,
_: NodeId, _: 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); let mir = cx.tcx.optimized_mir(def_id);
for (bb, bbdata) in mir.basic_blocks().iter_enumerated() { 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::Slice(ref sty) => check_ty(cx, sty, bindings),
TyKind::Array(ref fty, ref anon_const) => { TyKind::Array(ref fty, ref anon_const) => {
check_ty(cx, fty, bindings); 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, .. }) => { TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => {
check_ty(cx, mty, bindings) 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) 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 // Check if the binary expression is part of another bi/unary expression
// as a child node // 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 { 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 { match e.node {
hir::ExprKind::Binary(..) hir::ExprKind::Binary(..)
| hir::ExprKind::Unary(hir::UnOp::UnNot, _) | 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 // as a parent node
let mut visitor = BinaryExprVisitor { in_binary_expr: false }; let mut visitor = BinaryExprVisitor { in_binary_expr: false };
@ -182,12 +182,12 @@ fn check_binop<'a>(
} }
// Get the actually implemented trait // Get the actually implemented trait
let parent_fn = cx.tcx.hir.get_parent(expr.id); let parent_fn = cx.tcx.hir().get_parent(expr.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn); let parent_impl = cx.tcx.hir().get_parent(parent_fn);
if_chain! { if_chain! {
if parent_impl != ast::CRATE_NODE_ID; 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 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 let Some(idx) = trait_ids.iter().position(|&tid| tid == trait_ref.path.def.def_id());
if binop != expected_ops[idx]; 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) { 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.fn_sig(method_def_id);
let method_sig = cx.tcx.erase_late_bound_regions(&method_sig); 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, Some(b) => b,
None => return, None => return,
}; };
@ -192,7 +192,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
} }
// Exclude non-inherent impls // 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(_), _, _) | if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..)) 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.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig); 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: NodeId) { fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: NodeId) {
// skip trait implementations, see #605 // 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 { if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
return; return;
} }
@ -203,7 +203,7 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str])
GenericArg::Lifetime(_) => None, GenericArg::Lifetime(_) => None,
}); });
if let TyKind::Path(ref qpath) = ty.node; 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); if match_def_path(cx.tcx, did, path);
then { then {
return true; return true;
@ -223,7 +223,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
} }
match ast_ty.node { match ast_ty.node {
TyKind::Path(ref qpath) if !is_local => { 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); let def = cx.tables.qpath_def(qpath, hir_id);
if let Some(def_id) = opt_def_id(def) { if let Some(def_id) = opt_def_id(def) {
if Some(def_id) == cx.tcx.lang_items().owned_box() { 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) { fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) {
match mut_ty.ty.node { match mut_ty.ty.node {
TyKind::Path(ref qpath) => { 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); let def = cx.tables.qpath_def(qpath, hir_id);
if_chain! { if_chain! {
if let Some(def_id) = opt_def_id(def); 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) => { ExprKind::Call(_, ref args) | ExprKind::MethodCall(_, _, ref args) => {
for arg in args { for arg in args {
if is_unit(cx.tables.expr_ty(arg)) && !is_unit_literal(arg) { 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 // apparently stuff in the desugaring of `?` can trigger this
// so check for that here // so check for that here
// only the calls to `Try::from_error` is marked as desugared, // 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); 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); 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) => { 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 { for ty in &decl.inputs {
let mut vis = ImplicitHasherTypeVisitor::new(cx); 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> { 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); walk_expr(self, expr);
} }
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, '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

@ -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> { 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.fn_sig(trait_method.def_id);
let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig); 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.fn_sig(impl_method_def_id);
let impl_method_sig = cx.tcx.erase_late_bound_regions(&impl_method_sig); 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, item_path,
cx, 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); let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);
if let Some(impl_trait_ref) = impl_trait_ref { if let Some(impl_trait_ref) = impl_trait_ref {
for impl_item_ref in refs { 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) if let ImplItemKind::Method(MethodSig{ decl: impl_decl, .. }, impl_body_id)
= &impl_item.node { = &impl_item.node {
let item_type = cx.tcx.type_of(impl_def_id); 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); 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); visitor.visit_body(body);
} else { } else {
visitor.visit_impl_item(impl_item); visitor.visit_impl_item(impl_item);
@ -209,7 +209,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
} }
} else { } else {
for impl_item_ref in refs { 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); 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> { 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)) => { (&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 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 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 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)); 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); 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)); 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); 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); let eq_ty = self.eq_ty(lt, rt);
self.tables = full_table; self.tables = full_table;
@ -484,7 +484,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
CaptureClause::CaptureByRef => 1, CaptureClause::CaptureByRef => 1,
} }
.hash(&mut self.s); .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) => { ExprKind::Field(ref e, ref f) => {
let c: fn(_, _) -> _ = ExprKind::Field; let c: fn(_, _) -> _ = ExprKind::Field;
@ -551,7 +551,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(e); self.hash_expr(e);
let full_table = self.tables; let full_table = self.tables;
self.tables = self.cx.tcx.body_tables(l_id.body); 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; self.tables = full_table;
}, },
ExprKind::Ret(ref e) => { ExprKind::Ret(ref e) => {

View file

@ -74,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
match item.node { match item.node {
hir::ImplItemKind::Const(_, body_id) => { hir::ImplItemKind::Const(_, body_id) => {
println!("associated constant"); 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::Method(..) => println!("method"),
hir::ImplItemKind::Type(_) => println!("associated type"), hir::ImplItemKind::Type(_) => println!("associated type"),
@ -345,13 +345,13 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
println!("{}value:", ind); println!("{}value:", ind);
print_expr(cx, val, indent + 1); print_expr(cx, val, indent + 1);
println!("{}repeat count:", ind); 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) { 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); println!("item `{}`", item.name);
match item.vis.node { match item.vis.node {
hir::VisibilityKind::Public => println!("public"), hir::VisibilityKind::Public => println!("public"),
@ -364,7 +364,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
} }
match item.node { match item.node {
hir::ItemKind::ExternCrate(ref _renamed_from) => { 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) { if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(def_id) {
let source = cx.tcx.used_crate_source(crate_id); let source = cx.tcx.used_crate_source(crate_id);
if let Some(ref src) = source.dylib { 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, output: &mut self.registered_lints,
cx, cx,
}; };
let body_id = cx.tcx.hir.body_owned_by(impl_item_refs[0].id.node_id); 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); 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> { 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 { pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
let parent_id = cx.tcx.hir.get_parent(id); let parent_id = cx.tcx.hir().get_parent(id);
match cx.tcx.hir.body_owner_kind(parent_id) { match cx.tcx.hir().body_owner_kind(parent_id) {
hir::BodyOwnerKind::Fn => false, hir::BodyOwnerKind::Fn => false,
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true, 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. /// Get the name of the item the expression is in, if available.
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> { pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
let parent_id = cx.tcx.hir.get_parent(expr.id); let parent_id = cx.tcx.hir().get_parent(expr.id);
match cx.tcx.hir.find(parent_id) { match cx.tcx.hir().find(parent_id) {
Some(Node::Item(&Item { ref name, .. })) => Some(*name), Some(Node::Item(&Item { ref name, .. })) => Some(*name),
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => { Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
Some(ident.name) 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. /// 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> { 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 node_id: NodeId = e.id;
let parent_id: NodeId = map.get_parent_node(node_id); let parent_id: NodeId = map.get_parent_node(node_id);
if node_id == parent_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> { 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 let enclosing_node = map
.get_enclosing_scope(node) .get_enclosing_scope(node)
.and_then(|enclosing_id| map.find(enclosing_id)); .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::ImplItem(&ImplItem {
node: ImplItemKind::Method(_, eid), 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), ExprKind::Block(ref block, _) => Some(block),
_ => None, _ => 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 /// 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> { 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(); let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
cx.tcx.erase_late_bound_regions(&ret_ty) 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 { 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 prev_enclosing_node = None;
let mut enclosing_node = node; let mut enclosing_node = node;
while Some(enclosing_node) != prev_enclosing_node { while Some(enclosing_node) != prev_enclosing_node {

View file

@ -21,7 +21,7 @@ pub fn get_spans(
idx: usize, idx: usize,
replacements: &'static [(&'static str, &'static str)], replacements: &'static [(&'static str, &'static str)],
) -> Option<Vec<(Span, Cow<'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( get_binding_name(&body.arguments[idx]).map_or_else(
|| Some(vec![]), || Some(vec![]),
|name| extract_clone_suggestions(cx, name, replacements, body), |name| extract_clone_suggestions(cx, name, replacements, body),