Skip to content

Commit bb34749

Browse files
committed
add test
1 parent 38f6b96 commit bb34749

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(const_transmute, const_raw_ptr_deref)]
2+
3+
use std::{mem, usize};
4+
5+
// Make sure we error with the right kind of error on a too large slice.
6+
const TEST: () = { unsafe { //~ NOTE
7+
let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
8+
let _val = &*slice; //~ ERROR: any use of this value will cause an error
9+
//~^ NOTE: total size is bigger than largest supported object
10+
//~^^ on by default
11+
} };
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: any use of this value will cause an error
2+
--> $DIR/dangling.rs:8:16
3+
|
4+
LL | / const TEST: () = { unsafe {
5+
LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
6+
LL | | let _val = &*slice;
7+
| | ^^^^^^^ invalid slice: total size is bigger than largest supported object
8+
LL | |
9+
LL | |
10+
LL | | } };
11+
| |____-
12+
|
13+
= note: `#[deny(const_err)]` on by default
14+
15+
error: aborting due to previous error
16+

0 commit comments

Comments
 (0)