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,
|
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 {
|
for node in v.set {
|
||||||
span_lint_hir(
|
span_lint_hir(
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
#![feature(unwrap_infallible)]
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
||||||
#![allow(
|
#![allow(
|
||||||
|
@ -65,7 +65,7 @@ fn check_for_mutation(
|
|||||||
body.hir_id.owner.def_id,
|
body.hir_id.owner.def_id,
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
)
|
)
|
||||||
.walk_expr(body);
|
.walk_expr(body).into_ok();
|
||||||
|
|
||||||
delegate.mutation_span()
|
delegate.mutation_span()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
use rustc_middle::mir::{FakeReadCause, Mutability};
|
use rustc_middle::mir::{FakeReadCause, Mutability};
|
||||||
use rustc_middle::ty::{self, BorrowKind};
|
use rustc_middle::ty::{self, BorrowKind};
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use rustc_trait_selection::infer::TyCtxtInferExt;
|
|
||||||
|
|
||||||
use super::ITER_OVEREAGER_CLONED;
|
use super::ITER_OVEREAGER_CLONED;
|
||||||
use crate::redundant_clone::REDUNDANT_CLONE;
|
use crate::redundant_clone::REDUNDANT_CLONE;
|
||||||
@ -75,7 +74,7 @@ pub(super) fn check<'tcx>(
|
|||||||
closure.def_id,
|
closure.def_id,
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
)
|
)
|
||||||
.consume_body(body);
|
.consume_body(body).into_ok();
|
||||||
|
|
||||||
let mut to_be_discarded = false;
|
let mut to_be_discarded = false;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ fn check_closures<'tcx>(
|
|||||||
.associated_body()
|
.associated_body()
|
||||||
.map(|(_, body_id)| hir.body(body_id))
|
.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(),
|
async_closures: FxHashSet::default(),
|
||||||
tcx: cx.tcx,
|
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();
|
let mut checked_closures = FxHashSet::default();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ fn check_fn(
|
|||||||
// function body.
|
// function body.
|
||||||
let MovedVariablesCtxt { moved_vars } = {
|
let MovedVariablesCtxt { moved_vars } = {
|
||||||
let mut ctx = MovedVariablesCtxt::default();
|
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
|
ctx
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
|||||||
|
|
||||||
let mut s = S(HirIdSet::default());
|
let mut s = S(HirIdSet::default());
|
||||||
let v = ExprUseVisitor::for_clippy(cx, e.hir_id.owner.def_id, &mut s);
|
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
|
s.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +144,6 @@ fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
|||||||
|
|
||||||
let mut s = S(HirIdSet::default());
|
let mut s = S(HirIdSet::default());
|
||||||
let v = ExprUseVisitor::for_clippy(cx, e.hir_id.owner.def_id, &mut s);
|
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
|
s.0
|
||||||
}
|
}
|
||||||
|
@ -256,8 +256,8 @@ fn visit_branch(
|
|||||||
cond.hir_id.owner.def_id,
|
cond.hir_id.owner.def_id,
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
);
|
);
|
||||||
vis.walk_expr(cond);
|
vis.walk_expr(cond).into_ok();
|
||||||
vis.walk_expr(branch);
|
vis.walk_expr(branch).into_ok();
|
||||||
|
|
||||||
if delegate.is_mutated {
|
if delegate.is_mutated {
|
||||||
// if the variable is mutated, we don't know whether it can be unwrapped.
|
// if the variable is mutated, we don't know whether it can be unwrapped.
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
|
#![feature(unwrap_infallible)]
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
||||||
#![allow(
|
#![allow(
|
||||||
|
@ -830,7 +830,9 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
|
|||||||
applicability: Applicability::MachineApplicable,
|
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() {
|
if !visitor.suggestion_start.is_empty() {
|
||||||
return Some(DerefClosure {
|
return Some(DerefClosure {
|
||||||
|
@ -21,7 +21,8 @@ pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) ->
|
|||||||
expr.hir_id.owner.def_id,
|
expr.hir_id.owner.def_id,
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
)
|
)
|
||||||
.walk_expr(expr);
|
.walk_expr(expr)
|
||||||
|
.into_ok();
|
||||||
|
|
||||||
if delegate.skip {
|
if delegate.skip {
|
||||||
return None;
|
return None;
|
||||||
|
Loading…
Reference in New Issue
Block a user