Skip to content

Commit 38e9538

Browse files
committed
Revert "Remove tests that were also added in PR 79684."
This reverts commit e118a2c.
1 parent 6c890bb commit 38e9538

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// error-pattern: any use of this value will cause an error
2+
3+
#![feature(const_ptr_read)]
4+
#![feature(const_ptr_offset)]
5+
6+
fn main() {
7+
use std::ptr;
8+
9+
const DATA: [u32; 1] = [42];
10+
11+
const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) };
12+
13+
const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
14+
const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
15+
const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
error: any use of this value will cause an error
2+
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
3+
|
4+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
8+
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
9+
| inside `_READ` at $DIR/out_of_bounds_read.rs:13:33
10+
|
11+
::: $DIR/out_of_bounds_read.rs:13:5
12+
|
13+
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
14+
| ------------------------------------------------------
15+
|
16+
= note: `#[deny(const_err)]` on by default
17+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
19+
20+
error: any use of this value will cause an error
21+
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
22+
|
23+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25+
| |
26+
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
27+
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
28+
| inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
29+
| inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39
30+
|
31+
::: $DIR/out_of_bounds_read.rs:14:5
32+
|
33+
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
34+
| --------------------------------------------------------
35+
|
36+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
37+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
38+
39+
error: any use of this value will cause an error
40+
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
41+
|
42+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
43+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+
| |
45+
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
46+
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
47+
| inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
48+
| inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37
49+
|
50+
::: $DIR/out_of_bounds_read.rs:15:5
51+
|
52+
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
53+
| --------------------------------------------------------------------
54+
|
55+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
56+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
57+
58+
error: aborting due to 3 previous errors
59+

0 commit comments

Comments
 (0)