Fix clippy lint for identical if/else contraining ? expressions

Follow up to #114819.
This commit is contained in:
Esteban Küber 2023-08-23 00:58:09 +00:00
parent 50f7f8e0f8
commit 32eecd4b88
3 changed files with 23 additions and 3 deletions

View file

@ -10,6 +10,7 @@ use rustc_hir::{
GenericArgs, Guard, HirId, HirIdMap, InlineAsmOperand, Let, Lifetime, LifetimeName, Pat, PatField, PatKind, Path,
PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding,
};
use rustc_hir::MatchSource::TryDesugar;
use rustc_lexer::{tokenize, TokenKind};
use rustc_lint::LateContext;
use rustc_middle::ty::TypeckResults;
@ -311,7 +312,7 @@ impl HirEqInterExpr<'_, '_, '_> {
lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.name == r.ident.name)
},
(&ExprKind::Match(le, la, ref ls), &ExprKind::Match(re, ra, ref rs)) => {
ls == rs
(ls == rs || (matches!((ls, rs), (TryDesugar(_), TryDesugar(_)))))
&& self.eq_expr(le, re)
&& over(la, ra, |l, r| {
self.eq_pat(l.pat, r.pat)