Skip to content

Commit

Permalink
if boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
Medowhill committed May 29, 2024
1 parent ef1a0a9 commit f9a74df
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/tag_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1632,23 +1632,26 @@ impl<'tcx> SuggestingVisitor<'_, 'tcx> {

fn decompose_expr(&self, expr: &'tcx Expr<'tcx>) -> Option<Vec<&'tcx Expr<'tcx>>> {
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,
}
}
Expand Down

0 comments on commit f9a74df

Please sign in to comment.