Auto merge of #2125 - RalfJung:ref-validity, r=RalfJung
test for validity of references pointing to uninhabited types The new tests for https://github.com/rust-lang/rust/pull/97116
This commit is contained in:
commit
c5f1cdb323
3 changed files with 15 additions and 1 deletions
|
|
@ -1 +1 @@
|
|||
e1ec3260d79497080ca86540562d410ba67d2a95
|
||||
77972d2d0134fb597249b3b64dcf9510a790c34e
|
||||
|
|
|
|||
7
tests/compile-fail/validity/ref_to_uninhabited1.rs
Normal file
7
tests/compile-fail/validity/ref_to_uninhabited1.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(never_type)]
|
||||
use std::mem::{transmute, forget};
|
||||
|
||||
fn main() { unsafe {
|
||||
let x: Box<!> = transmute(&mut 42); //~ERROR encountered a box pointing to uninhabited type !
|
||||
forget(x);
|
||||
} }
|
||||
7
tests/compile-fail/validity/ref_to_uninhabited2.rs
Normal file
7
tests/compile-fail/validity/ref_to_uninhabited2.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use std::mem::transmute;
|
||||
|
||||
enum Void {}
|
||||
|
||||
fn main() { unsafe {
|
||||
let _x: &(i32, Void) = transmute(&42); //~ERROR encountered a reference pointing to uninhabited type (i32, Void)
|
||||
} }
|
||||
Loading…
Add table
Add a link
Reference in a new issue