diff options
Diffstat (limited to 'compiler/rustc_mir_build/src/errors.rs')
| -rw-r--r-- | compiler/rustc_mir_build/src/errors.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index f6f443b64a6..cf2962d9fcf 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -582,11 +582,37 @@ pub(crate) struct NonConstPath { #[derive(LintDiagnostic)] #[diag(mir_build_unreachable_pattern)] -pub(crate) struct UnreachablePattern { +pub(crate) struct UnreachablePattern<'tcx> { #[label] pub(crate) span: Option<Span>, - #[label(mir_build_catchall_label)] - pub(crate) catchall: Option<Span>, + #[subdiagnostic] + pub(crate) matches_no_values: Option<UnreachableMatchesNoValues<'tcx>>, + #[label(mir_build_unreachable_covered_by_catchall)] + pub(crate) covered_by_catchall: Option<Span>, + #[label(mir_build_unreachable_covered_by_one)] + pub(crate) covered_by_one: Option<Span>, + #[subdiagnostic] + pub(crate) covered_by_many: Option<UnreachableCoveredByMany>, +} + +#[derive(Subdiagnostic)] +#[note(mir_build_unreachable_matches_no_values)] +pub(crate) struct UnreachableMatchesNoValues<'tcx> { + pub(crate) ty: Ty<'tcx>, +} + +pub(crate) struct UnreachableCoveredByMany(pub(crate) Vec<Span>); + +impl Subdiagnostic for UnreachableCoveredByMany { + fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( + self, + diag: &mut Diag<'_, G>, + _f: &F, + ) { + for span in self.0 { + diag.span_label(span, fluent::mir_build_unreachable_covered_by_many); + } + } } #[derive(Diagnostic)] |
