Skip to content

Commit f44a6a7

Browse files
committed
Make body_owned_by return the body directly.
Almost all callers want this anyway, and now we can use it to also return fed bodies
1 parent 7f66e56 commit f44a6a7

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

clippy_lints/src/methods/option_map_unwrap_or.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub(super) fn check<'tcx>(
5959
};
6060

6161
let map = cx.tcx.hir();
62-
let body = map.body(map.body_owned_by(map.enclosing_body_owner(expr.hir_id)));
63-
reference_visitor.visit_body(body);
62+
let body = map.body_owned_by(map.enclosing_body_owner(expr.hir_id));
63+
reference_visitor.visit_body(&body);
6464

6565
if reference_visitor.found_reference {
6666
return;

clippy_lints/src/single_call_fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ impl SingleCallFn {
7979
.tcx
8080
.hir()
8181
.maybe_body_owned_by(fn_def_id)
82-
.map(|body| cx.tcx.hir().body(body))
8382
.map_or(true, |body| is_in_test_function(cx.tcx, body.value.hir_id))
8483
|| match cx.tcx.hir_node(fn_hir_id) {
8584
Node::Item(item) => is_from_proc_macro(cx, item),

clippy_lints/src/transmute/missing_transmute_annotations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ fn get_parent_local_binding_ty<'tcx>(cx: &LateContext<'tcx>, expr_hir_id: HirId)
3030

3131
fn is_function_block(cx: &LateContext<'_>, expr_hir_id: HirId) -> bool {
3232
let def_id = cx.tcx.hir().enclosing_body_owner(expr_hir_id);
33-
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(def_id) {
34-
let body = cx.tcx.hir().body(body_id);
33+
if let Some(body) = cx.tcx.hir().maybe_body_owned_by(def_id) {
34+
let body = cx.tcx.hir().body(body.id());
3535
return body.value.peel_blocks().hir_id == expr_hir_id;
3636
}
3737
false

clippy_lints/src/unconditional_recursion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl UnconditionalRecursion {
336336
// We need to use typeck here to infer the actual function being called.
337337
&& let body_def_id = cx.tcx.hir().enclosing_body_owner(call_expr.hir_id)
338338
&& let Some(body_owner) = cx.tcx.hir().maybe_body_owned_by(body_def_id)
339-
&& let typeck = cx.tcx.typeck_body(body_owner)
339+
&& let typeck = cx.tcx.typeck_body(body_owner.id())
340340
&& let Some(call_def_id) = typeck.type_dependent_def_id(call_expr.hir_id)
341341
{
342342
self.default_impl_for_type.insert(self_def_id, call_def_id);

clippy_lints/src/utils/author.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ impl<'tcx> LateLintPass<'tcx> for Author {
137137

138138
fn check_item(cx: &LateContext<'_>, hir_id: HirId) {
139139
let hir = cx.tcx.hir();
140-
if let Some(body_id) = hir.maybe_body_owned_by(hir_id.expect_owner().def_id) {
140+
if let Some(body) = hir.maybe_body_owned_by(hir_id.expect_owner().def_id) {
141141
check_node(cx, hir_id, |v| {
142-
v.expr(&v.bind("expr", hir.body(body_id).value));
142+
v.expr(&v.bind("expr", body.value));
143143
});
144144
}
145145
}

0 commit comments

Comments
 (0)