Propagate errors rather than using return_if_err
This commit is contained in:
parent
db193c1c9d
commit
e65cefcf6f
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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(
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user