Auto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate
Fix a false-positive inside const fn in `comparison_chain` closes https://github.com/rust-lang/rust-clippy/issues/7082 changelog: fix a false-positive inside const fn in [`comparison_chain`]
This commit is contained in:
commit
14f1551075
2 changed files with 33 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use clippy_utils::{get_trait_def_id, if_sequence, is_else_clause, paths, SpanlessEq};
|
||||
use clippy_utils::{get_trait_def_id, if_sequence, in_constant, is_else_clause, paths, SpanlessEq};
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
|
@ -64,6 +64,10 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
|
|||
return;
|
||||
}
|
||||
|
||||
if in_constant(cx, expr.hir_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that there exists at least one explicit else condition
|
||||
let (conds, _) = if_sequence(expr);
|
||||
if conds.len() < 2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue