forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#54125 - varkor:less-conservative-uninhabite…
…dness-check, r=nikomatsakis Less conservative uninhabitedness check Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays. Pulled out of rust-lang#47291 and rust-lang#50262. Fixes rust-lang#54586. r? @nikomatsakis
- Loading branch information
Showing
12 changed files
with
92 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,24 @@ | ||
// Copyright 2013-2014 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. | ||
|
||
// NOTE Instantiating an empty enum is UB. This test may break in the future. | ||
|
||
// LLDB can't handle zero-sized values | ||
// LLDB can't handle zero-sized values. | ||
// ignore-lldb | ||
|
||
|
||
// compile-flags:-g | ||
// gdb-command:run | ||
|
||
// gdb-command:print first | ||
// gdb-command:print *first | ||
// gdbg-check:$1 = {<No data fields>} | ||
// gdbr-check:$1 = <error reading variable> | ||
|
||
// gdb-command:print second | ||
// gdbg-check:$2 = {<No data fields>} | ||
// gdbr-check:$2 = <error reading variable> | ||
|
||
#![allow(unused_variables)] | ||
#![feature(omit_gdb_pretty_printer_section)] | ||
#![feature(maybe_uninit)] | ||
#![omit_gdb_pretty_printer_section] | ||
|
||
use std::mem::MaybeUninit; | ||
|
||
enum ANilEnum {} | ||
enum AnotherNilEnum {} | ||
enum Void {} | ||
|
||
// This test relies on gdbg printing the string "{<No data fields>}" for empty | ||
// structs (which may change some time) | ||
// The error from gdbr is expected since nil enums are not supposed to exist. | ||
fn main() { | ||
unsafe { | ||
let first: ANilEnum = MaybeUninit::uninitialized().into_inner(); | ||
let second: AnotherNilEnum = MaybeUninit::uninitialized().into_inner(); | ||
let first: *const Void = 1 as *const _; | ||
|
||
zzz(); // #break | ||
} | ||
zzz(); // #break | ||
} | ||
|
||
fn zzz() {()} | ||
fn zzz() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
// Copyright 2018 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(const_transmute)] | ||
|
||
use std::mem; | ||
|
||
#[derive(Copy, Clone)] | ||
enum Bar {} | ||
|
||
const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) }; | ||
union TransmuteUnion<A: Clone + Copy, B: Clone + Copy> { | ||
a: A, | ||
b: B, | ||
} | ||
|
||
const BAD_BAD_BAD: Bar = unsafe { (TransmuteUnion::<(), Bar> { a: () }).b }; | ||
//~^ ERROR this constant likely exhibits undefined behavior | ||
|
||
const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ||
//~^ ERROR this constant likely exhibits undefined behavior | ||
|
||
const BAD_BAD_ARRAY: [Bar; 1] = unsafe { mem::transmute(()) }; | ||
const BAD_BAD_ARRAY: [Bar; 1] = unsafe { (TransmuteUnion::<(), [Bar; 1]> { a: () }).b }; | ||
//~^ ERROR this constant likely exhibits undefined behavior | ||
|
||
fn main() { | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters