Skip to content

Commit d3725c2

Browse files
authored
Rollup merge of #100959 - LuisCardosoOliveira:translation-rename-attr-warning, r=davidtwco
translations: rename warn_ to warning ## Description This MR renames the the macro `warn_` to `warning`. To give a little bit of context, as [explained](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20diag.20translation/near/295074146) by ``@davidtwco`` in the Zulip channel, `warn_` was named like that because the keyword `warn` is a built-in attribute and at the time this macro was created the word `warning` was also taken. However, it is no longer the case and we can rename `warn_` to `warning`.
2 parents 1e2f33c + b508b50 commit d3725c2

File tree

7 files changed

+52
-50
lines changed

7 files changed

+52
-50
lines changed

compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ impl DiagnosticDeriveBuilder {
148148
// `#[help(..)]`/`#[note(..)]` when the user is specifying a alternative slug.
149149
Meta::List(MetaList { ref nested, .. }) => nested,
150150
// Subdiagnostics without spans can be applied to the type too, and these are just
151-
// paths: `#[help]`, `#[note]` and `#[warn_]`
151+
// paths: `#[help]`, `#[note]` and `#[warning]`
152152
Meta::Path(_) if !is_diag => {
153-
let fn_name = if name == "warn_" {
153+
let fn_name = if name == "warning" {
154154
Ident::new("warn", attr.span())
155155
} else {
156156
Ident::new(name, attr.span())
@@ -163,12 +163,15 @@ impl DiagnosticDeriveBuilder {
163163
// Check the kind before doing any further processing so that there aren't misleading
164164
// "no kind specified" errors if there are failures later.
165165
match name {
166-
"error" | "warning" | "lint" => throw_invalid_attr!(attr, &meta, |diag| {
167-
diag.help("`error`, `warning` and `lint` have been replaced by `diag`")
166+
"error" | "lint" => throw_invalid_attr!(attr, &meta, |diag| {
167+
diag.help("`error` and `lint` have been replaced by `diag`")
168168
}),
169-
"diag" | "help" | "note" | "warn_" => (),
169+
"warn_" => throw_invalid_attr!(attr, &meta, |diag| {
170+
diag.help("`warn_` have been replaced by `warning`")
171+
}),
172+
"diag" | "help" | "note" | "warning" => (),
170173
_ => throw_invalid_attr!(attr, &meta, |diag| {
171-
diag.help("only `diag`, `help`, `note` and `warn_` are valid attributes")
174+
diag.help("only `diag`, `help`, `note` and `warning` are valid attributes")
172175
}),
173176
}
174177

@@ -180,7 +183,7 @@ impl DiagnosticDeriveBuilder {
180183
if !is_diag && nested_iter.next().is_some() {
181184
throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
182185
diag.help(
183-
"`help`, `note` and `warn_` struct attributes can only have one argument",
186+
"`help`, `note` and `warning` struct attributes can only have one argument",
184187
)
185188
});
186189
}
@@ -348,12 +351,12 @@ impl DiagnosticDeriveBuilder {
348351
report_error_if_not_applied_to_span(attr, &info)?;
349352
Ok(self.add_spanned_subdiagnostic(binding, ident, parse_quote! { _subdiag::label }))
350353
}
351-
"note" | "help" | "warn_" => {
354+
"note" | "help" | "warning" => {
352355
let warn_ident = Ident::new("warn", Span::call_site());
353356
let (ident, path) = match name {
354357
"note" => (ident, parse_quote! { _subdiag::note }),
355358
"help" => (ident, parse_quote! { _subdiag::help }),
356-
"warn_" => (&warn_ident, parse_quote! { _subdiag::warn }),
359+
"warning" => (&warn_ident, parse_quote! { _subdiag::warn }),
357360
_ => unreachable!(),
358361
};
359362
if type_matches_path(&info.ty, &["rustc_span", "Span"]) {
@@ -390,7 +393,7 @@ impl DiagnosticDeriveBuilder {
390393
"suggestion" | "suggestion_short" | "suggestion_hidden" | "suggestion_verbose" => {
391394
return self.generate_inner_field_code_suggestion(attr, info);
392395
}
393-
"label" | "help" | "note" | "warn_" => (),
396+
"label" | "help" | "note" | "warning" => (),
394397
_ => throw_invalid_attr!(attr, &meta, |diag| {
395398
diag.help(
396399
"only `label`, `help`, `note`, `warn` or `suggestion{,_short,_hidden,_verbose}` are \
@@ -422,14 +425,14 @@ impl DiagnosticDeriveBuilder {
422425
Ok(self.add_spanned_subdiagnostic(binding, ident, msg))
423426
}
424427
"note" | "help" if type_is_unit(&info.ty) => Ok(self.add_subdiagnostic(ident, msg)),
425-
// `warn_` must be special-cased because the attribute `warn` already has meaning and
428+
// `warning` must be special-cased because the attribute `warn` already has meaning and
426429
// so isn't used, despite the diagnostic API being named `warn`.
427-
"warn_" if type_matches_path(&info.ty, &["rustc_span", "Span"]) => Ok(self
430+
"warning" if type_matches_path(&info.ty, &["rustc_span", "Span"]) => Ok(self
428431
.add_spanned_subdiagnostic(binding, &Ident::new("warn", Span::call_site()), msg)),
429-
"warn_" if type_is_unit(&info.ty) => {
432+
"warning" if type_is_unit(&info.ty) => {
430433
Ok(self.add_subdiagnostic(&Ident::new("warn", Span::call_site()), msg))
431434
}
432-
"note" | "help" | "warn_" => report_type_error(attr, "`Span` or `()`")?,
435+
"note" | "help" | "warning" => report_type_error(attr, "`Span` or `()`")?,
433436
_ => unreachable!(),
434437
}
435438
}

compiler/rustc_macros/src/diagnostics/subdiagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum SubdiagnosticKind {
3737
Note,
3838
/// `#[help(...)]`
3939
Help,
40-
/// `#[warn_(...)]`
40+
/// `#[warning(...)]`
4141
Warn,
4242
/// `#[suggestion{,_short,_hidden,_verbose}]`
4343
Suggestion(SubdiagnosticSuggestionKind),
@@ -51,7 +51,7 @@ impl FromStr for SubdiagnosticKind {
5151
"label" => Ok(SubdiagnosticKind::Label),
5252
"note" => Ok(SubdiagnosticKind::Note),
5353
"help" => Ok(SubdiagnosticKind::Help),
54-
"warn_" => Ok(SubdiagnosticKind::Warn),
54+
"warning" => Ok(SubdiagnosticKind::Warn),
5555
"suggestion" => Ok(SubdiagnosticKind::Suggestion(SubdiagnosticSuggestionKind::Normal)),
5656
"suggestion_short" => {
5757
Ok(SubdiagnosticKind::Suggestion(SubdiagnosticSuggestionKind::Short))

compiler/rustc_macros/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ decl_derive!(
132132
diag,
133133
help,
134134
note,
135-
warn_,
135+
warning,
136136
// field attributes
137137
skip_arg,
138138
primary_span,
@@ -149,7 +149,7 @@ decl_derive!(
149149
diag,
150150
help,
151151
note,
152-
warn_,
152+
warning,
153153
// field attributes
154154
skip_arg,
155155
primary_span,
@@ -166,7 +166,7 @@ decl_derive!(
166166
label,
167167
help,
168168
note,
169-
warn_,
169+
warning,
170170
suggestion,
171171
suggestion_short,
172172
suggestion_hidden,

compiler/rustc_passes/src/errors.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct IgnoredInlineAttrFnProto;
2828

2929
#[derive(LintDiagnostic)]
3030
#[diag(passes::inline_ignored_constants)]
31-
#[warn_]
31+
#[warning]
3232
#[note]
3333
pub struct IgnoredInlineAttrConstants;
3434

@@ -347,23 +347,23 @@ pub struct MustNotSuspend {
347347

348348
#[derive(LintDiagnostic)]
349349
#[diag(passes::cold)]
350-
#[warn_]
350+
#[warning]
351351
pub struct Cold {
352352
#[label]
353353
pub span: Span,
354354
}
355355

356356
#[derive(LintDiagnostic)]
357357
#[diag(passes::link)]
358-
#[warn_]
358+
#[warning]
359359
pub struct Link {
360360
#[label]
361361
pub span: Option<Span>,
362362
}
363363

364364
#[derive(LintDiagnostic)]
365365
#[diag(passes::link_name)]
366-
#[warn_]
366+
#[warning]
367367
pub struct LinkName<'a> {
368368
#[help]
369369
pub attr_span: Option<Span>,
@@ -449,15 +449,15 @@ pub struct RustcDirtyClean {
449449

450450
#[derive(LintDiagnostic)]
451451
#[diag(passes::link_section)]
452-
#[warn_]
452+
#[warning]
453453
pub struct LinkSection {
454454
#[label]
455455
pub span: Span,
456456
}
457457

458458
#[derive(LintDiagnostic)]
459459
#[diag(passes::no_mangle_foreign)]
460-
#[warn_]
460+
#[warning]
461461
#[note]
462462
pub struct NoMangleForeign {
463463
#[label]
@@ -469,7 +469,7 @@ pub struct NoMangleForeign {
469469

470470
#[derive(LintDiagnostic)]
471471
#[diag(passes::no_mangle)]
472-
#[warn_]
472+
#[warning]
473473
pub struct NoMangle {
474474
#[label]
475475
pub span: Span,
@@ -617,7 +617,7 @@ pub struct UnusedDuplicate {
617617
pub this: Span,
618618
#[note]
619619
pub other: Span,
620-
#[warn_]
620+
#[warning]
621621
pub warning: Option<()>,
622622
}
623623

src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ struct ErrorWithMultiSpan {
549549

550550
#[derive(SessionDiagnostic)]
551551
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
552-
#[warn_]
552+
#[warning]
553553
struct ErrorWithWarn {
554554
val: String,
555555
}
@@ -562,11 +562,11 @@ struct ErrorWithWarn {
562562
struct ErrorAttribute {}
563563

564564
#[derive(SessionDiagnostic)]
565-
#[warning(typeck::ambiguous_lifetime_bound, code = "E0123")]
566-
//~^ ERROR `#[warning(...)]` is not a valid attribute
565+
#[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
566+
//~^ ERROR `#[warn_(...)]` is not a valid attribute
567567
//~| ERROR diagnostic slug not specified
568-
//~| ERROR cannot find attribute `warning` in this scope
569-
struct WarningAttribute {}
568+
//~| ERROR cannot find attribute `warn_` in this scope
569+
struct WarnAttribute {}
570570

571571
#[derive(SessionDiagnostic)]
572572
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]

src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ error: `#[nonsense(...)]` is not a valid attribute
2121
LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= help: only `diag`, `help`, `note` and `warn_` are valid attributes
24+
= help: only `diag`, `help`, `note` and `warning` are valid attributes
2525

2626
error: diagnostic slug not specified
2727
--> $DIR/diagnostic-derive.rs:53:1
@@ -329,7 +329,7 @@ error: `#[error(...)]` is not a valid attribute
329329
LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
330330
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
331331
|
332-
= help: `error`, `warning` and `lint` have been replaced by `diag`
332+
= help: `error` and `lint` have been replaced by `diag`
333333

334334
error: diagnostic slug not specified
335335
--> $DIR/diagnostic-derive.rs:558:1
@@ -343,23 +343,23 @@ LL | | struct ErrorAttribute {}
343343
|
344344
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
345345

346-
error: `#[warning(...)]` is not a valid attribute
346+
error: `#[warn_(...)]` is not a valid attribute
347347
--> $DIR/diagnostic-derive.rs:565:1
348348
|
349-
LL | #[warning(typeck::ambiguous_lifetime_bound, code = "E0123")]
350-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349+
LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
350+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
351351
|
352-
= help: `error`, `warning` and `lint` have been replaced by `diag`
352+
= help: `warn_` have been replaced by `warning`
353353

354354
error: diagnostic slug not specified
355355
--> $DIR/diagnostic-derive.rs:565:1
356356
|
357-
LL | / #[warning(typeck::ambiguous_lifetime_bound, code = "E0123")]
357+
LL | / #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
358358
LL | |
359359
LL | |
360360
LL | |
361-
LL | | struct WarningAttribute {}
362-
| |__________________________^
361+
LL | | struct WarnAttribute {}
362+
| |_______________________^
363363
|
364364
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
365365

@@ -369,7 +369,7 @@ error: `#[lint(...)]` is not a valid attribute
369369
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
370370
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
371371
|
372-
= help: `error`, `warning` and `lint` have been replaced by `diag`
372+
= help: `error` and `lint` have been replaced by `diag`
373373

374374
error: diagnostic slug not specified
375375
--> $DIR/diagnostic-derive.rs:572:1
@@ -389,7 +389,7 @@ error: `#[lint(...)]` is not a valid attribute
389389
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
390390
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
391391
|
392-
= help: `error`, `warning` and `lint` have been replaced by `diag`
392+
= help: `error` and `lint` have been replaced by `diag`
393393

394394
error: diagnostic slug not specified
395395
--> $DIR/diagnostic-derive.rs:579:1
@@ -421,11 +421,11 @@ error: cannot find attribute `error` in this scope
421421
LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
422422
| ^^^^^
423423

424-
error: cannot find attribute `warning` in this scope
424+
error: cannot find attribute `warn_` in this scope
425425
--> $DIR/diagnostic-derive.rs:565:3
426426
|
427-
LL | #[warning(typeck::ambiguous_lifetime_bound, code = "E0123")]
428-
| ^^^^^^^
427+
LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
428+
| ^^^^^ help: a built-in attribute with a similar name exists: `warn`
429429

430430
error: cannot find attribute `lint` in this scope
431431
--> $DIR/diagnostic-derive.rs:572:3

src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,11 @@ enum AX {
510510
}
511511

512512
#[derive(SessionSubdiagnostic)]
513-
#[warn_(parser::add_paren)]
514-
struct AY {
515-
}
513+
#[warning(parser::add_paren)]
514+
struct AY {}
516515

517516
#[derive(SessionSubdiagnostic)]
518-
#[warn_(parser::add_paren)]
517+
#[warning(parser::add_paren)]
519518
struct AZ {
520519
#[primary_span]
521520
span: Span,

0 commit comments

Comments
 (0)