Propagate errors rather than using return_if_err

This commit is contained in:
Michael Goulet 2024-05-09 11:33:53 -04:00
parent db193c1c9d
commit e65cefcf6f
11 changed files with 17 additions and 13 deletions

View File

@ -104,7 +104,7 @@ fn check_fn(
too_large_for_stack: self.too_large_for_stack,
};
ExprUseVisitor::for_clippy(cx, fn_def_id, &mut v).consume_body(body);
ExprUseVisitor::for_clippy(cx, fn_def_id, &mut v).consume_body(body).into_ok();
for node in v.set {
span_lint_hir(

View File

@ -8,6 +8,7 @@
#![feature(never_type)]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
#![feature(unwrap_infallible)]
#![recursion_limit = "512"]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![allow(

View File

@ -65,7 +65,7 @@ fn check_for_mutation(
body.hir_id.owner.def_id,
&mut delegate,
)
.walk_expr(body);
.walk_expr(body).into_ok();
delegate.mutation_span()
}

View File

@ -9,7 +9,6 @@
use rustc_middle::mir::{FakeReadCause, Mutability};
use rustc_middle::ty::{self, BorrowKind};
use rustc_span::sym;
use rustc_trait_selection::infer::TyCtxtInferExt;
use super::ITER_OVEREAGER_CLONED;
use crate::redundant_clone::REDUNDANT_CLONE;
@ -75,7 +74,7 @@ pub(super) fn check<'tcx>(
closure.def_id,
&mut delegate,
)
.consume_body(body);
.consume_body(body).into_ok();
let mut to_be_discarded = false;

View File

@ -117,7 +117,7 @@ fn check_closures<'tcx>(
.associated_body()
.map(|(_, body_id)| hir.body(body_id))
{
euv::ExprUseVisitor::for_clippy(cx, closure, &mut *ctx).consume_body(body);
euv::ExprUseVisitor::for_clippy(cx, closure, &mut *ctx).consume_body(body).into_ok();
}
}
}
@ -194,7 +194,7 @@ fn check_fn(
async_closures: FxHashSet::default(),
tcx: cx.tcx,
};
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx).consume_body(body);
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx).consume_body(body).into_ok();
let mut checked_closures = FxHashSet::default();

View File

@ -133,7 +133,7 @@ fn check_fn(
// function body.
let MovedVariablesCtxt { moved_vars } = {
let mut ctx = MovedVariablesCtxt::default();
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx).consume_body(body);
euv::ExprUseVisitor::for_clippy(cx, fn_def_id, &mut ctx).consume_body(body).into_ok();
ctx
};

View File

@ -119,7 +119,7 @@ fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
let mut s = S(HirIdSet::default());
let v = ExprUseVisitor::for_clippy(cx, e.hir_id.owner.def_id, &mut s);
v.consume_expr(e);
v.consume_expr(e).into_ok();
s.0
}
@ -144,6 +144,6 @@ fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
let mut s = S(HirIdSet::default());
let v = ExprUseVisitor::for_clippy(cx, e.hir_id.owner.def_id, &mut s);
v.consume_expr(e);
v.consume_expr(e).into_ok();
s.0
}

View File

@ -256,8 +256,8 @@ fn visit_branch(
cond.hir_id.owner.def_id,
&mut delegate,
);
vis.walk_expr(cond);
vis.walk_expr(branch);
vis.walk_expr(cond).into_ok();
vis.walk_expr(branch).into_ok();
if delegate.is_mutated {
// if the variable is mutated, we don't know whether it can be unwrapped.

View File

@ -7,6 +7,7 @@
#![feature(never_type)]
#![feature(rustc_private)]
#![feature(assert_matches)]
#![feature(unwrap_infallible)]
#![recursion_limit = "512"]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![allow(

View File

@ -830,7 +830,9 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
applicability: Applicability::MachineApplicable,
};
ExprUseVisitor::for_clippy(cx, def_id, &mut visitor).consume_body(closure_body);
ExprUseVisitor::for_clippy(cx, def_id, &mut visitor)
.consume_body(closure_body)
.into_ok();
if !visitor.suggestion_start.is_empty() {
return Some(DerefClosure {

View File

@ -21,7 +21,8 @@ pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) ->
expr.hir_id.owner.def_id,
&mut delegate,
)
.walk_expr(expr);
.walk_expr(expr)
.into_ok();
if delegate.skip {
return None;