Auto merge of #108402 - clubby789:diag-bool-not-unit, r=davidtwco

Allow using `bool` instead of `Option<()>` in diagnostics

~~Disallow the unit type for `#[help]`, `#[note]` etc, instead using `bool` to express optional annotations without a span which I believe is more intuitive.~~

~~Test output ordering has changed in a few places, where a field was of type `()` and the annotation has been moved to the struct itself. If any of these changes are an issue, this can be restricted to allowing specifically `()`, and not `Option<()>`~~

~~Actual changes here: https://github.com/rust-lang/rust/pull/108402/files#diff-815b1d8debfc564112bd51093791d7c3f2ee288a37a8f5c0e89c11d1f609b4c0~~

Allows using `bool` in derive diagnostics to indicate an optional subdiagnostic without a span, where previously `Option<()>` had to be used

`@rustbot` label +A-diagnostics
This commit is contained in:
bors 2023-03-06 13:00:32 +00:00
commit f63ccaf25f
4 changed files with 77 additions and 45 deletions

View File

@ -6,8 +6,8 @@ use crate::diagnostics::error::{
}; };
use crate::diagnostics::utils::{ use crate::diagnostics::utils::{
build_field_mapping, is_doc_comment, report_error_if_not_applied_to_span, report_type_error, build_field_mapping, is_doc_comment, report_error_if_not_applied_to_span, report_type_error,
should_generate_set_arg, type_is_unit, type_matches_path, FieldInfo, FieldInnerTy, FieldMap, should_generate_set_arg, type_is_bool, type_is_unit, type_matches_path, FieldInfo,
HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind, FieldInnerTy, FieldMap, HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
}; };
use proc_macro2::{Ident, Span, TokenStream}; use proc_macro2::{Ident, Span, TokenStream};
use quote::{format_ident, quote}; use quote::{format_ident, quote};
@ -414,12 +414,15 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug)) Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug))
} }
SubdiagnosticKind::Note | SubdiagnosticKind::Help | SubdiagnosticKind::Warn => { SubdiagnosticKind::Note | SubdiagnosticKind::Help | SubdiagnosticKind::Warn => {
if type_matches_path(info.ty.inner_type(), &["rustc_span", "Span"]) { let inner = info.ty.inner_type();
if type_matches_path(inner, &["rustc_span", "Span"]) {
Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug)) Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug))
} else if type_is_unit(info.ty.inner_type()) { } else if type_is_unit(inner)
|| (matches!(info.ty, FieldInnerTy::Plain(_)) && type_is_bool(inner))
{
Ok(self.add_subdiagnostic(&fn_ident, slug)) Ok(self.add_subdiagnostic(&fn_ident, slug))
} else { } else {
report_type_error(attr, "`Span` or `()`")? report_type_error(attr, "`Span`, `bool` or `()`")?
} }
} }
SubdiagnosticKind::Suggestion { SubdiagnosticKind::Suggestion {

View File

@ -50,6 +50,11 @@ pub(crate) fn type_is_unit(ty: &Type) -> bool {
if let Type::Tuple(TypeTuple { elems, .. }) = ty { elems.is_empty() } else { false } if let Type::Tuple(TypeTuple { elems, .. }) = ty { elems.is_empty() } else { false }
} }
/// Checks whether the type `ty` is `bool`.
pub(crate) fn type_is_bool(ty: &Type) -> bool {
type_matches_path(ty, &["bool"])
}
/// Reports a type error for field with `attr`. /// Reports a type error for field with `attr`.
pub(crate) fn report_type_error( pub(crate) fn report_type_error(
attr: &Attribute, attr: &Attribute,
@ -192,6 +197,11 @@ impl<'ty> FieldInnerTy<'ty> {
#inner #inner
} }
}, },
FieldInnerTy::Plain(t) if type_is_bool(t) => quote! {
if #binding {
#inner
}
},
FieldInnerTy::Plain(..) => quote! { #inner }, FieldInnerTy::Plain(..) => quote! { #inner },
} }
} }

View File

@ -513,6 +513,19 @@ struct OptUnitField {
bar: Option<()>, bar: Option<()>,
} }
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct BoolField {
#[primary_span]
spans: Span,
#[help]
foo: bool,
#[help(no_crate_help)]
//~^ ERROR the `#[help(...)]` attribute can only be applied to fields of type `Span`, `bool` or `()`
// only allow plain 'bool' fields
bar: Option<bool>,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(no_crate_example, code = "E0123")] #[diag(no_crate_example, code = "E0123")]
struct LabelWithTrailingPath { struct LabelWithTrailingPath {

View File

@ -352,8 +352,14 @@ error: invalid applicability
LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")] LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: the `#[help(...)]` attribute can only be applied to fields of type `Span`, `bool` or `()`
--> $DIR/diagnostic-derive.rs:523:5
|
LL | #[help(no_crate_help)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: `#[label(foo)]` is not a valid attribute error: `#[label(foo)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:519:29 --> $DIR/diagnostic-derive.rs:532:29
| |
LL | #[label(no_crate_label, foo)] LL | #[label(no_crate_label, foo)]
| ^^^ | ^^^
@ -361,19 +367,19 @@ LL | #[label(no_crate_label, foo)]
= help: a diagnostic slug must be the first argument to the attribute = help: a diagnostic slug must be the first argument to the attribute
error: `#[label(foo = ...)]` is not a valid attribute error: `#[label(foo = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:527:29 --> $DIR/diagnostic-derive.rs:540:29
| |
LL | #[label(no_crate_label, foo = "...")] LL | #[label(no_crate_label, foo = "...")]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: `#[label(foo(...))]` is not a valid attribute error: `#[label(foo(...))]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:535:29 --> $DIR/diagnostic-derive.rs:548:29
| |
LL | #[label(no_crate_label, foo("..."))] LL | #[label(no_crate_label, foo("..."))]
| ^^^^^^^^^^ | ^^^^^^^^^^
error: `#[primary_span]` is not a valid attribute error: `#[primary_span]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:547:5 --> $DIR/diagnostic-derive.rs:560:5
| |
LL | #[primary_span] LL | #[primary_span]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -381,13 +387,13 @@ LL | #[primary_span]
= help: the `primary_span` field attribute is not valid for lint diagnostics = help: the `primary_span` field attribute is not valid for lint diagnostics
error: `#[error(...)]` is not a valid attribute error: `#[error(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:567:1 --> $DIR/diagnostic-derive.rs:580:1
| |
LL | #[error(no_crate_example, code = "E0123")] LL | #[error(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:567:1 --> $DIR/diagnostic-derive.rs:580:1
| |
LL | / #[error(no_crate_example, code = "E0123")] LL | / #[error(no_crate_example, code = "E0123")]
LL | | LL | |
@ -399,13 +405,13 @@ LL | | struct ErrorAttribute {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: `#[warn_(...)]` is not a valid attribute error: `#[warn_(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:574:1 --> $DIR/diagnostic-derive.rs:587:1
| |
LL | #[warn_(no_crate_example, code = "E0123")] LL | #[warn_(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:574:1 --> $DIR/diagnostic-derive.rs:587:1
| |
LL | / #[warn_(no_crate_example, code = "E0123")] LL | / #[warn_(no_crate_example, code = "E0123")]
LL | | LL | |
@ -417,13 +423,13 @@ LL | | struct WarnAttribute {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: `#[lint(...)]` is not a valid attribute error: `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:581:1 --> $DIR/diagnostic-derive.rs:594:1
| |
LL | #[lint(no_crate_example, code = "E0123")] LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:581:1 --> $DIR/diagnostic-derive.rs:594:1
| |
LL | / #[lint(no_crate_example, code = "E0123")] LL | / #[lint(no_crate_example, code = "E0123")]
LL | | LL | |
@ -435,19 +441,19 @@ LL | | struct LintAttributeOnSessionDiag {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: `#[lint(...)]` is not a valid attribute error: `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:588:1 --> $DIR/diagnostic-derive.rs:601:1
| |
LL | #[lint(no_crate_example, code = "E0123")] LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[lint(...)]` is not a valid attribute error: `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:588:1 --> $DIR/diagnostic-derive.rs:601:1
| |
LL | #[lint(no_crate_example, code = "E0123")] LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:588:1 --> $DIR/diagnostic-derive.rs:601:1
| |
LL | / #[lint(no_crate_example, code = "E0123")] LL | / #[lint(no_crate_example, code = "E0123")]
LL | | LL | |
@ -460,19 +466,19 @@ LL | | struct LintAttributeOnLintDiag {}
= help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]`
error: specified multiple times error: specified multiple times
--> $DIR/diagnostic-derive.rs:598:53 --> $DIR/diagnostic-derive.rs:611:53
| |
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
note: previously specified here note: previously specified here
--> $DIR/diagnostic-derive.rs:598:39 --> $DIR/diagnostic-derive.rs:611:39
| |
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: wrong types for suggestion error: wrong types for suggestion
--> $DIR/diagnostic-derive.rs:607:24 --> $DIR/diagnostic-derive.rs:620:24
| |
LL | suggestion: (Span, usize), LL | suggestion: (Span, usize),
| ^^^^^ | ^^^^^
@ -480,7 +486,7 @@ LL | suggestion: (Span, usize),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: wrong types for suggestion error: wrong types for suggestion
--> $DIR/diagnostic-derive.rs:615:17 --> $DIR/diagnostic-derive.rs:628:17
| |
LL | suggestion: (Span,), LL | suggestion: (Span,),
| ^^^^^^^ | ^^^^^^^
@ -488,13 +494,13 @@ LL | suggestion: (Span,),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: suggestion without `code = "..."` error: suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:622:5 --> $DIR/diagnostic-derive.rs:635:5
| |
LL | #[suggestion(no_crate_suggestion)] LL | #[suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[multipart_suggestion(...)]` is not a valid attribute error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:629:1 --> $DIR/diagnostic-derive.rs:642:1
| |
LL | #[multipart_suggestion(no_crate_suggestion)] LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -502,7 +508,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
= help: consider creating a `Subdiagnostic` instead = help: consider creating a `Subdiagnostic` instead
error: `#[multipart_suggestion(...)]` is not a valid attribute error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:632:1 --> $DIR/diagnostic-derive.rs:645:1
| |
LL | #[multipart_suggestion()] LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -510,7 +516,7 @@ LL | #[multipart_suggestion()]
= help: consider creating a `Subdiagnostic` instead = help: consider creating a `Subdiagnostic` instead
error: `#[multipart_suggestion(...)]` is not a valid attribute error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:636:5 --> $DIR/diagnostic-derive.rs:649:5
| |
LL | #[multipart_suggestion(no_crate_suggestion)] LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -518,7 +524,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
= help: consider creating a `Subdiagnostic` instead = help: consider creating a `Subdiagnostic` instead
error: `#[suggestion(...)]` is not a valid attribute error: `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:644:1 --> $DIR/diagnostic-derive.rs:657:1
| |
LL | #[suggestion(no_crate_suggestion, code = "...")] LL | #[suggestion(no_crate_suggestion, code = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -526,7 +532,7 @@ LL | #[suggestion(no_crate_suggestion, code = "...")]
= help: `#[label]` and `#[suggestion]` can only be applied to fields = help: `#[label]` and `#[suggestion]` can only be applied to fields
error: `#[label]` is not a valid attribute error: `#[label]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:653:1 --> $DIR/diagnostic-derive.rs:666:1
| |
LL | #[label] LL | #[label]
| ^^^^^^^^ | ^^^^^^^^
@ -534,7 +540,7 @@ LL | #[label]
= help: `#[label]` and `#[suggestion]` can only be applied to fields = help: `#[label]` and `#[suggestion]` can only be applied to fields
error: `#[subdiagnostic(...)]` is not a valid attribute error: `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:687:5 --> $DIR/diagnostic-derive.rs:700:5
| |
LL | #[subdiagnostic(bad)] LL | #[subdiagnostic(bad)]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
@ -542,13 +548,13 @@ LL | #[subdiagnostic(bad)]
= help: `eager` is the only supported nested attribute for `subdiagnostic` = help: `eager` is the only supported nested attribute for `subdiagnostic`
error: `#[subdiagnostic = ...]` is not a valid attribute error: `#[subdiagnostic = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:695:5 --> $DIR/diagnostic-derive.rs:708:5
| |
LL | #[subdiagnostic = "bad"] LL | #[subdiagnostic = "bad"]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[subdiagnostic(...)]` is not a valid attribute error: `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:703:5 --> $DIR/diagnostic-derive.rs:716:5
| |
LL | #[subdiagnostic(bad, bad)] LL | #[subdiagnostic(bad, bad)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -556,7 +562,7 @@ LL | #[subdiagnostic(bad, bad)]
= help: `eager` is the only supported nested attribute for `subdiagnostic` = help: `eager` is the only supported nested attribute for `subdiagnostic`
error: `#[subdiagnostic(...)]` is not a valid attribute error: `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:711:5 --> $DIR/diagnostic-derive.rs:724:5
| |
LL | #[subdiagnostic("bad")] LL | #[subdiagnostic("bad")]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -564,7 +570,7 @@ LL | #[subdiagnostic("bad")]
= help: `eager` is the only supported nested attribute for `subdiagnostic` = help: `eager` is the only supported nested attribute for `subdiagnostic`
error: `#[subdiagnostic(...)]` is not a valid attribute error: `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:719:5 --> $DIR/diagnostic-derive.rs:732:5
| |
LL | #[subdiagnostic(eager)] LL | #[subdiagnostic(eager)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -572,25 +578,25 @@ LL | #[subdiagnostic(eager)]
= help: eager subdiagnostics are not supported on lints = help: eager subdiagnostics are not supported on lints
error: expected at least one string literal for `code(...)` error: expected at least one string literal for `code(...)`
--> $DIR/diagnostic-derive.rs:777:18 --> $DIR/diagnostic-derive.rs:790:18
| |
LL | #[suggestion(code())] LL | #[suggestion(code())]
| ^^^^^^ | ^^^^^^
error: `code(...)` must contain only string literals error: `code(...)` must contain only string literals
--> $DIR/diagnostic-derive.rs:785:23 --> $DIR/diagnostic-derive.rs:798:23
| |
LL | #[suggestion(code(foo))] LL | #[suggestion(code(foo))]
| ^^^ | ^^^
error: `code = "..."`/`code(...)` must contain only string literals error: `code = "..."`/`code(...)` must contain only string literals
--> $DIR/diagnostic-derive.rs:793:18 --> $DIR/diagnostic-derive.rs:806:18
| |
LL | #[suggestion(code = 3)] LL | #[suggestion(code = 3)]
| ^^^^^^^^ | ^^^^^^^^
error: `#[suggestion(...)]` is not a valid attribute error: `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:808:5 --> $DIR/diagnostic-derive.rs:821:5
| |
LL | #[suggestion(no_crate_suggestion, code = "")] LL | #[suggestion(no_crate_suggestion, code = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -612,43 +618,43 @@ LL | #[nonsense]
| ^^^^^^^^ | ^^^^^^^^
error: cannot find attribute `error` in this scope error: cannot find attribute `error` in this scope
--> $DIR/diagnostic-derive.rs:567:3 --> $DIR/diagnostic-derive.rs:580:3
| |
LL | #[error(no_crate_example, code = "E0123")] LL | #[error(no_crate_example, code = "E0123")]
| ^^^^^ | ^^^^^
error: cannot find attribute `warn_` in this scope error: cannot find attribute `warn_` in this scope
--> $DIR/diagnostic-derive.rs:574:3 --> $DIR/diagnostic-derive.rs:587:3
| |
LL | #[warn_(no_crate_example, code = "E0123")] LL | #[warn_(no_crate_example, code = "E0123")]
| ^^^^^ help: a built-in attribute with a similar name exists: `warn` | ^^^^^ help: a built-in attribute with a similar name exists: `warn`
error: cannot find attribute `lint` in this scope error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:581:3 --> $DIR/diagnostic-derive.rs:594:3
| |
LL | #[lint(no_crate_example, code = "E0123")] LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^ help: a built-in attribute with a similar name exists: `link` | ^^^^ help: a built-in attribute with a similar name exists: `link`
error: cannot find attribute `lint` in this scope error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:588:3 --> $DIR/diagnostic-derive.rs:601:3
| |
LL | #[lint(no_crate_example, code = "E0123")] LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^ help: a built-in attribute with a similar name exists: `link` | ^^^^ help: a built-in attribute with a similar name exists: `link`
error: cannot find attribute `multipart_suggestion` in this scope error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:629:3 --> $DIR/diagnostic-derive.rs:642:3
| |
LL | #[multipart_suggestion(no_crate_suggestion)] LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: cannot find attribute `multipart_suggestion` in this scope error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:632:3 --> $DIR/diagnostic-derive.rs:645:3
| |
LL | #[multipart_suggestion()] LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: cannot find attribute `multipart_suggestion` in this scope error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:636:7 --> $DIR/diagnostic-derive.rs:649:7
| |
LL | #[multipart_suggestion(no_crate_suggestion)] LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -670,7 +676,7 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
--> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC
= note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 84 previous errors error: aborting due to 85 previous errors
Some errors have detailed explanations: E0277, E0425. Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`. For more information about an error, try `rustc --explain E0277`.