1
Fork 0

Rollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasper

Explicitly checking for or-pattern before test

Fixes https://github.com/rust-lang/rust/issues/72680

cc https://github.com/rust-lang/rust/issues/54883

r? ````@varkor````
This commit is contained in:
Dylan DPC 2020-11-15 03:02:40 +01:00 committed by GitHub
commit a29b68f326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 0 deletions

View file

@ -671,6 +671,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(&TestKind::Range { .. }, _) => None,
(&TestKind::Eq { .. } | &TestKind::Len { .. }, _) => {
// The call to `self.test(&match_pair)` below is not actually used to generate any
// MIR. Instead, we just want to compare with `test` (the parameter of the method)
// to see if it is the same.
//
// However, at this point we can still encounter or-patterns that were extracted
// from previous calls to `sort_candidate`, so we need to manually address that
// case to avoid panicking in `self.test()`.
if let PatKind::Or { .. } = &*match_pair.pattern.kind {
return None;
}
// These are all binary tests.
//
// FIXME(#29623) we can be more clever here