use translatable subdiagnostic
This commit is contained in:
parent
e79b179412
commit
2017a176eb
3 changed files with 9 additions and 1 deletions
|
@ -214,6 +214,9 @@ mir_build_mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsa
|
||||||
|
|
||||||
mir_build_non_const_path = runtime values cannot be referenced in patterns
|
mir_build_non_const_path = runtime values cannot be referenced in patterns
|
||||||
|
|
||||||
|
mir_build_non_exhaustive_match_all_arms_guarded =
|
||||||
|
match arms with guards don't count towards exhaustivity
|
||||||
|
|
||||||
mir_build_non_exhaustive_omitted_pattern = some variants are not matched explicitly
|
mir_build_non_exhaustive_omitted_pattern = some variants are not matched explicitly
|
||||||
.help = ensure that all variants are matched explicitly by adding the suggested match arms
|
.help = ensure that all variants are matched explicitly by adding the suggested match arms
|
||||||
.note = the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found
|
.note = the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||||
|
|
|
@ -432,6 +432,10 @@ impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[note(mir_build_non_exhaustive_match_all_arms_guarded)]
|
||||||
|
pub struct NonExhaustiveMatchAllArmsGuarded;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build_static_in_pattern, code = "E0158")]
|
#[diag(mir_build_static_in_pattern, code = "E0158")]
|
||||||
pub struct StaticInPattern {
|
pub struct StaticInPattern {
|
||||||
|
|
|
@ -833,7 +833,8 @@ fn non_exhaustive_match<'p, 'tcx>(
|
||||||
|
|
||||||
let all_arms_have_guards = arms.iter().all(|arm_id| thir[*arm_id].guard.is_some());
|
let all_arms_have_guards = arms.iter().all(|arm_id| thir[*arm_id].guard.is_some());
|
||||||
if !is_empty_match && all_arms_have_guards {
|
if !is_empty_match && all_arms_have_guards {
|
||||||
err.note("match arms with guards don't count towards exhaustivity");
|
err.subdiagnostic(NonExhaustiveMatchAllArmsGuarded);
|
||||||
|
// err.note(NonExhaustiveMatchAllArmsGuarded);
|
||||||
}
|
}
|
||||||
if let Some((span, sugg)) = suggestion {
|
if let Some((span, sugg)) = suggestion {
|
||||||
err.span_suggestion_verbose(span, msg, sugg, Applicability::HasPlaceholders);
|
err.span_suggestion_verbose(span, msg, sugg, Applicability::HasPlaceholders);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue