Skip to content

Commit 1ea091a

Browse files
committed
Rebase. Update expected output to match current output.
1 parent ae374cf commit 1ea091a

6 files changed

+57
-89
lines changed

tests/ui/consts/miri_unleashed/mutable_references.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::cell::UnsafeCell;
1010
static FOO: &&mut u32 = &&mut 42;
1111
//~^ ERROR encountered mutable pointer in final value of static
1212
//~| WARNING this was previously accepted by the compiler
13-
//~| ERROR it is undefined behavior to use this value
1413

1514
static BAR: &mut () = &mut ();
1615
//~^ ERROR encountered mutable pointer in final value of static
@@ -29,7 +28,6 @@ unsafe impl Sync for Meh {}
2928
static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
3029
//~^ ERROR encountered mutable pointer in final value of static
3130
//~| WARNING this was previously accepted by the compiler
32-
//~| ERROR it is undefined behavior to use this value
3331

3432
static OH_YES: &mut i32 = &mut 42;
3533
//~^ ERROR encountered mutable pointer in final value of static

tests/ui/consts/miri_unleashed/mutable_references.stderr

+15-37
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,8 @@ note: the lint level is defined here
1212
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15-
error[E0080]: it is undefined behavior to use this value
16-
--> $DIR/mutable_references.rs:10:1
17-
|
18-
LL | static FOO: &&mut u32 = &&mut 42;
19-
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered mutable reference or box pointing to read-only memory
20-
|
21-
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
22-
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
23-
HEX_DUMP
24-
}
25-
2615
error: encountered mutable pointer in final value of static
27-
--> $DIR/mutable_references.rs:15:1
16+
--> $DIR/mutable_references.rs:14:1
2817
|
2918
LL | static BAR: &mut () = &mut ();
3019
| ^^^^^^^^^^^^^^^^^^^
@@ -33,7 +22,7 @@ LL | static BAR: &mut () = &mut ();
3322
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
3423

3524
error: encountered mutable pointer in final value of static
36-
--> $DIR/mutable_references.rs:21:1
25+
--> $DIR/mutable_references.rs:20:1
3726
|
3827
LL | static BOO: &mut Foo<()> = &mut Foo(());
3928
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -42,27 +31,16 @@ LL | static BOO: &mut Foo<()> = &mut Foo(());
4231
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
4332

4433
error: encountered mutable pointer in final value of static
45-
--> $DIR/mutable_references.rs:29:1
34+
--> $DIR/mutable_references.rs:28:1
4635
|
4736
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
4837
| ^^^^^^^^^^^^^^^
4938
|
5039
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5140
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
5241

53-
error[E0080]: it is undefined behavior to use this value
54-
--> $DIR/mutable_references.rs:29:1
55-
|
56-
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
57-
| ^^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory
58-
|
59-
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
60-
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
61-
HEX_DUMP
62-
}
63-
6442
error: encountered mutable pointer in final value of static
65-
--> $DIR/mutable_references.rs:34:1
43+
--> $DIR/mutable_references.rs:32:1
6644
|
6745
LL | static OH_YES: &mut i32 = &mut 42;
6846
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -71,7 +49,7 @@ LL | static OH_YES: &mut i32 = &mut 42;
7149
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
7250

7351
error[E0080]: it is undefined behavior to use this value
74-
--> $DIR/mutable_references.rs:34:1
52+
--> $DIR/mutable_references.rs:32:1
7553
|
7654
LL | static OH_YES: &mut i32 = &mut 42;
7755
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
@@ -82,7 +60,7 @@ LL | static OH_YES: &mut i32 = &mut 42;
8260
}
8361

8462
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
85-
--> $DIR/mutable_references.rs:43:5
63+
--> $DIR/mutable_references.rs:41:5
8664
|
8765
LL | *OH_YES = 99;
8866
| ^^^^^^^^^^^^ cannot assign
@@ -95,27 +73,27 @@ help: skipping check that does not even have a feature gate
9573
LL | static FOO: &&mut u32 = &&mut 42;
9674
| ^^^^^^^
9775
help: skipping check that does not even have a feature gate
98-
--> $DIR/mutable_references.rs:15:23
76+
--> $DIR/mutable_references.rs:14:23
9977
|
10078
LL | static BAR: &mut () = &mut ();
10179
| ^^^^^^^
10280
help: skipping check that does not even have a feature gate
103-
--> $DIR/mutable_references.rs:21:28
81+
--> $DIR/mutable_references.rs:20:28
10482
|
10583
LL | static BOO: &mut Foo<()> = &mut Foo(());
10684
| ^^^^^^^^^^^^
10785
help: skipping check that does not even have a feature gate
108-
--> $DIR/mutable_references.rs:29:28
86+
--> $DIR/mutable_references.rs:28:28
10987
|
11088
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
11189
| ^^^^^^^^^^^^^^^^^^^^
11290
help: skipping check that does not even have a feature gate
113-
--> $DIR/mutable_references.rs:34:27
91+
--> $DIR/mutable_references.rs:32:27
11492
|
11593
LL | static OH_YES: &mut i32 = &mut 42;
11694
| ^^^^^^^
11795

118-
error: aborting due to 9 previous errors; 1 warning emitted
96+
error: aborting due to 7 previous errors; 1 warning emitted
11997

12098
Some errors have detailed explanations: E0080, E0594.
12199
For more information about an error, try `rustc --explain E0080`.
@@ -136,7 +114,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
136114

137115
Future breakage diagnostic:
138116
error: encountered mutable pointer in final value of static
139-
--> $DIR/mutable_references.rs:15:1
117+
--> $DIR/mutable_references.rs:14:1
140118
|
141119
LL | static BAR: &mut () = &mut ();
142120
| ^^^^^^^^^^^^^^^^^^^
@@ -151,7 +129,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
151129

152130
Future breakage diagnostic:
153131
error: encountered mutable pointer in final value of static
154-
--> $DIR/mutable_references.rs:21:1
132+
--> $DIR/mutable_references.rs:20:1
155133
|
156134
LL | static BOO: &mut Foo<()> = &mut Foo(());
157135
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -166,7 +144,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
166144

167145
Future breakage diagnostic:
168146
error: encountered mutable pointer in final value of static
169-
--> $DIR/mutable_references.rs:29:1
147+
--> $DIR/mutable_references.rs:28:1
170148
|
171149
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
172150
| ^^^^^^^^^^^^^^^
@@ -181,7 +159,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
181159

182160
Future breakage diagnostic:
183161
error: encountered mutable pointer in final value of static
184-
--> $DIR/mutable_references.rs:34:1
162+
--> $DIR/mutable_references.rs:32:1
185163
|
186164
LL | static OH_YES: &mut i32 = &mut 42;
187165
| ^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr

+23-45
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,8 @@ note: the lint level is defined here
1212
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15-
error[E0080]: it is undefined behavior to use this value
16-
--> $DIR/static-no-inner-mut.rs:9:1
17-
|
18-
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
19-
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
20-
|
21-
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
22-
= note: the raw bytes of the constant (size: 8, align: 8) {
23-
╾ALLOC0╼ │ ╾──────╼
24-
}
25-
2615
error: encountered mutable pointer in final value of static
27-
--> $DIR/static-no-inner-mut.rs:14:1
16+
--> $DIR/static-no-inner-mut.rs:13:1
2817
|
2918
LL | static REFMUT: &mut i32 = &mut 0;
3019
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,38 +22,27 @@ LL | static REFMUT: &mut i32 = &mut 0;
3322
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
3423

3524
error[E0080]: it is undefined behavior to use this value
36-
--> $DIR/static-no-inner-mut.rs:14:1
25+
--> $DIR/static-no-inner-mut.rs:13:1
3726
|
3827
LL | static REFMUT: &mut i32 = &mut 0;
3928
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
4029
|
4130
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4231
= note: the raw bytes of the constant (size: 8, align: 8) {
43-
ALLOC1╼ │ ╾──────╼
32+
ALLOC0╼ │ ╾──────╼
4433
}
4534

4635
error: encountered mutable pointer in final value of static
47-
--> $DIR/static-no-inner-mut.rs:20:1
36+
--> $DIR/static-no-inner-mut.rs:19:1
4837
|
4938
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
5039
| ^^^^^^^^^^^^^^^^^^^^^^^
5140
|
5241
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5342
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
5443

55-
error[E0080]: it is undefined behavior to use this value
56-
--> $DIR/static-no-inner-mut.rs:20:1
57-
|
58-
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
59-
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
60-
|
61-
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
62-
= note: the raw bytes of the constant (size: 8, align: 8) {
63-
╾ALLOC2╼ │ ╾──────╼
64-
}
65-
6644
error: encountered mutable pointer in final value of static
67-
--> $DIR/static-no-inner-mut.rs:25:1
45+
--> $DIR/static-no-inner-mut.rs:23:1
6846
|
6947
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
7048
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -73,18 +51,18 @@ LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
7351
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
7452

7553
error[E0080]: it is undefined behavior to use this value
76-
--> $DIR/static-no-inner-mut.rs:25:1
54+
--> $DIR/static-no-inner-mut.rs:23:1
7755
|
7856
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
7957
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
8058
|
8159
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8260
= note: the raw bytes of the constant (size: 8, align: 8) {
83-
ALLOC3╼ │ ╾──────╼
61+
ALLOC1╼ │ ╾──────╼
8462
}
8563

8664
error: encountered mutable pointer in final value of static
87-
--> $DIR/static-no-inner-mut.rs:43:1
65+
--> $DIR/static-no-inner-mut.rs:41:1
8866
|
8967
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
9068
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -93,7 +71,7 @@ LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
9371
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
9472

9573
error: encountered mutable pointer in final value of static
96-
--> $DIR/static-no-inner-mut.rs:47:1
74+
--> $DIR/static-no-inner-mut.rs:45:1
9775
|
9876
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
9977
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -102,7 +80,7 @@ LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *con
10280
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
10381

10482
error: encountered mutable pointer in final value of static
105-
--> $DIR/static-no-inner-mut.rs:51:1
83+
--> $DIR/static-no-inner-mut.rs:49:1
10684
|
10785
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
10886
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -118,37 +96,37 @@ help: skipping check that does not even have a feature gate
11896
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
11997
| ^^^^^^^^^^^^^^^^^^^
12098
help: skipping check that does not even have a feature gate
121-
--> $DIR/static-no-inner-mut.rs:14:27
99+
--> $DIR/static-no-inner-mut.rs:13:27
122100
|
123101
LL | static REFMUT: &mut i32 = &mut 0;
124102
| ^^^^^^
125103
help: skipping check that does not even have a feature gate
126-
--> $DIR/static-no-inner-mut.rs:20:56
104+
--> $DIR/static-no-inner-mut.rs:19:56
127105
|
128106
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
129107
| ^^^^
130108
help: skipping check that does not even have a feature gate
131-
--> $DIR/static-no-inner-mut.rs:25:44
109+
--> $DIR/static-no-inner-mut.rs:23:44
132110
|
133111
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
134112
| ^^^^^^^^
135113
help: skipping check that does not even have a feature gate
136-
--> $DIR/static-no-inner-mut.rs:43:52
114+
--> $DIR/static-no-inner-mut.rs:41:52
137115
|
138116
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
139117
| ^^^^^^^^^^^^^^^^^^^
140118
help: skipping check that does not even have a feature gate
141-
--> $DIR/static-no-inner-mut.rs:47:51
119+
--> $DIR/static-no-inner-mut.rs:45:51
142120
|
143121
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
144122
| ^^^^^^^
145123
help: skipping check that does not even have a feature gate
146-
--> $DIR/static-no-inner-mut.rs:51:52
124+
--> $DIR/static-no-inner-mut.rs:49:52
147125
|
148126
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
149127
| ^^^^^^
150128

151-
error: aborting due to 11 previous errors; 1 warning emitted
129+
error: aborting due to 9 previous errors; 1 warning emitted
152130

153131
For more information about this error, try `rustc --explain E0080`.
154132
Future incompatibility report: Future breakage diagnostic:
@@ -168,7 +146,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
168146

169147
Future breakage diagnostic:
170148
error: encountered mutable pointer in final value of static
171-
--> $DIR/static-no-inner-mut.rs:14:1
149+
--> $DIR/static-no-inner-mut.rs:13:1
172150
|
173151
LL | static REFMUT: &mut i32 = &mut 0;
174152
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -183,7 +161,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
183161

184162
Future breakage diagnostic:
185163
error: encountered mutable pointer in final value of static
186-
--> $DIR/static-no-inner-mut.rs:20:1
164+
--> $DIR/static-no-inner-mut.rs:19:1
187165
|
188166
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
189167
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +176,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
198176

199177
Future breakage diagnostic:
200178
error: encountered mutable pointer in final value of static
201-
--> $DIR/static-no-inner-mut.rs:25:1
179+
--> $DIR/static-no-inner-mut.rs:23:1
202180
|
203181
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
204182
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -213,7 +191,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
213191

214192
Future breakage diagnostic:
215193
error: encountered mutable pointer in final value of static
216-
--> $DIR/static-no-inner-mut.rs:43:1
194+
--> $DIR/static-no-inner-mut.rs:41:1
217195
|
218196
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
219197
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -228,7 +206,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
228206

229207
Future breakage diagnostic:
230208
error: encountered mutable pointer in final value of static
231-
--> $DIR/static-no-inner-mut.rs:47:1
209+
--> $DIR/static-no-inner-mut.rs:45:1
232210
|
233211
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
234212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -243,7 +221,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
243221

244222
Future breakage diagnostic:
245223
error: encountered mutable pointer in final value of static
246-
--> $DIR/static-no-inner-mut.rs:51:1
224+
--> $DIR/static-no-inner-mut.rs:49:1
247225
|
248226
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
249227
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/consts/miri_unleashed/static-no-inner-mut.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::sync::atomic::*;
99
static REF: &AtomicI32 = &AtomicI32::new(42);
1010
//~^ ERROR mutable pointer in final value
1111
//~| WARNING this was previously accepted by the compiler
12-
//~| ERROR it is undefined behavior to use this value
1312

1413
static REFMUT: &mut i32 = &mut 0;
1514
//~^ ERROR mutable pointer in final value
@@ -20,7 +19,6 @@ static REFMUT: &mut i32 = &mut 0;
2019
static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
2120
//~^ ERROR mutable pointer in final value
2221
//~| WARNING this was previously accepted by the compiler
23-
//~| ERROR it is undefined behavior to use this value
2422

2523
static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
2624
//~^ ERROR mutable pointer in final value

tests/ui/consts/refs-to-cell-in-final.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ impl Drop for JsValue {
2828
fn drop(&mut self) {}
2929
}
3030
const UNDEFINED: &JsValue = &JsValue::Undefined;
31-
//~^ERROR: mutable pointer in final value of constant
31+
//~^ WARNING: mutable pointer in final value of constant
32+
//~| WARNING: this was previously accepted by the compiler but is being phased out
3233

3334
// In contrast, this one works since it is being promoted.
3435
const NONE: &'static Option<Cell<i32>> = &None;

0 commit comments

Comments
 (0)