Skip to content

Commit 354c41e

Browse files
committed
Updated the test to include more output normalization.
1 parent 6ca46da commit 354c41e

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

tests/ui/consts/miri_unleashed/mutable_references.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//@ compile-flags: -Zunleash-the-miri-inside-of-you
2+
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
3+
//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
4+
25
#![deny(const_eval_mutable_ptr_in_final_value)]
36
use std::cell::UnsafeCell;
47

tests/ui/consts/miri_unleashed/mutable_references.stderr

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
error: encountered mutable pointer in final value of static
2-
--> $DIR/mutable_references.rs:7:1
2+
--> $DIR/mutable_references.rs:10:1
33
|
44
LL | static FOO: &&mut u32 = &&mut 42;
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
99
note: the lint level is defined here
10-
--> $DIR/mutable_references.rs:2:9
10+
--> $DIR/mutable_references.rs:5:9
1111
|
1212
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error[E0080]: it is undefined behavior to use this value
16-
--> $DIR/mutable_references.rs:7:1
16+
--> $DIR/mutable_references.rs:10:1
1717
|
1818
LL | static FOO: &&mut u32 = &&mut 42;
1919
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered mutable reference or box pointing to read-only memory
2020
|
2121
= 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<imm>╼ │ ╾──────╼
22+
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
23+
HEX_DUMP
2424
}
2525

2626
error: encountered mutable pointer in final value of static
27-
--> $DIR/mutable_references.rs:12:1
27+
--> $DIR/mutable_references.rs:15:1
2828
|
2929
LL | static BAR: &mut () = &mut ();
3030
| ^^^^^^^^^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL | static BAR: &mut () = &mut ();
3333
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
3434

3535
error: encountered mutable pointer in final value of static
36-
--> $DIR/mutable_references.rs:18:1
36+
--> $DIR/mutable_references.rs:21:1
3737
|
3838
LL | static BOO: &mut Foo<()> = &mut Foo(());
3939
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -42,7 +42,7 @@ LL | static BOO: &mut Foo<()> = &mut Foo(());
4242
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
4343

4444
error: encountered mutable pointer in final value of static
45-
--> $DIR/mutable_references.rs:26:1
45+
--> $DIR/mutable_references.rs:29:1
4646
|
4747
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
4848
| ^^^^^^^^^^^^^^^
@@ -51,18 +51,18 @@ LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
5151
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
5252

5353
error[E0080]: it is undefined behavior to use this value
54-
--> $DIR/mutable_references.rs:26:1
54+
--> $DIR/mutable_references.rs:29:1
5555
|
5656
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
5757
| ^^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory
5858
|
5959
= 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: 8, align: 8) {
61-
╾ALLOC1╼ │ ╾──────╼
60+
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
61+
HEX_DUMP
6262
}
6363

6464
error: encountered mutable pointer in final value of static
65-
--> $DIR/mutable_references.rs:31:1
65+
--> $DIR/mutable_references.rs:34:1
6666
|
6767
LL | static OH_YES: &mut i32 = &mut 42;
6868
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -71,46 +71,46 @@ LL | static OH_YES: &mut i32 = &mut 42;
7171
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
7272

7373
error[E0080]: it is undefined behavior to use this value
74-
--> $DIR/mutable_references.rs:31:1
74+
--> $DIR/mutable_references.rs:34:1
7575
|
7676
LL | static OH_YES: &mut i32 = &mut 42;
7777
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
7878
|
7979
= 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.
80-
= note: the raw bytes of the constant (size: 8, align: 8) {
81-
╾ALLOC2╼ │ ╾──────╼
80+
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
81+
HEX_DUMP
8282
}
8383

8484
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
85-
--> $DIR/mutable_references.rs:40:5
85+
--> $DIR/mutable_references.rs:43:5
8686
|
8787
LL | *OH_YES = 99;
8888
| ^^^^^^^^^^^^ cannot assign
8989

9090
warning: skipping const checks
9191
|
9292
help: skipping check that does not even have a feature gate
93-
--> $DIR/mutable_references.rs:7:26
93+
--> $DIR/mutable_references.rs:10:26
9494
|
9595
LL | static FOO: &&mut u32 = &&mut 42;
9696
| ^^^^^^^
9797
help: skipping check that does not even have a feature gate
98-
--> $DIR/mutable_references.rs:12:23
98+
--> $DIR/mutable_references.rs:15:23
9999
|
100100
LL | static BAR: &mut () = &mut ();
101101
| ^^^^^^^
102102
help: skipping check that does not even have a feature gate
103-
--> $DIR/mutable_references.rs:18:28
103+
--> $DIR/mutable_references.rs:21:28
104104
|
105105
LL | static BOO: &mut Foo<()> = &mut Foo(());
106106
| ^^^^^^^^^^^^
107107
help: skipping check that does not even have a feature gate
108-
--> $DIR/mutable_references.rs:26:28
108+
--> $DIR/mutable_references.rs:29:28
109109
|
110110
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
111111
| ^^^^^^^^^^^^^^^^^^^^
112112
help: skipping check that does not even have a feature gate
113-
--> $DIR/mutable_references.rs:31:27
113+
--> $DIR/mutable_references.rs:34:27
114114
|
115115
LL | static OH_YES: &mut i32 = &mut 42;
116116
| ^^^^^^^
@@ -121,75 +121,75 @@ Some errors have detailed explanations: E0080, E0594.
121121
For more information about an error, try `rustc --explain E0080`.
122122
Future incompatibility report: Future breakage diagnostic:
123123
error: encountered mutable pointer in final value of static
124-
--> $DIR/mutable_references.rs:7:1
124+
--> $DIR/mutable_references.rs:10:1
125125
|
126126
LL | static FOO: &&mut u32 = &&mut 42;
127127
| ^^^^^^^^^^^^^^^^^^^^^
128128
|
129129
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
130130
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
131131
note: the lint level is defined here
132-
--> $DIR/mutable_references.rs:2:9
132+
--> $DIR/mutable_references.rs:5:9
133133
|
134134
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
135135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136136

137137
Future breakage diagnostic:
138138
error: encountered mutable pointer in final value of static
139-
--> $DIR/mutable_references.rs:12:1
139+
--> $DIR/mutable_references.rs:15:1
140140
|
141141
LL | static BAR: &mut () = &mut ();
142142
| ^^^^^^^^^^^^^^^^^^^
143143
|
144144
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
145145
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
146146
note: the lint level is defined here
147-
--> $DIR/mutable_references.rs:2:9
147+
--> $DIR/mutable_references.rs:5:9
148148
|
149149
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
150150
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151151

152152
Future breakage diagnostic:
153153
error: encountered mutable pointer in final value of static
154-
--> $DIR/mutable_references.rs:18:1
154+
--> $DIR/mutable_references.rs:21:1
155155
|
156156
LL | static BOO: &mut Foo<()> = &mut Foo(());
157157
| ^^^^^^^^^^^^^^^^^^^^^^^^
158158
|
159159
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
160160
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
161161
note: the lint level is defined here
162-
--> $DIR/mutable_references.rs:2:9
162+
--> $DIR/mutable_references.rs:5:9
163163
|
164164
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
165165
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166166

167167
Future breakage diagnostic:
168168
error: encountered mutable pointer in final value of static
169-
--> $DIR/mutable_references.rs:26:1
169+
--> $DIR/mutable_references.rs:29:1
170170
|
171171
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
172172
| ^^^^^^^^^^^^^^^
173173
|
174174
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
175175
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
176176
note: the lint level is defined here
177-
--> $DIR/mutable_references.rs:2:9
177+
--> $DIR/mutable_references.rs:5:9
178178
|
179179
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
180180
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181181

182182
Future breakage diagnostic:
183183
error: encountered mutable pointer in final value of static
184-
--> $DIR/mutable_references.rs:31:1
184+
--> $DIR/mutable_references.rs:34:1
185185
|
186186
LL | static OH_YES: &mut i32 = &mut 42;
187187
| ^^^^^^^^^^^^^^^^^^^^^^^
188188
|
189189
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
190190
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
191191
note: the lint level is defined here
192-
--> $DIR/mutable_references.rs:2:9
192+
--> $DIR/mutable_references.rs:5:9
193193
|
194194
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
195195
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)