Skip to content

Commit cd621be

Browse files
committed
Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
1 parent 20f2958 commit cd621be

File tree

10 files changed

+73
-38
lines changed

10 files changed

+73
-38
lines changed

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ pub struct RegisterConflict<'a> {
277277
pub struct SubTupleBinding<'a> {
278278
#[primary_span]
279279
#[label]
280-
#[suggestion_verbose(
280+
#[suggestion(
281281
ast_lowering_sub_tuple_binding_suggestion,
282+
style = "verbose",
282283
code = "..",
283284
applicability = "maybe-incorrect"
284285
)]

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) struct GenericDoesNotLiveLongEnough {
4949
#[derive(LintDiagnostic)]
5050
#[diag(borrowck_var_does_not_need_mut)]
5151
pub(crate) struct VarNeedNotMut {
52-
#[suggestion_short(applicability = "machine-applicable", code = "")]
52+
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
5353
pub span: Span,
5454
}
5555
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
120120
#[primary_span]
121121
#[label]
122122
pub span: Span,
123-
#[suggestion_verbose(code = "{ty}")]
123+
#[suggestion(style = "verbose", code = "{ty}")]
124124
pub opt_sugg: Option<(Span, Applicability)>,
125125
}
126126

@@ -237,7 +237,11 @@ pub struct UnusedExternCrate {
237237
#[derive(LintDiagnostic)]
238238
#[diag(hir_analysis_extern_crate_not_idiomatic)]
239239
pub struct ExternCrateNotIdiomatic {
240-
#[suggestion_short(applicability = "machine-applicable", code = "{suggestion_code}")]
240+
#[suggestion(
241+
style = "short",
242+
applicability = "machine-applicable",
243+
code = "{suggestion_code}"
244+
)]
241245
pub span: Span,
242246
pub msg_code: String,
243247
pub suggestion_code: String,

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ pub struct MissingParentheseInRange {
113113
}
114114

115115
#[derive(Subdiagnostic)]
116-
#[multipart_suggestion_verbose(
116+
#[multipart_suggestion(
117117
hir_analysis_add_missing_parentheses_in_range,
118+
style = "verbose",
118119
applicability = "maybe-incorrect"
119120
)]
120121
pub struct AddMissingParenthesesInRange {

compiler/rustc_infer/src/errors/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ pub struct InferenceBadError<'a> {
109109

110110
#[derive(Subdiagnostic)]
111111
pub enum SourceKindSubdiag<'a> {
112-
#[suggestion_verbose(
112+
#[suggestion(
113113
infer_source_kind_subdiag_let,
114+
style = "verbose",
114115
code = ": {type_name}",
115116
applicability = "has-placeholders"
116117
)]
@@ -135,8 +136,9 @@ pub enum SourceKindSubdiag<'a> {
135136
parent_prefix: String,
136137
parent_name: String,
137138
},
138-
#[suggestion_verbose(
139+
#[suggestion(
139140
infer_source_kind_subdiag_generic_suggestion,
141+
style = "verbose",
140142
code = "::<{args}>",
141143
applicability = "has-placeholders"
142144
)]
@@ -150,8 +152,9 @@ pub enum SourceKindSubdiag<'a> {
150152

151153
#[derive(Subdiagnostic)]
152154
pub enum SourceKindMultiSuggestion<'a> {
153-
#[multipart_suggestion_verbose(
155+
#[multipart_suggestion(
154156
infer_source_kind_fully_qualified,
157+
style = "verbose",
155158
applicability = "has-placeholders"
156159
)]
157160
FullyQualified {
@@ -163,8 +166,9 @@ pub enum SourceKindMultiSuggestion<'a> {
163166
adjustment: &'a str,
164167
successor_pos: &'a str,
165168
},
166-
#[multipart_suggestion_verbose(
169+
#[multipart_suggestion(
167170
infer_source_kind_closure_return,
171+
style = "verbose",
168172
applicability = "has-placeholders"
169173
)]
170174
ClosureReturn {
@@ -478,8 +482,9 @@ pub enum ImplicitStaticLifetimeSubdiag {
478482
#[primary_span]
479483
span: Span,
480484
},
481-
#[suggestion_verbose(
485+
#[suggestion(
482486
infer_implicit_static_lifetime_suggestion,
487+
style = "verbose",
483488
code = " + '_",
484489
applicability = "maybe-incorrect"
485490
)]

compiler/rustc_lint/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct UnknownToolInScopedLint {
8383
pub struct BuiltinEllpisisInclusiveRangePatterns {
8484
#[primary_span]
8585
pub span: Span,
86-
#[suggestion_short(code = "{replace}", applicability = "machine-applicable")]
86+
#[suggestion(style = "short", code = "{replace}", applicability = "machine-applicable")]
8787
pub suggestion: Span,
8888
pub replace: String,
8989
}

compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ struct OpaqueHiddenInferredBoundLint<'tcx> {
150150
}
151151

152152
#[derive(Subdiagnostic)]
153-
#[suggestion_verbose(
153+
#[suggestion(
154154
lint_opaque_hidden_inferred_bound_sugg,
155+
style = "verbose",
155156
applicability = "machine-applicable",
156157
code = " + {trait_ref}"
157158
)]

compiler/rustc_macros/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
129129
/// }
130130
///
131131
/// #[derive(Subdiagnostic)]
132-
/// #[suggestion_verbose(parser::raw_identifier)]
132+
/// #[suggestion(style = "verbose",parser::raw_identifier)]
133133
/// pub struct RawIdentifierSuggestion<'tcx> {
134134
/// #[primary_span]
135135
/// span: Span,

compiler/rustc_parse/src/errors.rs

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) struct BadQPathStage2 {
6464
#[diag(parser_incorrect_semicolon)]
6565
pub(crate) struct IncorrectSemicolon<'a> {
6666
#[primary_span]
67-
#[suggestion_short(code = "", applicability = "machine-applicable")]
67+
#[suggestion(style = "short", code = "", applicability = "machine-applicable")]
6868
pub span: Span,
6969
#[help]
7070
pub opt_help: Option<()>,
@@ -136,7 +136,12 @@ pub(crate) struct InvalidComparisonOperator {
136136

137137
#[derive(Subdiagnostic)]
138138
pub(crate) enum InvalidComparisonOperatorSub {
139-
#[suggestion_short(use_instead, applicability = "machine-applicable", code = "{correct}")]
139+
#[suggestion(
140+
use_instead,
141+
style = "short",
142+
applicability = "machine-applicable",
143+
code = "{correct}"
144+
)]
140145
Correctable {
141146
#[primary_span]
142147
span: Span,
@@ -160,14 +165,16 @@ pub(crate) struct InvalidLogicalOperator {
160165

161166
#[derive(Subdiagnostic)]
162167
pub(crate) enum InvalidLogicalOperatorSub {
163-
#[suggestion_short(
168+
#[suggestion(
164169
use_amp_amp_for_conjunction,
170+
style = "short",
165171
applicability = "machine-applicable",
166172
code = "&&"
167173
)]
168174
Conjunction(#[primary_span] Span),
169-
#[suggestion_short(
175+
#[suggestion(
170176
use_pipe_pipe_for_disjunction,
177+
style = "short",
171178
applicability = "machine-applicable",
172179
code = "||"
173180
)]
@@ -178,7 +185,7 @@ pub(crate) enum InvalidLogicalOperatorSub {
178185
#[diag(parser_tilde_is_not_unary_operator)]
179186
pub(crate) struct TildeAsUnaryOperator(
180187
#[primary_span]
181-
#[suggestion_short(applicability = "machine-applicable", code = "!")]
188+
#[suggestion(style = "short", applicability = "machine-applicable", code = "!")]
182189
pub Span,
183190
);
184191

@@ -194,22 +201,25 @@ pub(crate) struct NotAsNegationOperator {
194201

195202
#[derive(Subdiagnostic)]
196203
pub enum NotAsNegationOperatorSub {
197-
#[suggestion_short(
204+
#[suggestion(
198205
parser_unexpected_token_after_not_default,
206+
style = "short",
199207
applicability = "machine-applicable",
200208
code = "!"
201209
)]
202210
SuggestNotDefault(#[primary_span] Span),
203211

204-
#[suggestion_short(
212+
#[suggestion(
205213
parser_unexpected_token_after_not_bitwise,
214+
style = "short",
206215
applicability = "machine-applicable",
207216
code = "!"
208217
)]
209218
SuggestNotBitwise(#[primary_span] Span),
210219

211-
#[suggestion_short(
220+
#[suggestion(
212221
parser_unexpected_token_after_not_logical,
222+
style = "short",
213223
applicability = "machine-applicable",
214224
code = "!"
215225
)]
@@ -249,7 +259,7 @@ pub(crate) struct UnexpectedTokenAfterLabel {
249259
#[primary_span]
250260
#[label(parser_unexpected_token_after_label)]
251261
pub span: Span,
252-
#[suggestion_verbose(suggestion_remove_label, code = "")]
262+
#[suggestion(suggestion_remove_label, style = "verbose", code = "")]
253263
pub remove_label: Option<Span>,
254264
#[subdiagnostic]
255265
pub enclose_in_block: Option<UnexpectedTokenAfterLabelSugg>,
@@ -272,7 +282,7 @@ pub(crate) struct RequireColonAfterLabeledExpression {
272282
pub span: Span,
273283
#[label]
274284
pub label: Span,
275-
#[suggestion_short(applicability = "machine-applicable", code = ": ")]
285+
#[suggestion(style = "short", applicability = "machine-applicable", code = ": ")]
276286
pub label_end: Span,
277287
}
278288

@@ -354,7 +364,7 @@ pub(crate) struct IntLiteralTooLarge {
354364
pub(crate) struct MissingSemicolonBeforeArray {
355365
#[primary_span]
356366
pub open_delim: Span,
357-
#[suggestion_verbose(applicability = "maybe-incorrect", code = ";")]
367+
#[suggestion(style = "verbose", applicability = "maybe-incorrect", code = ";")]
358368
pub semicolon: Span,
359369
}
360370

@@ -442,9 +452,9 @@ pub(crate) struct MissingInInForLoop {
442452
#[derive(Subdiagnostic)]
443453
pub(crate) enum MissingInInForLoopSub {
444454
// Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect
445-
#[suggestion_short(use_in_not_of, applicability = "maybe-incorrect", code = "in")]
455+
#[suggestion(use_in_not_of, style = "short", applicability = "maybe-incorrect", code = "in")]
446456
InNotOf(#[primary_span] Span),
447-
#[suggestion_short(add_in, applicability = "maybe-incorrect", code = " in ")]
457+
#[suggestion(add_in, style = "short", applicability = "maybe-incorrect", code = " in ")]
448458
AddIn(#[primary_span] Span),
449459
}
450460

@@ -470,7 +480,7 @@ pub(crate) struct CatchAfterTry {
470480
pub(crate) struct CommaAfterBaseStruct {
471481
#[primary_span]
472482
pub span: Span,
473-
#[suggestion_short(applicability = "machine-applicable", code = "")]
483+
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
474484
pub comma: Span,
475485
}
476486

@@ -512,15 +522,15 @@ pub(crate) struct RemoveLet {
512522
#[diag(parser_use_eq_instead)]
513523
pub(crate) struct UseEqInstead {
514524
#[primary_span]
515-
#[suggestion_short(applicability = "machine-applicable", code = "=")]
525+
#[suggestion(style = "short", applicability = "machine-applicable", code = "=")]
516526
pub span: Span,
517527
}
518528

519529
#[derive(Diagnostic)]
520530
#[diag(parser_use_empty_block_not_semi)]
521531
pub(crate) struct UseEmptyBlockNotSemi {
522532
#[primary_span]
523-
#[suggestion_hidden(applicability = "machine-applicable", code = "{{}}")]
533+
#[suggestion(style = "hidden", applicability = "machine-applicable", code = "{{}}")]
524534
pub span: Span,
525535
}
526536

@@ -576,7 +586,12 @@ pub(crate) struct LeadingPlusNotSupported {
576586
#[primary_span]
577587
#[label]
578588
pub span: Span,
579-
#[suggestion_verbose(suggestion_remove_plus, code = "", applicability = "machine-applicable")]
589+
#[suggestion(
590+
suggestion_remove_plus,
591+
style = "verbose",
592+
code = "",
593+
applicability = "machine-applicable"
594+
)]
580595
pub remove_plus: Option<Span>,
581596
#[subdiagnostic]
582597
pub add_parentheses: Option<ExprParenthesesNeeded>,
@@ -843,7 +858,7 @@ pub(crate) struct InvalidCurlyInLetElse {
843858
#[help]
844859
pub(crate) struct CompoundAssignmentExpressionInLet {
845860
#[primary_span]
846-
#[suggestion_short(code = "=", applicability = "maybe-incorrect")]
861+
#[suggestion(style = "short", code = "=", applicability = "maybe-incorrect")]
847862
pub span: Span,
848863
}
849864

@@ -864,8 +879,9 @@ pub(crate) struct InvalidMetaItem {
864879
}
865880

866881
#[derive(Subdiagnostic)]
867-
#[suggestion_verbose(
882+
#[suggestion(
868883
parser_sugg_escape_to_use_as_identifier,
884+
style = "verbose",
869885
applicability = "maybe-incorrect",
870886
code = "r#"
871887
)]
@@ -1003,7 +1019,12 @@ pub(crate) enum ExpectedSemiSugg {
10031019
applicability = "machine-applicable"
10041020
)]
10051021
ChangeToSemi(#[primary_span] Span),
1006-
#[suggestion_short(parser_sugg_add_semi, code = ";", applicability = "machine-applicable")]
1022+
#[suggestion(
1023+
parser_sugg_add_semi,
1024+
style = "short",
1025+
code = ";",
1026+
applicability = "machine-applicable"
1027+
)]
10071028
AddSemi(#[primary_span] Span),
10081029
}
10091030

@@ -1057,8 +1078,9 @@ pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
10571078
pub(crate) struct ComparisonOperatorsCannotBeChained {
10581079
#[primary_span]
10591080
pub span: Vec<Span>,
1060-
#[suggestion_verbose(
1081+
#[suggestion(
10611082
parser_sugg_turbofish_syntax,
1083+
style = "verbose",
10621084
code = "::",
10631085
applicability = "maybe-incorrect"
10641086
)]
@@ -1072,8 +1094,9 @@ pub(crate) struct ComparisonOperatorsCannotBeChained {
10721094

10731095
#[derive(Subdiagnostic)]
10741096
pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
1075-
#[suggestion_verbose(
1097+
#[suggestion(
10761098
sugg_split_comparison,
1099+
style = "verbose",
10771100
code = " && {middle_term}",
10781101
applicability = "maybe-incorrect"
10791102
)]
@@ -1215,15 +1238,15 @@ pub(crate) enum UnexpectedConstParamDeclarationSugg {
12151238
pub(crate) struct UnexpectedConstInGenericParam {
12161239
#[primary_span]
12171240
pub span: Span,
1218-
#[suggestion_verbose(code = "", applicability = "maybe-incorrect")]
1241+
#[suggestion(style = "verbose", code = "", applicability = "maybe-incorrect")]
12191242
pub to_remove: Option<Span>,
12201243
}
12211244

12221245
#[derive(Diagnostic)]
12231246
#[diag(parser_async_move_order_incorrect)]
12241247
pub(crate) struct AsyncMoveOrderIncorrect {
12251248
#[primary_span]
1226-
#[suggestion_verbose(code = "async move", applicability = "maybe-incorrect")]
1249+
#[suggestion(style = "verbose", code = "async move", applicability = "maybe-incorrect")]
12271250
pub span: Span,
12281251
}
12291252

compiler/rustc_passes/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub struct DocTestUnknownAny {
291291
#[note(no_op_note)]
292292
pub struct DocTestUnknownSpotlight {
293293
pub path: String,
294-
#[suggestion_short(applicability = "machine-applicable", code = "notable_trait")]
294+
#[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
295295
pub span: Span,
296296
}
297297

0 commit comments

Comments
 (0)