@@ -12,8 +12,19 @@ note: the lint level is defined here
12
12
LL | #![deny(const_eval_mutable_ptr_in_final_value)]
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
14
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
+
15
26
error: encountered mutable pointer in final value of static
16
- --> $DIR/mutable_references.rs:14 :1
27
+ --> $DIR/mutable_references.rs:15 :1
17
28
|
18
29
LL | static BAR: &mut () = &mut ();
19
30
| ^^^^^^^^^^^^^^^^^^^
@@ -22,7 +33,7 @@ LL | static BAR: &mut () = &mut ();
22
33
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
23
34
24
35
error: encountered mutable pointer in final value of static
25
- --> $DIR/mutable_references.rs:20 :1
36
+ --> $DIR/mutable_references.rs:21 :1
26
37
|
27
38
LL | static BOO: &mut Foo<()> = &mut Foo(());
28
39
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -31,16 +42,27 @@ LL | static BOO: &mut Foo<()> = &mut Foo(());
31
42
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
32
43
33
44
error: encountered mutable pointer in final value of static
34
- --> $DIR/mutable_references.rs:28 :1
45
+ --> $DIR/mutable_references.rs:29 :1
35
46
|
36
47
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
37
48
| ^^^^^^^^^^^^^^^
38
49
|
39
50
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
40
51
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
41
52
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
+
42
64
error: encountered mutable pointer in final value of static
43
- --> $DIR/mutable_references.rs:32 :1
65
+ --> $DIR/mutable_references.rs:34 :1
44
66
|
45
67
LL | static OH_YES: &mut i32 = &mut 42;
46
68
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -49,7 +71,7 @@ LL | static OH_YES: &mut i32 = &mut 42;
49
71
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
50
72
51
73
error[E0080]: it is undefined behavior to use this value
52
- --> $DIR/mutable_references.rs:32 :1
74
+ --> $DIR/mutable_references.rs:34 :1
53
75
|
54
76
LL | static OH_YES: &mut i32 = &mut 42;
55
77
| ^^^^^^^^^^^^^^^^^^^^^^^ 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;
60
82
}
61
83
62
84
error[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
64
86
|
65
87
LL | *OH_YES = 99;
66
88
| ^^^^^^^^^^^^ cannot assign
@@ -73,27 +95,27 @@ help: skipping check that does not even have a feature gate
73
95
LL | static FOO: &&mut u32 = &&mut 42;
74
96
| ^^^^^^^
75
97
help: skipping check that does not even have a feature gate
76
- --> $DIR/mutable_references.rs:14 :23
98
+ --> $DIR/mutable_references.rs:15 :23
77
99
|
78
100
LL | static BAR: &mut () = &mut ();
79
101
| ^^^^^^^
80
102
help: skipping check that does not even have a feature gate
81
- --> $DIR/mutable_references.rs:20 :28
103
+ --> $DIR/mutable_references.rs:21 :28
82
104
|
83
105
LL | static BOO: &mut Foo<()> = &mut Foo(());
84
106
| ^^^^^^^^^^^^
85
107
help: skipping check that does not even have a feature gate
86
- --> $DIR/mutable_references.rs:28 :28
108
+ --> $DIR/mutable_references.rs:29 :28
87
109
|
88
110
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
89
111
| ^^^^^^^^^^^^^^^^^^^^
90
112
help: skipping check that does not even have a feature gate
91
- --> $DIR/mutable_references.rs:32 :27
113
+ --> $DIR/mutable_references.rs:34 :27
92
114
|
93
115
LL | static OH_YES: &mut i32 = &mut 42;
94
116
| ^^^^^^^
95
117
96
- error: aborting due to 7 previous errors; 1 warning emitted
118
+ error: aborting due to 9 previous errors; 1 warning emitted
97
119
98
120
Some errors have detailed explanations: E0080, E0594.
99
121
For more information about an error, try `rustc --explain E0080`.
@@ -114,7 +136,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
114
136
115
137
Future breakage diagnostic:
116
138
error: encountered mutable pointer in final value of static
117
- --> $DIR/mutable_references.rs:14 :1
139
+ --> $DIR/mutable_references.rs:15 :1
118
140
|
119
141
LL | static BAR: &mut () = &mut ();
120
142
| ^^^^^^^^^^^^^^^^^^^
@@ -129,7 +151,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
129
151
130
152
Future breakage diagnostic:
131
153
error: encountered mutable pointer in final value of static
132
- --> $DIR/mutable_references.rs:20 :1
154
+ --> $DIR/mutable_references.rs:21 :1
133
155
|
134
156
LL | static BOO: &mut Foo<()> = &mut Foo(());
135
157
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -144,7 +166,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
144
166
145
167
Future breakage diagnostic:
146
168
error: encountered mutable pointer in final value of static
147
- --> $DIR/mutable_references.rs:28 :1
169
+ --> $DIR/mutable_references.rs:29 :1
148
170
|
149
171
LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
150
172
| ^^^^^^^^^^^^^^^
@@ -159,7 +181,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)]
159
181
160
182
Future breakage diagnostic:
161
183
error: encountered mutable pointer in final value of static
162
- --> $DIR/mutable_references.rs:32 :1
184
+ --> $DIR/mutable_references.rs:34 :1
163
185
|
164
186
LL | static OH_YES: &mut i32 = &mut 42;
165
187
| ^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments