about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-10 15:52:24 +0000
committerbors <bors@rust-lang.org>2024-02-10 15:52:24 +0000
commit6cc4843512d613f51ec81aba689180c31b0b28b6 (patch)
tree032317f05e63866f8eea1a3927c3dc5a8fdcded4 /compiler/rustc_error_codes
parent5f40394baa07b6fb50bc70dedd8b780524b20934 (diff)
parent4def37386c181e9afb0dfc7f6c137f3730e5fca1 (diff)
downloadrust-6cc4843512d613f51ec81aba689180c31b0b28b6.tar.gz
rust-6cc4843512d613f51ec81aba689180c31b0b28b6.zip
Auto merge of #119614 - RalfJung:const-refs-to-static, r=oli-obk
unstably allow constants to refer to statics and read from immutable statics

I am not aware of any fundamental reason why we cannot allow constants to mention statics. What we really need is that constants do not *read from* statics that can change their value:
- This would break the principle that "constants behave as-if their expression was inlined everywhere and executed at runtime". This is enforced by halting const-eval interpretation when a read from a mutable global occurs.
- When building a valtree we want to be sure that the constant and everything it refers to is truly immutable. This is enforced by aborting valtree construction when a read from a mutable global occurs.

r? `@oli-obk` -- if you are okay with experimenting with this feature, I will create a tracking issue.
Based on and blocked on https://github.com/rust-lang/rust/pull/119044; only the last commit is new.
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0013.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0013.md b/compiler/rustc_error_codes/src/error_codes/E0013.md
index 5605302772f..9f4848343ff 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0013.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0013.md
@@ -1,9 +1,11 @@
+#### Note: this error code is no longer emitted by the compiler
+
 Static and const variables can refer to other const variables. But a const
 variable cannot refer to a static variable.
 
 Erroneous code example:
 
-```compile_fail,E0013
+```compile_fail,E0658
 static X: i32 = 42;
 const Y: i32 = X;
 ```