diff options
| author | bors <bors@rust-lang.org> | 2024-07-26 10:51:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-26 10:51:04 +0000 |
| commit | 355efacf0d430331c962a38af39049b76bb6266b (patch) | |
| tree | 93b3896181a79c48fa9b48229e9f91d6306fbbb3 /compiler/rustc_pattern_analysis/tests/intersection.rs | |
| parent | 83d67685acb520fe68d5d5adde4b25fb725490de (diff) | |
| parent | 940769a79b3c71915533d6eddc001a9b71bf5402 (diff) | |
| download | rust-355efacf0d430331c962a38af39049b76bb6266b.tar.gz rust-355efacf0d430331c962a38af39049b76bb6266b.zip | |
Auto merge of #128034 - Nadrieril:explain-unreachable, r=compiler-errors
exhaustiveness: Explain why a given pattern is considered unreachable This PR tells the user why a given pattern is considered unreachable. I reused the intersection information we were already computing; even though it's incomplete I convinced myself that it is sufficient to always get a set of patterns that cover the unreachable one. I'm not a fan of the diagnostic messages I came up with, I'm open to suggestions. Fixes https://github.com/rust-lang/rust/issues/127870. This is also the other one of the two diagnostic improvements I wanted to do before https://github.com/rust-lang/rust/pull/122792. Note: the first commit is an unrelated drive-by tweak. r? `@compiler-errors`
Diffstat (limited to 'compiler/rustc_pattern_analysis/tests/intersection.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/tests/intersection.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_pattern_analysis/tests/intersection.rs b/compiler/rustc_pattern_analysis/tests/intersection.rs index 4a96b7248da..8c8cb3c796d 100644 --- a/compiler/rustc_pattern_analysis/tests/intersection.rs +++ b/compiler/rustc_pattern_analysis/tests/intersection.rs @@ -67,4 +67,24 @@ fn test_nested() { ), &[&[], &[]], ); + let ty = Ty::Tuple(&[Ty::Bool; 3]); + assert_intersects( + pats!(ty; + (true, true, _), + (true, _, true), + (false, _, _), + ), + &[&[], &[], &[]], + ); + let ty = Ty::Tuple(&[Ty::Bool, Ty::Bool, Ty::U8]); + assert_intersects( + pats!(ty; + (true, _, _), + (_, true, 0..10), + (_, true, 10..), + (_, true, 3), + _, + ), + &[&[], &[], &[], &[1], &[0, 1, 2, 3]], + ); } |
