mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Disallow #[primary_span] on LintDiagnostics
This commit is contained in:
parent
a960f8304c
commit
bd0d3f745d
@ -340,11 +340,20 @@ impl DiagnosticDeriveBuilder {
|
||||
Ok(quote! {})
|
||||
}
|
||||
"primary_span" => {
|
||||
report_error_if_not_applied_to_span(attr, &info)?;
|
||||
match self.kind {
|
||||
DiagnosticDeriveKind::SessionDiagnostic => {
|
||||
report_error_if_not_applied_to_span(attr, &info)?;
|
||||
|
||||
Ok(quote! {
|
||||
#diag.set_span(#binding);
|
||||
})
|
||||
Ok(quote! {
|
||||
#diag.set_span(#binding);
|
||||
})
|
||||
}
|
||||
DiagnosticDeriveKind::LintDiagnostic => {
|
||||
throw_invalid_attr!(attr, &meta, |diag| {
|
||||
diag.help("the `primary_span` field attribute is not valid for lint diagnostics")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
"label" => {
|
||||
report_error_if_not_applied_to_span(attr, &info)?;
|
||||
|
@ -613,7 +613,6 @@ pub struct NonExportedMacroInvalidAttrs {
|
||||
#[derive(LintDiagnostic)]
|
||||
#[lint(passes::unused_duplicate)]
|
||||
pub struct UnusedDuplicate {
|
||||
#[primary_span]
|
||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||
pub this: Span,
|
||||
#[note]
|
||||
|
@ -551,6 +551,14 @@ struct LintsGood {
|
||||
struct ErrorsBad {
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[lint(typeck::ambiguous_lifetime_bound)]
|
||||
struct PrimarySpanOnLint {
|
||||
#[primary_span]
|
||||
//~^ ERROR `#[primary_span]` is not a valid attribute
|
||||
span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
struct ErrorWithMultiSpan {
|
||||
|
@ -355,6 +355,14 @@ LL | #[error(typeck::ambiguous_lifetime_bound)]
|
||||
|
|
||||
= help: use the `#[lint(...)]` attribute to create a lint
|
||||
|
||||
error: `#[primary_span]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:557:5
|
||||
|
|
||||
LL | #[primary_span]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: the `primary_span` field attribute is not valid for lint diagnostics
|
||||
|
||||
error: cannot find attribute `nonsense` in this scope
|
||||
--> $DIR/diagnostic-derive.rs:53:3
|
||||
|
|
||||
@ -387,7 +395,7 @@ LL | arg: impl IntoDiagnosticArg,
|
||||
| ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
||||
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 46 previous errors
|
||||
error: aborting due to 47 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0425.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user