diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-02-25 14:13:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-25 14:13:25 +0200 |
| commit | 33c19129c363eae3b84bdcc0fdf632f211dbd26a (patch) | |
| tree | 194265bf8f890eabd02a94afcac327e70a3d552b /src/test | |
| parent | ef043a7c43070e125361e6609c85ea8a67631e0d (diff) | |
| parent | 87e544bca5ae1bd187f11239abcab1f73c836049 (diff) | |
| download | rust-33c19129c363eae3b84bdcc0fdf632f211dbd26a.tar.gz rust-33c19129c363eae3b84bdcc0fdf632f211dbd26a.zip | |
Rollup merge of #39980 - arielb1:privately-uninhabited, r=nikomatsakis
check_match: don't treat privately uninhabited types as uninhabited Fixes #38972, which is a regression in 1.16 from @canndrew's patchset. r? @nikomatsakis beta-nominating because regression.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/match-privately-empty.rs | 30 | ||||
| -rw-r--r-- | src/test/compile-fail/uninhabited-matches-feature-gated.rs | 10 | ||||
| -rw-r--r-- | src/test/run-pass/issue-38972.rs | 25 |
3 files changed, 58 insertions, 7 deletions
diff --git a/src/test/compile-fail/match-privately-empty.rs b/src/test/compile-fail/match-privately-empty.rs new file mode 100644 index 00000000000..3affb1c03e9 --- /dev/null +++ b/src/test/compile-fail/match-privately-empty.rs @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +mod private { + pub struct Private { + _bot: !, + pub misc: bool, + } + pub const DATA: Option<Private> = None; +} + +fn main() { + match private::DATA { + //~^ ERROR non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered + None => {} + Some(private::Private { + misc: false, + .. + }) => {} + } +} diff --git a/src/test/compile-fail/uninhabited-matches-feature-gated.rs b/src/test/compile-fail/uninhabited-matches-feature-gated.rs index 0f8b0a6c238..0c3ea53a903 100644 --- a/src/test/compile-fail/uninhabited-matches-feature-gated.rs +++ b/src/test/compile-fail/uninhabited-matches-feature-gated.rs @@ -19,16 +19,13 @@ fn main() { }; let x: &Void = unsafe { std::mem::uninitialized() }; - let _ = match x {}; - //~^ ERROR non-exhaustive + let _ = match x {}; //~ ERROR non-exhaustive let x: (Void,) = unsafe { std::mem::uninitialized() }; - let _ = match x {}; - //~^ ERROR non-exhaustive + let _ = match x {}; //~ ERROR non-exhaustive let x: [Void; 1] = unsafe { std::mem::uninitialized() }; - let _ = match x {}; - //~^ ERROR non-exhaustive + let _ = match x {}; //~ ERROR non-exhaustive let x: &[Void] = unsafe { std::mem::uninitialized() }; let _ = match x { //~ ERROR non-exhaustive @@ -47,4 +44,3 @@ fn main() { let Ok(x) = x; //~^ ERROR refutable } - diff --git a/src/test/run-pass/issue-38972.rs b/src/test/run-pass/issue-38972.rs new file mode 100644 index 00000000000..d5df84e0fb0 --- /dev/null +++ b/src/test/run-pass/issue-38972.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This issue tracks a regression (a new warning) without +// feature(never_type). When we make that the default, please +// remove this test. + +enum Foo { } + +fn make_foo() -> Option<Foo> { None } + +#[deny(warnings)] +fn main() { + match make_foo() { + None => {}, + Some(_) => {} + } +} |
