Skip to content

Commit 2017a17

Browse files
use translatable subdiagnostic
1 parent e79b179 commit 2017a17

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/rustc_mir_build/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ mir_build_mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsa
214214
215215
mir_build_non_const_path = runtime values cannot be referenced in patterns
216216
217+
mir_build_non_exhaustive_match_all_arms_guarded =
218+
match arms with guards don't count towards exhaustivity
219+
217220
mir_build_non_exhaustive_omitted_pattern = some variants are not matched explicitly
218221
.help = ensure that all variants are matched explicitly by adding the suggested match arms
219222
.note = the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found

compiler/rustc_mir_build/src/errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
432432
}
433433
}
434434

435+
#[derive(Subdiagnostic)]
436+
#[note(mir_build_non_exhaustive_match_all_arms_guarded)]
437+
pub struct NonExhaustiveMatchAllArmsGuarded;
438+
435439
#[derive(Diagnostic)]
436440
#[diag(mir_build_static_in_pattern, code = "E0158")]
437441
pub struct StaticInPattern {

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ fn non_exhaustive_match<'p, 'tcx>(
833833

834834
let all_arms_have_guards = arms.iter().all(|arm_id| thir[*arm_id].guard.is_some());
835835
if !is_empty_match && all_arms_have_guards {
836-
err.note("match arms with guards don't count towards exhaustivity");
836+
err.subdiagnostic(NonExhaustiveMatchAllArmsGuarded);
837+
// err.note(NonExhaustiveMatchAllArmsGuarded);
837838
}
838839
if let Some((span, sugg)) = suggestion {
839840
err.span_suggestion_verbose(span, msg, sugg, Applicability::HasPlaceholders);

0 commit comments

Comments
 (0)