Skip to content

Commit c5f1cdb

Browse files
committed
Auto merge of #2125 - RalfJung:ref-validity, r=RalfJung
test for validity of references pointing to uninhabited types The new tests for rust-lang/rust#97116
2 parents a5cf247 + 439f861 commit c5f1cdb

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e1ec3260d79497080ca86540562d410ba67d2a95
1+
77972d2d0134fb597249b3b64dcf9510a790c34e
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(never_type)]
2+
use std::mem::{transmute, forget};
3+
4+
fn main() { unsafe {
5+
let x: Box<!> = transmute(&mut 42); //~ERROR encountered a box pointing to uninhabited type !
6+
forget(x);
7+
} }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::mem::transmute;
2+
3+
enum Void {}
4+
5+
fn main() { unsafe {
6+
let _x: &(i32, Void) = transmute(&42); //~ERROR encountered a reference pointing to uninhabited type (i32, Void)
7+
} }

0 commit comments

Comments
 (0)