Skip to content

Commit f1fdbe2

Browse files
committed
get rid of a bunch of unnecessary NOTE in const tests
1 parent a1507b8 commit f1fdbe2

9 files changed

+46
-81
lines changed

src/test/ui/consts/const-eval/dangling.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
use std::mem;
44

55
// Make sure we error with the right kind of error on a too large slice.
6-
const TEST: () = { unsafe { //~ NOTE
6+
const TEST: () = { unsafe {
77
let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
88
let _val = &*slice; //~ ERROR: any use of this value will cause an error
9-
//~| NOTE: slice is bigger than largest supported object
10-
//~| on by default
9+
//~| slice is bigger than largest supported object
1110
//~| WARN this was previously accepted by the compiler but is being phased out
12-
//~| NOTE
1311
} };
1412

1513
fn main() {}

src/test/ui/consts/const-eval/dangling.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
66
LL | | let _val = &*slice;
77
| | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object
88
LL | |
9-
... |
109
LL | |
1110
LL | | } };
1211
| |____-

src/test/ui/consts/const-points-to-static.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
const TEST: &u8 = &MY_STATIC;
77
//~^ ERROR it is undefined behavior to use this value
8-
//~| NOTE encountered a reference pointing to a static variable
9-
//~| NOTE undefined behavior
10-
//~| NOTE the raw bytes of the constant
8+
//~| encountered a reference pointing to a static variable
119

1210
static MY_STATIC: u8 = 4;
1311

src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error[E0080]: it is undefined behavior to use this value
33
|
44
LL | / const REF_INTERIOR_MUT: &usize = {
55
LL | |
6-
LL | |
7-
LL | |
86
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
97
LL | | unsafe { &*(&FOO as *const _ as *const usize) }
108
LL | | };
@@ -16,12 +14,10 @@ LL | | };
1614
}
1715

1816
error[E0080]: it is undefined behavior to use this value
19-
--> $DIR/const_refers_to_static2.rs:20:1
17+
--> $DIR/const_refers_to_static2.rs:18:1
2018
|
2119
LL | / const READ_IMMUT: &usize = {
2220
LL | |
23-
LL | |
24-
LL | |
2521
LL | | static FOO: usize = 0;
2622
LL | | &FOO
2723
LL | | };
@@ -35,17 +31,17 @@ LL | | };
3531
warning: skipping const checks
3632
|
3733
help: skipping check that does not even have a feature gate
38-
--> $DIR/const_refers_to_static2.rs:16:18
34+
--> $DIR/const_refers_to_static2.rs:14:18
3935
|
4036
LL | unsafe { &*(&FOO as *const _ as *const usize) }
4137
| ^^^
4238
help: skipping check for `const_raw_ptr_deref` feature
43-
--> $DIR/const_refers_to_static2.rs:16:14
39+
--> $DIR/const_refers_to_static2.rs:14:14
4440
|
4541
LL | unsafe { &*(&FOO as *const _ as *const usize) }
4642
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4743
help: skipping check that does not even have a feature gate
48-
--> $DIR/const_refers_to_static2.rs:25:6
44+
--> $DIR/const_refers_to_static2.rs:21:6
4945
|
5046
LL | &FOO
5147
| ^^^

src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ use std::sync::atomic::Ordering;
99
// so they cause an immediate error when *defining* the const.
1010

1111
const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
12-
//~| NOTE encountered a reference pointing to a static variable
13-
//~| NOTE undefined behavior
14-
//~| NOTE the raw bytes of the constant
12+
//~| encountered a reference pointing to a static variable
1513
static FOO: AtomicUsize = AtomicUsize::new(0);
1614
unsafe { &*(&FOO as *const _ as *const usize) }
1715
};
1816

1917
// ok some day perhaps
2018
const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
21-
//~| NOTE encountered a reference pointing to a static variable
22-
//~| NOTE undefined behavior
23-
//~| NOTE the raw bytes of the constant
19+
//~| encountered a reference pointing to a static variable
2420
static FOO: usize = 0;
2521
&FOO
2622
};

src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr

+24-30
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error[E0080]: it is undefined behavior to use this value
33
|
44
LL | / const SLICE_MUT: &[u8; 1] = {
55
LL | |
6-
LL | |
7-
LL | |
86
LL | | unsafe { &static_cross_crate::ZERO }
97
LL | | };
108
| |__^ type validation failed: encountered a reference pointing to a static variable
@@ -15,18 +13,16 @@ LL | | };
1513
}
1614

1715
error: could not evaluate constant pattern
18-
--> $DIR/const_refers_to_static_cross_crate.rs:47:9
16+
--> $DIR/const_refers_to_static_cross_crate.rs:40:9
1917
|
2018
LL | SLICE_MUT => true,
2119
| ^^^^^^^^^
2220

2321
error[E0080]: it is undefined behavior to use this value
24-
--> $DIR/const_refers_to_static_cross_crate.rs:19:1
22+
--> $DIR/const_refers_to_static_cross_crate.rs:17:1
2523
|
2624
LL | / const U8_MUT: &u8 = {
2725
LL | |
28-
LL | |
29-
LL | |
3026
LL | | unsafe { &static_cross_crate::ZERO[0] }
3127
LL | | };
3228
| |__^ type validation failed: encountered a reference pointing to a static variable
@@ -37,143 +33,141 @@ LL | | };
3733
}
3834

3935
error: could not evaluate constant pattern
40-
--> $DIR/const_refers_to_static_cross_crate.rs:56:9
36+
--> $DIR/const_refers_to_static_cross_crate.rs:49:9
4137
|
4238
LL | U8_MUT => true,
4339
| ^^^^^^
4440

4541
warning: any use of this value will cause an error
46-
--> $DIR/const_refers_to_static_cross_crate.rs:29:15
42+
--> $DIR/const_refers_to_static_cross_crate.rs:25:15
4743
|
4844
LL | / const U8_MUT2: &u8 = {
4945
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
5046
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
5147
LL | |
5248
LL | |
5349
LL | |
54-
LL | |
5550
LL | | };
5651
| |__-
5752
|
5853
note: the lint level is defined here
59-
--> $DIR/const_refers_to_static_cross_crate.rs:27:8
54+
--> $DIR/const_refers_to_static_cross_crate.rs:23:8
6055
|
6156
LL | #[warn(const_err)]
6257
| ^^^^^^^^^
6358
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6459
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
6560

6661
error: could not evaluate constant pattern
67-
--> $DIR/const_refers_to_static_cross_crate.rs:67:9
62+
--> $DIR/const_refers_to_static_cross_crate.rs:60:9
6863
|
6964
LL | U8_MUT2 => true,
7065
| ^^^^^^^
7166

7267
warning: any use of this value will cause an error
73-
--> $DIR/const_refers_to_static_cross_crate.rs:37:51
68+
--> $DIR/const_refers_to_static_cross_crate.rs:32:51
7469
|
7570
LL | / const U8_MUT3: &u8 = {
7671
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
7772
| | ^^^^^^^^^^^ constant accesses static
7873
LL | |
7974
LL | |
80-
... |
8175
LL | |
8276
LL | | };
8377
| |__-
8478
|
8579
note: the lint level is defined here
86-
--> $DIR/const_refers_to_static_cross_crate.rs:35:8
80+
--> $DIR/const_refers_to_static_cross_crate.rs:30:8
8781
|
8882
LL | #[warn(const_err)]
8983
| ^^^^^^^^^
9084
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9185
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
9286

9387
error: could not evaluate constant pattern
94-
--> $DIR/const_refers_to_static_cross_crate.rs:75:9
88+
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
9589
|
9690
LL | U8_MUT3 => true,
9791
| ^^^^^^^
9892

9993
error: could not evaluate constant pattern
100-
--> $DIR/const_refers_to_static_cross_crate.rs:47:9
94+
--> $DIR/const_refers_to_static_cross_crate.rs:40:9
10195
|
10296
LL | SLICE_MUT => true,
10397
| ^^^^^^^^^
10498

10599
error: could not evaluate constant pattern
106-
--> $DIR/const_refers_to_static_cross_crate.rs:56:9
100+
--> $DIR/const_refers_to_static_cross_crate.rs:49:9
107101
|
108102
LL | U8_MUT => true,
109103
| ^^^^^^
110104

111105
error: could not evaluate constant pattern
112-
--> $DIR/const_refers_to_static_cross_crate.rs:67:9
106+
--> $DIR/const_refers_to_static_cross_crate.rs:60:9
113107
|
114108
LL | U8_MUT2 => true,
115109
| ^^^^^^^
116110

117111
error: could not evaluate constant pattern
118-
--> $DIR/const_refers_to_static_cross_crate.rs:75:9
112+
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
119113
|
120114
LL | U8_MUT3 => true,
121115
| ^^^^^^^
122116

123117
warning: skipping const checks
124118
|
125119
help: skipping check that does not even have a feature gate
126-
--> $DIR/const_refers_to_static_cross_crate.rs:16:15
120+
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
127121
|
128122
LL | unsafe { &static_cross_crate::ZERO }
129123
| ^^^^^^^^^^^^^^^^^^^^^^^^
130124
help: skipping check that does not even have a feature gate
131-
--> $DIR/const_refers_to_static_cross_crate.rs:16:15
125+
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
132126
|
133127
LL | unsafe { &static_cross_crate::ZERO }
134128
| ^^^^^^^^^^^^^^^^^^^^^^^^
135129
help: skipping check that does not even have a feature gate
136-
--> $DIR/const_refers_to_static_cross_crate.rs:23:15
130+
--> $DIR/const_refers_to_static_cross_crate.rs:19:15
137131
|
138132
LL | unsafe { &static_cross_crate::ZERO[0] }
139133
| ^^^^^^^^^^^^^^^^^^^^^^^^
140134
help: skipping check that does not even have a feature gate
141-
--> $DIR/const_refers_to_static_cross_crate.rs:23:15
135+
--> $DIR/const_refers_to_static_cross_crate.rs:19:15
142136
|
143137
LL | unsafe { &static_cross_crate::ZERO[0] }
144138
| ^^^^^^^^^^^^^^^^^^^^^^^^
145139
help: skipping check that does not even have a feature gate
146-
--> $DIR/const_refers_to_static_cross_crate.rs:23:15
140+
--> $DIR/const_refers_to_static_cross_crate.rs:19:15
147141
|
148142
LL | unsafe { &static_cross_crate::ZERO[0] }
149143
| ^^^^^^^^^^^^^^^^^^^^^^^^
150144
help: skipping check that does not even have a feature gate
151-
--> $DIR/const_refers_to_static_cross_crate.rs:29:17
145+
--> $DIR/const_refers_to_static_cross_crate.rs:25:17
152146
|
153147
LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
154148
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
155149
help: skipping check that does not even have a feature gate
156-
--> $DIR/const_refers_to_static_cross_crate.rs:37:20
150+
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
157151
|
158152
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
159153
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160154
help: skipping check that does not even have a feature gate
161-
--> $DIR/const_refers_to_static_cross_crate.rs:37:20
155+
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
162156
|
163157
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
164158
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165159
help: skipping check that does not even have a feature gate
166-
--> $DIR/const_refers_to_static_cross_crate.rs:37:20
160+
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
167161
|
168162
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
169163
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170164
help: skipping check for `const_panic` feature
171-
--> $DIR/const_refers_to_static_cross_crate.rs:37:77
165+
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
172166
|
173167
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
174168
| ^^^^^^^^
175169
help: skipping check that does not even have a feature gate
176-
--> $DIR/const_refers_to_static_cross_crate.rs:37:20
170+
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
177171
|
178172
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
179173
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,29 @@ extern crate static_cross_crate;
1010
// Sneaky: reference to a mutable static.
1111
// Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking!
1212
const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior to use this value
13-
//~| NOTE encountered a reference pointing to a static variable
14-
//~| NOTE undefined behavior
15-
//~| NOTE the raw bytes of the constant
13+
//~| encountered a reference pointing to a static variable
1614
unsafe { &static_cross_crate::ZERO }
1715
};
1816

1917
const U8_MUT: &u8 = { //~ ERROR undefined behavior to use this value
20-
//~| NOTE encountered a reference pointing to a static variable
21-
//~| NOTE undefined behavior
22-
//~| NOTE the raw bytes of the constant
18+
//~| encountered a reference pointing to a static variable
2319
unsafe { &static_cross_crate::ZERO[0] }
2420
};
2521

2622
// Also test indirection that reads from other static. This causes a const_err.
27-
#[warn(const_err)] //~ NOTE
28-
const U8_MUT2: &u8 = { //~ NOTE
23+
#[warn(const_err)]
24+
const U8_MUT2: &u8 = {
2925
unsafe { &(*static_cross_crate::ZERO_REF)[0] }
3026
//~^ WARN [const_err]
31-
//~| NOTE constant accesses static
27+
//~| constant accesses static
3228
//~| WARN this was previously accepted by the compiler but is being phased out
33-
//~| NOTE
3429
};
35-
#[warn(const_err)] //~ NOTE
36-
const U8_MUT3: &u8 = { //~ NOTE
30+
#[warn(const_err)]
31+
const U8_MUT3: &u8 = {
3732
unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
3833
//~^ WARN [const_err]
39-
//~| NOTE constant accesses static
40-
//~| NOTE in this expansion of panic!
34+
//~| constant accesses static
4135
//~| WARN this was previously accepted by the compiler but is being phased out
42-
//~| NOTE
4336
};
4437

4538
pub fn test(x: &[u8; 1]) -> bool {

src/test/ui/consts/ptr_comparisons.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,18 @@ check!(!eq, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0);
5959
// at runtime it would be zero and at compile-time it would not be zero.
6060

6161
const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
62-
//~^ NOTE
6362

6463
const _: *const u8 =
65-
//~^ NOTE
6664
unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
6765
//~^ ERROR any use of this value will cause an error
68-
//~| NOTE
6966
//~| WARN this was previously accepted by the compiler but is being phased out
70-
//~| NOTE
7167

7268
const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
7369
//~^ ERROR any use of this value will cause an error
74-
//~| NOTE cannot cast pointer to integer
75-
//~| NOTE
70+
//~| cannot cast pointer to integer
7671
//~| WARN this was previously accepted by the compiler but is being phased out
77-
//~| NOTE
7872

7973
const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
8074
//~^ ERROR any use of this value will cause an error
81-
//~| NOTE cannot cast pointer to integer
82-
//~| NOTE
75+
//~| cannot cast pointer to integer
8376
//~| WARN this was previously accepted by the compiler but is being phased out
84-
//~| NOTE

src/test/ui/consts/ptr_comparisons.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
1818
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1919

2020
error: any use of this value will cause an error
21-
--> $DIR/ptr_comparisons.rs:66:33
21+
--> $DIR/ptr_comparisons.rs:64:33
2222
|
2323
LL | / const _: *const u8 =
24-
LL | |
2524
LL | | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
2625
| |_________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___-
2726
| |
@@ -31,7 +30,7 @@ LL | | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 100
3130
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
3231

3332
error: any use of this value will cause an error
34-
--> $DIR/ptr_comparisons.rs:72:27
33+
--> $DIR/ptr_comparisons.rs:68:27
3534
|
3635
LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
3736
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
@@ -42,7 +41,7 @@ LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) +
4241
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
4342

4443
error: any use of this value will cause an error
45-
--> $DIR/ptr_comparisons.rs:79:27
44+
--> $DIR/ptr_comparisons.rs:73:27
4645
|
4746
LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
4847
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---

0 commit comments

Comments
 (0)