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
Rollup merge of rust-lang#100897 - RalfJung:const-not-to-mutable, r=lcnr
extra sanity check against consts pointing to mutable memory
This should be both unreachable and redundant (since we already ensure that validation only reads from read-only memory, when validating consts), but I feel like we cannot be paranoid enough here, and also if this ever fails it'll be a nicer error than the "cannot read from mutable memory" error.
Copy file name to clipboardExpand all lines: src/test/ui/consts/const-points-to-static.32bit.stderr
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
2
2
--> $DIR/const-points-to-static.rs:6:1
3
3
|
4
4
LL | const TEST: &u8 = &MY_STATIC;
5
-
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 4, align: 4) {
Copy file name to clipboardExpand all lines: src/test/ui/consts/const-points-to-static.64bit.stderr
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
2
2
--> $DIR/const-points-to-static.rs:6:1
3
3
|
4
4
LL | const TEST: &u8 = &MY_STATIC;
5
-
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 8, align: 8) {
Copy file name to clipboardExpand all lines: src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
2
2
--> $DIR/const_refers_to_static2.rs:11:1
3
3
|
4
4
LL | const REF_INTERIOR_MUT: &usize = {
5
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 4, align: 4) {
@@ -13,7 +13,7 @@ error[E0080]: it is undefined behavior to use this value
13
13
--> $DIR/const_refers_to_static2.rs:18:1
14
14
|
15
15
LL | const READ_IMMUT: &usize = {
16
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
16
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
17
17
|
18
18
= 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.
19
19
= note: the raw bytes of the constant (size: 4, align: 4) {
Copy file name to clipboardExpand all lines: src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
2
2
--> $DIR/const_refers_to_static2.rs:11:1
3
3
|
4
4
LL | const REF_INTERIOR_MUT: &usize = {
5
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 8, align: 8) {
@@ -13,7 +13,7 @@ error[E0080]: it is undefined behavior to use this value
13
13
--> $DIR/const_refers_to_static2.rs:18:1
14
14
|
15
15
LL | const READ_IMMUT: &usize = {
16
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
16
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
17
17
|
18
18
= 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.
19
19
= note: the raw bytes of the constant (size: 8, align: 8) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 4, align: 4) {
@@ -19,7 +19,7 @@ error[E0080]: it is undefined behavior to use this value
| ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
22
+
| ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
23
23
|
24
24
= 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.
25
25
= note: the raw bytes of the constant (size: 4, align: 4) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
6
6
|
7
7
= 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.
8
8
= note: the raw bytes of the constant (size: 8, align: 8) {
@@ -19,7 +19,7 @@ error[E0080]: it is undefined behavior to use this value
| ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable
22
+
| ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
23
23
|
24
24
= 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.
25
25
= note: the raw bytes of the constant (size: 8, align: 8) {
0 commit comments