about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-03-01 11:43:19 +0000
committerbors <bors@rust-lang.org>2025-03-01 11:43:19 +0000
commit8c392966a013fd8a09e6b78b3c8d6e442bc278e1 (patch)
tree2739778e1d2a658ac43ab4827ea95193ba3d00d8 /compiler/rustc_const_eval/src/errors.rs
parent0c72c0d11adeba449886089c6bd5d48363f7a2cd (diff)
parentc03756a56b2e5a5e327f4e81b37ede0c92e8d305 (diff)
downloadrust-8c392966a013fd8a09e6b78b3c8d6e442bc278e1.tar.gz
rust-8c392966a013fd8a09e6b78b3c8d6e442bc278e1.zip
Auto merge of #137848 - matthiaskrgr:rollup-vxtrkis, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136503 (Tweak output of const panic diagnostic)
 - #137390 (tests: fix up new test for nocapture -> capture(none) change)
 - #137617 (Introduce `feature(generic_const_parameter_types)`)
 - #137719 (Add missing case explanation for doc inlined re-export of doc hidden item)
 - #137763 (Use `mk_ty_from_kind` a bit less, clean up lifetime handling in borrowck)
 - #137769 (Do not yeet `unsafe<>` from type when formatting unsafe binder)
 - #137776 (Some `rustc_transmute` cleanups)
 - #137800 (Remove `ParamEnv::without_caller_bounds`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_const_eval/src/errors.rs')
-rw-r--r--compiler/rustc_const_eval/src/errors.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index ef756e58c5e..b020eeccf71 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -6,6 +6,7 @@ use rustc_abi::WrappingRange;
 use rustc_errors::codes::*;
 use rustc_errors::{
     Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level,
+    MultiSpan, SubdiagMessageOp, Subdiagnostic,
 };
 use rustc_hir::ConstContext;
 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@@ -17,6 +18,7 @@ use rustc_middle::mir::interpret::{
 use rustc_middle::ty::{self, Mutability, Ty};
 use rustc_span::{Span, Symbol};
 
+use crate::fluent_generated as fluent;
 use crate::interpret::InternKind;
 
 #[derive(Diagnostic)]
@@ -278,14 +280,31 @@ pub(crate) struct NonConstImplNote {
     pub span: Span,
 }
 
-#[derive(Subdiagnostic, Clone)]
-#[note(const_eval_frame_note)]
+#[derive(Clone)]
 pub struct FrameNote {
-    #[primary_span]
     pub span: Span,
     pub times: i32,
     pub where_: &'static str,
     pub instance: String,
+    pub has_label: bool,
+}
+
+impl Subdiagnostic for FrameNote {
+    fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
+        self,
+        diag: &mut Diag<'_, G>,
+        f: &F,
+    ) {
+        diag.arg("times", self.times);
+        diag.arg("where_", self.where_);
+        diag.arg("instance", self.instance);
+        let mut span: MultiSpan = self.span.into();
+        if self.has_label && !self.span.is_dummy() {
+            span.push_span_label(self.span, fluent::const_eval_frame_note_last);
+        }
+        let msg = f(diag, fluent::const_eval_frame_note.into());
+        diag.span_note(span, msg);
+    }
 }
 
 #[derive(Subdiagnostic)]