From 03f0ca0cf4bf427516f9d87a959b7c97c9ff9447 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Oct 2020 19:32:59 +0100 Subject: [PATCH] Add test --- .../or-patterns/exhaustiveness-unreachable-pattern.rs | 11 +++++++++-- .../exhaustiveness-unreachable-pattern.stderr | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs index a1147cb5cfc..97a8f526176 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs @@ -77,10 +77,17 @@ fn main() { (false | true, false | true) => {} } match (true, true) { - (true, false) => {} - (false, true) => {} + (true, true) => {} + (false, false) => {} (false | true, false | true) => {} } + // https://github.com/rust-lang/rust/issues/76836 + match None { + Some(false) => {} + None | Some(true + | false) => {} // expected unreachable warning here + } + // A subpattern that is unreachable in all branches is overall unreachable. match (true, true) { (false, true) => {} diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr index d92b545a869..e83cd247a57 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr @@ -101,13 +101,13 @@ LL | Some(0 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:89:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:96:15 | LL | | true) => {} | ^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:95:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:102:15 | LL | | true, | ^^^^