Skip to content

Commit bd78f3b

Browse files
committed
Auto merge of rust-lang#102315 - RalfJung:assert_unsafe_precondition, r=thomcc
add a few more assert_unsafe_precondition Add debug-assertion checking for `ptr.read()`, `ptr.write(_)`, and `unreachable_unchecked.` This is quite useful for [cargo-careful](https://github.com/RalfJung/cargo-careful).
2 parents 4490fbc + 69c341e commit bd78f3b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tests/fail/unaligned_pointers/unaligned_ptr1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
fn main() {
55
// Try many times as this might work by chance.
6-
for _ in 0..10 {
6+
for _ in 0..20 {
77
let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
88
let x = &x[0] as *const _ as *const u32;
99
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.

tests/fail/unaligned_pointers/unaligned_ptr_addr_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ptr;
44

55
fn main() {
66
// Try many times as this might work by chance.
7-
for _ in 0..10 {
7+
for _ in 0..20 {
88
let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
99
let x = &x[0] as *const _ as *const u32;
1010
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.

0 commit comments

Comments
 (0)