Skip to content

Commit

Permalink
Rollup merge of rust-lang#111015 - cjgillot:chained-let-and, r=compil…
Browse files Browse the repository at this point in the history
…er-errors

Remove wrong assertion in match checking.

This assertions is completely misguided, introduced by rust-lang#108504. The responsible PR is on beta, nominating for backport.

Instead of checking that this is not a `&&`, it would make sense to check that neither arms of that `&&` is a `let`. This seems like a lot of code for unclear benefit.

r? `@saethlin`
  • Loading branch information
matthiaskrgr authored Apr 30, 2023
2 parents 1b262b8 + 84cb7ec commit 07726e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
let refutable = !is_let_irrefutable(&mut ncx, local_lint_level, tpat);
Some((expr.span, refutable))
}
ExprKind::LogicalOp { op: LogicalOp::And, .. } => {
bug!()
}
_ => None,
}
};
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/match/guards-parenthesized-and.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass

fn main() {
let c = 1;
let w = "T";
match Some(5) {
None if c == 1 && (w != "Y" && w != "E") => {}
_ => panic!(),
}
}

0 comments on commit 07726e3

Please sign in to comment.