about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-06-28 21:46:01 -0700
committerMichael Goulet <michael@errs.io>2022-07-08 03:47:28 +0000
commit1c4afbd1de7a0aa548a4b8f184aede5c5954e63a (patch)
tree30ea10bba7e58092da9241cb02fbe1cc559c2921 /compiler/rustc_const_eval
parent934079fd9e3df668895ed6d64db7221d03f3b027 (diff)
downloadrust-1c4afbd1de7a0aa548a4b8f184aede5c5954e63a.tar.gz
rust-1c4afbd1de7a0aa548a4b8f184aede5c5954e63a.zip
Migrate NonConstOp diagnostic
Diffstat (limited to 'compiler/rustc_const_eval')
-rw-r--r--compiler/rustc_const_eval/src/errors.rs7
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/ops.rs9
2 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index f19e8046d42..40398011f1f 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -19,3 +19,10 @@ pub(crate) struct UnstableInStable {
     )]
     pub attr_span: Span,
 }
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::thread_local_access, code = "E0625")]
+pub(crate) struct NonConstOpErr {
+    #[primary_span]
+    pub span: Span,
+}
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
index 9574661282b..01080560021 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
@@ -20,6 +20,7 @@ use rustc_span::{BytePos, Pos, Span, Symbol};
 use rustc_trait_selection::traits::SelectionContext;
 
 use super::ConstCx;
+use crate::errors::NonConstOpErr;
 use crate::util::{call_kind, CallDesugaringKind, CallKind};
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -760,13 +761,7 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
         ccx: &ConstCx<'_, 'tcx>,
         span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
-        struct_span_err!(
-            ccx.tcx.sess,
-            span,
-            E0625,
-            "thread-local statics cannot be \
-            accessed at compile-time"
-        )
+        ccx.tcx.sess.create_err(NonConstOpErr { span })
     }
 }