Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0af7fa2

Browse files
committedFeb 28, 2025
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: rust-lang#127282. CC rust-lang/rust-playground#1117
1 parent f45d4ac commit 0af7fa2

File tree

114 files changed

+1585
-517
lines changed

Some content is hidden

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

114 files changed

+1585
-517
lines changed
 

‎compiler/rustc_ast_passes/src/errors.rs

+47-23
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,
@@ -536,7 +551,12 @@ pub(crate) struct WhereClauseBeforeTypeAlias {
536551

537552
#[derive(Subdiagnostic)]
538553
pub(crate) enum WhereClauseBeforeTypeAliasSugg {
539-
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
554+
#[suggestion(
555+
ast_passes_remove_suggestion,
556+
applicability = "machine-applicable",
557+
code = "",
558+
style = "verbose"
559+
)]
540560
Remove {
541561
#[primary_span]
542562
span: Span,
@@ -720,7 +740,11 @@ pub(crate) struct AssociatedSuggestion {
720740
}
721741

722742
#[derive(Subdiagnostic)]
723-
#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
743+
#[multipart_suggestion(
744+
ast_passes_suggestion_path,
745+
applicability = "maybe-incorrect",
746+
style = "verbose"
747+
)]
724748
pub(crate) struct AssociatedSuggestion2 {
725749
#[suggestion_part(code = "{args}")]
726750
pub span: Span,
@@ -739,7 +763,7 @@ pub(crate) struct FeatureOnNonNightly {
739763
pub channel: &'static str,
740764
#[subdiagnostic]
741765
pub stable_features: Vec<StableFeature>,
742-
#[suggestion(code = "", applicability = "machine-applicable")]
766+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
743767
pub sugg: Option<Span>,
744768
}
745769

‎compiler/rustc_builtin_macros/src/errors.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) struct AssertRequiresBoolean {
4141
pub(crate) struct AssertRequiresExpression {
4242
#[primary_span]
4343
pub(crate) span: Span,
44-
#[suggestion(code = "", applicability = "maybe-incorrect")]
44+
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
4545
pub(crate) token: Span,
4646
}
4747

@@ -231,7 +231,8 @@ pub(crate) enum ConcatBytesInvalidSuggestion {
231231
#[suggestion(
232232
builtin_macros_byte_char,
233233
code = "b{snippet}",
234-
applicability = "machine-applicable"
234+
applicability = "machine-applicable",
235+
style = "verbose"
235236
)]
236237
CharLit {
237238
#[primary_span]
@@ -241,7 +242,8 @@ pub(crate) enum ConcatBytesInvalidSuggestion {
241242
#[suggestion(
242243
builtin_macros_byte_str,
243244
code = "b{snippet}",
244-
applicability = "machine-applicable"
245+
applicability = "machine-applicable",
246+
style = "verbose"
245247
)]
246248
StrLit {
247249
#[primary_span]
@@ -251,7 +253,8 @@ pub(crate) enum ConcatBytesInvalidSuggestion {
251253
#[suggestion(
252254
builtin_macros_number_array,
253255
code = "[{snippet}]",
254-
applicability = "machine-applicable"
256+
applicability = "machine-applicable",
257+
style = "verbose"
255258
)]
256259
IntLit {
257260
#[primary_span]
@@ -355,15 +358,15 @@ pub(crate) enum BadDeriveLitHelp {
355358
#[derive(Diagnostic)]
356359
#[diag(builtin_macros_derive_path_args_list)]
357360
pub(crate) struct DerivePathArgsList {
358-
#[suggestion(code = "", applicability = "machine-applicable")]
361+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
359362
#[primary_span]
360363
pub(crate) span: Span,
361364
}
362365

363366
#[derive(Diagnostic)]
364367
#[diag(builtin_macros_derive_path_args_value)]
365368
pub(crate) struct DerivePathArgsValue {
366-
#[suggestion(code = "", applicability = "machine-applicable")]
369+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
367370
#[primary_span]
368371
pub(crate) span: Span,
369372
}
@@ -380,7 +383,12 @@ pub(crate) struct NoDefaultVariant {
380383
}
381384

382385
#[derive(Subdiagnostic)]
383-
#[suggestion(builtin_macros_suggestion, code = "#[default] ", applicability = "maybe-incorrect")]
386+
#[suggestion(
387+
builtin_macros_suggestion,
388+
code = "#[default] ",
389+
applicability = "maybe-incorrect",
390+
style = "verbose"
391+
)]
384392
pub(crate) struct NoDefaultVariantSugg {
385393
#[primary_span]
386394
pub(crate) span: Span,
@@ -612,7 +620,8 @@ pub(crate) enum InvalidFormatStringSuggestion {
612620
#[suggestion(
613621
builtin_macros_format_remove_raw_ident,
614622
code = "",
615-
applicability = "machine-applicable"
623+
applicability = "machine-applicable",
624+
style = "verbose"
616625
)]
617626
RemoveRawIdent {
618627
#[primary_span]
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.