-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(const_transmute, const_raw_ptr_deref)] | ||
|
||
use std::{mem, usize}; | ||
|
||
// Make sure we error with the right kind of error on a too large slice. | ||
const TEST: () = { unsafe { //~ NOTE | ||
let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); | ||
let _val = &*slice; //~ ERROR: any use of this value will cause an error | ||
//~^ NOTE: total size is bigger than largest supported object | ||
//~^^ on by default | ||
} }; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: any use of this value will cause an error | ||
--> $DIR/dangling.rs:8:16 | ||
| | ||
LL | / const TEST: () = { unsafe { | ||
LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); | ||
LL | | let _val = &*slice; | ||
| | ^^^^^^^ invalid slice: total size is bigger than largest supported object | ||
LL | | | ||
LL | | | ||
LL | | } }; | ||
| |____- | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
|
||
error: aborting due to previous error | ||
|