diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-06-22 00:12:13 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-06-25 21:07:16 +0800 |
| commit | d2d17c60bd62c03b91f6ded31b34da90addf2fc0 (patch) | |
| tree | 712bb199f9527c72eee0185f4ff98101132bebee /compiler/rustc_mir_build/src/errors.rs | |
| parent | 2fcf1776b9ccef89993dfe40e9f5c4908e2d2d48 (diff) | |
| download | rust-d2d17c60bd62c03b91f6ded31b34da90addf2fc0.tar.gz rust-d2d17c60bd62c03b91f6ded31b34da90addf2fc0.zip | |
Add runtime check to avoid overwrite arg easily in diag and store and restore snapshot when set subdiag arg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'compiler/rustc_mir_build/src/errors.rs')
| -rw-r--r-- | compiler/rustc_mir_build/src/errors.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index ae09db50235..23869878e06 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -994,14 +994,15 @@ pub(crate) struct PatternNotCovered<'s, 'tcx> { pub(crate) uncovered: Uncovered, #[subdiagnostic] pub(crate) inform: Option<Inform>, - #[label(mir_build_confused)] - pub(crate) interpreted_as_const: Option<Span>, #[subdiagnostic] - pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConst>, + pub(crate) interpreted_as_const: Option<InterpretedAsConst>, + #[subdiagnostic] + pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>, #[subdiagnostic] pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>, #[note(mir_build_privately_uninhabited)] pub(crate) witness_1_is_privately_uninhabited: bool, + pub(crate) witness_1: String, #[note(mir_build_pattern_ty)] pub(crate) _p: (), pub(crate) pattern_ty: Ty<'tcx>, @@ -1016,6 +1017,14 @@ pub(crate) struct PatternNotCovered<'s, 'tcx> { #[note(mir_build_more_information)] pub(crate) struct Inform; +#[derive(Subdiagnostic)] +#[label(mir_build_confused)] +pub(crate) struct InterpretedAsConst { + #[primary_span] + pub(crate) span: Span, + pub(crate) variable: String, +} + pub(crate) struct AdtDefinedHere<'tcx> { pub(crate) adt_def_span: Span, pub(crate) ty: Ty<'tcx>, @@ -1046,7 +1055,7 @@ impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> { applicability = "maybe-incorrect", style = "verbose" )] -pub(crate) struct InterpretedAsConst { +pub(crate) struct InterpretedAsConstSugg { #[primary_span] pub(crate) span: Span, pub(crate) variable: String, |
