diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-02-28 22:26:20 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-03-12 21:38:31 +0100 |
| commit | b878ab6a270928fa45850183b82b13eac1e80c39 (patch) | |
| tree | 81a2fba3be80525225d820e228b1621360310256 /compiler/rustc_pattern_analysis/src | |
| parent | 9f2aa5b85a2584568f1ad34f23d029eeafb20d4b (diff) | |
| download | rust-b878ab6a270928fa45850183b82b13eac1e80c39.tar.gz rust-b878ab6a270928fa45850183b82b13eac1e80c39.zip | |
Don't suggest an arm when suggesting a never pattern
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/pat.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_pattern_analysis/src/pat.rs b/compiler/rustc_pattern_analysis/src/pat.rs index 780a386fe65..33d2fe89f43 100644 --- a/compiler/rustc_pattern_analysis/src/pat.rs +++ b/compiler/rustc_pattern_analysis/src/pat.rs @@ -321,6 +321,14 @@ impl<Cx: TypeCx> WitnessPat<Cx> { &self.ty } + pub fn is_never_pattern(&self) -> bool { + match self.ctor() { + Never => true, + Or => self.fields.iter().all(|p| p.is_never_pattern()), + _ => self.fields.iter().any(|p| p.is_never_pattern()), + } + } + pub fn iter_fields(&self) -> impl Iterator<Item = &WitnessPat<Cx>> { self.fields.iter() } |
