Skip to content

Commit 7df41a7

Browse files
committed
rustup
1 parent 4e1bc7e commit 7df41a7

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20ffea6938b5839c390252e07940b99e3b6a889a
1+
75b7e52e92c3b00fc891b47f5b2efdff0a2be55a

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,5 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
116116
"-Zmir-opt-level=0",
117117
"--cfg=miri",
118118
"-Cdebug-assertions=on",
119+
"-Zextra-const-ub-checks",
119120
];

tests/fail/const-ub-checks.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(const_ptr_read)]
2+
3+
const UNALIGNED_READ: () = unsafe {
4+
let x = &[0u8; 4];
5+
let ptr = x.as_ptr().cast::<u32>();
6+
ptr.read(); //~ERROR: evaluation of constant value failed
7+
};
8+
9+
fn main() {
10+
let _x = UNALIGNED_READ;
11+
}

tests/fail/const-ub-checks.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/const-ub-checks.rs:LL:CC
3+
|
4+
LL | ptr.read();
5+
| ^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)