From b321cd5573d5bfc4b21f456be146c8d29d67bd1d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 23 Dec 2024 21:04:17 +0000 Subject: Add note back to conditionally-const error message --- compiler/rustc_const_eval/src/check_consts/ops.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_const_eval') diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index ebd680ac28a..55e43f5af35 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -92,7 +92,7 @@ impl<'tcx> NonConstOp<'tcx> for ConditionallyConstCall<'tcx> { } fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - ccx.tcx.sess.create_feature_err( + let mut err = ccx.tcx.sess.create_feature_err( errors::ConditionallyConstCall { span, def_path_str: ccx.tcx.def_path_str_with_args(self.callee, self.args), @@ -100,7 +100,15 @@ impl<'tcx> NonConstOp<'tcx> for ConditionallyConstCall<'tcx> { kind: ccx.const_kind(), }, sym::const_trait_impl, - ) + ); + + err.note(format!( + "calls in {}s are limited to constant functions, \ + tuple structs and tuple variants", + ccx.const_kind(), + )); + + err } } -- cgit 1.4.1-3-g733a5