diff options
| author | Albin Hedman <albin9604@gmail.com> | 2021-06-27 14:24:49 +0200 |
|---|---|---|
| committer | Albin Hedman <albin9604@gmail.com> | 2021-06-27 14:24:49 +0200 |
| commit | 4aa1267cbb9d2428e9da6fa05838206c965a96d4 (patch) | |
| tree | 9efc0b34c080247f2c656b7e4e4e04a0bc31befd /src/test | |
| parent | c0125532ead50d3ae4bc4846e7fbdb23da6d8531 (diff) | |
| download | rust-4aa1267cbb9d2428e9da6fa05838206c965a96d4.tar.gz rust-4aa1267cbb9d2428e9da6fa05838206c965a96d4.zip | |
Update and bless tests for const read out of bounds
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/const-ptr/out_of_bounds_read.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/const-ptr/out_of_bounds_read.stderr | 62 |
2 files changed, 36 insertions, 28 deletions
diff --git a/src/test/ui/const-ptr/out_of_bounds_read.rs b/src/test/ui/const-ptr/out_of_bounds_read.rs index 183aa9e5122..c45198cc39b 100644 --- a/src/test/ui/const-ptr/out_of_bounds_read.rs +++ b/src/test/ui/const-ptr/out_of_bounds_read.rs @@ -1,4 +1,4 @@ -// error-pattern: any use of this value will cause an error +// error-pattern: evaluation of constant value failed #![feature(const_ptr_read)] #![feature(const_ptr_offset)] diff --git a/src/test/ui/const-ptr/out_of_bounds_read.stderr b/src/test/ui/const-ptr/out_of_bounds_read.stderr index 87b7c377b00..67175d5d1f5 100644 --- a/src/test/ui/const-ptr/out_of_bounds_read.stderr +++ b/src/test/ui/const-ptr/out_of_bounds_read.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/intrinsics.rs:LL:COL | LL | unsafe { copy_nonoverlapping(src, dst, count) } @@ -6,19 +6,18 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | | | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `_READ` at $DIR/out_of_bounds_read.rs:13:33 | - ::: $DIR/out_of_bounds_read.rs:13:5 + ::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL | -LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ------------------------------------------------------ +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + ::: $DIR/out_of_bounds_read.rs:13:33 | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; + | ----------------------- inside `_READ` at $DIR/out_of_bounds_read.rs:13:33 -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/intrinsics.rs:LL:COL | LL | unsafe { copy_nonoverlapping(src, dst, count) } @@ -26,19 +25,23 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | | | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL - | inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39 | - ::: $DIR/out_of_bounds_read.rs:14:5 + ::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL | -LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | -------------------------------------------------------- +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + ::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | +LL | unsafe { read(self) } + | ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | + ::: $DIR/out_of_bounds_read.rs:14:39 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; + | ------------------- inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39 -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/intrinsics.rs:LL:COL | LL | unsafe { copy_nonoverlapping(src, dst, count) } @@ -46,17 +49,22 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | | | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL - | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - | inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37 | - ::: $DIR/out_of_bounds_read.rs:15:5 + ::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL | -LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | -------------------------------------------------------------------- +LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); + | --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + ::: $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +LL | unsafe { read(self) } + | ---------- inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + | + ::: $DIR/out_of_bounds_read.rs:15:37 + | +LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; + | --------------------------------- inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37 error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. |
