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.
This commit is contained in:
commit
33c19129c3
5 changed files with 153 additions and 36 deletions
30
src/test/compile-fail/match-privately-empty.rs
Normal file
30
src/test/compile-fail/match-privately-empty.rs
Normal file
|
|
@ -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,
|
||||
..
|
||||
}) => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/test/run-pass/issue-38972.rs
Normal file
25
src/test/run-pass/issue-38972.rs
Normal file
|
|
@ -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(_) => {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue