Skip to content

Commit

Permalink
Rollup merge of rust-lang#62930 - iluuu1994:test-for-51559, r=oli-obk
Browse files Browse the repository at this point in the history
Add test for rust-lang#51559

Closes rust-lang#51559
  • Loading branch information
Centril authored Jul 25, 2019
2 parents fe07132 + f49a965 commit 6e8d7b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/ui/consts/issue-51559.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(const_raw_ptr_to_usize_cast)]

const BAR: *mut () = ((|| 3) as fn() -> i32) as *mut ();
pub const FOO: usize = unsafe { BAR as usize };
//~^ ERROR it is undefined behavior to use this value

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/consts/issue-51559.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/issue-51559.rs:4:1
|
LL | pub const FOO: usize = unsafe { BAR as usize };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain (non-pointer) bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.

0 comments on commit 6e8d7b6

Please sign in to comment.