From f9a74dfce097de52639a2153bab4cc1eb9f8dcde Mon Sep 17 00:00:00 2001 From: Jaemin Hong Date: Wed, 29 May 2024 14:17:11 +0000 Subject: [PATCH] if boolean --- src/tag_analysis.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/tag_analysis.rs b/src/tag_analysis.rs index 59c74e0..379dc39 100644 --- a/src/tag_analysis.rs +++ b/src/tag_analysis.rs @@ -1632,23 +1632,26 @@ impl<'tcx> SuggestingVisitor<'_, 'tcx> { fn decompose_expr(&self, expr: &'tcx Expr<'tcx>) -> Option>> { let expr = unwrap_cast_and_drop(expr); - let ExprKind::Binary(Spanned { node, .. }, lhs, rhs) = expr.kind else { return None }; - match node { - BinOpKind::Or => { - let mut exprs1 = self.decompose_expr(lhs)?; - let exprs2 = self.decompose_expr(rhs)?; - exprs1.extend(exprs2); - Some(exprs1) - } - BinOpKind::Eq => { - if let (Some(struct_expr), None) | (None, Some(struct_expr)) = - (self.get_struct(lhs), self.get_struct(rhs)) - { - Some(vec![struct_expr]) - } else { - None + match expr.kind { + ExprKind::Binary(Spanned { node, .. }, lhs, rhs) => match node { + BinOpKind::Or => { + let mut exprs1 = self.decompose_expr(lhs)?; + let exprs2 = self.decompose_expr(rhs)?; + exprs1.extend(exprs2); + Some(exprs1) } - } + BinOpKind::Eq => { + if let (Some(struct_expr), None) | (None, Some(struct_expr)) = + (self.get_struct(lhs), self.get_struct(rhs)) + { + Some(vec![struct_expr]) + } else { + None + } + } + _ => None, + }, + ExprKind::Field(struct_expr, _) => Some(vec![struct_expr]), _ => None, } }