diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-01-31 01:23:35 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-01-31 01:43:41 +0100 |
| commit | ee2cddd8f2232aaac044c07b1a8ea1ceec083107 (patch) | |
| tree | 70c5fefce735eb5a4b9a593fc740d59b7bb63dc4 /compiler/rustc_pattern_analysis | |
| parent | 5ad7454f7503b6af2800bf4a7c875962cb03f913 (diff) | |
| download | rust-ee2cddd8f2232aaac044c07b1a8ea1ceec083107.tar.gz rust-ee2cddd8f2232aaac044c07b1a8ea1ceec083107.zip | |
It is correct to lower `!` to `_`.
Diffstat (limited to 'compiler/rustc_pattern_analysis')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 223d6cefc83..bef03ef30d8 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -680,8 +680,9 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> { cx.pattern_arena.alloc_from_iter(pats.into_iter().map(|p| self.lower_pat(p))) } PatKind::Never => { - // FIXME(never_patterns): handle `!` in exhaustiveness. This is a sane default - // in the meantime. + // A never pattern matches all the values of its type (namely none). Moreover it + // must be compatible with other constructors, since we can use `!` on a type like + // `Result<!, !>` which has other constructors. Hence we lower it as a wildcard. ctor = Wildcard; fields = &[]; } |
