Skip to content

Commit c012553

Browse files
committed
Update and bless tests for copy intrinsic
1 parent 56c78b2 commit c012553

File tree

2 files changed

+20
-67
lines changed

2 files changed

+20
-67
lines changed

src/test/ui/consts/copy-intrinsic.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,27 @@ const COPY_OOB_1: () = unsafe {
2424
let mut x = 0i32;
2525
let dangle = (&mut x as *mut i32).wrapping_add(10);
2626
// Even if the first ptr is an int ptr and this is a ZST copy, we should detect dangling 2nd ptrs.
27-
copy_nonoverlapping(0x100 as *const i32, dangle, 0); //~ ERROR any use of this value will cause an error
28-
//~| memory access failed: pointer must be in-bounds
29-
//~| previously accepted
27+
copy_nonoverlapping(0x100 as *const i32, dangle, 0); //~ evaluation of constant value failed [E0080]
3028
};
3129
const COPY_OOB_2: () = unsafe {
3230
let x = 0i32;
3331
let dangle = (&x as *const i32).wrapping_add(10);
3432
// Even if the second ptr is an int ptr and this is a ZST copy, we should detect dangling 1st ptrs.
35-
copy_nonoverlapping(dangle, 0x100 as *mut i32, 0); //~ ERROR any use of this value will cause an error
33+
copy_nonoverlapping(dangle, 0x100 as *mut i32, 0); //~ evaluation of constant value failed [E0080]
3634
//~| memory access failed: pointer must be in-bounds
37-
//~| previously accepted
3835
};
3936

4037
const COPY_SIZE_OVERFLOW: () = unsafe {
4138
let x = 0;
4239
let mut y = 0;
43-
copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR any use of this value will cause an error
40+
copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ evaluation of constant value failed [E0080]
4441
//~| overflow computing total size of `copy`
45-
//~| previously accepted
4642
};
4743
const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe {
4844
let x = 0;
4945
let mut y = 0;
50-
copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR any use of this value will cause an error
46+
copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ evaluation of constant value failed [E0080]
5147
//~| overflow computing total size of `copy_nonoverlapping`
52-
//~| previously accepted
5348
};
5449

5550
fn main() {
+16-58
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,27 @@
1-
error: any use of this value will cause an error
1+
error[E0080]: evaluation of constant value failed
22
--> $DIR/copy-intrinsic.rs:27:5
33
|
4-
LL | / const COPY_OOB_1: () = unsafe {
5-
LL | | let mut x = 0i32;
6-
LL | | let dangle = (&mut x as *mut i32).wrapping_add(10);
7-
LL | | // Even if the first ptr is an int ptr and this is a ZST copy, we should detect dangling 2nd ptrs.
8-
LL | | copy_nonoverlapping(0x100 as *const i32, dangle, 0);
9-
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset 40, but is outside bounds of alloc4 which has size 4
10-
LL | |
11-
LL | |
12-
LL | | };
13-
| |__-
14-
|
15-
= note: `#[deny(const_err)]` on by default
16-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
17-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
4+
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset 40, but is outside bounds of alloc4 which has size 4
186

19-
error: any use of this value will cause an error
20-
--> $DIR/copy-intrinsic.rs:35:5
21-
|
22-
LL | / const COPY_OOB_2: () = unsafe {
23-
LL | | let x = 0i32;
24-
LL | | let dangle = (&x as *const i32).wrapping_add(10);
25-
LL | | // Even if the second ptr is an int ptr and this is a ZST copy, we should detect dangling 1st ptrs.
26-
LL | | copy_nonoverlapping(dangle, 0x100 as *mut i32, 0);
27-
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset 40, but is outside bounds of alloc6 which has size 4
28-
LL | |
29-
LL | |
30-
LL | | };
31-
| |__-
7+
error[E0080]: evaluation of constant value failed
8+
--> $DIR/copy-intrinsic.rs:33:5
329
|
33-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
34-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
10+
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 0);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset 40, but is outside bounds of alloc6 which has size 4
3512

36-
error: any use of this value will cause an error
37-
--> $DIR/copy-intrinsic.rs:43:5
13+
error[E0080]: evaluation of constant value failed
14+
--> $DIR/copy-intrinsic.rs:40:5
3815
|
39-
LL | / const COPY_SIZE_OVERFLOW: () = unsafe {
40-
LL | | let x = 0;
41-
LL | | let mut y = 0;
42-
LL | | copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
43-
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
44-
LL | |
45-
LL | |
46-
LL | | };
47-
| |__-
48-
|
49-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
50-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
16+
LL | copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
5118

52-
error: any use of this value will cause an error
53-
--> $DIR/copy-intrinsic.rs:50:5
54-
|
55-
LL | / const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe {
56-
LL | | let x = 0;
57-
LL | | let mut y = 0;
58-
LL | | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
59-
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping`
60-
LL | |
61-
LL | |
62-
LL | | };
63-
| |__-
19+
error[E0080]: evaluation of constant value failed
20+
--> $DIR/copy-intrinsic.rs:46:5
6421
|
65-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
22+
LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping`
6724

6825
error: aborting due to 4 previous errors
6926

27+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)