Skip to content

test for validity of references pointing to uninhabited types #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e1ec3260d79497080ca86540562d410ba67d2a95
77972d2d0134fb597249b3b64dcf9510a790c34e
7 changes: 7 additions & 0 deletions tests/compile-fail/validity/ref_to_uninhabited1.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions tests/compile-fail/validity/ref_to_uninhabited2.rs
Original file line number Diff line number Diff line change
@@ -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)
} }