Skip to content

Commit

Permalink
Move some Map methods onto TyCtxt.
Browse files Browse the repository at this point in the history
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
  • Loading branch information
nnethercote committed Feb 17, 2025
1 parent fc532c5 commit 8cf9eea
Show file tree
Hide file tree
Showing 102 changed files with 146 additions and 150 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/arbitrary_source_item_ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
return;
}

let items = module.item_ids.iter().map(|&id| cx.tcx.hir().item(id));
let items = module.item_ids.iter().map(|&id| cx.tcx.hir_item(id));

// Iterates over the items within a module.
//
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
// XXXkhuey maybe we should?
return;
},
CoroutineSource::Block => cx.tcx.hir().body(*body_id).value,
CoroutineSource::Block => cx.tcx.hir_body(*body_id).value,
CoroutineSource::Closure => {
// Like `async fn`, async closures are wrapped in an additional block
// to move all of the closure's arguments into the future.

let async_closure_body = cx.tcx.hir().body(*body_id).value;
let async_closure_body = cx.tcx.hir_body(*body_id).value;
let ExprKind::Block(block, _) = async_closure_body.kind else {
return;
};
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub(super) fn is_lint_level(symbol: Symbol, attr_id: AttrId) -> bool {

pub(super) fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
if let ItemKind::Fn { body: eid, .. } = item.kind {
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
} else {
true
}
}

pub(super) fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
match item.kind {
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value),
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value),
_ => false,
}
}
Expand All @@ -39,7 +39,7 @@ pub(super) fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> b
match item.kind {
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
},
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: &Msrv, expr: &Expr<'_>) -> Opti
})
},
ExprKind::Closure(closure) => {
let body = cx.tcx.hir().body(closure.body);
let body = cx.tcx.hir_body(closure.body);
let params = body
.params
.iter()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collection_is_never_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
let is_read_in_closure_arg = args.iter().any(|arg| {
if let ExprKind::Closure(closure) = arg.kind
// To keep things simple, we only check the first param to see if its read.
&& let Body { params: [param, ..], value } = cx.tcx.hir().body(closure.body)
&& let Body { params: [param, ..], value } = cx.tcx.hir_body(closure.body)
{
!has_no_read_access(cx, param.hir_id, *value)
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/derivable_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
&& let impl_item_hir = child.id.hir_id()
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
&& let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
&& !attrs.iter().any(|attr| attr.doc_str().is_some())
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc/missing_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn check(
} else if let Some(body_id) = body_id
&& let Some(future) = cx.tcx.lang_items().future_trait()
&& let typeck = cx.tcx.typeck_body(body_id)
&& let body = cx.tcx.hir().body(body_id)
&& let body = cx.tcx.hir_body(body_id)
&& let ret_ty = typeck.expr_ty(body.value)
&& implements_trait_with_env(
cx.tcx,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id())
|| item.span.in_external_macro(cx.tcx.sess.source_map()))
{
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);

let panic_info = FindPanicUnwrap::find_span(cx, cx.tcx.typeck(item.owner_id), body.value);
missing_headers::check(
Expand Down Expand Up @@ -649,7 +649,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
&& !impl_item.span.in_external_macro(cx.tcx.sess.source_map())
&& !is_trait_impl_item(cx, impl_item.hir_id())
{
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);

let panic_span = FindPanicUnwrap::find_span(cx, cx.tcx.typeck(impl_item.owner_id), body.value);
missing_headers::check(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/empty_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl LateLintPass<'_> for EmptyDrop {
&& let impl_item_hir = child.id.hir_id()
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
&& let func_expr = peel_blocks(func_expr)
&& let ExprKind::Block(block, _) = func_expr.kind
&& block.stmts.is_empty()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx
&& matches!(c.fn_decl.output, FnRetTy::DefaultReturn(_))
&& !expr.span.from_expansion()
{
cx.tcx.hir().body(c.body)
cx.tcx.hir_body(c.body)
} else {
return;
};
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/extra_unused_type_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> {
}

fn is_empty_body(cx: &LateContext<'_>, body: BodyId) -> bool {
matches!(cx.tcx.hir().body(body).value.kind, ExprKind::Block(b, _) if b.stmts.is_empty() && b.expr.is_none())
matches!(cx.tcx.hir_body(body).value.kind, ExprKind::Block(b, _) if b.stmts.is_empty() && b.expr.is_none())
}

impl<'tcx> LateLintPass<'tcx> for ExtraUnusedTypeParameters {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ fn lint_impl_body(cx: &LateContext<'_>, impl_span: Span, impl_items: &[hir::Impl

for impl_item in impl_items {
if impl_item.ident.name == sym::from
&& let ImplItemKind::Fn(_, body_id) = cx.tcx.hir().impl_item(impl_item.id).kind
&& let ImplItemKind::Fn(_, body_id) = cx.tcx.hir_impl_item(impl_item.id).kind
{
// 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 mut fpu = FindPanicUnwrap {
lcx: cx,
typeck_results: cx.tcx.typeck(impl_item.id.owner_id.def_id),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/format_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn is_format_trait_impl(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) -> Optio
&& let Some(name) = cx.tcx.get_diagnostic_name(did)
&& matches!(name, sym::Debug | sym::Display)
{
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);
let formatter_name = body
.params
.get(1)
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/from_over_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ fn convert_to_from(
// bad suggestion/fix.
return None;
}
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
let impl_item = cx.tcx.hir_impl_item(impl_item_ref.id);
let ImplItemKind::Fn(ref sig, body_id) = impl_item.kind else {
return None;
};
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);
let [input] = body.params else { return None };
let PatKind::Binding(.., self_ident, None) = input.pat.kind else {
return None;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions/impl_trait_in_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
&& let hir::ItemKind::Impl(impl_) = item.kind
&& let hir::Impl { of_trait, .. } = *impl_
&& of_trait.is_none()
&& let body = cx.tcx.hir().body(body_id)
&& let body = cx.tcx.hir_body(body_id)
&& cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public()
&& !is_in_test(cx.tcx, impl_item.hir_id())
{
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/functions/must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
check_must_use_candidate(
cx,
sig.decl,
cx.tcx.hir().body(*body_id),
cx.tcx.hir_body(*body_id),
item.span,
item.owner_id,
item.span.with_hi(sig.decl.output.span().hi()),
Expand All @@ -59,7 +59,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
check_must_use_candidate(
cx,
sig.decl,
cx.tcx.hir().body(*body_id),
cx.tcx.hir_body(*body_id),
item.span,
item.owner_id,
item.span.with_hi(sig.decl.output.span().hi()),
Expand All @@ -79,7 +79,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
if let Some(attr) = attr {
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr, attrs, sig);
} else if let hir::TraitFn::Provided(eid) = *eid {
let body = cx.tcx.hir().body(eid);
let body = cx.tcx.hir_body(eid);
if attr.is_none() && is_public && !is_proc_macro(attrs) {
check_must_use_candidate(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(super) fn check_fn<'tcx>(

pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
if let hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(eid)) = item.kind {
let body = cx.tcx.hir().body(eid);
let body = cx.tcx.hir_body(eid);
check_raw_ptr(cx, sig.header.safety(), sig.decl, body, item.owner_id.def_id);
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implicit_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
});

let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
for item in impl_.items.iter().map(|item| cx.tcx.hir().impl_item(item.id)) {
for item in impl_.items.iter().map(|item| cx.tcx.hir_impl_item(item.id)) {
ctr_vis.visit_impl_item(item);
}

Expand All @@ -154,7 +154,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
body: body_id,
..
} => {
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);

for ty in sig.decl.inputs {
let mut vis = ImplicitHasherTypeVisitor::new(cx);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
}
if method.ident.name.as_str() == "flat_map" && args.len() == 1 {
if let ExprKind::Closure(&Closure { body, .. }) = args[0].kind {
let body = cx.tcx.hir().body(body);
let body = cx.tcx.hir_body(body);
return is_infinite(cx, body.value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/items_after_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LateLintPass<'_> for ItemsAfterStatements {
.iter()
.skip_while(|stmt| matches!(stmt.kind, StmtKind::Item(..)))
.filter_map(|stmt| match stmt.kind {
StmtKind::Item(id) => Some(cx.tcx.hir().item(id)),
StmtKind::Item(id) => Some(cx.tcx.hir_item(id)),
_ => None,
})
// Ignore macros since they can only see previously defined locals.
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/items_after_test_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn cfg_test_module<'tcx>(cx: &LateContext<'tcx>, item: &Item<'tcx>) -> bool {

impl LateLintPass<'_> for ItemsAfterTestModule {
fn check_mod(&mut self, cx: &LateContext<'_>, module: &Mod<'_>, _: HirId) {
let mut items = module.item_ids.iter().map(|&id| cx.tcx.hir().item(id));
let mut items = module.item_ids.iter().map(|&id| cx.tcx.hir_item(id));

let Some((mod_pos, test_mod)) = items.by_ref().enumerate().find(|(_, item)| cfg_test_module(cx, item)) else {
return;
Expand Down Expand Up @@ -91,7 +91,7 @@ impl LateLintPass<'_> for ItemsAfterTestModule {
"items after a test module",
|diag| {
if let Some(prev) = mod_pos.checked_sub(1)
&& let prev = cx.tcx.hir().item(module.item_ids[prev])
&& let prev = cx.tcx.hir_item(module.item_ids[prev])
&& let items_span = last.span.with_lo(test_mod.span.hi())
&& let Some(items) = items_span.get_source_text(cx)
{
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/iter_without_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter {
})
&& let Some(iter_assoc_span) = imp.items.iter().find_map(|item| {
if item.ident.name.as_str() == "IntoIter" {
Some(cx.tcx.hir().impl_item(item.id).expect_type().span)
Some(cx.tcx.hir_impl_item(item.id).expect_type().span)
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ enum LenOutput {

fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&'tcx PathSegment<'tcx>> {
if let ty::Alias(_, alias_ty) = ty.kind()
&& let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir().get_if_local(alias_ty.def_id)
&& let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir_get_if_local(alias_ty.def_id)
&& let OpaqueTyOrigin::AsyncFn { .. } = opaque.origin
&& let [GenericBound::Trait(trait_ref)] = &opaque.bounds
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn could_use_elision<'tcx>(
}

if let Some(body_id) = body {
let body = cx.tcx.hir().body(body_id);
let body = cx.tcx.hir_body(body_id);

let first_ident = body.params.first().and_then(|param| param.pat.simple_ident());
if non_elidable_self_type(cx, func, first_ident, msrv) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lines_filter_map_ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn should_lint(cx: &LateContext<'_>, args: &[Expr<'_>], method_str: &str) -> boo
ExprKind::Closure(Closure { body, .. }) => {
if let Body {
params: [param], value, ..
} = cx.tcx.hir().body(*body)
} = cx.tcx.hir_body(*body)
&& let ExprKind::MethodCall(method, receiver, [], _) = value.kind
&& path_to_local_id(receiver, param.pat.hir_id)
&& let Some(method_did) = cx.typeck_results().type_dependent_def_id(value.hir_id)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'tcx> Visitor<'tcx> for VarVisitor<'_, 'tcx> {
}
},
ExprKind::Closure(&Closure { body, .. }) => {
let body = self.cx.tcx.hir().body(body);
let body = self.cx.tcx.hir_body(body);
self.visit_expr(body.value);
},
_ => walk_expr(self, expr),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/while_let_on_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
loop_id: loop_expr.hir_id,
after_loop: false,
};
v.visit_expr(cx.tcx.hir().body(cx.enclosing_body.unwrap()).value)
v.visit_expr(cx.tcx.hir_body(cx.enclosing_body.unwrap()).value)
.is_break()
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
&& let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)) =
kind
{
return Some(cx.tcx.hir().body(body));
return Some(cx.tcx.hir_body(body));
}

None
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_option_as_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn check_arms(cx: &LateContext<'_>, none_arm: &Arm<'_>, some_arm: &Arm<'_>) -> b
fn returns_empty_slice(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
match expr.kind {
ExprKind::Path(_) => clippy_utils::is_path_diagnostic_item(cx, expr, sym::default_fn),
ExprKind::Closure(cl) => is_empty_slice(cx, cx.tcx.hir().body(cl.body).value),
ExprKind::Closure(cl) => is_empty_slice(cx, cx.tcx.hir_body(cl.body).value),
_ => false,
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/manual_retain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn check_into_iter(
&& SpanlessEq::new(cx).eq_expr(left_expr, struct_expr)
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = target_expr.kind
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
&& let filter_body = cx.tcx.hir().body(closure.body)
&& let filter_body = cx.tcx.hir_body(closure.body)
&& let [filter_params] = filter_body.params
{
if match_map_type(cx, left_expr) {
Expand Down Expand Up @@ -139,7 +139,7 @@ fn check_iter(
&& SpanlessEq::new(cx).eq_expr(left_expr, struct_expr)
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
&& let filter_body = cx.tcx.hir().body(closure.body)
&& let filter_body = cx.tcx.hir_body(closure.body)
&& let [filter_params] = filter_body.params
{
match filter_params.pat.kind {
Expand Down Expand Up @@ -198,7 +198,7 @@ fn check_to_owned(
&& SpanlessEq::new(cx).eq_expr(left_expr, str_expr)
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
&& let filter_body = cx.tcx.hir().body(closure.body)
&& let filter_body = cx.tcx.hir_body(closure.body)
&& let [filter_params] = filter_body.params
{
if let hir::PatKind::Ref(pat, _) = filter_params.pat.kind {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_unit_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn unit_closure<'tcx>(
expr: &hir::Expr<'_>,
) -> Option<(&'tcx hir::Param<'tcx>, &'tcx hir::Expr<'tcx>)> {
if let hir::ExprKind::Closure(&hir::Closure { fn_decl, body, .. }) = expr.kind
&& let body = cx.tcx.hir().body(body)
&& let body = cx.tcx.hir_body(body)
&& let body_expr = &body.value
&& fn_decl.inputs.len() == 1
&& is_unit_expression(cx, body_expr)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/bind_instead_of_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl BindInsteadOfMap {

match arg.kind {
hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) => {
let closure_body = cx.tcx.hir().body(body);
let closure_body = cx.tcx.hir_body(body);
let closure_expr = peel_blocks(closure_body.value);

if self.lint_closure_autofixable(cx, expr, recv, closure_expr, fn_decl_span) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(
filter_arg: &'tcx Expr<'_>,
) {
if let ExprKind::Closure(&Closure { body, .. }) = filter_arg.kind
&& let body = cx.tcx.hir().body(body)
&& let body = cx.tcx.hir_body(body)
&& let [param] = body.params
&& let PatKind::Binding(_, arg_id, _, _) = strip_pat_refs(param.pat).kind
&& let ExprKind::Binary(ref op, l, r) = body.value.kind
Expand Down
Loading

0 comments on commit 8cf9eea

Please sign in to comment.