don't trigger blocks_in_conditions when the condition contains a return
This commit is contained in:
parent
1419ac2982
commit
243e0ee274
3 changed files with 22 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::snippet_block_with_applicability;
|
||||
use clippy_utils::{higher, is_from_proc_macro};
|
||||
use clippy_utils::{contains_return, higher, is_from_proc_macro};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BlockCheckMode, Expr, ExprKind, MatchSource};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
|
|
@ -86,6 +86,13 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions {
|
|||
if expr.span.from_expansion() || ex.span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Linting should not be triggered to cases where `return` is included in the condition.
|
||||
// #9911
|
||||
if contains_return(block.expr) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue