You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added deny(const_eval_mutable_ptr_in_final_value) attribute to all tests that were expecting the hard error for it.
I attempted to do this in a manner that preserved the line numbers to reduce the
review effort on the resulting diff, but we still have to deal with the
ramifications of how a future-incompat lint behaves compared to a hard-error (in
terms of its impact on the diagnostic output).
error[E0080]: it is undefined behavior to use this value
16
+
--> $DIR/mutable_references.rs:7: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: 8, align: 8) {
23
+
╾ALLOC0<imm>╼ │ ╾──────╼
24
+
}
6
25
7
26
error: encountered mutable pointer in final value of static
8
27
--> $DIR/mutable_references.rs:10:1
9
28
|
10
29
LL | static BAR: &mut () = &mut ();
11
30
| ^^^^^^^^^^^^^^^^^^^
31
+
|
32
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
33
+
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
12
34
13
35
error: encountered mutable pointer in final value of static
14
36
--> $DIR/mutable_references.rs:15:1
15
37
|
16
38
LL | static BOO: &mut Foo<()> = &mut Foo(());
17
39
| ^^^^^^^^^^^^^^^^^^^^^^^^
40
+
|
41
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
42
+
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
18
43
19
44
error: encountered mutable pointer in final value of static
| ^^^^^^^^^^^^^^^ 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: 8, align: 8) {
61
+
╾ALLOC1╼ │ ╾──────╼
62
+
}
24
63
25
64
error: encountered mutable pointer in final value of static
26
65
--> $DIR/mutable_references.rs:25:1
27
66
|
28
67
LL | static OH_YES: &mut i32 = &mut 42;
29
68
| ^^^^^^^^^^^^^^^^^^^^^^^
69
+
|
70
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
71
+
= note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
72
+
73
+
error[E0080]: it is undefined behavior to use this value
74
+
--> $DIR/mutable_references.rs:25:1
75
+
|
76
+
LL | static OH_YES: &mut i32 = &mut 42;
77
+
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
78
+
|
79
+
= 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╼ │ ╾──────╼
82
+
}
30
83
31
84
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
32
85
--> $DIR/mutable_references.rs:32:5
@@ -62,6 +115,82 @@ help: skipping check that does not even have a feature gate
62
115
LL | static OH_YES: &mut i32 = &mut 42;
63
116
| ^^^^^^^
64
117
65
-
error: aborting due to 6 previous errors; 1 warning emitted
118
+
error: aborting due to 9 previous errors; 1 warning emitted
119
+
120
+
Some errors have detailed explanations: E0080, E0594.
121
+
For more information about an error, try `rustc --explain E0080`.
0 commit comments