mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Don't require visit_body
to take a lifetime that must outlive the function call
This commit is contained in:
parent
e3e27ba3dd
commit
7f66e567b2
9 changed files with 14 additions and 14 deletions
|
@ -49,7 +49,7 @@ declare_clippy_lint! {
|
|||
declare_lint_pass!(DefaultNumericFallback => [DEFAULT_NUMERIC_FALLBACK]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for DefaultNumericFallback {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
let hir = cx.tcx.hir();
|
||||
let is_parent_const = matches!(
|
||||
hir.body_const_context(hir.body_owner_def_id(body.id())),
|
||||
|
|
|
@ -641,7 +641,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'_>) {
|
||||
if Some(body.id()) == self.current_body {
|
||||
for pat in self.ref_locals.drain(..).filter_map(|(_, x)| x) {
|
||||
let replacements = pat.replacements;
|
||||
|
|
|
@ -328,7 +328,7 @@ impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
|
|||
impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
|
||||
type NestedFilter = nested_filter::OnlyBodies;
|
||||
|
||||
fn visit_body(&mut self, body: &'tcx Body<'_>) {
|
||||
fn visit_body(&mut self, body: &Body<'tcx>) {
|
||||
let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body.id()));
|
||||
walk_body(self, body);
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BodyVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx rustc_hir::Body<'tcx>) {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &rustc_hir::Body<'tcx>) {
|
||||
if is_lint_allowed(cx, MACRO_METAVARS_IN_UNSAFE, body.value.hir_id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowsForGenericArgs<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'_>) {
|
||||
if self.possible_borrowers.last().map_or(false, |&(local_def_id, _)| {
|
||||
local_def_id == cx.tcx.hir().body_owner_def_id(body.id())
|
||||
}) {
|
||||
|
|
|
@ -221,7 +221,7 @@ pub struct OnlyUsedInRecursion {
|
|||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'tcx>) {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
if body.value.span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'tcx>) {
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
if self.entered_body == Some(body.value.hir_id) {
|
||||
self.entered_body = None;
|
||||
self.params.flag_for_linting();
|
||||
|
|
|
@ -868,11 +868,11 @@ impl<'tcx> LateLintPass<'tcx> for Operators {
|
|||
self.arithmetic_context.expr_post(e.hir_id);
|
||||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, b: &'tcx Body<'_>) {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, b: &Body<'_>) {
|
||||
self.arithmetic_context.enter_body(cx, b);
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, b: &'tcx Body<'_>) {
|
||||
fn check_body_post(&mut self, cx: &LateContext<'tcx>, b: &Body<'_>) {
|
||||
self.arithmetic_context.body_post(cx, b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
let hir = cx.tcx.hir();
|
||||
let mut parents = hir.parent_iter(body.value.hir_id);
|
||||
let (item_id, sig, is_trait_item) = match parents.next() {
|
||||
|
@ -525,7 +525,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
|
|||
})
|
||||
}
|
||||
|
||||
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) {
|
||||
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&Body<'tcx>>) {
|
||||
if let FnRetTy::Return(ty) = sig.decl.output
|
||||
&& let Some((out, Mutability::Mut, _)) = get_ref_lm(ty)
|
||||
{
|
||||
|
@ -559,7 +559,7 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
|
|||
}
|
||||
|
||||
#[expect(clippy::too_many_lines)]
|
||||
fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: &[PtrArg<'tcx>]) -> Vec<PtrArgResult> {
|
||||
fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, args: &[PtrArg<'tcx>]) -> Vec<PtrArgResult> {
|
||||
struct V<'cx, 'tcx> {
|
||||
cx: &'cx LateContext<'tcx>,
|
||||
/// Map from a local id to which argument it came from (index into `Self::args` and
|
||||
|
|
|
@ -370,11 +370,11 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_body(&mut self, _: &LateContext<'tcx>, _: &'tcx Body<'tcx>) {
|
||||
fn check_body(&mut self, _: &LateContext<'tcx>, _: &Body<'tcx>) {
|
||||
self.try_block_depth_stack.push(0);
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, _: &LateContext<'tcx>, _: &'tcx Body<'tcx>) {
|
||||
fn check_body_post(&mut self, _: &LateContext<'tcx>, _: &Body<'tcx>) {
|
||||
self.try_block_depth_stack.pop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue