Skip to content

Commit 8cf9eea

Browse files
committed
Move some Map methods onto TyCtxt.
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`.
1 parent fc532c5 commit 8cf9eea

File tree

102 files changed

+146
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+146
-150
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
338338
return;
339339
}
340340

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

343343
// Iterates over the items within a module.
344344
//

clippy_lints/src/async_yields_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
6060
// XXXkhuey maybe we should?
6161
return;
6262
},
63-
CoroutineSource::Block => cx.tcx.hir().body(*body_id).value,
63+
CoroutineSource::Block => cx.tcx.hir_body(*body_id).value,
6464
CoroutineSource::Closure => {
6565
// Like `async fn`, async closures are wrapped in an additional block
6666
// to move all of the closure's arguments into the future.
6767

68-
let async_closure_body = cx.tcx.hir().body(*body_id).value;
68+
let async_closure_body = cx.tcx.hir_body(*body_id).value;
6969
let ExprKind::Block(block, _) = async_closure_body.kind else {
7070
return;
7171
};

clippy_lints/src/attrs/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ pub(super) fn is_lint_level(symbol: Symbol, attr_id: AttrId) -> bool {
2222

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

3131
pub(super) fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
3232
match item.kind {
33-
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value),
33+
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value),
3434
_ => false,
3535
}
3636
}
@@ -39,7 +39,7 @@ pub(super) fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> b
3939
match item.kind {
4040
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
4141
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
42-
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
42+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
4343
},
4444
_ => false,
4545
}

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: &Msrv, expr: &Expr<'_>) -> Opti
452452
})
453453
},
454454
ExprKind::Closure(closure) => {
455-
let body = cx.tcx.hir().body(closure.body);
455+
let body = cx.tcx.hir_body(closure.body);
456456
let params = body
457457
.params
458458
.iter()

clippy_lints/src/collection_is_never_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
118118
let is_read_in_closure_arg = args.iter().any(|arg| {
119119
if let ExprKind::Closure(closure) = arg.kind
120120
// To keep things simple, we only check the first param to see if its read.
121-
&& let Body { params: [param, ..], value } = cx.tcx.hir().body(closure.body)
121+
&& let Body { params: [param, ..], value } = cx.tcx.hir_body(closure.body)
122122
{
123123
!has_no_read_access(cx, param.hir_id, *value)
124124
} else {

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
197197
&& let impl_item_hir = child.id.hir_id()
198198
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
199199
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
200-
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
200+
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
201201
&& let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
202202
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
203203
&& !attrs.iter().any(|attr| attr.doc_str().is_some())

clippy_lints/src/doc/missing_headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn check(
6868
} else if let Some(body_id) = body_id
6969
&& let Some(future) = cx.tcx.lang_items().future_trait()
7070
&& let typeck = cx.tcx.typeck_body(body_id)
71-
&& let body = cx.tcx.hir().body(body_id)
71+
&& let body = cx.tcx.hir_body(body_id)
7272
&& let ret_ty = typeck.expr_ty(body.value)
7373
&& implements_trait_with_env(
7474
cx.tcx,

clippy_lints/src/doc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
597597
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id())
598598
|| item.span.in_external_macro(cx.tcx.sess.source_map()))
599599
{
600-
let body = cx.tcx.hir().body(body_id);
600+
let body = cx.tcx.hir_body(body_id);
601601

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

654654
let panic_span = FindPanicUnwrap::find_span(cx, cx.tcx.typeck(impl_item.owner_id), body.value);
655655
missing_headers::check(

clippy_lints/src/empty_drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl LateLintPass<'_> for EmptyDrop {
4444
&& let impl_item_hir = child.id.hir_id()
4545
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
4646
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
47-
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
47+
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
4848
&& let func_expr = peel_blocks(func_expr)
4949
&& let ExprKind::Block(block, _) = func_expr.kind
5050
&& block.stmts.is_empty()

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx
9797
&& matches!(c.fn_decl.output, FnRetTy::DefaultReturn(_))
9898
&& !expr.span.from_expansion()
9999
{
100-
cx.tcx.hir().body(c.body)
100+
cx.tcx.hir_body(c.body)
101101
} else {
102102
return;
103103
};

0 commit comments

Comments
 (0)