macros: use typed identifiers in subdiag derive
As in the diagnostic derive, using typed identifiers in the subdiagnostic derive improves the diagnostics of using the subdiagnostic derive as Fluent messages will be confirmed to exist at compile-time. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
99bc979403
commit
abd3467d47
9 changed files with 314 additions and 213 deletions
|
@ -347,6 +347,27 @@ impl<S: Into<String>> From<S> for DiagnosticMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
|
||||||
|
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagnosticMessage` and the
|
||||||
|
/// subdiagnostic derive refers to typed identifiers that are `DiagnosticMessage`s, so need to be
|
||||||
|
/// able to convert between these, as much as they'll be converted back into `DiagnosticMessage`
|
||||||
|
/// using `with_subdiagnostic_message` eventually. Don't use this other than for the derive.
|
||||||
|
impl Into<SubdiagnosticMessage> for DiagnosticMessage {
|
||||||
|
fn into(self) -> SubdiagnosticMessage {
|
||||||
|
match self {
|
||||||
|
DiagnosticMessage::Str(s) => SubdiagnosticMessage::Str(s),
|
||||||
|
DiagnosticMessage::FluentIdentifier(id, None) => {
|
||||||
|
SubdiagnosticMessage::FluentIdentifier(id)
|
||||||
|
}
|
||||||
|
// There isn't really a sensible behaviour for this because it loses information but
|
||||||
|
// this is the most sensible of the behaviours.
|
||||||
|
DiagnosticMessage::FluentIdentifier(_, Some(attr)) => {
|
||||||
|
SubdiagnosticMessage::FluentAttr(attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A span together with some additional data.
|
/// A span together with some additional data.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SpanLabel {
|
pub struct SpanLabel {
|
||||||
|
|
|
@ -72,12 +72,12 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
/// ```ignore (rust)
|
/// ```ignore (rust)
|
||||||
/// #[derive(SessionSubdiagnostic)]
|
/// #[derive(SessionSubdiagnostic)]
|
||||||
/// pub enum ExpectedIdentifierLabel<'tcx> {
|
/// pub enum ExpectedIdentifierLabel<'tcx> {
|
||||||
/// #[label(slug = "parser-expected-identifier")]
|
/// #[label(parser::expected_identifier)]
|
||||||
/// WithoutFound {
|
/// WithoutFound {
|
||||||
/// #[primary_span]
|
/// #[primary_span]
|
||||||
/// span: Span,
|
/// span: Span,
|
||||||
/// }
|
/// }
|
||||||
/// #[label(slug = "parser-expected-identifier-found")]
|
/// #[label(parser::expected_identifier_found)]
|
||||||
/// WithFound {
|
/// WithFound {
|
||||||
/// #[primary_span]
|
/// #[primary_span]
|
||||||
/// span: Span,
|
/// span: Span,
|
||||||
|
@ -86,7 +86,7 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[derive(SessionSubdiagnostic)]
|
/// #[derive(SessionSubdiagnostic)]
|
||||||
/// #[suggestion_verbose(slug = "parser-raw-identifier")]
|
/// #[suggestion_verbose(parser::raw_identifier)]
|
||||||
/// pub struct RawIdentifierSuggestion<'tcx> {
|
/// pub struct RawIdentifierSuggestion<'tcx> {
|
||||||
/// #[primary_span]
|
/// #[primary_span]
|
||||||
/// span: Span,
|
/// span: Span,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use quote::{format_ident, quote};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use syn::{spanned::Spanned, Meta, MetaList, MetaNameValue};
|
use syn::{parse_quote, spanned::Spanned, Meta, MetaList, MetaNameValue, NestedMeta, Path};
|
||||||
use synstructure::{BindingInfo, Structure, VariantInfo};
|
use synstructure::{BindingInfo, Structure, VariantInfo};
|
||||||
|
|
||||||
/// Which kind of suggestion is being created?
|
/// Which kind of suggestion is being created?
|
||||||
|
@ -194,8 +194,8 @@ struct SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
kind: Option<(SubdiagnosticKind, proc_macro::Span)>,
|
kind: Option<(SubdiagnosticKind, proc_macro::Span)>,
|
||||||
|
|
||||||
/// Slug of the subdiagnostic - corresponds to the Fluent identifier for the message - from the
|
/// Slug of the subdiagnostic - corresponds to the Fluent identifier for the message - from the
|
||||||
/// `#[kind(slug = "...")]` attribute on the type or variant.
|
/// `#[kind(slug)]` attribute on the type or variant.
|
||||||
slug: Option<(String, proc_macro::Span)>,
|
slug: Option<(Path, proc_macro::Span)>,
|
||||||
/// If a suggestion, the code to suggest as a replacement - from the `#[kind(code = "...")]`
|
/// If a suggestion, the code to suggest as a replacement - from the `#[kind(code = "...")]`
|
||||||
/// attribute on the type or variant.
|
/// attribute on the type or variant.
|
||||||
code: Option<(TokenStream, proc_macro::Span)>,
|
code: Option<(TokenStream, proc_macro::Span)>,
|
||||||
|
@ -224,9 +224,34 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
let meta = attr.parse_meta()?;
|
let meta = attr.parse_meta()?;
|
||||||
let kind = match meta {
|
let kind = match meta {
|
||||||
Meta::List(MetaList { ref nested, .. }) => {
|
Meta::List(MetaList { ref nested, .. }) => {
|
||||||
for nested_attr in nested {
|
let mut nested_iter = nested.into_iter();
|
||||||
|
if let Some(nested_attr) = nested_iter.next() {
|
||||||
|
match nested_attr {
|
||||||
|
NestedMeta::Meta(Meta::Path(path)) => {
|
||||||
|
self.slug.set_once((path.clone(), span));
|
||||||
|
}
|
||||||
|
NestedMeta::Meta(meta @ Meta::NameValue(_))
|
||||||
|
if matches!(
|
||||||
|
meta.path().segments.last().unwrap().ident.to_string().as_str(),
|
||||||
|
"code" | "applicability"
|
||||||
|
) =>
|
||||||
|
{
|
||||||
|
// don't error for valid follow-up attributes
|
||||||
|
}
|
||||||
|
nested_attr => {
|
||||||
|
throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
||||||
|
diag.help(
|
||||||
|
"first argument of the attribute should be the diagnostic \
|
||||||
|
slug",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for nested_attr in nested_iter {
|
||||||
let meta = match nested_attr {
|
let meta = match nested_attr {
|
||||||
syn::NestedMeta::Meta(ref meta) => meta,
|
NestedMeta::Meta(ref meta) => meta,
|
||||||
_ => throw_invalid_nested_attr!(attr, &nested_attr),
|
_ => throw_invalid_nested_attr!(attr, &nested_attr),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -241,7 +266,6 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
let formatted_str = self.build_format(&s.value(), s.span());
|
let formatted_str = self.build_format(&s.value(), s.span());
|
||||||
self.code.set_once((formatted_str, span));
|
self.code.set_once((formatted_str, span));
|
||||||
}
|
}
|
||||||
"slug" => self.slug.set_once((s.value(), span)),
|
|
||||||
"applicability" => {
|
"applicability" => {
|
||||||
let value = match Applicability::from_str(&s.value()) {
|
let value = match Applicability::from_str(&s.value()) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
|
@ -253,11 +277,23 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
self.applicability.set_once((quote! { #value }, span));
|
self.applicability.set_once((quote! { #value }, span));
|
||||||
}
|
}
|
||||||
_ => throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
_ => throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
||||||
diag.help("only `code`, `slug` and `applicability` are valid nested attributes")
|
diag.help(
|
||||||
|
"only `code` and `applicability` are valid nested \
|
||||||
|
attributes",
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => throw_invalid_nested_attr!(attr, &nested_attr),
|
_ => throw_invalid_nested_attr!(attr, &nested_attr, |diag| {
|
||||||
|
if matches!(meta, Meta::Path(_)) {
|
||||||
|
diag.help(
|
||||||
|
"a diagnostic slug must be the first argument to the \
|
||||||
|
attribute",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
diag
|
||||||
|
}
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,10 +317,27 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches!(
|
||||||
|
kind,
|
||||||
|
SubdiagnosticKind::Label | SubdiagnosticKind::Help | SubdiagnosticKind::Note
|
||||||
|
) && self.applicability.is_some()
|
||||||
|
{
|
||||||
|
throw_span_err!(
|
||||||
|
span,
|
||||||
|
&format!(
|
||||||
|
"`applicability` is not a valid nested attribute of a `{}` attribute",
|
||||||
|
name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if self.slug.is_none() {
|
if self.slug.is_none() {
|
||||||
throw_span_err!(
|
throw_span_err!(
|
||||||
span,
|
span,
|
||||||
&format!("`slug` must be set in a `#[{}(...)]` attribute", name)
|
&format!(
|
||||||
|
"diagnostic slug must be first argument of a `#[{}(...)]` attribute",
|
||||||
|
name
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +388,10 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
return Ok(quote! {});
|
return Ok(quote! {});
|
||||||
}
|
}
|
||||||
_ => throw_invalid_attr!(attr, &meta, |diag| {
|
_ => throw_invalid_attr!(attr, &meta, |diag| {
|
||||||
diag.help("only `primary_span`, `applicability` and `skip_arg` are valid field attributes")
|
diag.help(
|
||||||
|
"only `primary_span`, `applicability` and `skip_arg` are valid field \
|
||||||
|
attributes",
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
_ => throw_invalid_attr!(attr, &meta),
|
_ => throw_invalid_attr!(attr, &meta),
|
||||||
|
@ -375,7 +431,11 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Missing slug errors will already have been reported.
|
// Missing slug errors will already have been reported.
|
||||||
let slug = self.slug.as_ref().map(|(slug, _)| &**slug).unwrap_or("missing-slug");
|
let slug = self
|
||||||
|
.slug
|
||||||
|
.as_ref()
|
||||||
|
.map(|(slug, _)| slug.clone())
|
||||||
|
.unwrap_or_else(|| parse_quote! { you::need::to::specify::a::slug });
|
||||||
let code = match self.code.as_ref() {
|
let code = match self.code.as_ref() {
|
||||||
Some((code, _)) => Some(quote! { #code }),
|
Some((code, _)) => Some(quote! { #code }),
|
||||||
None if is_suggestion => {
|
None if is_suggestion => {
|
||||||
|
@ -397,7 +457,7 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
|
||||||
|
|
||||||
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);
|
||||||
let message = quote! { rustc_errors::SubdiagnosticMessage::message(#slug) };
|
let message = quote! { rustc_errors::fluent::#slug };
|
||||||
let call = if matches!(kind, SubdiagnosticKind::Suggestion(..)) {
|
let call = if matches!(kind, SubdiagnosticKind::Suggestion(..)) {
|
||||||
if let Some(span) = span_field {
|
if let Some(span) = span_field {
|
||||||
quote! { #diag.#name(#span, #message, #code, #applicability); }
|
quote! { #diag.#name(#span, #message, #code, #applicability); }
|
||||||
|
|
|
@ -265,7 +265,7 @@ struct BadTypePlus {
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
pub enum BadTypePlusSub {
|
pub enum BadTypePlusSub {
|
||||||
#[suggestion(
|
#[suggestion(
|
||||||
slug = "parser-add-paren",
|
parser::add_paren,
|
||||||
code = "{sum_with_parens}",
|
code = "{sum_with_parens}",
|
||||||
applicability = "machine-applicable"
|
applicability = "machine-applicable"
|
||||||
)]
|
)]
|
||||||
|
@ -274,12 +274,12 @@ pub enum BadTypePlusSub {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
},
|
},
|
||||||
#[label(slug = "parser-forgot-paren")]
|
#[label(parser::forgot_paren)]
|
||||||
ForgotParen {
|
ForgotParen {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
},
|
},
|
||||||
#[label(slug = "parser-expect-path")]
|
#[label(parser::expect_path)]
|
||||||
ExpectPath {
|
ExpectPath {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -197,7 +197,7 @@ pub struct AddressOfTemporaryTaken {
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
pub enum AddReturnTypeSuggestion<'tcx> {
|
pub enum AddReturnTypeSuggestion<'tcx> {
|
||||||
#[suggestion(
|
#[suggestion(
|
||||||
slug = "typeck-add-return-type-add",
|
typeck::add_return_type_add,
|
||||||
code = "-> {found} ",
|
code = "-> {found} ",
|
||||||
applicability = "machine-applicable"
|
applicability = "machine-applicable"
|
||||||
)]
|
)]
|
||||||
|
@ -207,7 +207,7 @@ pub enum AddReturnTypeSuggestion<'tcx> {
|
||||||
found: Ty<'tcx>,
|
found: Ty<'tcx>,
|
||||||
},
|
},
|
||||||
#[suggestion(
|
#[suggestion(
|
||||||
slug = "typeck-add-return-type-missing-here",
|
typeck::add_return_type_missing_here,
|
||||||
code = "-> _ ",
|
code = "-> _ ",
|
||||||
applicability = "has-placeholders"
|
applicability = "has-placeholders"
|
||||||
)]
|
)]
|
||||||
|
@ -219,12 +219,12 @@ pub enum AddReturnTypeSuggestion<'tcx> {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
pub enum ExpectedReturnTypeLabel<'tcx> {
|
pub enum ExpectedReturnTypeLabel<'tcx> {
|
||||||
#[label(slug = "typeck-expected-default-return-type")]
|
#[label(typeck::expected_default_return_type)]
|
||||||
Unit {
|
Unit {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
},
|
},
|
||||||
#[label(slug = "typeck-expected-return-type")]
|
#[label(typeck::expected_return_type)]
|
||||||
Other {
|
Other {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct DeriveSessionDiagnostic {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[note(slug = "note")]
|
#[note(parser::add_paren)]
|
||||||
struct Note {
|
struct Note {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -470,7 +470,7 @@ struct NoApplicability {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[note(slug = "note")]
|
#[note(parser::add_paren)]
|
||||||
struct Note;
|
struct Note;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
|
|
@ -20,7 +20,7 @@ use rustc_span::Span;
|
||||||
use rustc_macros::SessionSubdiagnostic;
|
use rustc_macros::SessionSubdiagnostic;
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "label-a")]
|
#[label(parser::add_paren)]
|
||||||
struct A {
|
struct A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -29,13 +29,13 @@ struct A {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum B {
|
enum B {
|
||||||
#[label(slug = "label-b-a")]
|
#[label(parser::add_paren)]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
var: String,
|
var: String,
|
||||||
},
|
},
|
||||||
#[label(slug = "label-b-b")]
|
#[label(parser::add_paren)]
|
||||||
B {
|
B {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -44,7 +44,7 @@ enum B {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "label-c")]
|
#[label(parser::add_paren)]
|
||||||
//~^ ERROR label without `#[primary_span]` field
|
//~^ ERROR label without `#[primary_span]` field
|
||||||
struct C {
|
struct C {
|
||||||
var: String,
|
var: String,
|
||||||
|
@ -116,7 +116,8 @@ struct K {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug)]
|
#[label(slug)]
|
||||||
//~^ ERROR `#[label(slug)]` is not a valid attribute
|
//~^ ERROR cannot find value `slug` in module `rustc_errors::fluent`
|
||||||
|
//~^^ NOTE not found in `rustc_errors::fluent`
|
||||||
struct L {
|
struct L {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -125,7 +126,7 @@ struct L {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label()]
|
#[label()]
|
||||||
//~^ ERROR `slug` must be set in a `#[label(...)]` attribute
|
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
|
||||||
struct M {
|
struct M {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -133,7 +134,7 @@ struct M {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(code = "...")]
|
#[label(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR `code` is not a valid nested attribute of a `label` attribute
|
//~^ ERROR `code` is not a valid nested attribute of a `label` attribute
|
||||||
struct N {
|
struct N {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -141,12 +142,21 @@ struct N {
|
||||||
var: String,
|
var: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionSubdiagnostic)]
|
||||||
|
#[label(parser::add_paren, applicability = "machine-applicable")]
|
||||||
|
//~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute
|
||||||
|
struct O {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
var: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[foo]
|
#[foo]
|
||||||
//~^ ERROR cannot find attribute `foo` in this scope
|
//~^ ERROR cannot find attribute `foo` in this scope
|
||||||
//~^^ ERROR unsupported type attribute for subdiagnostic enum
|
//~^^ ERROR unsupported type attribute for subdiagnostic enum
|
||||||
enum O {
|
enum P {
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -155,7 +165,7 @@ enum O {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum P {
|
enum Q {
|
||||||
#[bar]
|
#[bar]
|
||||||
//~^ ERROR `#[bar]` is not a valid attribute
|
//~^ ERROR `#[bar]` is not a valid attribute
|
||||||
//~^^ ERROR cannot find attribute `bar` in this scope
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
||||||
|
@ -166,21 +176,9 @@ enum P {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
|
||||||
enum Q {
|
|
||||||
#[bar = "..."]
|
|
||||||
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
|
||||||
//~^^ ERROR cannot find attribute `bar` in this scope
|
|
||||||
A {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
var: String,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum R {
|
enum R {
|
||||||
#[bar = 4]
|
#[bar = "..."]
|
||||||
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
||||||
//~^^ ERROR cannot find attribute `bar` in this scope
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
||||||
A {
|
A {
|
||||||
|
@ -192,6 +190,18 @@ enum R {
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum S {
|
enum S {
|
||||||
|
#[bar = 4]
|
||||||
|
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
||||||
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
||||||
|
A {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
var: String,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(SessionSubdiagnostic)]
|
||||||
|
enum T {
|
||||||
#[bar("...")]
|
#[bar("...")]
|
||||||
//~^ ERROR `#[bar("...")]` is not a valid attribute
|
//~^ ERROR `#[bar("...")]` is not a valid attribute
|
||||||
//~^^ ERROR cannot find attribute `bar` in this scope
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
||||||
|
@ -203,9 +213,9 @@ enum S {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum T {
|
enum U {
|
||||||
#[label(code = "...")]
|
#[label(code = "...")]
|
||||||
//~^ ERROR `code` is not a valid nested attribute of a `label`
|
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -214,8 +224,8 @@ enum T {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum U {
|
enum V {
|
||||||
#[label(slug = "label-u")]
|
#[label(parser::add_paren)]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -230,17 +240,17 @@ enum U {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
//~^ ERROR label without `#[primary_span]` field
|
//~^ ERROR label without `#[primary_span]` field
|
||||||
struct V {
|
struct W {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
//~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span`
|
//~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span`
|
||||||
span: String,
|
span: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
struct W {
|
struct X {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -249,8 +259,8 @@ struct W {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
struct X {
|
struct Y {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[bar]
|
#[bar]
|
||||||
|
@ -260,8 +270,8 @@ struct X {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
struct Y {
|
struct Z {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[bar = "..."]
|
#[bar = "..."]
|
||||||
|
@ -271,8 +281,8 @@ struct Y {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
struct Z {
|
struct AA {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[bar("...")]
|
#[bar("...")]
|
||||||
|
@ -282,8 +292,8 @@ struct Z {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "label-aa")]
|
#[label(parser::add_paren)]
|
||||||
struct AA {
|
struct AB {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[skip_arg]
|
#[skip_arg]
|
||||||
|
@ -291,37 +301,36 @@ struct AA {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
union AB {
|
union AC {
|
||||||
//~^ ERROR unexpected unsupported untagged union
|
//~^ ERROR unexpected unsupported untagged union
|
||||||
span: u32,
|
span: u32,
|
||||||
b: u64
|
b: u64
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "label-ac-1")]
|
#[label(parser::add_paren)]
|
||||||
//~^ NOTE previously specified here
|
//~^ NOTE previously specified here
|
||||||
//~^^ NOTE previously specified here
|
//~^^ NOTE previously specified here
|
||||||
#[label(slug = "label-ac-2")]
|
#[label(parser::add_paren)]
|
||||||
//~^ ERROR specified multiple times
|
//~^ ERROR specified multiple times
|
||||||
//~^^ ERROR specified multiple times
|
//~^^ ERROR specified multiple times
|
||||||
struct AC {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
|
||||||
#[label(slug = "label-ad-1", slug = "label-ad-2")]
|
|
||||||
//~^ ERROR specified multiple times
|
|
||||||
//~^^ NOTE previously specified here
|
|
||||||
struct AD {
|
struct AD {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label(slug = "label-ad-1")]
|
#[label(parser::add_paren, parser::add_paren)]
|
||||||
|
//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute
|
||||||
struct AE {
|
struct AE {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(SessionSubdiagnostic)]
|
||||||
|
#[label(parser::add_paren)]
|
||||||
|
struct AF {
|
||||||
|
#[primary_span]
|
||||||
//~^ NOTE previously specified here
|
//~^ NOTE previously specified here
|
||||||
span_a: Span,
|
span_a: Span,
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -330,15 +339,15 @@ struct AE {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
struct AF {
|
struct AG {
|
||||||
//~^ ERROR subdiagnostic kind not specified
|
//~^ ERROR subdiagnostic kind not specified
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "suggestion-af", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
struct AG {
|
struct AH {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -347,8 +356,8 @@ struct AG {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum AH {
|
enum AI {
|
||||||
#[suggestion(slug = "suggestion-ag-a", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -356,7 +365,7 @@ enum AH {
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
var: String,
|
var: String,
|
||||||
},
|
},
|
||||||
#[suggestion(slug = "suggestion-ag-b", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
B {
|
B {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -367,10 +376,10 @@ enum AH {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code = "...", code = "...")]
|
#[suggestion(parser::add_paren, code = "...", code = "...")]
|
||||||
//~^ ERROR specified multiple times
|
//~^ ERROR specified multiple times
|
||||||
//~^^ NOTE previously specified here
|
//~^^ NOTE previously specified here
|
||||||
struct AI {
|
struct AJ {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -378,8 +387,8 @@ struct AI {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
struct AJ {
|
struct AK {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -391,9 +400,9 @@ struct AJ {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
//~^ ERROR suggestion without `applicability`
|
||||||
struct AK {
|
struct AL {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -402,17 +411,17 @@ struct AK {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
//~^ ERROR suggestion without `applicability`
|
||||||
struct AL {
|
struct AM {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...")]
|
#[suggestion(parser::add_paren)]
|
||||||
//~^ ERROR suggestion without `code = "..."`
|
//~^ ERROR suggestion without `code = "..."`
|
||||||
struct AM {
|
struct AN {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
#[applicability]
|
||||||
|
@ -420,34 +429,34 @@ struct AM {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code ="...", applicability = "foo")]
|
#[suggestion(parser::add_paren, code ="...", applicability = "foo")]
|
||||||
//~^ ERROR invalid applicability
|
//~^ ERROR invalid applicability
|
||||||
struct AN {
|
struct AO {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[help(slug = "label-am")]
|
#[help(parser::add_paren)]
|
||||||
struct AO {
|
struct AP {
|
||||||
var: String
|
var: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[note(slug = "label-an")]
|
#[note(parser::add_paren)]
|
||||||
struct AP;
|
struct AQ;
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code = "...")]
|
#[suggestion(parser::add_paren, code = "...")]
|
||||||
//~^ ERROR suggestion without `applicability`
|
//~^ ERROR suggestion without `applicability`
|
||||||
//~^^ ERROR suggestion without `#[primary_span]` field
|
//~^^ ERROR suggestion without `#[primary_span]` field
|
||||||
struct AQ {
|
struct AR {
|
||||||
var: String,
|
var: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code ="...", applicability = "machine-applicable")]
|
#[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")]
|
||||||
struct AR {
|
struct AS {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
@ -455,8 +464,8 @@ struct AR {
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[label]
|
#[label]
|
||||||
//~^ ERROR unsupported type attribute for subdiagnostic enum
|
//~^ ERROR unsupported type attribute for subdiagnostic enum
|
||||||
enum AS {
|
enum AT {
|
||||||
#[label(slug = "...")]
|
#[label(parser::add_paren)]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -465,24 +474,24 @@ enum AS {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")]
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
||||||
struct AT {
|
struct AU {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
var: String,
|
var: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")]
|
#[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
|
||||||
struct AU {
|
struct AV {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum AV {
|
enum AW {
|
||||||
#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")]
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -491,8 +500,8 @@ enum AV {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(SessionSubdiagnostic)]
|
||||||
enum AW {
|
enum AX {
|
||||||
#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")]
|
#[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
|
||||||
A {
|
A {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
error: label without `#[primary_span]` field
|
error: label without `#[primary_span]` field
|
||||||
--> $DIR/subdiagnostic-derive.rs:47:1
|
--> $DIR/subdiagnostic-derive.rs:47:1
|
||||||
|
|
|
|
||||||
LL | / #[label(slug = "label-c")]
|
LL | / #[label(parser::add_paren)]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct C {
|
LL | | struct C {
|
||||||
LL | | var: String,
|
LL | | var: String,
|
||||||
|
@ -32,98 +32,106 @@ error: `#[label(bug = ...)]` is not a valid attribute
|
||||||
LL | #[label(bug = "...")]
|
LL | #[label(bug = "...")]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: only `code`, `slug` and `applicability` are valid nested attributes
|
= help: first argument of the attribute should be the diagnostic slug
|
||||||
|
|
||||||
error: `#[label("...")]` is not a valid attribute
|
error: `#[label("...")]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:91:9
|
--> $DIR/subdiagnostic-derive.rs:91:9
|
||||||
|
|
|
|
||||||
LL | #[label("...")]
|
LL | #[label("...")]
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= help: first argument of the attribute should be the diagnostic slug
|
||||||
|
|
||||||
error: `#[label(slug = ...)]` is not a valid attribute
|
error: `#[label(slug = ...)]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:100:9
|
--> $DIR/subdiagnostic-derive.rs:100:9
|
||||||
|
|
|
|
||||||
LL | #[label(slug = 4)]
|
LL | #[label(slug = 4)]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: first argument of the attribute should be the diagnostic slug
|
||||||
|
|
||||||
error: `#[label(slug(...))]` is not a valid attribute
|
error: `#[label(slug(...))]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:109:9
|
--> $DIR/subdiagnostic-derive.rs:109:9
|
||||||
|
|
|
|
||||||
LL | #[label(slug("..."))]
|
LL | #[label(slug("..."))]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[label(slug)]` is not a valid attribute
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:118:9
|
|
||||||
|
|
|
|
||||||
LL | #[label(slug)]
|
= help: first argument of the attribute should be the diagnostic slug
|
||||||
| ^^^^
|
|
||||||
|
|
||||||
error: `slug` must be set in a `#[label(...)]` attribute
|
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:127:1
|
--> $DIR/subdiagnostic-derive.rs:128:1
|
||||||
|
|
|
|
||||||
LL | #[label()]
|
LL | #[label()]
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: `code` is not a valid nested attribute of a `label` attribute
|
error: `code` is not a valid nested attribute of a `label` attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:136:1
|
--> $DIR/subdiagnostic-derive.rs:137:1
|
||||||
|
|
|
|
||||||
LL | #[label(code = "...")]
|
LL | #[label(parser::add_paren, code = "...")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `applicability` is not a valid nested attribute of a `label` attribute
|
||||||
|
--> $DIR/subdiagnostic-derive.rs:146:1
|
||||||
|
|
|
||||||
|
LL | #[label(parser::add_paren, applicability = "machine-applicable")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: unsupported type attribute for subdiagnostic enum
|
error: unsupported type attribute for subdiagnostic enum
|
||||||
--> $DIR/subdiagnostic-derive.rs:145:1
|
--> $DIR/subdiagnostic-derive.rs:155:1
|
||||||
|
|
|
|
||||||
LL | #[foo]
|
LL | #[foo]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: `#[bar]` is not a valid attribute
|
error: `#[bar]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:159:5
|
--> $DIR/subdiagnostic-derive.rs:169:5
|
||||||
|
|
|
|
||||||
LL | #[bar]
|
LL | #[bar]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: `#[bar = ...]` is not a valid attribute
|
error: `#[bar = ...]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:171:5
|
--> $DIR/subdiagnostic-derive.rs:181:5
|
||||||
|
|
|
|
||||||
LL | #[bar = "..."]
|
LL | #[bar = "..."]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[bar = ...]` is not a valid attribute
|
error: `#[bar = ...]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:183:5
|
--> $DIR/subdiagnostic-derive.rs:193:5
|
||||||
|
|
|
|
||||||
LL | #[bar = 4]
|
LL | #[bar = 4]
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[bar("...")]` is not a valid attribute
|
error: `#[bar("...")]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:195:11
|
--> $DIR/subdiagnostic-derive.rs:205:11
|
||||||
|
|
|
|
||||||
LL | #[bar("...")]
|
LL | #[bar("...")]
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= help: first argument of the attribute should be the diagnostic slug
|
||||||
|
|
||||||
error: `code` is not a valid nested attribute of a `label` attribute
|
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:207:5
|
--> $DIR/subdiagnostic-derive.rs:217:5
|
||||||
|
|
|
|
||||||
LL | #[label(code = "...")]
|
LL | #[label(code = "...")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: subdiagnostic kind not specified
|
error: subdiagnostic kind not specified
|
||||||
--> $DIR/subdiagnostic-derive.rs:224:5
|
--> $DIR/subdiagnostic-derive.rs:234:5
|
||||||
|
|
|
|
||||||
LL | B {
|
LL | B {
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: the `#[primary_span]` attribute can only be applied to fields of type `Span`
|
error: the `#[primary_span]` attribute can only be applied to fields of type `Span`
|
||||||
--> $DIR/subdiagnostic-derive.rs:236:5
|
--> $DIR/subdiagnostic-derive.rs:246:5
|
||||||
|
|
|
|
||||||
LL | #[primary_span]
|
LL | #[primary_span]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: label without `#[primary_span]` field
|
error: label without `#[primary_span]` field
|
||||||
--> $DIR/subdiagnostic-derive.rs:233:1
|
--> $DIR/subdiagnostic-derive.rs:243:1
|
||||||
|
|
|
|
||||||
LL | / #[label(slug = "...")]
|
LL | / #[label(parser::add_paren)]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct V {
|
LL | | struct W {
|
||||||
LL | | #[primary_span]
|
LL | | #[primary_span]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | span: String,
|
LL | | span: String,
|
||||||
|
@ -131,13 +139,13 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: `#[applicability]` is only valid on suggestions
|
error: `#[applicability]` is only valid on suggestions
|
||||||
--> $DIR/subdiagnostic-derive.rs:246:5
|
--> $DIR/subdiagnostic-derive.rs:256:5
|
||||||
|
|
|
|
||||||
LL | #[applicability]
|
LL | #[applicability]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[bar]` is not a valid attribute
|
error: `#[bar]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:256:5
|
--> $DIR/subdiagnostic-derive.rs:266:5
|
||||||
|
|
|
|
||||||
LL | #[bar]
|
LL | #[bar]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
@ -145,21 +153,21 @@ LL | #[bar]
|
||||||
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
|
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
|
||||||
|
|
||||||
error: `#[bar = ...]` is not a valid attribute
|
error: `#[bar = ...]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:267:5
|
--> $DIR/subdiagnostic-derive.rs:277:5
|
||||||
|
|
|
|
||||||
LL | #[bar = "..."]
|
LL | #[bar = "..."]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[bar(...)]` is not a valid attribute
|
error: `#[bar(...)]` is not a valid attribute
|
||||||
--> $DIR/subdiagnostic-derive.rs:278:5
|
--> $DIR/subdiagnostic-derive.rs:288:5
|
||||||
|
|
|
|
||||||
LL | #[bar("...")]
|
LL | #[bar("...")]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: unexpected unsupported untagged union
|
error: unexpected unsupported untagged union
|
||||||
--> $DIR/subdiagnostic-derive.rs:294:1
|
--> $DIR/subdiagnostic-derive.rs:304:1
|
||||||
|
|
|
|
||||||
LL | / union AB {
|
LL | / union AC {
|
||||||
LL | |
|
LL | |
|
||||||
LL | | span: u32,
|
LL | | span: u32,
|
||||||
LL | | b: u64
|
LL | | b: u64
|
||||||
|
@ -167,95 +175,91 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/subdiagnostic-derive.rs:304:9
|
--> $DIR/subdiagnostic-derive.rs:314:1
|
||||||
|
|
|
|
||||||
LL | #[label(slug = "label-ac-2")]
|
LL | #[label(parser::add_paren)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/subdiagnostic-derive.rs:301:9
|
--> $DIR/subdiagnostic-derive.rs:311:1
|
||||||
|
|
|
|
||||||
LL | #[label(slug = "label-ac-1")]
|
LL | #[label(parser::add_paren)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/subdiagnostic-derive.rs:304:1
|
--> $DIR/subdiagnostic-derive.rs:314:1
|
||||||
|
|
|
|
||||||
LL | #[label(slug = "label-ac-2")]
|
LL | #[label(parser::add_paren)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/subdiagnostic-derive.rs:301:1
|
--> $DIR/subdiagnostic-derive.rs:311:1
|
||||||
|
|
|
|
||||||
LL | #[label(slug = "label-ac-1")]
|
LL | #[label(parser::add_paren)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `#[label(parser::add_paren)]` is not a valid attribute
|
||||||
|
--> $DIR/subdiagnostic-derive.rs:323:28
|
||||||
|
|
|
||||||
|
LL | #[label(parser::add_paren, parser::add_paren)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: a diagnostic slug must be the first argument to the attribute
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/subdiagnostic-derive.rs:313:30
|
--> $DIR/subdiagnostic-derive.rs:336:5
|
||||||
|
|
|
||||||
LL | #[label(slug = "label-ad-1", slug = "label-ad-2")]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: previously specified here
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:313:9
|
|
||||||
|
|
|
||||||
LL | #[label(slug = "label-ad-1", slug = "label-ad-2")]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: specified multiple times
|
|
||||||
--> $DIR/subdiagnostic-derive.rs:327:5
|
|
||||||
|
|
|
|
||||||
LL | #[primary_span]
|
LL | #[primary_span]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/subdiagnostic-derive.rs:324:5
|
--> $DIR/subdiagnostic-derive.rs:333:5
|
||||||
|
|
|
|
||||||
LL | #[primary_span]
|
LL | #[primary_span]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: subdiagnostic kind not specified
|
error: subdiagnostic kind not specified
|
||||||
--> $DIR/subdiagnostic-derive.rs:333:8
|
--> $DIR/subdiagnostic-derive.rs:342:8
|
||||||
|
|
|
|
||||||
LL | struct AF {
|
LL | struct AG {
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/subdiagnostic-derive.rs:370:42
|
--> $DIR/subdiagnostic-derive.rs:379:47
|
||||||
|
|
|
|
||||||
LL | #[suggestion(slug = "...", code = "...", code = "...")]
|
LL | #[suggestion(parser::add_paren, code = "...", code = "...")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/subdiagnostic-derive.rs:370:28
|
--> $DIR/subdiagnostic-derive.rs:379:33
|
||||||
|
|
|
|
||||||
LL | #[suggestion(slug = "...", code = "...", code = "...")]
|
LL | #[suggestion(parser::add_paren, code = "...", code = "...")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/subdiagnostic-derive.rs:388:5
|
--> $DIR/subdiagnostic-derive.rs:397:5
|
||||||
|
|
|
|
||||||
LL | #[applicability]
|
LL | #[applicability]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/subdiagnostic-derive.rs:385:5
|
--> $DIR/subdiagnostic-derive.rs:394:5
|
||||||
|
|
|
|
||||||
LL | #[applicability]
|
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:399:5
|
--> $DIR/subdiagnostic-derive.rs:408:5
|
||||||
|
|
|
|
||||||
LL | #[applicability]
|
LL | #[applicability]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
error: suggestion without `applicability`
|
||||||
--> $DIR/subdiagnostic-derive.rs:394:1
|
--> $DIR/subdiagnostic-derive.rs:403:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(slug = "...", code = "...")]
|
LL | / #[suggestion(parser::add_paren, code = "...")]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct AK {
|
LL | | struct AL {
|
||||||
LL | | #[primary_span]
|
LL | | #[primary_span]
|
||||||
... |
|
... |
|
||||||
LL | | applicability: Span,
|
LL | | applicability: Span,
|
||||||
|
@ -263,22 +267,22 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
error: suggestion without `applicability`
|
||||||
--> $DIR/subdiagnostic-derive.rs:405:1
|
--> $DIR/subdiagnostic-derive.rs:414:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(slug = "...", code = "...")]
|
LL | / #[suggestion(parser::add_paren, code = "...")]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct AL {
|
LL | | struct AM {
|
||||||
LL | | #[primary_span]
|
LL | | #[primary_span]
|
||||||
LL | | span: Span,
|
LL | | span: Span,
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: suggestion without `code = "..."`
|
error: suggestion without `code = "..."`
|
||||||
--> $DIR/subdiagnostic-derive.rs:413:1
|
--> $DIR/subdiagnostic-derive.rs:422:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(slug = "...")]
|
LL | / #[suggestion(parser::add_paren)]
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct AM {
|
LL | | struct AN {
|
||||||
LL | | #[primary_span]
|
LL | | #[primary_span]
|
||||||
... |
|
... |
|
||||||
LL | | applicability: Applicability,
|
LL | | applicability: Applicability,
|
||||||
|
@ -286,50 +290,50 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: invalid applicability
|
error: invalid applicability
|
||||||
--> $DIR/subdiagnostic-derive.rs:423:41
|
--> $DIR/subdiagnostic-derive.rs:432:46
|
||||||
|
|
|
|
||||||
LL | #[suggestion(slug = "...", code ="...", applicability = "foo")]
|
LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: suggestion without `applicability`
|
error: suggestion without `applicability`
|
||||||
--> $DIR/subdiagnostic-derive.rs:441:1
|
--> $DIR/subdiagnostic-derive.rs:450:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(slug = "...", code = "...")]
|
LL | / #[suggestion(parser::add_paren, code = "...")]
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct AQ {
|
LL | | struct AR {
|
||||||
LL | | var: String,
|
LL | | var: String,
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: suggestion without `#[primary_span]` field
|
error: suggestion without `#[primary_span]` field
|
||||||
--> $DIR/subdiagnostic-derive.rs:441:1
|
--> $DIR/subdiagnostic-derive.rs:450:1
|
||||||
|
|
|
|
||||||
LL | / #[suggestion(slug = "...", code = "...")]
|
LL | / #[suggestion(parser::add_paren, code = "...")]
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | struct AQ {
|
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:456:1
|
--> $DIR/subdiagnostic-derive.rs:465: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:476:34
|
--> $DIR/subdiagnostic-derive.rs:485:39
|
||||||
|
|
|
|
||||||
LL | #[suggestion(slug = "...", 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:495:38
|
--> $DIR/subdiagnostic-derive.rs:504:43
|
||||||
|
|
|
|
||||||
LL | #[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")]
|
LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: cannot find attribute `foo` in this scope
|
error: cannot find attribute `foo` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:63:3
|
--> $DIR/subdiagnostic-derive.rs:63:3
|
||||||
|
@ -338,52 +342,59 @@ LL | #[foo]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `foo` in this scope
|
error: cannot find attribute `foo` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:145:3
|
--> $DIR/subdiagnostic-derive.rs:155:3
|
||||||
|
|
|
|
||||||
LL | #[foo]
|
LL | #[foo]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:159:7
|
--> $DIR/subdiagnostic-derive.rs:169:7
|
||||||
|
|
|
|
||||||
LL | #[bar]
|
LL | #[bar]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:171:7
|
--> $DIR/subdiagnostic-derive.rs:181:7
|
||||||
|
|
|
|
||||||
LL | #[bar = "..."]
|
LL | #[bar = "..."]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:183:7
|
--> $DIR/subdiagnostic-derive.rs:193:7
|
||||||
|
|
|
|
||||||
LL | #[bar = 4]
|
LL | #[bar = 4]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:195:7
|
--> $DIR/subdiagnostic-derive.rs:205:7
|
||||||
|
|
|
|
||||||
LL | #[bar("...")]
|
LL | #[bar("...")]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:256:7
|
--> $DIR/subdiagnostic-derive.rs:266:7
|
||||||
|
|
|
|
||||||
LL | #[bar]
|
LL | #[bar]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:267:7
|
--> $DIR/subdiagnostic-derive.rs:277:7
|
||||||
|
|
|
|
||||||
LL | #[bar = "..."]
|
LL | #[bar = "..."]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: cannot find attribute `bar` in this scope
|
error: cannot find attribute `bar` in this scope
|
||||||
--> $DIR/subdiagnostic-derive.rs:278:7
|
--> $DIR/subdiagnostic-derive.rs:288:7
|
||||||
|
|
|
|
||||||
LL | #[bar("...")]
|
LL | #[bar("...")]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 51 previous errors
|
error[E0425]: cannot find value `slug` in module `rustc_errors::fluent`
|
||||||
|
--> $DIR/subdiagnostic-derive.rs:118:9
|
||||||
|
|
|
||||||
|
LL | #[label(slug)]
|
||||||
|
| ^^^^ not found in `rustc_errors::fluent`
|
||||||
|
|
||||||
|
error: aborting due to 52 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue