Skip to content

Commit b64979d

Browse files
committed
Make some suggestions "verbose"
The verbose "diff" suggestion format is easier to read, and the only one supported by annotate-snippets. Making verbose the default in one go would result in a huge PR that is too hard to land: #127282. CC rust-lang/rust-playground#1117
1 parent 28b83ee commit b64979d

File tree

116 files changed

+1675
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1675
-532
lines changed

compiler/rustc_ast_lowering/src/errors.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ pub(crate) struct GenericTypeWithParentheses {
1414
}
1515

1616
#[derive(Subdiagnostic)]
17-
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
17+
#[multipart_suggestion(
18+
ast_lowering_use_angle_brackets,
19+
applicability = "maybe-incorrect",
20+
style = "verbose"
21+
)]
1822
pub(crate) struct UseAngleBrackets {
1923
#[suggestion_part(code = "<")]
2024
pub open_param: Span,
@@ -47,7 +51,8 @@ pub(crate) struct TupleStructWithDefault {
4751
#[suggestion(
4852
ast_lowering_invalid_abi_suggestion,
4953
code = "{suggestion}",
50-
applicability = "maybe-incorrect"
54+
applicability = "maybe-incorrect",
55+
style = "verbose"
5156
)]
5257
pub(crate) struct InvalidAbiSuggestion {
5358
#[primary_span]
@@ -134,7 +139,7 @@ pub(crate) struct ClosureCannotBeStatic {
134139
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
135140
pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
136141
#[primary_span]
137-
#[suggestion(code = "", applicability = "machine-applicable")]
142+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
138143
pub span: Span,
139144
}
140145

@@ -335,7 +340,7 @@ pub(crate) struct MisplacedRelaxTraitBound {
335340
pub(crate) struct MatchArmWithNoBody {
336341
#[primary_span]
337342
pub span: Span,
338-
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
343+
#[suggestion(code = " => todo!(),", applicability = "has-placeholders", style = "verbose")]
339344
pub suggestion: Span,
340345
}
341346

@@ -344,15 +349,15 @@ pub(crate) struct MatchArmWithNoBody {
344349
pub(crate) struct NeverPatternWithBody {
345350
#[primary_span]
346351
#[label]
347-
#[suggestion(code = "", applicability = "maybe-incorrect")]
352+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
348353
pub span: Span,
349354
}
350355

351356
#[derive(Diagnostic)]
352357
#[diag(ast_lowering_never_pattern_with_guard)]
353358
pub(crate) struct NeverPatternWithGuard {
354359
#[primary_span]
355-
#[suggestion(code = "", applicability = "maybe-incorrect")]
360+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
356361
pub span: Span,
357362
}
358363

@@ -377,19 +382,19 @@ pub(crate) enum BadReturnTypeNotation {
377382
#[diag(ast_lowering_bad_return_type_notation_inputs)]
378383
Inputs {
379384
#[primary_span]
380-
#[suggestion(code = "()", applicability = "maybe-incorrect")]
385+
#[suggestion(code = "()", applicability = "maybe-incorrect", style = "verbose")]
381386
span: Span,
382387
},
383388
#[diag(ast_lowering_bad_return_type_notation_output)]
384389
Output {
385390
#[primary_span]
386-
#[suggestion(code = "", applicability = "maybe-incorrect")]
391+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
387392
span: Span,
388393
},
389394
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
390395
NeedsDots {
391396
#[primary_span]
392-
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
397+
#[suggestion(code = "(..)", applicability = "maybe-incorrect", style = "verbose")]
393398
span: Span,
394399
},
395400
#[diag(ast_lowering_bad_return_type_notation_position)]
@@ -457,7 +462,8 @@ pub(crate) struct InvalidLegacyConstGenericArg {
457462
#[derive(Subdiagnostic)]
458463
#[multipart_suggestion(
459464
ast_lowering_invalid_legacy_const_generic_arg_suggestion,
460-
applicability = "maybe-incorrect"
465+
applicability = "maybe-incorrect",
466+
style = "verbose"
461467
)]
462468
pub(crate) struct UseConstGenericArg {
463469
#[suggestion_part(code = "::<{const_args}>")]

compiler/rustc_ast_passes/src/errors.rs

+48-24
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub(crate) struct VisibilityNotPermitted {
1818
#[suggestion(
1919
ast_passes_remove_qualifier_sugg,
2020
code = "",
21-
applicability = "machine-applicable"
21+
applicability = "machine-applicable",
22+
style = "verbose"
2223
)]
2324
pub remove_qualifier_sugg: Span,
2425
}
@@ -44,19 +45,21 @@ pub(crate) struct TraitFnConst {
4445
pub in_impl: bool,
4546
#[label(ast_passes_const_context_label)]
4647
pub const_context_label: Option<Span>,
47-
#[suggestion(ast_passes_remove_const_sugg, code = "")]
48+
#[suggestion(ast_passes_remove_const_sugg, code = "", style = "verbose")]
4849
pub remove_const_sugg: (Span, Applicability),
4950
pub requires_multiple_changes: bool,
5051
#[suggestion(
5152
ast_passes_make_impl_const_sugg,
5253
code = "const ",
53-
applicability = "maybe-incorrect"
54+
applicability = "maybe-incorrect",
55+
style = "verbose"
5456
)]
5557
pub make_impl_const_sugg: Option<Span>,
5658
#[suggestion(
5759
ast_passes_make_trait_const_sugg,
5860
code = "#[const_trait]\n",
59-
applicability = "maybe-incorrect"
61+
applicability = "maybe-incorrect",
62+
style = "verbose"
6063
)]
6164
pub make_trait_const_sugg: Option<Span>,
6265
}
@@ -128,7 +131,7 @@ pub(crate) struct ForbiddenDefault {
128131
pub(crate) struct AssocConstWithoutBody {
129132
#[primary_span]
130133
pub span: Span,
131-
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
134+
#[suggestion(code = " = <expr>;", applicability = "has-placeholders", style = "verbose")]
132135
pub replace_span: Span,
133136
}
134137

@@ -137,7 +140,7 @@ pub(crate) struct AssocConstWithoutBody {
137140
pub(crate) struct AssocFnWithoutBody {
138141
#[primary_span]
139142
pub span: Span,
140-
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
143+
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders", style = "verbose")]
141144
pub replace_span: Span,
142145
}
143146

@@ -146,7 +149,7 @@ pub(crate) struct AssocFnWithoutBody {
146149
pub(crate) struct AssocTypeWithoutBody {
147150
#[primary_span]
148151
pub span: Span,
149-
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
152+
#[suggestion(code = " = <type>;", applicability = "has-placeholders", style = "verbose")]
150153
pub replace_span: Span,
151154
}
152155

@@ -155,7 +158,7 @@ pub(crate) struct AssocTypeWithoutBody {
155158
pub(crate) struct ConstWithoutBody {
156159
#[primary_span]
157160
pub span: Span,
158-
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
161+
#[suggestion(code = " = <expr>;", applicability = "has-placeholders", style = "verbose")]
159162
pub replace_span: Span,
160163
}
161164

@@ -164,7 +167,7 @@ pub(crate) struct ConstWithoutBody {
164167
pub(crate) struct StaticWithoutBody {
165168
#[primary_span]
166169
pub span: Span,
167-
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
170+
#[suggestion(code = " = <expr>;", applicability = "has-placeholders", style = "verbose")]
168171
pub replace_span: Span,
169172
}
170173

@@ -173,7 +176,7 @@ pub(crate) struct StaticWithoutBody {
173176
pub(crate) struct TyAliasWithoutBody {
174177
#[primary_span]
175178
pub span: Span,
176-
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
179+
#[suggestion(code = " = <type>;", applicability = "has-placeholders", style = "verbose")]
177180
pub replace_span: Span,
178181
}
179182

@@ -182,22 +185,30 @@ pub(crate) struct TyAliasWithoutBody {
182185
pub(crate) struct FnWithoutBody {
183186
#[primary_span]
184187
pub span: Span,
185-
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
188+
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders", style = "verbose")]
186189
pub replace_span: Span,
187190
#[subdiagnostic]
188191
pub extern_block_suggestion: Option<ExternBlockSuggestion>,
189192
}
190193

191194
#[derive(Subdiagnostic)]
192195
pub(crate) enum ExternBlockSuggestion {
193-
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
196+
#[multipart_suggestion(
197+
ast_passes_extern_block_suggestion,
198+
applicability = "maybe-incorrect",
199+
style = "verbose"
200+
)]
194201
Implicit {
195202
#[suggestion_part(code = "extern {{")]
196203
start_span: Span,
197204
#[suggestion_part(code = " }}")]
198205
end_span: Span,
199206
},
200-
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
207+
#[multipart_suggestion(
208+
ast_passes_extern_block_suggestion,
209+
applicability = "maybe-incorrect",
210+
style = "verbose"
211+
)]
201212
Explicit {
202213
#[suggestion_part(code = "extern \"{abi}\" {{")]
203214
start_span: Span,
@@ -250,7 +261,7 @@ pub(crate) struct BoundInContext<'a> {
250261
#[note(ast_passes_extern_keyword_link)]
251262
pub(crate) struct ExternTypesCannotHave<'a> {
252263
#[primary_span]
253-
#[suggestion(code = "", applicability = "maybe-incorrect")]
264+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
254265
pub span: Span,
255266
pub descr: &'a str,
256267
pub remove_descr: &'a str,
@@ -280,7 +291,7 @@ pub(crate) struct FnBodyInExtern {
280291
#[primary_span]
281292
#[label(ast_passes_cannot_have)]
282293
pub span: Span,
283-
#[suggestion(code = ";", applicability = "maybe-incorrect")]
294+
#[suggestion(code = ";", applicability = "maybe-incorrect", style = "verbose")]
284295
pub body: Span,
285296
#[label]
286297
pub block: Span,
@@ -290,7 +301,7 @@ pub(crate) struct FnBodyInExtern {
290301
#[diag(ast_passes_extern_fn_qualifiers)]
291302
pub(crate) struct FnQualifierInExtern {
292303
#[primary_span]
293-
#[suggestion(code = "", applicability = "maybe-incorrect")]
304+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
294305
pub span: Span,
295306
#[label]
296307
pub block: Span,
@@ -343,7 +354,7 @@ pub(crate) struct ModuleNonAscii {
343354
#[diag(ast_passes_auto_generic, code = E0567)]
344355
pub(crate) struct AutoTraitGeneric {
345356
#[primary_span]
346-
#[suggestion(code = "", applicability = "machine-applicable")]
357+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
347358
pub span: Span,
348359
#[label]
349360
pub ident: Span,
@@ -353,7 +364,7 @@ pub(crate) struct AutoTraitGeneric {
353364
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
354365
pub(crate) struct AutoTraitBounds {
355366
#[primary_span]
356-
#[suggestion(code = "", applicability = "machine-applicable")]
367+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
357368
pub span: Span,
358369
#[label]
359370
pub ident: Span,
@@ -364,7 +375,7 @@ pub(crate) struct AutoTraitBounds {
364375
pub(crate) struct AutoTraitItems {
365376
#[primary_span]
366377
pub spans: Vec<Span>,
367-
#[suggestion(code = "", applicability = "machine-applicable")]
378+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
368379
pub total: Span,
369380
#[label]
370381
pub ident: Span,
@@ -440,7 +451,11 @@ pub(crate) struct AtLeastOneTrait {
440451
pub(crate) struct OutOfOrderParams<'a> {
441452
#[primary_span]
442453
pub spans: Vec<Span>,
443-
#[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
454+
#[suggestion(
455+
code = "{ordered_params}",
456+
applicability = "machine-applicable",
457+
style = "verbose"
458+
)]
444459
pub sugg_span: Span,
445460
pub param_ord: &'a ParamKindOrd,
446461
pub max_param: &'a ParamKindOrd,
@@ -537,7 +552,12 @@ pub(crate) struct WhereClauseBeforeTypeAlias {
537552
#[derive(Subdiagnostic)]
538553

539554
pub(crate) enum WhereClauseBeforeTypeAliasSugg {
540-
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
555+
#[suggestion(
556+
ast_passes_remove_suggestion,
557+
applicability = "machine-applicable",
558+
code = "",
559+
style = "verbose"
560+
)]
541561
Remove {
542562
#[primary_span]
543563
span: Span,
@@ -721,7 +741,11 @@ pub(crate) struct AssociatedSuggestion {
721741
}
722742

723743
#[derive(Subdiagnostic)]
724-
#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
744+
#[multipart_suggestion(
745+
ast_passes_suggestion_path,
746+
applicability = "maybe-incorrect",
747+
style = "verbose"
748+
)]
725749
pub(crate) struct AssociatedSuggestion2 {
726750
#[suggestion_part(code = "{args}")]
727751
pub span: Span,
@@ -747,7 +771,7 @@ pub(crate) struct FeatureOnNonNightly {
747771
pub channel: &'static str,
748772
#[subdiagnostic]
749773
pub stable_features: Vec<StableFeature>,
750-
#[suggestion(code = "", applicability = "machine-applicable")]
774+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
751775
pub sugg: Option<Span>,
752776
}
753777

@@ -804,7 +828,7 @@ pub(crate) struct NegativeBoundWithParentheticalNotation {
804828
pub(crate) struct MatchArmWithNoBody {
805829
#[primary_span]
806830
pub span: Span,
807-
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
831+
#[suggestion(code = " => todo!(),", applicability = "has-placeholders", style = "verbose")]
808832
pub suggestion: Span,
809833
}
810834

0 commit comments

Comments
 (0)