diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2022-08-19 15:40:48 +0200 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2022-08-21 09:17:43 +0200 |
| commit | 7f3a6fd7f6c04635f3d541201199f127f2a2e65e (patch) | |
| tree | 4b9be1a4a7d5610f9ad2b58054724d900de1ee42 /compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | |
| parent | bd0d3f745d40c9de9c5dbc24dc7f8fb64ceb5575 (diff) | |
| download | rust-7f3a6fd7f6c04635f3d541201199f127f2a2e65e.tar.gz rust-7f3a6fd7f6c04635f3d541201199f127f2a2e65e.zip | |
Replace #[lint/warning/error] with #[diag]
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs index 31ea6bb779e..9df9fa4e9bf 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs @@ -141,7 +141,7 @@ impl DiagnosticDeriveBuilder { let name = name.as_str(); let meta = attr.parse_meta()?; - let is_diag = matches!(name, "error" | "warning" | "lint" | "diag"); + let is_diag = name == "diag"; let nested = match meta { // Most attributes are lists, like `#[diag(..)]` for most cases or @@ -163,20 +163,9 @@ impl DiagnosticDeriveBuilder { // Check the kind before doing any further processing so that there aren't misleading // "no kind specified" errors if there are failures later. match name { - "error" | "warning" => { - if self.kind == DiagnosticDeriveKind::LintDiagnostic { - span_err(span, "only `#[lint(..)]` is supported") - .help("use the `#[lint(...)]` attribute to create a lint") - .emit(); - } - } - "lint" => { - if self.kind == DiagnosticDeriveKind::SessionDiagnostic { - span_err(span, "only `#[error(..)]` and `#[warning(..)]` are supported") - .help("use the `#[error(...)]` attribute to create a error") - .emit(); - } - } + "error" | "warning" | "lint" => throw_invalid_attr!(attr, &meta, |diag| { + diag.help("`error`, `warning` and `lint` have been replaced by `diag`") + }), "diag" | "help" | "note" | "warn_" => (), _ => throw_invalid_attr!(attr, &meta, |diag| { diag.help("only `diag`, `help`, `note` and `warn_` are valid attributes") |
