about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-02 13:00:46 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-02 13:00:46 +0000
commit64b75f736ddaf10887a508941ab7dea9a67d01d4 (patch)
tree112874253d76ae8f8f777800270fa4dcef6388fc /compiler/rustc_const_eval/src/interpret
parent6c5c48e880ca0668c5c8a8029769636831985137 (diff)
downloadrust-64b75f736ddaf10887a508941ab7dea9a67d01d4.tar.gz
rust-64b75f736ddaf10887a508941ab7dea9a67d01d4.zip
Forbid implicit nested statics in thread local statics
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
-rw-r--r--compiler/rustc_const_eval/src/interpret/intern.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs
index f4e46c9499e..d0f0190fea7 100644
--- a/compiler/rustc_const_eval/src/interpret/intern.rs
+++ b/compiler/rustc_const_eval/src/interpret/intern.rs
@@ -28,7 +28,7 @@ use rustc_span::sym;
 
 use super::{AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy};
 use crate::const_eval;
-use crate::errors::{DanglingPtrInFinal, MutablePtrInFinal};
+use crate::errors::{DanglingPtrInFinal, MutablePtrInFinal, NestedStaticInThreadLocal};
 
 pub trait CompileTimeMachine<'mir, 'tcx: 'mir, T> = Machine<
         'mir,
@@ -108,6 +108,10 @@ fn intern_as_new_static<'tcx>(
     );
     tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());
 
+    if tcx.is_thread_local_static(static_id.into()) {
+        tcx.dcx().emit_err(NestedStaticInThreadLocal { span: tcx.def_span(static_id) });
+    }
+
     // These do not inherit the codegen attrs of the parent static allocation, since
     // it doesn't make sense for them to inherit their `#[no_mangle]` and `#[link_name = ..]`
     // and the like.