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:
Eduard-Mihai Burtescu 2017-02-25 14:13:25 +02:00 committed by GitHub
commit 33c19129c3
5 changed files with 153 additions and 36 deletions

View 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,
..
}) => {}
}
}

View file

@ -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
}

View 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(_) => {}
}
}