SessionSubdiagnostic: make #[applicability]
optional
This commit is contained in:
parent
6e8dad5c07
commit
9dc0643744
3 changed files with 13 additions and 55 deletions
|
@ -469,14 +469,10 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let span_field = self.span_field.as_ref().map(|(span, _)| span);
|
let span_field = self.span_field.as_ref().map(|(span, _)| span);
|
||||||
let applicability = match self.applicability.clone() {
|
let applicability = self.applicability.take().map_or_else(
|
||||||
Some((applicability, _)) => Some(applicability),
|
|| quote! { rustc_errors::Applicability::Unspecified },
|
||||||
None if is_suggestion => {
|
|(applicability, _)| applicability,
|
||||||
span_err(self.span, "suggestion without `applicability`").emit();
|
);
|
||||||
Some(quote! { rustc_errors::Applicability::Unspecified })
|
|
||||||
}
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let diag = &self.diag;
|
let diag = &self.diag;
|
||||||
let name = format_ident!("{}{}", if span_field.is_some() { "span_" } else { "" }, kind);
|
let name = format_ident!("{}{}", if span_field.is_some() { "span_" } else { "" }, kind);
|
||||||
|
|
|
@ -401,7 +401,6 @@ struct AK {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(parser::add_paren, code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
|
||||||
struct AL {
|
struct AL {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -412,7 +411,6 @@ struct AL {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(parser::add_paren, code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
|
||||||
struct AM {
|
struct AM {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -448,8 +446,7 @@ struct AQ;
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(parser::add_paren, code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
//~^ ERROR suggestion without `#[primary_span]` field
|
||||||
//~^^ ERROR suggestion without `#[primary_span]` field
|
|
||||||
struct AR {
|
struct AR {
|
||||||
var: String,
|
var: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,36 +249,13 @@ LL | #[applicability]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: the `#[applicability]` attribute can only be applied to fields of type `Applicability`
|
error: the `#[applicability]` attribute can only be applied to fields of type `Applicability`
|
||||||
--> $DIR/subdiagnostic-derive.rs:408:5
|
--> $DIR/subdiagnostic-derive.rs:407:5
|
||||||
|
|
|
|
||||||
LL | #[applicability]
|
LL | #[applicability]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:403:1
|
|
||||||
|
|
|
||||||
LL | / #[suggestion(parser::add_paren, code = "...")]
|
|
||||||
LL | |
|
|
||||||
LL | | struct AL {
|
|
||||||
LL | | #[primary_span]
|
|
||||||
... |
|
|
||||||
LL | | applicability: Span,
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:414:1
|
|
||||||
|
|
|
||||||
LL | / #[suggestion(parser::add_paren, code = "...")]
|
|
||||||
LL | |
|
|
||||||
LL | | struct AM {
|
|
||||||
LL | | #[primary_span]
|
|
||||||
LL | | span: Span,
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: suggestion without `code = "..."`
|
error: suggestion without `code = "..."`
|
||||||
--> $DIR/subdiagnostic-derive.rs:422:1
|
--> $DIR/subdiagnostic-derive.rs:420:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(parser::add_paren)]
|
LL | / #[suggestion(parser::add_paren)]
|
||||||
LL | |
|
LL | |
|
||||||
|
@ -290,47 +267,35 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: invalid applicability
|
error: invalid applicability
|
||||||
--> $DIR/subdiagnostic-derive.rs:432:46
|
--> $DIR/subdiagnostic-derive.rs:430:46
|
||||||
|
|
|
|
||||||
LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
|
LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:450:1
|
|
||||||
|
|
|
||||||
LL | / #[suggestion(parser::add_paren, code = "...")]
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | struct AR {
|
|
||||||
LL | | var: String,
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: suggestion without `#[primary_span]` field
|
error: suggestion without `#[primary_span]` field
|
||||||
--> $DIR/subdiagnostic-derive.rs:450:1
|
--> $DIR/subdiagnostic-derive.rs:448:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(parser::add_paren, code = "...")]
|
LL | / #[suggestion(parser::add_paren, code = "...")]
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
|
||||||
LL | | struct AR {
|
LL | | struct AR {
|
||||||
LL | | var: String,
|
LL | | var: String,
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: unsupported type attribute for subdiagnostic enum
|
error: unsupported type attribute for subdiagnostic enum
|
||||||
--> $DIR/subdiagnostic-derive.rs:465:1
|
--> $DIR/subdiagnostic-derive.rs:462:1
|
||||||
|
|
|
|
||||||
LL | #[label]
|
LL | #[label]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `var` doesn't refer to a field on this type
|
error: `var` doesn't refer to a field on this type
|
||||||
--> $DIR/subdiagnostic-derive.rs:485:39
|
--> $DIR/subdiagnostic-derive.rs:482:39
|
||||||
|
|
|
|
||||||
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: `var` doesn't refer to a field on this type
|
error: `var` doesn't refer to a field on this type
|
||||||
--> $DIR/subdiagnostic-derive.rs:504:43
|
--> $DIR/subdiagnostic-derive.rs:501:43
|
||||||
|
|
|
|
||||||
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
@ -395,6 +360,6 @@ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent`
|
||||||
LL | #[label(slug)]
|
LL | #[label(slug)]
|
||||||
| ^^^^ not found in `rustc_errors::fluent`
|
| ^^^^ not found in `rustc_errors::fluent`
|
||||||
|
|
||||||
error: aborting due to 52 previous errors
|
error: aborting due to 49 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0425`.
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue