about summary refs log tree commit diff
path: root/src
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 /src
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 'src')
-rw-r--r--src/tools/miri/src/diagnostics.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs
index 92c58d48dc7..7f91af59d56 100644
--- a/src/tools/miri/src/diagnostics.rs
+++ b/src/tools/miri/src/diagnostics.rs
@@ -290,7 +290,7 @@ pub fn report_error<'tcx, 'mir>(
                 ) =>
             {
                 ecx.handle_ice(); // print interpreter backtrace
-                bug!("This validation error should be impossible in Miri: {}", ecx.format_error(e));
+                bug!("This validation error should be impossible in Miri: {}", format_interp_error(ecx.tcx.dcx(), e));
             }
             UndefinedBehavior(_) => "Undefined Behavior",
             ResourceExhaustion(_) => "resource exhaustion",
@@ -304,7 +304,7 @@ pub fn report_error<'tcx, 'mir>(
             ) => "post-monomorphization error",
             _ => {
                 ecx.handle_ice(); // print interpreter backtrace
-                bug!("This error should be impossible in Miri: {}", ecx.format_error(e));
+                bug!("This error should be impossible in Miri: {}", format_interp_error(ecx.tcx.dcx(), e));
             }
         };
         #[rustfmt::skip]
@@ -370,7 +370,7 @@ pub fn report_error<'tcx, 'mir>(
         _ => {}
     }
 
-    msg.insert(0, ecx.format_error(e));
+    msg.insert(0, format_interp_error(ecx.tcx.dcx(), e));
 
     report_msg(
         DiagLevel::Error,