Fix tests

This commit is contained in:
mejrs 2022-11-08 00:42:00 +01:00
parent fe212eca76
commit d494502f64
4 changed files with 165 additions and 157 deletions

View File

@ -165,40 +165,48 @@ impl<'a> LintDiagnosticDerive<'a> {
fn make_check(slug: &syn::Path) -> TokenStream { fn make_check(slug: &syn::Path) -> TokenStream {
quote! { quote! {
const _: () = { const _: () = {
let krate = env!("CARGO_MANIFEST_DIR").as_bytes(); const krate_str: &str = match option_env!("CARGO_CRATE_NAME") {
Some(c) => c,
None => "",
};
const krate: &[u8] = krate_str.as_bytes();
let mut start = 0; if krate.len() > 6
while !(krate[start] == b'r' && krate[0] == b'r'
&& krate[start + 1] == b'u' && krate[1] == b'u'
&& krate[start + 2] == b's' && krate[2] == b's'
&& krate[start + 3] == b't' && krate[3] == b't'
&& krate[start + 4] == b'c' && krate[4] == b'c'
&& krate[start + 5] == b'_') && krate[5] == b'_'
{ {
if krate.len() == start + 5 { let slug = stringify!(#slug).as_bytes();
panic!(concat!("crate does not contain \"rustc_\": ", env!("CARGO_MANIFEST_DIR")));
}
start += 1;
}
start += 6;
let slug = stringify!(#slug).as_bytes(); let mut pos = 0;
loop {
let mut pos = 0; let b = slug[pos];
loop { if krate.len() == pos + 6 {
let b = slug[pos]; if b != b'_' {
if krate.len() == start + pos { panic!(concat!(
if b != b'_' { "slug \"",
panic!(concat!("slug \"", stringify!(#slug), "\" does not match the crate (", env!("CARGO_MANIFEST_DIR") ,") it is in")); stringify!(#slug),
"\" does not match the crate it is in"
));
}
break;
} }
break let a = krate[pos + 6];
}
let a = krate[start+pos];
if a != b { if a != b {
panic!(concat!("slug \"", stringify!(#slug), "\" does not match the crate (", env!("CARGO_MANIFEST_DIR") ,") it is in")); panic!(concat!(
"slug \"",
stringify!(#slug),
"\" does not match the crate it is in"
));
}
pos += 1;
} }
pos += 1; } else {
// Crate does not start with "rustc_"
} }
}; };
} }

View File

@ -471,7 +471,7 @@ struct NoApplicability {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[note(parser_add_paren)] #[note(parse_add_paren)]
struct Note; struct Note;
#[derive(Diagnostic)] #[derive(Diagnostic)]

View File

@ -20,7 +20,7 @@ use rustc_macros::Subdiagnostic;
use rustc_span::Span; use rustc_span::Span;
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct A { struct A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -29,13 +29,13 @@ struct A {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum B { enum B {
#[label(parser_add_paren)] #[label(parse_add_paren)]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
var: String, var: String,
}, },
#[label(parser_add_paren)] #[label(parse_add_paren)]
B { B {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -44,7 +44,7 @@ enum B {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
//~^ ERROR label without `#[primary_span]` field //~^ ERROR label without `#[primary_span]` field
struct C { struct C {
var: String, var: String,
@ -138,7 +138,7 @@ struct M {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren, code = "...")] #[label(parse_add_paren, code = "...")]
//~^ ERROR `#[label(code = ...)]` is not a valid attribute //~^ ERROR `#[label(code = ...)]` is not a valid attribute
struct N { struct N {
#[primary_span] #[primary_span]
@ -147,7 +147,7 @@ struct N {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren, applicability = "machine-applicable")] #[label(parse_add_paren, applicability = "machine-applicable")]
//~^ ERROR `#[label(applicability = ...)]` is not a valid attribute //~^ ERROR `#[label(applicability = ...)]` is not a valid attribute
struct O { struct O {
#[primary_span] #[primary_span]
@ -160,7 +160,7 @@ struct O {
//~^ 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 P { enum P {
#[label(parser_add_paren)] #[label(parse_add_paren)]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -230,7 +230,7 @@ enum U {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum V { enum V {
#[label(parser_add_paren)] #[label(parse_add_paren)]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -244,7 +244,7 @@ enum V {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
//~^ ERROR label without `#[primary_span]` field //~^ ERROR label without `#[primary_span]` field
struct W { struct W {
#[primary_span] #[primary_span]
@ -253,7 +253,7 @@ struct W {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct X { struct X {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -263,7 +263,7 @@ struct X {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct Y { struct Y {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -274,7 +274,7 @@ struct Y {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct Z { struct Z {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -285,7 +285,7 @@ struct Z {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct AA { struct AA {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -296,7 +296,7 @@ struct AA {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct AB { struct AB {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -312,23 +312,23 @@ union AC {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct AD { struct AD {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren, parser_add_paren)] #[label(parse_add_paren, parse_add_paren)]
//~^ ERROR `#[label(parser_add_paren)]` is not a valid attribute //~^ ERROR `#[label(parse_add_paren)]` is not a valid attribute
struct AE { struct AE {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct AF { struct AF {
#[primary_span] #[primary_span]
//~^ NOTE previously specified here //~^ NOTE previously specified here
@ -346,7 +346,7 @@ struct AG {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
struct AH { struct AH {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -357,7 +357,7 @@ struct AH {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum AI { enum AI {
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -365,7 +365,7 @@ enum AI {
applicability: Applicability, applicability: Applicability,
var: String, var: String,
}, },
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
B { B {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -376,7 +376,7 @@ enum AI {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...", code = "...")] #[suggestion(parse_add_paren, code = "...", code = "...")]
//~^ ERROR specified multiple times //~^ ERROR specified multiple times
//~^^ NOTE previously specified here //~^^ NOTE previously specified here
struct AJ { struct AJ {
@ -387,7 +387,7 @@ struct AJ {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
struct AK { struct AK {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -400,7 +400,7 @@ struct AK {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
struct AL { struct AL {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -410,14 +410,14 @@ struct AL {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
struct AM { struct AM {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren)] #[suggestion(parse_add_paren)]
//~^ ERROR suggestion without `code = "..."` //~^ ERROR suggestion without `code = "..."`
struct AN { struct AN {
#[primary_span] #[primary_span]
@ -427,7 +427,7 @@ struct AN {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...", applicability = "foo")] #[suggestion(parse_add_paren, code = "...", applicability = "foo")]
//~^ ERROR invalid applicability //~^ ERROR invalid applicability
struct AO { struct AO {
#[primary_span] #[primary_span]
@ -435,24 +435,24 @@ struct AO {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[help(parser_add_paren)] #[help(parse_add_paren)]
struct AP { struct AP {
var: String, var: String,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[note(parser_add_paren)] #[note(parse_add_paren)]
struct AQ; struct AQ;
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field //~^ ERROR suggestion without `#[primary_span]` field
struct AR { struct AR {
var: String, var: String,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] #[suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")]
struct AS { struct AS {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -462,7 +462,7 @@ struct AS {
#[label] #[label]
//~^ ERROR unsupported type attribute for subdiagnostic enum //~^ ERROR unsupported type attribute for subdiagnostic enum
enum AT { enum AT {
#[label(parser_add_paren)] #[label(parse_add_paren)]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -471,7 +471,7 @@ enum AT {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")]
struct AU { struct AU {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -479,7 +479,7 @@ struct AU {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] #[suggestion(parse_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 AV { struct AV {
#[primary_span] #[primary_span]
@ -488,7 +488,7 @@ struct AV {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum AW { enum AW {
#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")]
A { A {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -498,7 +498,7 @@ enum AW {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum AX { enum AX {
#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] #[suggestion(parse_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]
@ -507,18 +507,18 @@ enum AX {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[warning(parser_add_paren)] #[warning(parse_add_paren)]
struct AY {} struct AY {}
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[warning(parser_add_paren)] #[warning(parse_add_paren)]
struct AZ { struct AZ {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "...")] #[suggestion(parse_add_paren, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field //~^ ERROR suggestion without `#[primary_span]` field
struct BA { struct BA {
#[suggestion_part] #[suggestion_part]
@ -533,7 +533,7 @@ struct BA {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
//~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute //~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute
struct BBa { struct BBa {
@ -541,7 +541,7 @@ struct BBa {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BBb { struct BBb {
#[suggestion_part] #[suggestion_part]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
@ -549,7 +549,7 @@ struct BBb {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BBc { struct BBc {
#[suggestion_part()] #[suggestion_part()]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
@ -557,7 +557,7 @@ struct BBc {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
struct BC { struct BC {
#[primary_span] #[primary_span]
@ -566,7 +566,7 @@ struct BC {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BD { struct BD {
#[suggestion_part] #[suggestion_part]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
@ -586,7 +586,7 @@ struct BD {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BE { struct BE {
#[suggestion_part(code = "...", code = ",,,")] #[suggestion_part(code = "...", code = ",,,")]
//~^ ERROR specified multiple times //~^ ERROR specified multiple times
@ -595,7 +595,7 @@ struct BE {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BF { struct BF {
#[suggestion_part(code = "(")] #[suggestion_part(code = "(")]
first: Span, first: Span,
@ -604,7 +604,7 @@ struct BF {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BG { struct BG {
#[applicability] #[applicability]
appl: Applicability, appl: Applicability,
@ -615,7 +615,7 @@ struct BG {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BH { struct BH {
#[applicability] #[applicability]
//~^ ERROR `#[applicability]` has no effect //~^ ERROR `#[applicability]` has no effect
@ -627,14 +627,14 @@ struct BH {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")]
struct BI { struct BI {
#[suggestion_part(code = "")] #[suggestion_part(code = "")]
spans: Vec<Span>, spans: Vec<Span>,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct BJ { struct BJ {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -643,7 +643,7 @@ struct BJ {
/// with a doc comment on the type.. /// with a doc comment on the type..
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser_add_paren)] #[label(parse_add_paren)]
struct BK { struct BK {
/// ..and the field /// ..and the field
#[primary_span] #[primary_span]
@ -654,7 +654,7 @@ struct BK {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
enum BL { enum BL {
/// ..and the variant.. /// ..and the variant..
#[label(parser_add_paren)] #[label(parse_add_paren)]
Foo { Foo {
/// ..and the field /// ..and the field
#[primary_span] #[primary_span]
@ -663,7 +663,7 @@ enum BL {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BM { struct BM {
#[suggestion_part(code("foo"))] #[suggestion_part(code("foo"))]
//~^ ERROR expected exactly one string literal for `code = ...` //~^ ERROR expected exactly one string literal for `code = ...`
@ -672,7 +672,7 @@ struct BM {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BN { struct BN {
#[suggestion_part(code("foo", "bar"))] #[suggestion_part(code("foo", "bar"))]
//~^ ERROR expected exactly one string literal for `code = ...` //~^ ERROR expected exactly one string literal for `code = ...`
@ -681,7 +681,7 @@ struct BN {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BO { struct BO {
#[suggestion_part(code(3))] #[suggestion_part(code(3))]
//~^ ERROR expected exactly one string literal for `code = ...` //~^ ERROR expected exactly one string literal for `code = ...`
@ -690,7 +690,7 @@ struct BO {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BP { struct BP {
#[suggestion_part(code())] #[suggestion_part(code())]
//~^ ERROR expected exactly one string literal for `code = ...` //~^ ERROR expected exactly one string literal for `code = ...`
@ -699,7 +699,7 @@ struct BP {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser_add_paren)] #[multipart_suggestion(parse_add_paren)]
struct BQ { struct BQ {
#[suggestion_part(code = 3)] #[suggestion_part(code = 3)]
//~^ ERROR `code = "..."`/`code(...)` must contain only string literals //~^ ERROR `code = "..."`/`code(...)` must contain only string literals
@ -708,42 +708,42 @@ struct BQ {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "")] #[suggestion(parse_add_paren, code = "")]
struct SuggestionStyleDefault { struct SuggestionStyleDefault {
#[primary_span] #[primary_span]
sub: Span, sub: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "short")] #[suggestion(parse_add_paren, code = "", style = "short")]
struct SuggestionStyleShort { struct SuggestionStyleShort {
#[primary_span] #[primary_span]
sub: Span, sub: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "hidden")] #[suggestion(parse_add_paren, code = "", style = "hidden")]
struct SuggestionStyleHidden { struct SuggestionStyleHidden {
#[primary_span] #[primary_span]
sub: Span, sub: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "verbose")] #[suggestion(parse_add_paren, code = "", style = "verbose")]
struct SuggestionStyleVerbose { struct SuggestionStyleVerbose {
#[primary_span] #[primary_span]
sub: Span, sub: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "tool-only")] #[suggestion(parse_add_paren, code = "", style = "tool-only")]
struct SuggestionStyleToolOnly { struct SuggestionStyleToolOnly {
#[primary_span] #[primary_span]
sub: Span, sub: Span,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] #[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")]
//~^ ERROR specified multiple times //~^ ERROR specified multiple times
//~| NOTE previously specified here //~| NOTE previously specified here
struct SuggestionStyleTwice { struct SuggestionStyleTwice {
@ -752,7 +752,7 @@ struct SuggestionStyleTwice {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion_hidden(parser_add_paren, code = "")] #[suggestion_hidden(parse_add_paren, code = "")]
//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute //~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
struct SuggestionStyleOldSyntax { struct SuggestionStyleOldSyntax {
#[primary_span] #[primary_span]
@ -760,7 +760,7 @@ struct SuggestionStyleOldSyntax {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion_hidden(parser_add_paren, code = "", style = "normal")] #[suggestion_hidden(parse_add_paren, code = "", style = "normal")]
//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute //~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
struct SuggestionStyleOldAndNewSyntax { struct SuggestionStyleOldAndNewSyntax {
#[primary_span] #[primary_span]
@ -768,7 +768,7 @@ struct SuggestionStyleOldAndNewSyntax {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = "foo")] #[suggestion(parse_add_paren, code = "", style = "foo")]
//~^ ERROR invalid suggestion style //~^ ERROR invalid suggestion style
struct SuggestionStyleInvalid1 { struct SuggestionStyleInvalid1 {
#[primary_span] #[primary_span]
@ -776,7 +776,7 @@ struct SuggestionStyleInvalid1 {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style = 42)] #[suggestion(parse_add_paren, code = "", style = 42)]
//~^ ERROR `#[suggestion(style = ...)]` is not a valid attribute //~^ ERROR `#[suggestion(style = ...)]` is not a valid attribute
struct SuggestionStyleInvalid2 { struct SuggestionStyleInvalid2 {
#[primary_span] #[primary_span]
@ -784,7 +784,7 @@ struct SuggestionStyleInvalid2 {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style)] #[suggestion(parse_add_paren, code = "", style)]
//~^ ERROR `#[suggestion(style)]` is not a valid attribute //~^ ERROR `#[suggestion(style)]` is not a valid attribute
struct SuggestionStyleInvalid3 { struct SuggestionStyleInvalid3 {
#[primary_span] #[primary_span]
@ -792,7 +792,7 @@ struct SuggestionStyleInvalid3 {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser_add_paren, code = "", style("foo"))] #[suggestion(parse_add_paren, code = "", style("foo"))]
//~^ ERROR `#[suggestion(style(...))]` is not a valid attribute //~^ ERROR `#[suggestion(style(...))]` is not a valid attribute
struct SuggestionStyleInvalid4 { struct SuggestionStyleInvalid4 {
#[primary_span] #[primary_span]

View File

@ -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(parser_add_paren)] LL | / #[label(parse_add_paren)]
LL | | LL | |
LL | | struct C { LL | | struct C {
LL | | var: String, LL | | var: String,
@ -81,16 +81,16 @@ LL | #[label()]
| ^^^^^^^^^^ | ^^^^^^^^^^
error: `#[label(code = ...)]` is not a valid attribute error: `#[label(code = ...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:141:27 --> $DIR/subdiagnostic-derive.rs:141:26
| |
LL | #[label(parser_add_paren, code = "...")] LL | #[label(parse_add_paren, code = "...")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: `#[label(applicability = ...)]` is not a valid attribute error: `#[label(applicability = ...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:150:27 --> $DIR/subdiagnostic-derive.rs:150:26
| |
LL | #[label(parser_add_paren, applicability = "machine-applicable")] LL | #[label(parse_add_paren, applicability = "machine-applicable")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unsupported type attribute for subdiagnostic enum error: unsupported type attribute for subdiagnostic enum
--> $DIR/subdiagnostic-derive.rs:159:1 --> $DIR/subdiagnostic-derive.rs:159:1
@ -143,7 +143,7 @@ LL | #[primary_span]
error: label without `#[primary_span]` field error: label without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:247:1 --> $DIR/subdiagnostic-derive.rs:247:1
| |
LL | / #[label(parser_add_paren)] LL | / #[label(parse_add_paren)]
LL | | LL | |
LL | | struct W { LL | | struct W {
LL | | #[primary_span] LL | | #[primary_span]
@ -190,11 +190,11 @@ LL | | b: u64,
LL | | } LL | | }
| |_^ | |_^
error: `#[label(parser_add_paren)]` is not a valid attribute error: `#[label(parse_add_paren)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:323:27 --> $DIR/subdiagnostic-derive.rs:323:26
| |
LL | #[label(parser_add_paren, parser_add_paren)] LL | #[label(parse_add_paren, parse_add_paren)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
| |
= help: a diagnostic slug must be the first argument to the attribute = help: a diagnostic slug must be the first argument to the attribute
@ -217,16 +217,16 @@ LL | struct AG {
| ^^ | ^^
error: specified multiple times error: specified multiple times
--> $DIR/subdiagnostic-derive.rs:379:46 --> $DIR/subdiagnostic-derive.rs:379:45
| |
LL | #[suggestion(parser_add_paren, code = "...", code = "...")] LL | #[suggestion(parse_add_paren, code = "...", code = "...")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
note: previously specified here note: previously specified here
--> $DIR/subdiagnostic-derive.rs:379:32 --> $DIR/subdiagnostic-derive.rs:379:31
| |
LL | #[suggestion(parser_add_paren, code = "...", code = "...")] LL | #[suggestion(parse_add_paren, code = "...", code = "...")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: specified multiple times error: specified multiple times
--> $DIR/subdiagnostic-derive.rs:397:5 --> $DIR/subdiagnostic-derive.rs:397:5
@ -249,19 +249,19 @@ LL | #[applicability]
error: suggestion without `code = "..."` error: suggestion without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:420:1 --> $DIR/subdiagnostic-derive.rs:420:1
| |
LL | #[suggestion(parser_add_paren)] LL | #[suggestion(parse_add_paren)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: invalid applicability error: invalid applicability
--> $DIR/subdiagnostic-derive.rs:430:46 --> $DIR/subdiagnostic-derive.rs:430:45
| |
LL | #[suggestion(parser_add_paren, code = "...", applicability = "foo")] LL | #[suggestion(parse_add_paren, code = "...", applicability = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: suggestion without `#[primary_span]` field error: suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:448:1 --> $DIR/subdiagnostic-derive.rs:448:1
| |
LL | / #[suggestion(parser_add_paren, code = "...")] LL | / #[suggestion(parse_add_paren, code = "...")]
LL | | LL | |
LL | | struct AR { LL | | struct AR {
LL | | var: String, LL | | var: String,
@ -275,16 +275,16 @@ 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:482:39 --> $DIR/subdiagnostic-derive.rs:482:38
| |
LL | #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] LL | #[suggestion(parse_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:501:43 --> $DIR/subdiagnostic-derive.rs:501:42
| |
LL | #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] LL | #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")]
| ^^^^^^^ | ^^^^^^^
error: `#[suggestion_part]` is not a valid attribute error: `#[suggestion_part]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:524:5 --> $DIR/subdiagnostic-derive.rs:524:5
@ -305,7 +305,7 @@ LL | #[suggestion_part(code = "...")]
error: suggestion without `#[primary_span]` field error: suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:521:1 --> $DIR/subdiagnostic-derive.rs:521:1
| |
LL | / #[suggestion(parser_add_paren, code = "...")] LL | / #[suggestion(parse_add_paren, code = "...")]
LL | | LL | |
LL | | struct BA { LL | | struct BA {
LL | | #[suggestion_part] LL | | #[suggestion_part]
@ -315,17 +315,17 @@ LL | | }
| |_^ | |_^
error: `#[multipart_suggestion(code = ...)]` is not a valid attribute error: `#[multipart_suggestion(code = ...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:536:42 --> $DIR/subdiagnostic-derive.rs:536:41
| |
LL | #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] LL | #[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
= help: only `style` and `applicability` are valid nested attributes = help: only `style` and `applicability` are valid nested attributes
error: multipart suggestion without any `#[suggestion_part(...)]` fields error: multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive.rs:536:1 --> $DIR/subdiagnostic-derive.rs:536:1
| |
LL | / #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] LL | / #[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")]
LL | | LL | |
LL | | LL | |
LL | | struct BBa { LL | | struct BBa {
@ -356,7 +356,7 @@ LL | #[primary_span]
error: multipart suggestion without any `#[suggestion_part(...)]` fields error: multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive.rs:560:1 --> $DIR/subdiagnostic-derive.rs:560:1
| |
LL | / #[multipart_suggestion(parser_add_paren)] LL | / #[multipart_suggestion(parse_add_paren)]
LL | | LL | |
LL | | struct BC { LL | | struct BC {
LL | | #[primary_span] LL | | #[primary_span]
@ -446,60 +446,60 @@ LL | #[suggestion_part(code = 3)]
| ^^^^^^^^ | ^^^^^^^^
error: specified multiple times error: specified multiple times
--> $DIR/subdiagnostic-derive.rs:746:61 --> $DIR/subdiagnostic-derive.rs:746:60
| |
LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] LL | #[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
| |
note: previously specified here note: previously specified here
--> $DIR/subdiagnostic-derive.rs:746:43 --> $DIR/subdiagnostic-derive.rs:746:42
| |
LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] LL | #[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: `#[suggestion_hidden(...)]` is not a valid attribute error: `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:755:1 --> $DIR/subdiagnostic-derive.rs:755:1
| |
LL | #[suggestion_hidden(parser_add_paren, code = "")] LL | #[suggestion_hidden(parse_add_paren, code = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: Use `#[suggestion(..., style = "hidden")]` instead = help: Use `#[suggestion(..., style = "hidden")]` instead
error: `#[suggestion_hidden(...)]` is not a valid attribute error: `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:763:1 --> $DIR/subdiagnostic-derive.rs:763:1
| |
LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] LL | #[suggestion_hidden(parse_add_paren, code = "", style = "normal")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: Use `#[suggestion(..., style = "hidden")]` instead = help: Use `#[suggestion(..., style = "hidden")]` instead
error: invalid suggestion style error: invalid suggestion style
--> $DIR/subdiagnostic-derive.rs:771:51 --> $DIR/subdiagnostic-derive.rs:771:50
| |
LL | #[suggestion(parser_add_paren, code = "", style = "foo")] LL | #[suggestion(parse_add_paren, code = "", style = "foo")]
| ^^^^^ | ^^^^^
| |
= help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`
error: `#[suggestion(style = ...)]` is not a valid attribute error: `#[suggestion(style = ...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:779:43 --> $DIR/subdiagnostic-derive.rs:779:42
| |
LL | #[suggestion(parser_add_paren, code = "", style = 42)] LL | #[suggestion(parse_add_paren, code = "", style = 42)]
| ^^^^^^^^^^ | ^^^^^^^^^^
error: `#[suggestion(style)]` is not a valid attribute error: `#[suggestion(style)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:787:43 --> $DIR/subdiagnostic-derive.rs:787:42
| |
LL | #[suggestion(parser_add_paren, code = "", style)] LL | #[suggestion(parse_add_paren, code = "", style)]
| ^^^^^ | ^^^^^
| |
= 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: `#[suggestion(style(...))]` is not a valid attribute error: `#[suggestion(style(...))]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:795:43 --> $DIR/subdiagnostic-derive.rs:795:42
| |
LL | #[suggestion(parser_add_paren, code = "", style("foo"))] LL | #[suggestion(parse_add_paren, code = "", style("foo"))]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
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