about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/transform
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-06-19 20:13:08 -0700
committerMichael Goulet <michael@errs.io>2022-06-19 20:18:08 -0700
commit5373d738e862c13be971bc3b78c3d9c2af6e8ba7 (patch)
tree433655f7e293e88faad8f24b25e0d18c7693b498 /compiler/rustc_const_eval/src/transform
parent611e7b9cea2b982b63de7f6697b2a9079b0bf188 (diff)
downloadrust-5373d738e862c13be971bc3b78c3d9c2af6e8ba7.tar.gz
rust-5373d738e862c13be971bc3b78c3d9c2af6e8ba7.zip
Mention formatting macros when encountering ArgumentV1::new in const
Diffstat (limited to 'compiler/rustc_const_eval/src/transform')
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/ops.rs12
1 files changed, 11 insertions, 1 deletions
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 4e71baa77b0..0c587220cb7 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs
@@ -10,7 +10,8 @@ use rustc_middle::mir;
 use rustc_middle::ty::print::with_no_trimmed_paths;
 use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
 use rustc_middle::ty::{
-    suggest_constraining_type_param, Adt, Closure, FnDef, FnPtr, Param, TraitPredicate, Ty,
+    suggest_constraining_type_param, Adt, Closure, DefIdTree, FnDef, FnPtr, Param, TraitPredicate,
+    Ty,
 };
 use rustc_middle::ty::{Binder, BoundConstness, ImplPolarity, TraitRef};
 use rustc_session::parse::feature_err;
@@ -300,6 +301,15 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
                 diag_trait(&mut err, self_ty, tcx.lang_items().deref_trait().unwrap());
                 err
             }
+            _ if tcx.opt_parent(callee) == tcx.get_diagnostic_item(sym::ArgumentV1Methods) => {
+                struct_span_err!(
+                    ccx.tcx.sess,
+                    span,
+                    E0015,
+                    "cannot call non-const formatting macro in {}s",
+                    ccx.const_kind(),
+                )
+            }
             _ => struct_span_err!(
                 ccx.tcx.sess,
                 span,