Rollup merge of #100240 - cjgillot:noice-structural-match, r=davidtwco
Fail gracefully when const pattern is not structural match. Fixes https://github.com/rust-lang/rust/issues/82909
This commit is contained in:
commit
b11b8d6939
3 changed files with 47 additions and 1 deletions
|
@ -168,7 +168,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
|
|||
// once indirect_structural_match is a full fledged error, this
|
||||
// level of indirection can be eliminated
|
||||
|
||||
let inlined_const_as_pat = self.recur(cv, mir_structural_match_violation).unwrap();
|
||||
let inlined_const_as_pat =
|
||||
self.recur(cv, mir_structural_match_violation).unwrap_or_else(|_| Pat {
|
||||
span: self.span,
|
||||
ty: cv.ty(),
|
||||
kind: Box::new(PatKind::Constant { value: cv }),
|
||||
});
|
||||
|
||||
if self.include_lint_checks && !self.saw_const_match_error.get() {
|
||||
// If we were able to successfully convert the const to some pat,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue