1
Fork 0

UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic

Also renames:
- sym::AddSubdiagnostic to sym:: Subdiagnostic
- rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"
This commit is contained in:
Jhonny Bill Mena 2022-09-18 11:47:31 -04:00
parent a3396b2070
commit 5f91719f75
24 changed files with 130 additions and 128 deletions

View file

@ -1,5 +1,5 @@
use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay}; use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
use rustc_macros::{Diagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol}; use rustc_span::{symbol::Ident, Span, Symbol};
#[derive(Diagnostic, Clone, Copy)] #[derive(Diagnostic, Clone, Copy)]
@ -221,7 +221,7 @@ pub struct InvalidAsmTemplateModifierRegClass {
pub sub: InvalidAsmTemplateModifierRegClassSub, pub sub: InvalidAsmTemplateModifierRegClassSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum InvalidAsmTemplateModifierRegClassSub { pub enum InvalidAsmTemplateModifierRegClassSub {
#[note(ast_lowering::support_modifiers)] #[note(ast_lowering::support_modifiers)]
SupportModifier { class_name: Symbol, modifiers: String }, SupportModifier { class_name: Symbol, modifiers: String },

View file

@ -71,7 +71,7 @@ pub struct InvalidVisibility {
pub note: Option<InvalidVisibilityNote>, pub note: Option<InvalidVisibilityNote>,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum InvalidVisibilityNote { pub enum InvalidVisibilityNote {
#[note(ast_passes::individual_impl_items)] #[note(ast_passes::individual_impl_items)]
IndividualImplItems, IndividualImplItems,

View file

@ -98,7 +98,7 @@ pub(crate) struct InvalidIssueString {
// The error kinds of `IntErrorKind` are duplicated here in order to allow the messages to be // The error kinds of `IntErrorKind` are duplicated here in order to allow the messages to be
// translatable. // translatable.
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum InvalidIssueStringCause { pub(crate) enum InvalidIssueStringCause {
#[label(attr::must_not_be_zero)] #[label(attr::must_not_be_zero)]
MustNotBeZero { MustNotBeZero {
@ -274,7 +274,7 @@ pub(crate) struct IncorrectReprFormatGeneric<'a> {
pub cause: Option<IncorrectReprFormatGenericCause<'a>>, pub cause: Option<IncorrectReprFormatGenericCause<'a>>,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum IncorrectReprFormatGenericCause<'a> { pub(crate) enum IncorrectReprFormatGenericCause<'a> {
#[suggestion(attr::suggestion, code = "{name}({int})", applicability = "machine-applicable")] #[suggestion(attr::suggestion, code = "{name}({int})", applicability = "machine-applicable")]
Int { Int {

View file

@ -1,5 +1,5 @@
use rustc_errors::{IntoDiagnosticArg, MultiSpan}; use rustc_errors::{IntoDiagnosticArg, MultiSpan};
use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_span::Span; use rustc_span::Span;
@ -23,7 +23,7 @@ pub(crate) struct HigherRankedLifetimeError {
pub span: Span, pub span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum HigherRankedErrorCause { pub(crate) enum HigherRankedErrorCause {
#[note(borrowck::could_not_prove)] #[note(borrowck::could_not_prove)]
CouldNotProve { predicate: String }, CouldNotProve { predicate: String },
@ -72,7 +72,7 @@ pub(crate) struct FnMutError {
pub ty_err: FnMutReturnTypeErr, pub ty_err: FnMutReturnTypeErr,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum VarHereDenote { pub(crate) enum VarHereDenote {
#[label(borrowck::var_here_captured)] #[label(borrowck::var_here_captured)]
Captured { Captured {
@ -91,7 +91,7 @@ pub(crate) enum VarHereDenote {
}, },
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum FnMutReturnTypeErr { pub(crate) enum FnMutReturnTypeErr {
#[label(borrowck::returned_closure_escaped)] #[label(borrowck::returned_closure_escaped)]
ReturnClosure { ReturnClosure {
@ -117,7 +117,7 @@ pub(crate) struct LifetimeOutliveErr {
pub span: Span, pub span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum LifetimeReturnCategoryErr<'a> { pub(crate) enum LifetimeReturnCategoryErr<'a> {
#[label(borrowck::returned_lifetime_wrong)] #[label(borrowck::returned_lifetime_wrong)]
WrongReturn { WrongReturn {
@ -149,7 +149,7 @@ impl IntoDiagnosticArg for RegionName {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum RequireStaticErr { pub(crate) enum RequireStaticErr {
#[note(borrowck::used_impl_require_static)] #[note(borrowck::used_impl_require_static)]
UsedImpl { UsedImpl {

View file

@ -268,14 +268,14 @@ type FluentId = Cow<'static, str>;
/// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent /// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent
/// message so messages of this type must be combined with a `DiagnosticMessage` (using /// message so messages of this type must be combined with a `DiagnosticMessage` (using
/// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from /// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
/// the `SessionSubdiagnostic` derive refer to Fluent identifiers directly. /// the `Subdiagnostic` derive refer to Fluent identifiers directly.
#[rustc_diagnostic_item = "SubdiagnosticMessage"] #[rustc_diagnostic_item = "SubdiagnosticMessage"]
pub enum SubdiagnosticMessage { pub enum SubdiagnosticMessage {
/// Non-translatable diagnostic message. /// Non-translatable diagnostic message.
// FIXME(davidtwco): can a `Cow<'static, str>` be used here? // FIXME(davidtwco): can a `Cow<'static, str>` be used here?
Str(String), Str(String),
/// Identifier of a Fluent message. Instances of this variant are generated by the /// Identifier of a Fluent message. Instances of this variant are generated by the
/// `SessionSubdiagnostic` derive. /// `Subdiagnostic` derive.
FluentIdentifier(FluentId), FluentIdentifier(FluentId),
/// Attribute of a Fluent message. Needs to be combined with a Fluent identifier to produce an /// Attribute of a Fluent message. Needs to be combined with a Fluent identifier to produce an
/// actual translated message. Instances of this variant are generated by the `fluent_messages` /// actual translated message. Instances of this variant are generated by the `fluent_messages`

View file

@ -176,8 +176,9 @@ impl IntoDiagnosticArg for hir::ConstContext {
} }
/// Trait implemented by error types. This should not be implemented manually. Instead, use /// Trait implemented by error types. This should not be implemented manually. Instead, use
/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic]. /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
#[rustc_diagnostic_item = "AddSubdiagnostic"] #[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "Subdiagnostic")]
pub trait AddToDiagnostic { pub trait AddToDiagnostic {
/// Add a subdiagnostic to an existing diagnostic. /// Add a subdiagnostic to an existing diagnostic.
fn add_to_diagnostic(self, diag: &mut Diagnostic); fn add_to_diagnostic(self, diag: &mut Diagnostic);
@ -891,8 +892,8 @@ impl Diagnostic {
self self
} }
/// Add a subdiagnostic from a type that implements `SessionSubdiagnostic` - see /// Add a subdiagnostic from a type that implements `Subdiagnostic` - see
/// [rustc_macros::SessionSubdiagnostic]. /// [rustc_macros::Subdiagnostic].
pub fn subdiagnostic(&mut self, subdiagnostic: impl AddToDiagnostic) -> &mut Self { pub fn subdiagnostic(&mut self, subdiagnostic: impl AddToDiagnostic) -> &mut Self {
subdiagnostic.add_to_diagnostic(self); subdiagnostic.add_to_diagnostic(self);
self self

View file

@ -593,7 +593,7 @@ pub fn compile_declarative_macro(
(mk_syn_ext(expander), rule_spans) (mk_syn_ext(expander), rule_spans)
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum ExplainDocComment { enum ExplainDocComment {
#[label(expand::explain_doc_comment_inner)] #[label(expand::explain_doc_comment_inner)]
Inner { Inner {

View file

@ -1,5 +1,5 @@
use rustc_errors::{fluent, AddToDiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler}; use rustc_errors::{fluent, AddToDiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
use rustc_macros::{Diagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::lint::Level; use rustc_session::lint::Level;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
@ -51,7 +51,7 @@ pub struct MalformedAttribute {
pub sub: MalformedAttributeSub, pub sub: MalformedAttributeSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum MalformedAttributeSub { pub enum MalformedAttributeSub {
#[label(lint::bad_attribute_argument)] #[label(lint::bad_attribute_argument)]
BadAttributeArgument(#[primary_span] Span), BadAttributeArgument(#[primary_span] Span),

View file

@ -404,7 +404,7 @@ impl LateLintPass<'_> for Diagnostics {
let Impl { of_trait: Some(of_trait), .. } = impl_ && let Impl { of_trait: Some(of_trait), .. } = impl_ &&
let Some(def_id) = of_trait.trait_def_id() && let Some(def_id) = of_trait.trait_def_id() &&
let Some(name) = cx.tcx.get_diagnostic_name(def_id) && let Some(name) = cx.tcx.get_diagnostic_name(def_id) &&
matches!(name, sym::Diagnostic | sym::AddSubdiagnostic | sym::DecorateLint) matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::DecorateLint)
{ {
found_impl = true; found_impl = true;
break; break;

View file

@ -9,7 +9,7 @@ use diagnostic::{LintDiagnosticDerive, SessionDiagnosticDerive};
pub(crate) use fluent::fluent_messages; pub(crate) use fluent::fluent_messages;
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::format_ident; use quote::format_ident;
use subdiagnostic::SessionSubdiagnosticDerive; use subdiagnostic::SubdiagnosticDerive;
use synstructure::Structure; use synstructure::Structure;
/// Implements `#[derive(Diagnostic)]`, which allows for errors to be specified as a struct, /// Implements `#[derive(Diagnostic)]`, which allows for errors to be specified as a struct,
@ -108,12 +108,12 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
LintDiagnosticDerive::new(format_ident!("diag"), s).into_tokens() LintDiagnosticDerive::new(format_ident!("diag"), s).into_tokens()
} }
/// Implements `#[derive(SessionSubdiagnostic)]`, which allows for labels, notes, helps and /// Implements `#[derive(Subdiagnostic)]`, which allows for labels, notes, helps and
/// suggestions to be specified as a structs or enums, independent from the actual diagnostics /// suggestions to be specified as a structs or enums, independent from the actual diagnostics
/// emitting code or diagnostic derives. /// emitting code or diagnostic derives.
/// ///
/// ```ignore (rust) /// ```ignore (rust)
/// #[derive(SessionSubdiagnostic)] /// #[derive(Subdiagnostic)]
/// pub enum ExpectedIdentifierLabel<'tcx> { /// pub enum ExpectedIdentifierLabel<'tcx> {
/// #[label(parser::expected_identifier)] /// #[label(parser::expected_identifier)]
/// WithoutFound { /// WithoutFound {
@ -128,7 +128,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
/// } /// }
/// } /// }
/// ///
/// #[derive(SessionSubdiagnostic)] /// #[derive(Subdiagnostic)]
/// #[suggestion_verbose(parser::raw_identifier)] /// #[suggestion_verbose(parser::raw_identifier)]
/// pub struct RawIdentifierSuggestion<'tcx> { /// pub struct RawIdentifierSuggestion<'tcx> {
/// #[primary_span] /// #[primary_span]
@ -155,5 +155,5 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident }); /// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
/// ``` /// ```
pub fn session_subdiagnostic_derive(s: Structure<'_>) -> TokenStream { pub fn session_subdiagnostic_derive(s: Structure<'_>) -> TokenStream {
SessionSubdiagnosticDerive::new(s).into_tokens() SubdiagnosticDerive::new(s).into_tokens()
} }

View file

@ -98,19 +98,19 @@ impl quote::IdentFragment for SubdiagnosticKind {
} }
/// The central struct for constructing the `add_to_diagnostic` method from an annotated struct. /// The central struct for constructing the `add_to_diagnostic` method from an annotated struct.
pub(crate) struct SessionSubdiagnosticDerive<'a> { pub(crate) struct SubdiagnosticDerive<'a> {
structure: Structure<'a>, structure: Structure<'a>,
diag: syn::Ident, diag: syn::Ident,
} }
impl<'a> SessionSubdiagnosticDerive<'a> { impl<'a> SubdiagnosticDerive<'a> {
pub(crate) fn new(structure: Structure<'a>) -> Self { pub(crate) fn new(structure: Structure<'a>) -> Self {
let diag = format_ident!("diag"); let diag = format_ident!("diag");
Self { structure, diag } Self { structure, diag }
} }
pub(crate) fn into_tokens(self) -> TokenStream { pub(crate) fn into_tokens(self) -> TokenStream {
let SessionSubdiagnosticDerive { mut structure, diag } = self; let SubdiagnosticDerive { mut structure, diag } = self;
let implementation = { let implementation = {
let ast = structure.ast(); let ast = structure.ast();
let span = ast.span().unwrap(); let span = ast.span().unwrap();
@ -119,7 +119,7 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
syn::Data::Union(..) => { syn::Data::Union(..) => {
span_err( span_err(
span, span,
"`#[derive(SessionSubdiagnostic)]` can only be used on structs and enums", "`#[derive(Subdiagnostic)]` can only be used on structs and enums",
); );
} }
} }
@ -146,7 +146,7 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
} }
} }
let mut builder = SessionSubdiagnosticDeriveBuilder { let mut builder = SubdiagnosticDeriveBuilder {
diag: &diag, diag: &diag,
variant, variant,
span, span,
@ -178,10 +178,10 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
} }
/// Tracks persistent information required for building up the call to add to the diagnostic /// Tracks persistent information required for building up the call to add to the diagnostic
/// for the final generated method. This is a separate struct to `SessionSubdiagnosticDerive` /// for the final generated method. This is a separate struct to `SubdiagnosticDerive`
/// only to be able to destructure and split `self.builder` and the `self.structure` up to avoid a /// only to be able to destructure and split `self.builder` and the `self.structure` up to avoid a
/// double mut borrow later on. /// double mut borrow later on.
struct SessionSubdiagnosticDeriveBuilder<'a> { struct SubdiagnosticDeriveBuilder<'a> {
/// The identifier to use for the generated `DiagnosticBuilder` instance. /// The identifier to use for the generated `DiagnosticBuilder` instance.
diag: &'a syn::Ident, diag: &'a syn::Ident,
@ -205,7 +205,7 @@ struct SessionSubdiagnosticDeriveBuilder<'a> {
has_suggestion_parts: bool, has_suggestion_parts: bool,
} }
impl<'a> HasFieldMap for SessionSubdiagnosticDeriveBuilder<'a> { impl<'a> HasFieldMap for SubdiagnosticDeriveBuilder<'a> {
fn get_field_binding(&self, field: &String) -> Option<&TokenStream> { fn get_field_binding(&self, field: &String) -> Option<&TokenStream> {
self.fields.get(field) self.fields.get(field)
} }
@ -241,7 +241,7 @@ impl<'a> FromIterator<&'a SubdiagnosticKind> for KindsStatistics {
} }
} }
impl<'a> SessionSubdiagnosticDeriveBuilder<'a> { impl<'a> SubdiagnosticDeriveBuilder<'a> {
fn identify_kind(&mut self) -> Result<Vec<(SubdiagnosticKind, Path)>, DiagnosticDeriveError> { fn identify_kind(&mut self) -> Result<Vec<(SubdiagnosticKind, Path)>, DiagnosticDeriveError> {
let mut kind_slugs = vec![]; let mut kind_slugs = vec![];

View file

@ -161,7 +161,7 @@ decl_derive!(
suggestion_verbose)] => diagnostics::lint_diagnostic_derive suggestion_verbose)] => diagnostics::lint_diagnostic_derive
); );
decl_derive!( decl_derive!(
[SessionSubdiagnostic, attributes( [Subdiagnostic, attributes(
// struct/variant attributes // struct/variant attributes
label, label,
help, help,

View file

@ -25,7 +25,7 @@ pub struct OpaqueHiddenTypeMismatch<'tcx> {
pub sub: TypeMismatchReason, pub sub: TypeMismatchReason,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum TypeMismatchReason { pub enum TypeMismatchReason {
#[label(middle::conflict_types)] #[label(middle::conflict_types)]
ConflictType { ConflictType {

View file

@ -20,7 +20,7 @@ use rustc_errors::{
fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult, fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult,
}; };
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed}; use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
use rustc_macros::{Diagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{Span, SpanSnippetError, DUMMY_SP}; use rustc_span::{Span, SpanSnippetError, DUMMY_SP};
@ -261,7 +261,7 @@ struct BadTypePlus {
pub sub: BadTypePlusSub, pub sub: BadTypePlusSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum BadTypePlusSub { pub enum BadTypePlusSub {
#[suggestion( #[suggestion(
parser::add_paren, parser::add_paren,
@ -342,7 +342,7 @@ pub struct InvalidVariableDeclaration {
pub sub: InvalidVariableDeclarationSub, pub sub: InvalidVariableDeclarationSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum InvalidVariableDeclarationSub { pub enum InvalidVariableDeclarationSub {
#[suggestion( #[suggestion(
parser::switch_mut_let_order, parser::switch_mut_let_order,
@ -372,7 +372,7 @@ pub(crate) struct InvalidComparisonOperator {
pub sub: InvalidComparisonOperatorSub, pub sub: InvalidComparisonOperatorSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum InvalidComparisonOperatorSub { pub(crate) enum InvalidComparisonOperatorSub {
#[suggestion_short( #[suggestion_short(
parser::use_instead, parser::use_instead,
@ -400,7 +400,7 @@ pub(crate) struct InvalidLogicalOperator {
pub sub: InvalidLogicalOperatorSub, pub sub: InvalidLogicalOperatorSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum InvalidLogicalOperatorSub { pub(crate) enum InvalidLogicalOperatorSub {
#[suggestion_short( #[suggestion_short(
parser::use_amp_amp_for_conjunction, parser::use_amp_amp_for_conjunction,
@ -605,7 +605,7 @@ pub(crate) struct IfExpressionMissingThenBlock {
pub sub: IfExpressionMissingThenBlockSub, pub sub: IfExpressionMissingThenBlockSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum IfExpressionMissingThenBlockSub { pub(crate) enum IfExpressionMissingThenBlockSub {
#[help(parser::condition_possibly_unfinished)] #[help(parser::condition_possibly_unfinished)]
UnfinishedCondition(#[primary_span] Span), UnfinishedCondition(#[primary_span] Span),
@ -668,7 +668,7 @@ pub(crate) struct MissingInInForLoop {
pub sub: MissingInInForLoopSub, pub sub: MissingInInForLoopSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum MissingInInForLoopSub { pub(crate) enum MissingInInForLoopSub {
// Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect // Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect
#[suggestion_short(parser::use_in_not_of, applicability = "maybe-incorrect", code = "in")] #[suggestion_short(parser::use_in_not_of, applicability = "maybe-incorrect", code = "in")]

View file

@ -1,5 +1,5 @@
use rustc_errors::{Applicability, MultiSpan}; use rustc_errors::{Applicability, MultiSpan};
use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
@ -583,7 +583,7 @@ pub struct MacroExport;
#[diag(passes::plugin_registrar)] #[diag(passes::plugin_registrar)]
pub struct PluginRegistrar; pub struct PluginRegistrar;
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum UnusedNote { pub enum UnusedNote {
#[note(passes::unused_empty_lints_note)] #[note(passes::unused_empty_lints_note)]
EmptyList { name: Symbol }, EmptyList { name: Symbol },

View file

@ -1,5 +1,5 @@
use rustc_errors::DiagnosticArgFromDisplay; use rustc_errors::DiagnosticArgFromDisplay;
use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -14,7 +14,7 @@ pub struct FieldIsPrivate {
pub label: FieldIsPrivateLabel, pub label: FieldIsPrivateLabel,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum FieldIsPrivateLabel { pub enum FieldIsPrivateLabel {
#[label(privacy::field_is_private_is_update_syntax_label)] #[label(privacy::field_is_private_is_update_syntax_label)]
IsUpdateSyntax { IsUpdateSyntax {

View file

@ -1,6 +1,7 @@
use rustc_errors::AddToDiagnostic; use rustc_errors::AddToDiagnostic;
use rustc_session::Limit; use rustc_session::Limit;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use rustc_macros::{Diagnostic, Subdiagnostic};
pub struct CycleStack { pub struct CycleStack {
pub span: Span, pub span: Span,
@ -20,7 +21,7 @@ pub enum HandleCycleError {
DelayBug, DelayBug,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum StackCount { pub enum StackCount {
#[note(query_system::cycle_stack_single)] #[note(query_system::cycle_stack_single)]
Single, Single,
@ -28,7 +29,7 @@ pub enum StackCount {
Multiple, Multiple,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum Alias { pub enum Alias {
#[note(query_system::cycle_recursive_ty_alias)] #[note(query_system::cycle_recursive_ty_alias)]
#[help(query_system::cycle_recursive_ty_alias_help1)] #[help(query_system::cycle_recursive_ty_alias_help1)]
@ -38,7 +39,7 @@ pub enum Alias {
Trait, Trait,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[note(query_system::cycle_usage)] #[note(query_system::cycle_usage)]
pub struct CycleUsage { pub struct CycleUsage {
#[primary_span] #[primary_span]

View file

@ -34,13 +34,13 @@ pub struct FeatureGateError<'a> {
pub explain: &'a str, pub explain: &'a str,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[note(session::feature_diagnostic_for_issue)] #[note(session::feature_diagnostic_for_issue)]
pub struct FeatureDiagnosticForIssue { pub struct FeatureDiagnosticForIssue {
pub n: NonZeroU32, pub n: NonZeroU32,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[help(session::feature_diagnostic_help)] #[help(session::feature_diagnostic_help)]
pub struct FeatureDiagnosticHelp { pub struct FeatureDiagnosticHelp {
pub feature: Symbol, pub feature: Symbol,

View file

@ -125,7 +125,6 @@ symbols! {
Symbols { Symbols {
AcqRel, AcqRel,
Acquire, Acquire,
AddSubdiagnostic,
Alignment, Alignment,
Any, Any,
Arc, Arc,
@ -283,6 +282,7 @@ symbols! {
String, String,
StructuralEq, StructuralEq,
StructuralPartialEq, StructuralPartialEq,
Subdiagnostic,
SubdiagnosticMessage, SubdiagnosticMessage,
Sync, Sync,
T, T,

View file

@ -1,6 +1,6 @@
//! Errors emitted by ty_utils //! Errors emitted by ty_utils
use rustc_macros::{Diagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_span::Span; use rustc_span::Span;
@ -22,7 +22,7 @@ pub struct GenericConstantTooComplex {
pub sub: GenericConstantTooComplexSub, pub sub: GenericConstantTooComplexSub,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum GenericConstantTooComplexSub { pub enum GenericConstantTooComplexSub {
#[label(ty_utils::borrow_not_supported)] #[label(ty_utils::borrow_not_supported)]
BorrowNotSupported(#[primary_span] Span), BorrowNotSupported(#[primary_span] Span),

View file

@ -1,7 +1,7 @@
//! Errors emitted by typeck. //! Errors emitted by typeck.
use rustc_errors::IntoDiagnostic; use rustc_errors::IntoDiagnostic;
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler}; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler};
use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_span::{symbol::Ident, Span, Symbol}; use rustc_span::{symbol::Ident, Span, Symbol};
@ -194,7 +194,7 @@ pub struct AddressOfTemporaryTaken {
pub span: Span, pub span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum AddReturnTypeSuggestion { pub enum AddReturnTypeSuggestion {
#[suggestion( #[suggestion(
typeck::add_return_type_add, typeck::add_return_type_add,
@ -217,7 +217,7 @@ pub enum AddReturnTypeSuggestion {
}, },
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
pub enum ExpectedReturnTypeLabel<'tcx> { pub enum ExpectedReturnTypeLabel<'tcx> {
#[label(typeck::expected_default_return_type)] #[label(typeck::expected_default_return_type)]
Unit { Unit {

View file

@ -15,7 +15,7 @@ use rustc_errors::{
AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, Handler, fluent ErrorGuaranteed, Handler, fluent
}; };
use rustc_macros::{Diagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span; use rustc_span::Span;
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -25,7 +25,7 @@ struct DeriveSessionDiagnostic {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[note(parser::add_paren)] #[note(parser::add_paren)]
struct Note { struct Note {
#[primary_span] #[primary_span]

View file

@ -17,7 +17,7 @@ use rustc_span::symbol::Ident;
use rustc_span::Span; use rustc_span::Span;
extern crate rustc_macros; extern crate rustc_macros;
use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
extern crate rustc_middle; extern crate rustc_middle;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
@ -462,7 +462,7 @@ struct NoApplicability {
suggestion: Span, suggestion: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[note(parser::add_paren)] #[note(parser::add_paren)]
struct Note; struct Note;

View file

@ -1,8 +1,8 @@
// check-fail // check-fail
// Tests error conditions for specifying subdiagnostics using #[derive(SessionSubdiagnostic)] // Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)]
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
// changing the output of this test. Since SessionSubdiagnostic is strictly internal to the compiler // changing the output of this test. Since Subdiagnostic is strictly internal to the compiler
// the test is just ignored on stable and beta: // the test is just ignored on stable and beta:
// ignore-beta // ignore-beta
// ignore-stable // ignore-stable
@ -17,9 +17,9 @@ extern crate rustc_macros;
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_span::Span; use rustc_span::Span;
use rustc_macros::SessionSubdiagnostic; use rustc_macros::Subdiagnostic;
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct A { struct A {
#[primary_span] #[primary_span]
@ -27,7 +27,7 @@ struct A {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum B { enum B {
#[label(parser::add_paren)] #[label(parser::add_paren)]
A { A {
@ -43,14 +43,14 @@ enum B {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
//~^ ERROR label without `#[primary_span]` field //~^ ERROR label without `#[primary_span]` field
struct C { struct C {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label] #[label]
//~^ ERROR `#[label]` is not a valid attribute //~^ ERROR `#[label]` is not a valid attribute
struct D { struct D {
@ -59,7 +59,7 @@ struct D {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[foo] #[foo]
//~^ ERROR `#[foo]` is not a valid attribute //~^ ERROR `#[foo]` is not a valid attribute
//~^^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR cannot find attribute `foo` in this scope
@ -69,7 +69,7 @@ struct E {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label = "..."] #[label = "..."]
//~^ ERROR `#[label = ...]` is not a valid attribute //~^ ERROR `#[label = ...]` is not a valid attribute
struct F { struct F {
@ -78,7 +78,7 @@ struct F {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(bug = "...")] #[label(bug = "...")]
//~^ ERROR `#[label(bug = ...)]` is not a valid attribute //~^ ERROR `#[label(bug = ...)]` is not a valid attribute
struct G { struct G {
@ -87,7 +87,7 @@ struct G {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label("...")] #[label("...")]
//~^ ERROR `#[label("...")]` is not a valid attribute //~^ ERROR `#[label("...")]` is not a valid attribute
struct H { struct H {
@ -96,7 +96,7 @@ struct H {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(slug = 4)] #[label(slug = 4)]
//~^ ERROR `#[label(slug = ...)]` is not a valid attribute //~^ ERROR `#[label(slug = ...)]` is not a valid attribute
struct J { struct J {
@ -105,7 +105,7 @@ struct J {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(slug("..."))] #[label(slug("..."))]
//~^ ERROR `#[label(slug(...))]` is not a valid attribute //~^ ERROR `#[label(slug(...))]` is not a valid attribute
struct K { struct K {
@ -114,7 +114,7 @@ struct K {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(slug)] #[label(slug)]
//~^ ERROR cannot find value `slug` in module `rustc_errors::fluent` //~^ ERROR cannot find value `slug` in module `rustc_errors::fluent`
//~^^ NOTE not found in `rustc_errors::fluent` //~^^ NOTE not found in `rustc_errors::fluent`
@ -124,7 +124,7 @@ struct L {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label()] #[label()]
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
struct M { struct M {
@ -133,7 +133,7 @@ struct M {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren, 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 {
@ -142,7 +142,7 @@ struct N {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren, applicability = "machine-applicable")] #[label(parser::add_paren, applicability = "machine-applicable")]
//~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute //~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute
struct O { struct O {
@ -151,7 +151,7 @@ struct O {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[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
@ -164,7 +164,7 @@ enum P {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum Q { enum Q {
#[bar] #[bar]
//~^ ERROR `#[bar]` is not a valid attribute //~^ ERROR `#[bar]` is not a valid attribute
@ -176,7 +176,7 @@ enum Q {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum R { enum R {
#[bar = "..."] #[bar = "..."]
//~^ ERROR `#[bar = ...]` is not a valid attribute //~^ ERROR `#[bar = ...]` is not a valid attribute
@ -188,7 +188,7 @@ enum R {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum S { enum S {
#[bar = 4] #[bar = 4]
//~^ ERROR `#[bar = ...]` is not a valid attribute //~^ ERROR `#[bar = ...]` is not a valid attribute
@ -200,7 +200,7 @@ enum S {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum T { enum T {
#[bar("...")] #[bar("...")]
//~^ ERROR `#[bar(...)]` is not a valid attribute //~^ ERROR `#[bar(...)]` is not a valid attribute
@ -212,7 +212,7 @@ enum T {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum U { enum U {
#[label(code = "...")] #[label(code = "...")]
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
@ -223,7 +223,7 @@ enum U {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum V { enum V {
#[label(parser::add_paren)] #[label(parser::add_paren)]
A { A {
@ -239,7 +239,7 @@ enum V {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
//~^ ERROR label without `#[primary_span]` field //~^ ERROR label without `#[primary_span]` field
struct W { struct W {
@ -248,7 +248,7 @@ struct W {
span: String, span: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct X { struct X {
#[primary_span] #[primary_span]
@ -258,7 +258,7 @@ struct X {
applicability: Applicability, applicability: Applicability,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct Y { struct Y {
#[primary_span] #[primary_span]
@ -269,7 +269,7 @@ struct Y {
bar: String, bar: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct Z { struct Z {
#[primary_span] #[primary_span]
@ -280,7 +280,7 @@ struct Z {
bar: String, bar: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct AA { struct AA {
#[primary_span] #[primary_span]
@ -291,7 +291,7 @@ struct AA {
bar: String, bar: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct AB { struct AB {
#[primary_span] #[primary_span]
@ -300,14 +300,14 @@ struct AB {
z: Z z: Z
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
union AC { union AC {
//~^ ERROR unexpected unsupported untagged union //~^ ERROR unexpected unsupported untagged union
span: u32, span: u32,
b: u64 b: u64
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct AD { struct AD {
@ -315,7 +315,7 @@ struct AD {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren, parser::add_paren)] #[label(parser::add_paren, parser::add_paren)]
//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute //~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute
struct AE { struct AE {
@ -323,7 +323,7 @@ struct AE {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label(parser::add_paren)] #[label(parser::add_paren)]
struct AF { struct AF {
#[primary_span] #[primary_span]
@ -334,14 +334,14 @@ struct AF {
span_b: Span, span_b: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
struct AG { struct AG {
//~^ ERROR subdiagnostic kind not specified //~^ ERROR subdiagnostic kind not specified
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
struct AH { struct AH {
#[primary_span] #[primary_span]
@ -351,7 +351,7 @@ struct AH {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum AI { enum AI {
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
A { A {
@ -371,7 +371,7 @@ enum AI {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...", code = "...")] #[suggestion(parser::add_paren, code = "...", code = "...")]
//~^ ERROR specified multiple times //~^ ERROR specified multiple times
//~^^ NOTE previously specified here //~^^ NOTE previously specified here
@ -382,7 +382,7 @@ struct AJ {
applicability: Applicability, applicability: Applicability,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
struct AK { struct AK {
#[primary_span] #[primary_span]
@ -395,7 +395,7 @@ struct AK {
applicability_b: Applicability, applicability_b: Applicability,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
struct AL { struct AL {
#[primary_span] #[primary_span]
@ -405,14 +405,14 @@ struct AL {
applicability: Span, applicability: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
struct AM { struct AM {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren)] #[suggestion(parser::add_paren)]
//~^ ERROR suggestion without `code = "..."` //~^ ERROR suggestion without `code = "..."`
struct AN { struct AN {
@ -422,7 +422,7 @@ struct AN {
applicability: Applicability, applicability: Applicability,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code ="...", applicability = "foo")] #[suggestion(parser::add_paren, code ="...", applicability = "foo")]
//~^ ERROR invalid applicability //~^ ERROR invalid applicability
struct AO { struct AO {
@ -430,31 +430,31 @@ struct AO {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[help(parser::add_paren)] #[help(parser::add_paren)]
struct AP { struct AP {
var: String var: String
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[note(parser::add_paren)] #[note(parser::add_paren)]
struct AQ; struct AQ;
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field //~^ ERROR suggestion without `#[primary_span]` field
struct AR { struct AR {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")] #[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")]
struct AS { struct AS {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[label] #[label]
//~^ ERROR unsupported type attribute for subdiagnostic enum //~^ ERROR unsupported type attribute for subdiagnostic enum
enum AT { enum AT {
@ -466,7 +466,7 @@ enum AT {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
struct AU { struct AU {
#[primary_span] #[primary_span]
@ -474,7 +474,7 @@ struct AU {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, 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 AV { struct AV {
@ -482,7 +482,7 @@ struct AV {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum AW { enum AW {
#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")]
A { A {
@ -492,7 +492,7 @@ enum AW {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
enum AX { enum AX {
#[suggestion(parser::add_paren, 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
@ -502,18 +502,18 @@ enum AX {
} }
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[warning(parser::add_paren)] #[warning(parser::add_paren)]
struct AY {} struct AY {}
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[warning(parser::add_paren)] #[warning(parser::add_paren)]
struct AZ { struct AZ {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(parser::add_paren, code = "...")] #[suggestion(parser::add_paren, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field //~^ ERROR suggestion without `#[primary_span]` field
struct BA { struct BA {
@ -528,7 +528,7 @@ struct BA {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
//~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute //~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute
@ -536,7 +536,7 @@ struct BBa {
var: String, var: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
struct BBb { struct BBb {
#[suggestion_part] #[suggestion_part]
@ -544,7 +544,7 @@ struct BBb {
span1: Span, span1: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
struct BBc { struct BBc {
#[suggestion_part()] #[suggestion_part()]
@ -552,7 +552,7 @@ struct BBc {
span1: Span, span1: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren)] #[multipart_suggestion(parser::add_paren)]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
struct BC { struct BC {
@ -561,7 +561,7 @@ struct BC {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren)] #[multipart_suggestion(parser::add_paren)]
struct BD { struct BD {
#[suggestion_part] #[suggestion_part]
@ -581,7 +581,7 @@ struct BD {
s2: String, s2: String,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
struct BE { struct BE {
#[suggestion_part(code = "...", code = ",,,")] #[suggestion_part(code = "...", code = ",,,")]
@ -590,7 +590,7 @@ struct BE {
span: Span, span: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
struct BF { struct BF {
#[suggestion_part(code = "(")] #[suggestion_part(code = "(")]
@ -599,7 +599,7 @@ struct BF {
second: Span, second: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren)] #[multipart_suggestion(parser::add_paren)]
struct BG { struct BG {
#[applicability] #[applicability]
@ -610,7 +610,7 @@ struct BG {
second: Span, second: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
//~^ NOTE previously specified here //~^ NOTE previously specified here
struct BH { struct BH {
@ -623,7 +623,7 @@ struct BH {
second: Span, second: Span,
} }
#[derive(SessionSubdiagnostic)] #[derive(Subdiagnostic)]
#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")]
struct BI { struct BI {
#[suggestion_part(code = "")] #[suggestion_part(code = "")]