test for validity of references pointing to uninhabited types

This commit is contained in:
Ralf Jung 2022-05-17 17:36:34 +02:00
parent a5cf247469
commit 30548bb57e
2 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,6 @@
#![feature(never_type)]
use std::mem::transmute;
fn main() { unsafe {
let _x: &! = transmute(&42); //~ERROR encountered a reference pointing to uninhabited type !
} }

View 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)
} }