Auto merge of #80632 - Nadrieril:fix-80501, r=varkor
Identify unreachable subpatterns more reliably In https://github.com/rust-lang/rust/pull/80104 I used `Span`s to identify unreachable sub-patterns in the presence of or-patterns during exhaustiveness checking. In https://github.com/rust-lang/rust/issues/80501 it was revealed that `Span`s are complicated and that this was not a good idea. Instead, this PR identifies subpatterns logically: as a path in the tree of subpatterns of a given pattern. I made a struct that captures a set of such subpatterns. This is a bit complex, but thankfully self-contained; the rest of the code does not need to know anything about it. Fixes https://github.com/rust-lang/rust/issues/80501. I think I managed to keep the perf neutral. r? `@varkor`
This commit is contained in:
commit
36ecbc94eb
6 changed files with 473 additions and 224 deletions
|
|
@ -0,0 +1,27 @@
|
|||
// check-pass
|
||||
#![deny(unreachable_patterns)]
|
||||
pub enum TypeCtor {
|
||||
Slice,
|
||||
Array,
|
||||
}
|
||||
|
||||
pub struct ApplicationTy(TypeCtor);
|
||||
|
||||
macro_rules! ty_app {
|
||||
($ctor:pat) => {
|
||||
ApplicationTy($ctor)
|
||||
};
|
||||
}
|
||||
|
||||
fn _foo(ty: ApplicationTy) {
|
||||
match ty {
|
||||
ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {}
|
||||
}
|
||||
|
||||
// same as above, with the macro expanded
|
||||
match ty {
|
||||
ApplicationTy(TypeCtor::Array) | ApplicationTy(TypeCtor::Slice) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue