2022-04-26 10:59:45 +00:00
|
|
|
// check-fail
|
2022-09-18 15:47:31 +00:00
|
|
|
// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
|
|
|
|
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
2022-09-18 15:47:31 +00:00
|
|
|
// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler
|
2022-04-26 10:59:45 +00:00
|
|
|
// the test is just ignored on stable and beta:
|
|
|
|
// ignore-beta
|
|
|
|
// ignore-stable
|
|
|
|
|
|
|
|
#![feature(rustc_private)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
extern crate rustc_errors;
|
|
|
|
extern crate rustc_session;
|
|
|
|
extern crate rustc_span;
|
|
|
|
extern crate rustc_macros;
|
|
|
|
|
|
|
|
use rustc_errors::Applicability;
|
|
|
|
use rustc_span::Span;
|
2022-09-18 15:47:31 +00:00
|
|
|
use rustc_macros::Subdiagnostic;
|
2022-04-26 10:59:45 +00:00
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
struct A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
enum B {
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
},
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
B {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR label without `#[primary_span]` field
|
|
|
|
struct C {
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct D {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[foo]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[foo]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^^ ERROR cannot find attribute `foo` in this scope
|
|
|
|
struct E {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label = "..."]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label = ...]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct F {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label(bug = "...")]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label(bug = ...)]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct G {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label("...")]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label("...")]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct H {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label(slug = 4)]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label(slug = ...)]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct J {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label(slug("..."))]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[label(slug(...))]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct K {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label(slug)]
|
2022-06-23 15:12:52 +00:00
|
|
|
//~^ ERROR cannot find value `slug` in module `rustc_errors::fluent`
|
|
|
|
//~^^ NOTE not found in `rustc_errors::fluent`
|
2022-04-26 10:59:45 +00:00
|
|
|
struct L {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label()]
|
2022-06-23 15:12:52 +00:00
|
|
|
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
struct M {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren, code = "...")]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR `code` is not a valid nested attribute of a `label` attribute
|
|
|
|
struct N {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[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,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[foo]
|
|
|
|
//~^ ERROR cannot find attribute `foo` in this scope
|
|
|
|
//~^^ ERROR unsupported type attribute for subdiagnostic enum
|
2022-06-23 15:12:52 +00:00
|
|
|
enum P {
|
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum Q {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[bar]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR `#[bar]` is not a valid attribute
|
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum R {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[bar = "..."]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum S {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[bar = 4]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum T {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[bar("...")]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR `#[bar(...)]` is not a valid attribute
|
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum U {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label(code = "...")]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum V {
|
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
},
|
|
|
|
B {
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR subdiagnostic kind not specified
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR label without `#[primary_span]` field
|
2022-06-23 15:12:52 +00:00
|
|
|
struct W {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
2022-07-11 16:15:31 +00:00
|
|
|
//~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
2022-04-26 10:59:45 +00:00
|
|
|
span: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct X {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
//~^ ERROR `#[applicability]` is only valid on suggestions
|
|
|
|
applicability: Applicability,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct Y {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[bar]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[bar]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
|
|
|
bar: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct Z {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[bar = "..."]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[bar = ...]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
|
|
|
bar: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct AA {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[bar("...")]
|
2022-04-27 03:06:13 +00:00
|
|
|
//~^ ERROR `#[bar(...)]` is not a valid attribute
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^^ ERROR cannot find attribute `bar` in this scope
|
|
|
|
bar: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct AB {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[skip_arg]
|
|
|
|
z: Z
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
union AC {
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR unexpected unsupported untagged union
|
|
|
|
span: u32,
|
|
|
|
b: u64
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct AD {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren, parser::add_paren)]
|
|
|
|
//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute
|
|
|
|
struct AE {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[label(parser::add_paren)]
|
|
|
|
struct AF {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ NOTE previously specified here
|
2022-04-26 10:59:45 +00:00
|
|
|
span_a: Span,
|
|
|
|
#[primary_span]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR specified multiple times
|
2022-04-26 10:59:45 +00:00
|
|
|
span_b: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AG {
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR subdiagnostic kind not specified
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
|
|
|
struct AH {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum AI {
|
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
var: String,
|
|
|
|
},
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
2022-04-26 10:59:45 +00:00
|
|
|
B {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...", code = "...")]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR specified multiple times
|
|
|
|
//~^^ NOTE previously specified here
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AJ {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
|
|
|
struct AK {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ NOTE previously specified here
|
2022-04-26 10:59:45 +00:00
|
|
|
applicability_a: Applicability,
|
|
|
|
#[applicability]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR specified multiple times
|
2022-04-26 10:59:45 +00:00
|
|
|
applicability_b: Applicability,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
|
|
|
struct AL {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability`
|
2022-04-26 10:59:45 +00:00
|
|
|
applicability: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
|
|
|
struct AM {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR suggestion without `code = "..."`
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AN {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code ="...", applicability = "foo")]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR invalid applicability
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AO {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[help(parser::add_paren)]
|
|
|
|
struct AP {
|
2022-04-26 10:59:45 +00:00
|
|
|
var: String
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[note(parser::add_paren)]
|
|
|
|
struct AQ;
|
2022-04-26 10:59:45 +00:00
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
2022-09-01 17:42:49 +00:00
|
|
|
//~^ ERROR suggestion without `#[primary_span]` field
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AR {
|
2022-04-26 10:59:45 +00:00
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")]
|
|
|
|
struct AS {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-04-26 10:59:45 +00:00
|
|
|
#[label]
|
|
|
|
//~^ ERROR unsupported type attribute for subdiagnostic enum
|
2022-06-23 15:12:52 +00:00
|
|
|
enum AT {
|
|
|
|
#[label(parser::add_paren)]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
|
|
|
struct AU {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR `var` doesn't refer to a field on this type
|
2022-06-23 15:12:52 +00:00
|
|
|
struct AV {
|
2022-04-26 10:59:45 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum AW {
|
|
|
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
2022-04-26 10:59:45 +00:00
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 15:12:52 +00:00
|
|
|
enum AX {
|
|
|
|
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
|
2022-04-26 10:59:45 +00:00
|
|
|
//~^ ERROR `var` doesn't refer to a field on this type
|
|
|
|
A {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
}
|
2022-07-11 17:46:24 +00:00
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-24 15:57:10 +00:00
|
|
|
#[warning(parser::add_paren)]
|
|
|
|
struct AY {}
|
2022-07-11 17:46:24 +00:00
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-24 15:57:10 +00:00
|
|
|
#[warning(parser::add_paren)]
|
2022-07-11 17:46:24 +00:00
|
|
|
struct AZ {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
}
|
2022-09-01 17:42:49 +00:00
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[suggestion(parser::add_paren, code = "...")]
|
|
|
|
//~^ ERROR suggestion without `#[primary_span]` field
|
|
|
|
struct BA {
|
|
|
|
#[suggestion_part]
|
|
|
|
//~^ ERROR `#[suggestion_part]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
#[suggestion_part(code = "...")]
|
|
|
|
//~^ ERROR `#[suggestion_part(...)]` is not a valid attribute
|
|
|
|
span2: Span,
|
|
|
|
#[applicability]
|
|
|
|
applicability: Applicability,
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")]
|
|
|
|
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
|
|
|
|
//~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute
|
|
|
|
struct BBa {
|
|
|
|
var: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
struct BBb {
|
|
|
|
#[suggestion_part]
|
|
|
|
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
|
|
|
|
span1: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
struct BBc {
|
|
|
|
#[suggestion_part()]
|
|
|
|
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
|
|
|
|
span1: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren)]
|
|
|
|
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
|
|
|
|
struct BC {
|
|
|
|
#[primary_span]
|
|
|
|
//~^ ERROR `#[primary_span]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren)]
|
|
|
|
struct BD {
|
|
|
|
#[suggestion_part]
|
|
|
|
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
|
|
|
|
span1: Span,
|
|
|
|
#[suggestion_part()]
|
|
|
|
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
|
|
|
|
span2: Span,
|
|
|
|
#[suggestion_part(foo = "bar")]
|
|
|
|
//~^ ERROR `#[suggestion_part(foo = ...)]` is not a valid attribute
|
|
|
|
span4: Span,
|
|
|
|
#[suggestion_part(code = "...")]
|
|
|
|
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
|
|
|
s1: String,
|
|
|
|
#[suggestion_part()]
|
|
|
|
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
|
|
|
s2: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
struct BE {
|
|
|
|
#[suggestion_part(code = "...", code = ",,,")]
|
|
|
|
//~^ ERROR specified multiple times
|
|
|
|
//~| NOTE previously specified here
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
struct BF {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
first: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
second: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren)]
|
|
|
|
struct BG {
|
|
|
|
#[applicability]
|
|
|
|
appl: Applicability,
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
first: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
second: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
//~^ NOTE previously specified here
|
|
|
|
struct BH {
|
|
|
|
#[applicability]
|
|
|
|
//~^ ERROR specified multiple times
|
|
|
|
appl: Applicability,
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
first: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
second: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 17:42:49 +00:00
|
|
|
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
|
|
|
|
struct BI {
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
spans: Vec<Span>,
|
|
|
|
}
|