about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
diff options
context:
space:
mode:
authornidnogg <henriquevt98@gmail.com>2022-08-18 22:49:59 -0300
committernidnogg <henriquevt98@gmail.com>2022-08-21 23:22:53 -0300
commit33e8aaf830578d71ac55c6e612dbcff7aef766d2 (patch)
treecd84891407dd3a15109e30b8d39023f32aeec11d /compiler/rustc_const_eval
parent70ea98633e44b1220e40c1e8bcdc82edcc18da77 (diff)
downloadrust-33e8aaf830578d71ac55c6e612dbcff7aef766d2.tar.gz
rust-33e8aaf830578d71ac55c6e612dbcff7aef766d2.zip
Migration on ops.rs for unstable const functions
Diffstat (limited to 'compiler/rustc_const_eval')
-rw-r--r--compiler/rustc_const_eval/src/errors.rs8
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/ops.rs8
2 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index 728d890ca60..19e9e33ab80 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -103,3 +103,11 @@ pub(crate) struct UnallowedFnPointerCall {
     pub span: Span,
     pub kind: ConstContext,
 }
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::unstable_const_fn)]
+pub(crate) struct UnstableConstFn {
+    #[primary_span]
+    pub span: Span,
+    pub def_id: String,
+}
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 ba7f2d07277..22d681fd336 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
@@ -25,7 +25,7 @@ use rustc_trait_selection::traits::SelectionContext;
 use super::ConstCx;
 use crate::errors::{
     MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
-    TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall,
+    TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall, UnstableConstFn,
 };
 use crate::util::{call_kind, CallDesugaringKind, CallKind};
 
@@ -351,10 +351,8 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
         let FnCallUnstable(def_id, feature) = *self;
 
-        let mut err = ccx.tcx.sess.struct_span_err(
-            span,
-            &format!("`{}` is not yet stable as a const fn", ccx.tcx.def_path_str(def_id)),
-        );
+        let mut err =
+            ccx.tcx.sess.create_err(UnstableConstFn { span, def_id: ccx.tcx.def_path_str(def_id) });
 
         if ccx.is_const_stable_const_fn() {
             err.help("const-stable functions can only call other const-stable functions");