@@ -12,8 +12,19 @@ note: the lint level is defined here
1212LL | #![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+
1526error: encountered mutable pointer in final value of static
16- --> $DIR/mutable_references.rs:14 :1
27+ --> $DIR/mutable_references.rs:15 :1
1728 |
1829LL | static BAR: &mut () = &mut ();
1930 | ^^^^^^^^^^^^^^^^^^^
@@ -22,7 +33,7 @@ LL | static BAR: &mut () = &mut ();
2233 = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
2334
2435error: encountered mutable pointer in final value of static
25- --> $DIR/mutable_references.rs:20 :1
36+ --> $DIR/mutable_references.rs:21 :1
2637 |
2738LL | static BOO: &mut Foo<()> = &mut Foo(());
2839 | ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -31,16 +42,27 @@ LL | static BOO: &mut Foo<()> = &mut Foo(());
3142 = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
3243
3344error: encountered mutable pointer in final value of static
34- --> $DIR/mutable_references.rs:28 :1
45+ --> $DIR/mutable_references.rs:29 :1
3546 |
3647LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
3748 | ^^^^^^^^^^^^^^^
3849 |
3950 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4051 = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
4152
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+
4264error: encountered mutable pointer in final value of static
43- --> $DIR/mutable_references.rs:32 :1
65+ --> $DIR/mutable_references.rs:34 :1
4466 |
4567LL | static OH_YES: &mut i32 = &mut 42;
4668 | ^^^^^^^^^^^^^^^^^^^^^^^
@@ -49,7 +71,7 @@ LL | static OH_YES: &mut i32 = &mut 42;
4971 = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
5072
5173error[E0080]: it is undefined behavior to use this value
52- --> $DIR/mutable_references.rs:32 :1
74+ --> $DIR/mutable_references.rs:34 :1
5375 |
5476LL | static OH_YES: &mut i32 = &mut 42;
5577 | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
@@ -60,7 +82,7 @@ LL | static OH_YES: &mut i32 = &mut 42;
6082 }
6183
6284error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
63- --> $DIR/mutable_references.rs:41 :5
85+ --> $DIR/mutable_references.rs:43 :5
6486 |
6587LL | *OH_YES = 99;
6688 | ^^^^^^^^^^^^ cannot assign
@@ -73,27 +95,27 @@ help: skipping check that does not even have a feature gate
7395LL | static FOO: &&mut u32 = &&mut 42;
7496 | ^^^^^^^
7597help: skipping check that does not even have a feature gate
76- --> $DIR/mutable_references.rs:14 :23
98+ --> $DIR/mutable_references.rs:15 :23
7799 |
78100LL | static BAR: &mut () = &mut ();
79101 | ^^^^^^^
80102help: skipping check that does not even have a feature gate
81- --> $DIR/mutable_references.rs:20 :28
103+ --> $DIR/mutable_references.rs:21 :28
82104 |
83105LL | static BOO: &mut Foo<()> = &mut Foo(());
84106 | ^^^^^^^^^^^^
85107help: skipping check that does not even have a feature gate
86- --> $DIR/mutable_references.rs:28 :28
108+ --> $DIR/mutable_references.rs:29 :28
87109 |
88110LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
89111 | ^^^^^^^^^^^^^^^^^^^^
90112help: skipping check that does not even have a feature gate
91- --> $DIR/mutable_references.rs:32 :27
113+ --> $DIR/mutable_references.rs:34 :27
92114 |
93115LL | static OH_YES: &mut i32 = &mut 42;
94116 | ^^^^^^^
95117
96- error: aborting due to 7 previous errors; 1 warning emitted
118+ error: aborting due to 9 previous errors; 1 warning emitted
97119
98120Some errors have detailed explanations: E0080, E0594.
99121For more information about an error, try `rustc --explain E0080`.
@@ -114,7 +136,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
114136
115137Future breakage diagnostic:
116138error: encountered mutable pointer in final value of static
117- --> $DIR/mutable_references.rs:14 :1
139+ --> $DIR/mutable_references.rs:15 :1
118140 |
119141LL | static BAR: &mut () = &mut ();
120142 | ^^^^^^^^^^^^^^^^^^^
@@ -129,7 +151,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
129151
130152Future breakage diagnostic:
131153error: encountered mutable pointer in final value of static
132- --> $DIR/mutable_references.rs:20 :1
154+ --> $DIR/mutable_references.rs:21 :1
133155 |
134156LL | static BOO: &mut Foo<()> = &mut Foo(());
135157 | ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -144,7 +166,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
144166
145167Future breakage diagnostic:
146168error: encountered mutable pointer in final value of static
147- --> $DIR/mutable_references.rs:28 :1
169+ --> $DIR/mutable_references.rs:29 :1
148170 |
149171LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
150172 | ^^^^^^^^^^^^^^^
@@ -159,7 +181,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
159181
160182Future breakage diagnostic:
161183error: encountered mutable pointer in final value of static
162- --> $DIR/mutable_references.rs:32 :1
184+ --> $DIR/mutable_references.rs:34 :1
163185 |
164186LL | static OH_YES: &mut i32 = &mut 42;
165187 | ^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments