@@ -6,7 +6,14 @@ use rustc_span::Span;
66use crate :: rustc:: { RustcPatCtxt , WitnessPat } ;
77
88#[ derive( Subdiagnostic ) ]
9- #[ label( pattern_analysis_uncovered) ]
9+ #[ label(
10+ "{$count ->
11+ [1] pattern `{$witness_1}`
12+ [2] patterns `{$witness_1}` and `{$witness_2}`
13+ [3] patterns `{$witness_1}`, `{$witness_2}` and `{$witness_3}`
14+ *[other] patterns `{$witness_1}`, `{$witness_2}`, `{$witness_3}` and {$remainder} more
15+ } not covered"
16+ ) ]
1017pub struct Uncovered {
1118 #[ primary_span]
1219 span : Span ,
@@ -40,10 +47,10 @@ impl Uncovered {
4047}
4148
4249#[ derive( LintDiagnostic ) ]
43- #[ diag( pattern_analysis_overlapping_range_endpoints ) ]
44- #[ note]
50+ #[ diag( "multiple patterns overlap on their endpoints" ) ]
51+ #[ note( "you likely meant to write mutually exclusive ranges" ) ]
4552pub struct OverlappingRangeEndpoints {
46- #[ label]
53+ #[ label( "... with this range" ) ]
4754 pub range : Span ,
4855 #[ subdiagnostic]
4956 pub overlap : Vec < Overlap > ,
@@ -66,10 +73,14 @@ impl Subdiagnostic for Overlap {
6673}
6774
6875#[ derive( LintDiagnostic ) ]
69- #[ diag( pattern_analysis_excluside_range_missing_max ) ]
76+ #[ diag( "exclusive range missing `{$max}`" ) ]
7077pub struct ExclusiveRangeMissingMax {
71- #[ label]
72- #[ suggestion( code = "{suggestion}" , applicability = "maybe-incorrect" ) ]
78+ #[ label( "this range doesn't match `{$max}` because `..` is an exclusive range" ) ]
79+ #[ suggestion(
80+ "use an inclusive range instead" ,
81+ code = "{suggestion}" ,
82+ applicability = "maybe-incorrect"
83+ ) ]
7384 /// This is an exclusive range that looks like `lo..max` (i.e. doesn't match `max`).
7485 pub first_range : Span ,
7586 /// Suggest `lo..=max` instead.
@@ -78,10 +89,14 @@ pub struct ExclusiveRangeMissingMax {
7889}
7990
8091#[ derive( LintDiagnostic ) ]
81- #[ diag( pattern_analysis_excluside_range_missing_gap ) ]
92+ #[ diag( "multiple ranges are one apart" ) ]
8293pub struct ExclusiveRangeMissingGap {
83- #[ label]
84- #[ suggestion( code = "{suggestion}" , applicability = "maybe-incorrect" ) ]
94+ #[ label( "this range doesn't match `{$gap}` because `..` is an exclusive range" ) ]
95+ #[ suggestion(
96+ "use an inclusive range instead" ,
97+ code = "{suggestion}" ,
98+ applicability = "maybe-incorrect"
99+ ) ]
85100 /// This is an exclusive range that looks like `lo..gap` (i.e. doesn't match `gap`).
86101 pub first_range : Span ,
87102 pub gap : String , // a printed pattern
@@ -113,35 +128,41 @@ impl Subdiagnostic for GappedRange {
113128}
114129
115130#[ derive( LintDiagnostic ) ]
116- #[ diag( pattern_analysis_non_exhaustive_omitted_pattern) ]
117- #[ help]
118- #[ note]
131+ #[ diag( "some variants are not matched explicitly" ) ]
132+ #[ help( "ensure that all variants are matched explicitly by adding the suggested match arms" ) ]
133+ #[ note(
134+ "the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found"
135+ ) ]
119136pub ( crate ) struct NonExhaustiveOmittedPattern < ' tcx > {
120137 pub scrut_ty : Ty < ' tcx > ,
121138 #[ subdiagnostic]
122139 pub uncovered : Uncovered ,
123140}
124141
125142#[ derive( LintDiagnostic ) ]
126- #[ diag( pattern_analysis_non_exhaustive_omitted_pattern_lint_on_arm ) ]
127- #[ help]
143+ #[ diag( "the lint level must be set on the whole match" ) ]
144+ #[ help( "it no longer has any effect to set the lint level on an individual match arm" ) ]
128145pub ( crate ) struct NonExhaustiveOmittedPatternLintOnArm {
129- #[ label]
146+ #[ label( "remove this attribute" ) ]
130147 pub lint_span : Span ,
131- #[ suggestion( code = "#[{lint_level}({lint_name})]\n " , applicability = "maybe-incorrect" ) ]
148+ #[ suggestion(
149+ "set the lint level on the whole match" ,
150+ code = "#[{lint_level}({lint_name})]\n " ,
151+ applicability = "maybe-incorrect"
152+ ) ]
132153 pub suggest_lint_on_match : Option < Span > ,
133154 pub lint_level : & ' static str ,
134155 pub lint_name : & ' static str ,
135156}
136157
137158#[ derive( Diagnostic ) ]
138- #[ diag( pattern_analysis_mixed_deref_pattern_constructors ) ]
159+ #[ diag( "mix of deref patterns and normal constructors" ) ]
139160pub ( crate ) struct MixedDerefPatternConstructors < ' tcx > {
140161 #[ primary_span]
141162 pub spans : Vec < Span > ,
142163 pub smart_pointer_ty : Ty < ' tcx > ,
143- #[ label( pattern_analysis_deref_pattern_label ) ]
164+ #[ label( "matches on the result of dereferencing `{$smart_pointer_ty}`" ) ]
144165 pub deref_pattern_label : Span ,
145- #[ label( pattern_analysis_normal_constructor_label ) ]
166+ #[ label( "matches directly on `{$smart_pointer_ty}`" ) ]
146167 pub normal_constructor_label : Span ,
147168}
0 commit comments