Skip to content

Commit 7f66e56

Browse files
committed
Don't require visit_body to take a lifetime that must outlive the function call
1 parent e3e27ba commit 7f66e56

9 files changed

+14
-14
lines changed

clippy_lints/src/default_numeric_fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare_clippy_lint! {
4949
declare_lint_pass!(DefaultNumericFallback => [DEFAULT_NUMERIC_FALLBACK]);
5050

5151
impl<'tcx> LateLintPass<'tcx> for DefaultNumericFallback {
52-
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
52+
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
5353
let hir = cx.tcx.hir();
5454
let is_parent_const = matches!(
5555
hir.body_const_context(hir.body_owner_def_id(body.id())),

clippy_lints/src/dereference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
641641
}
642642
}
643643

644-
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
644+
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'_>) {
645645
if Some(body.id()) == self.current_body {
646646
for pat in self.ref_locals.drain(..).filter_map(|(_, x)| x) {
647647
let replacements = pat.replacements;

clippy_lints/src/implicit_hasher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
328328
impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
329329
type NestedFilter = nested_filter::OnlyBodies;
330330

331-
fn visit_body(&mut self, body: &'tcx Body<'_>) {
331+
fn visit_body(&mut self, body: &Body<'tcx>) {
332332
let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body.id()));
333333
walk_body(self, body);
334334
self.maybe_typeck_results = old_maybe_typeck_results;

clippy_lints/src/macro_metavars_in_unsafe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BodyVisitor<'a, 'tcx> {
186186
}
187187

188188
impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
189-
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx rustc_hir::Body<'tcx>) {
189+
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &rustc_hir::Body<'tcx>) {
190190
if is_lint_allowed(cx, MACRO_METAVARS_IN_UNSAFE, body.value.hir_id) {
191191
return;
192192
}

clippy_lints/src/needless_borrows_for_generic_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowsForGenericArgs<'tcx> {
129129
}
130130
}
131131

132-
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
132+
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'_>) {
133133
if self.possible_borrowers.last().map_or(false, |&(local_def_id, _)| {
134134
local_def_id == cx.tcx.hir().body_owner_def_id(body.id())
135135
}) {

clippy_lints/src/only_used_in_recursion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub struct OnlyUsedInRecursion {
221221
}
222222

223223
impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
224-
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'tcx>) {
224+
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
225225
if body.value.span.from_expansion() {
226226
return;
227227
}
@@ -350,7 +350,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
350350
}
351351
}
352352

353-
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'tcx>) {
353+
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
354354
if self.entered_body == Some(body.value.hir_id) {
355355
self.entered_body = None;
356356
self.params.flag_for_linting();

clippy_lints/src/operators/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,11 @@ impl<'tcx> LateLintPass<'tcx> for Operators {
868868
self.arithmetic_context.expr_post(e.hir_id);
869869
}
870870

871-
fn check_body(&mut self, cx: &LateContext<'tcx>, b: &'tcx Body<'_>) {
871+
fn check_body(&mut self, cx: &LateContext<'tcx>, b: &Body<'_>) {
872872
self.arithmetic_context.enter_body(cx, b);
873873
}
874874

875-
fn check_body_post(&mut self, cx: &LateContext<'tcx>, b: &'tcx Body<'_>) {
875+
fn check_body_post(&mut self, cx: &LateContext<'tcx>, b: &Body<'_>) {
876876
self.arithmetic_context.body_post(cx, b);
877877
}
878878
}

clippy_lints/src/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
188188
}
189189
}
190190

191-
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
191+
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
192192
let hir = cx.tcx.hir();
193193
let mut parents = hir.parent_iter(body.value.hir_id);
194194
let (item_id, sig, is_trait_item) = match parents.next() {
@@ -525,7 +525,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
525525
})
526526
}
527527

528-
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) {
528+
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&Body<'tcx>>) {
529529
if let FnRetTy::Return(ty) = sig.decl.output
530530
&& let Some((out, Mutability::Mut, _)) = get_ref_lm(ty)
531531
{
@@ -559,7 +559,7 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
559559
}
560560

561561
#[expect(clippy::too_many_lines)]
562-
fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: &[PtrArg<'tcx>]) -> Vec<PtrArgResult> {
562+
fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, args: &[PtrArg<'tcx>]) -> Vec<PtrArgResult> {
563563
struct V<'cx, 'tcx> {
564564
cx: &'cx LateContext<'tcx>,
565565
/// Map from a local id to which argument it came from (index into `Self::args` and

clippy_lints/src/question_mark.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,11 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark {
370370
}
371371
}
372372

373-
fn check_body(&mut self, _: &LateContext<'tcx>, _: &'tcx Body<'tcx>) {
373+
fn check_body(&mut self, _: &LateContext<'tcx>, _: &Body<'tcx>) {
374374
self.try_block_depth_stack.push(0);
375375
}
376376

377-
fn check_body_post(&mut self, _: &LateContext<'tcx>, _: &'tcx Body<'tcx>) {
377+
fn check_body_post(&mut self, _: &LateContext<'tcx>, _: &Body<'tcx>) {
378378
self.try_block_depth_stack.pop();
379379
}
380380

0 commit comments

Comments
 (0)