diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 6dbb2582a37..052979d6d45 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -1,5 +1,5 @@ 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}; #[derive(Diagnostic, Clone, Copy)] @@ -221,7 +221,7 @@ pub struct InvalidAsmTemplateModifierRegClass { pub sub: InvalidAsmTemplateModifierRegClassSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum InvalidAsmTemplateModifierRegClassSub { #[note(ast_lowering::support_modifiers)] SupportModifier { class_name: Symbol, modifiers: String }, diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 20e2209acbe..035f0ce1cbc 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -71,7 +71,7 @@ pub struct InvalidVisibility { pub note: Option, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum InvalidVisibilityNote { #[note(ast_passes::individual_impl_items)] IndividualImplItems, diff --git a/compiler/rustc_attr/src/session_diagnostics.rs b/compiler/rustc_attr/src/session_diagnostics.rs index 5e8f9b79850..940a48ed915 100644 --- a/compiler/rustc_attr/src/session_diagnostics.rs +++ b/compiler/rustc_attr/src/session_diagnostics.rs @@ -98,7 +98,7 @@ pub(crate) struct InvalidIssueString { // The error kinds of `IntErrorKind` are duplicated here in order to allow the messages to be // translatable. -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum InvalidIssueStringCause { #[label(attr::must_not_be_zero)] MustNotBeZero { @@ -274,7 +274,7 @@ pub(crate) struct IncorrectReprFormatGeneric<'a> { pub cause: Option>, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum IncorrectReprFormatGenericCause<'a> { #[suggestion(attr::suggestion, code = "{name}({int})", applicability = "machine-applicable")] Int { diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index aa8f26eece5..9f19453a1a6 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -1,5 +1,5 @@ use rustc_errors::{IntoDiagnosticArg, MultiSpan}; -use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; use rustc_span::Span; @@ -23,7 +23,7 @@ pub(crate) struct HigherRankedLifetimeError { pub span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum HigherRankedErrorCause { #[note(borrowck::could_not_prove)] CouldNotProve { predicate: String }, @@ -72,7 +72,7 @@ pub(crate) struct FnMutError { pub ty_err: FnMutReturnTypeErr, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum VarHereDenote { #[label(borrowck::var_here_captured)] Captured { @@ -91,7 +91,7 @@ pub(crate) enum VarHereDenote { }, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum FnMutReturnTypeErr { #[label(borrowck::returned_closure_escaped)] ReturnClosure { @@ -117,7 +117,7 @@ pub(crate) struct LifetimeOutliveErr { pub span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum LifetimeReturnCategoryErr<'a> { #[label(borrowck::returned_lifetime_wrong)] WrongReturn { @@ -149,7 +149,7 @@ impl IntoDiagnosticArg for RegionName { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum RequireStaticErr { #[note(borrowck::used_impl_require_static)] UsedImpl { diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index b6e0f3faa73..ff33ae7e8f2 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -268,14 +268,14 @@ type FluentId = Cow<'static, str>; /// 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 /// `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"] pub enum SubdiagnosticMessage { /// Non-translatable diagnostic message. // FIXME(davidtwco): can a `Cow<'static, str>` be used here? Str(String), /// Identifier of a Fluent message. Instances of this variant are generated by the - /// `SessionSubdiagnostic` derive. + /// `Subdiagnostic` derive. FluentIdentifier(FluentId), /// 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` diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index d3a263ac56d..c66889189ad 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -176,8 +176,9 @@ impl IntoDiagnosticArg for hir::ConstContext { } /// Trait implemented by error types. This should not be implemented manually. Instead, use -/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic]. -#[rustc_diagnostic_item = "AddSubdiagnostic"] +/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. +#[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")] +#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "Subdiagnostic")] pub trait AddToDiagnostic { /// Add a subdiagnostic to an existing diagnostic. fn add_to_diagnostic(self, diag: &mut Diagnostic); @@ -891,8 +892,8 @@ impl Diagnostic { self } - /// Add a subdiagnostic from a type that implements `SessionSubdiagnostic` - see - /// [rustc_macros::SessionSubdiagnostic]. + /// Add a subdiagnostic from a type that implements `Subdiagnostic` - see + /// [rustc_macros::Subdiagnostic]. pub fn subdiagnostic(&mut self, subdiagnostic: impl AddToDiagnostic) -> &mut Self { subdiagnostic.add_to_diagnostic(self); self diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 7764ffd246e..6d2c7aac6af 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -593,7 +593,7 @@ pub fn compile_declarative_macro( (mk_syn_ext(expander), rule_spans) } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum ExplainDocComment { #[label(expand::explain_doc_comment_inner)] Inner { diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index 0c66ce475c4..3a89d90c88a 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -1,5 +1,5 @@ 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_span::{Span, Symbol}; @@ -51,7 +51,7 @@ pub struct MalformedAttribute { pub sub: MalformedAttributeSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum MalformedAttributeSub { #[label(lint::bad_attribute_argument)] BadAttributeArgument(#[primary_span] Span), diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 36d8ade22ae..942475d31fe 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -404,7 +404,7 @@ impl LateLintPass<'_> for Diagnostics { let Impl { of_trait: Some(of_trait), .. } = impl_ && let Some(def_id) = of_trait.trait_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; break; diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs index 1d5b32c2556..8eaa8b87c0f 100644 --- a/compiler/rustc_macros/src/diagnostics/mod.rs +++ b/compiler/rustc_macros/src/diagnostics/mod.rs @@ -9,7 +9,7 @@ use diagnostic::{LintDiagnosticDerive, SessionDiagnosticDerive}; pub(crate) use fluent::fluent_messages; use proc_macro2::TokenStream; use quote::format_ident; -use subdiagnostic::SessionSubdiagnosticDerive; +use subdiagnostic::SubdiagnosticDerive; use synstructure::Structure; /// 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() } -/// 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 /// emitting code or diagnostic derives. /// /// ```ignore (rust) -/// #[derive(SessionSubdiagnostic)] +/// #[derive(Subdiagnostic)] /// pub enum ExpectedIdentifierLabel<'tcx> { /// #[label(parser::expected_identifier)] /// WithoutFound { @@ -128,7 +128,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// } /// } /// -/// #[derive(SessionSubdiagnostic)] +/// #[derive(Subdiagnostic)] /// #[suggestion_verbose(parser::raw_identifier)] /// pub struct RawIdentifierSuggestion<'tcx> { /// #[primary_span] @@ -155,5 +155,5 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident }); /// ``` pub fn session_subdiagnostic_derive(s: Structure<'_>) -> TokenStream { - SessionSubdiagnosticDerive::new(s).into_tokens() + SubdiagnosticDerive::new(s).into_tokens() } diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index f1bb7feb062..bdeca3420bc 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -98,19 +98,19 @@ impl quote::IdentFragment for SubdiagnosticKind { } /// 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>, diag: syn::Ident, } -impl<'a> SessionSubdiagnosticDerive<'a> { +impl<'a> SubdiagnosticDerive<'a> { pub(crate) fn new(structure: Structure<'a>) -> Self { let diag = format_ident!("diag"); Self { structure, diag } } pub(crate) fn into_tokens(self) -> TokenStream { - let SessionSubdiagnosticDerive { mut structure, diag } = self; + let SubdiagnosticDerive { mut structure, diag } = self; let implementation = { let ast = structure.ast(); let span = ast.span().unwrap(); @@ -119,7 +119,7 @@ impl<'a> SessionSubdiagnosticDerive<'a> { syn::Data::Union(..) => { span_err( 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, variant, span, @@ -178,10 +178,10 @@ impl<'a> SessionSubdiagnosticDerive<'a> { } /// 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 /// double mut borrow later on. -struct SessionSubdiagnosticDeriveBuilder<'a> { +struct SubdiagnosticDeriveBuilder<'a> { /// The identifier to use for the generated `DiagnosticBuilder` instance. diag: &'a syn::Ident, @@ -205,7 +205,7 @@ struct SessionSubdiagnosticDeriveBuilder<'a> { 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> { 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, DiagnosticDeriveError> { let mut kind_slugs = vec![]; diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 9dd7ccad8bb..8fd23ee5ced 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -161,7 +161,7 @@ decl_derive!( suggestion_verbose)] => diagnostics::lint_diagnostic_derive ); decl_derive!( - [SessionSubdiagnostic, attributes( + [Subdiagnostic, attributes( // struct/variant attributes label, help, diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index 6d15feb888a..a4ceb494569 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -25,7 +25,7 @@ pub struct OpaqueHiddenTypeMismatch<'tcx> { pub sub: TypeMismatchReason, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum TypeMismatchReason { #[label(middle::conflict_types)] ConflictType { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 9989ebb7cdf..78bc29fc375 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -20,7 +20,7 @@ use rustc_errors::{ fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult, }; 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::symbol::{kw, sym, Ident}; use rustc_span::{Span, SpanSnippetError, DUMMY_SP}; @@ -261,7 +261,7 @@ struct BadTypePlus { pub sub: BadTypePlusSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum BadTypePlusSub { #[suggestion( parser::add_paren, @@ -342,7 +342,7 @@ pub struct InvalidVariableDeclaration { pub sub: InvalidVariableDeclarationSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum InvalidVariableDeclarationSub { #[suggestion( parser::switch_mut_let_order, @@ -372,7 +372,7 @@ pub(crate) struct InvalidComparisonOperator { pub sub: InvalidComparisonOperatorSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum InvalidComparisonOperatorSub { #[suggestion_short( parser::use_instead, @@ -400,7 +400,7 @@ pub(crate) struct InvalidLogicalOperator { pub sub: InvalidLogicalOperatorSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum InvalidLogicalOperatorSub { #[suggestion_short( parser::use_amp_amp_for_conjunction, @@ -605,7 +605,7 @@ pub(crate) struct IfExpressionMissingThenBlock { pub sub: IfExpressionMissingThenBlockSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum IfExpressionMissingThenBlockSub { #[help(parser::condition_possibly_unfinished)] UnfinishedCondition(#[primary_span] Span), @@ -668,7 +668,7 @@ pub(crate) struct MissingInInForLoop { pub sub: MissingInInForLoopSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub(crate) enum MissingInInForLoopSub { // 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")] diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index bff2978bd13..52aea9bba43 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -1,5 +1,5 @@ use rustc_errors::{Applicability, MultiSpan}; -use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; #[derive(LintDiagnostic)] @@ -583,7 +583,7 @@ pub struct MacroExport; #[diag(passes::plugin_registrar)] pub struct PluginRegistrar; -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum UnusedNote { #[note(passes::unused_empty_lints_note)] EmptyList { name: Symbol }, diff --git a/compiler/rustc_privacy/src/errors.rs b/compiler/rustc_privacy/src/errors.rs index 71552119482..f3a617c2f0f 100644 --- a/compiler/rustc_privacy/src/errors.rs +++ b/compiler/rustc_privacy/src/errors.rs @@ -1,5 +1,5 @@ use rustc_errors::DiagnosticArgFromDisplay; -use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] @@ -14,7 +14,7 @@ pub struct FieldIsPrivate { pub label: FieldIsPrivateLabel, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum FieldIsPrivateLabel { #[label(privacy::field_is_private_is_update_syntax_label)] IsUpdateSyntax { diff --git a/compiler/rustc_query_system/src/error.rs b/compiler/rustc_query_system/src/error.rs index 4c770152f12..ceec75fce28 100644 --- a/compiler/rustc_query_system/src/error.rs +++ b/compiler/rustc_query_system/src/error.rs @@ -1,6 +1,7 @@ use rustc_errors::AddToDiagnostic; use rustc_session::Limit; use rustc_span::{Span, Symbol}; +use rustc_macros::{Diagnostic, Subdiagnostic}; pub struct CycleStack { pub span: Span, @@ -20,7 +21,7 @@ pub enum HandleCycleError { DelayBug, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum StackCount { #[note(query_system::cycle_stack_single)] Single, @@ -28,7 +29,7 @@ pub enum StackCount { Multiple, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum Alias { #[note(query_system::cycle_recursive_ty_alias)] #[help(query_system::cycle_recursive_ty_alias_help1)] @@ -38,7 +39,7 @@ pub enum Alias { Trait, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(query_system::cycle_usage)] pub struct CycleUsage { #[primary_span] diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 7ffe757463f..997a45272bc 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -34,13 +34,13 @@ pub struct FeatureGateError<'a> { pub explain: &'a str, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(session::feature_diagnostic_for_issue)] pub struct FeatureDiagnosticForIssue { pub n: NonZeroU32, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[help(session::feature_diagnostic_help)] pub struct FeatureDiagnosticHelp { pub feature: Symbol, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ea69334616b..1baad6a9fd7 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -125,7 +125,6 @@ symbols! { Symbols { AcqRel, Acquire, - AddSubdiagnostic, Alignment, Any, Arc, @@ -283,6 +282,7 @@ symbols! { String, StructuralEq, StructuralPartialEq, + Subdiagnostic, SubdiagnosticMessage, Sync, T, diff --git a/compiler/rustc_ty_utils/src/errors.rs b/compiler/rustc_ty_utils/src/errors.rs index 85165187310..753c474a34b 100644 --- a/compiler/rustc_ty_utils/src/errors.rs +++ b/compiler/rustc_ty_utils/src/errors.rs @@ -1,6 +1,6 @@ //! Errors emitted by ty_utils -use rustc_macros::{Diagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; use rustc_span::Span; @@ -22,7 +22,7 @@ pub struct GenericConstantTooComplex { pub sub: GenericConstantTooComplexSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum GenericConstantTooComplexSub { #[label(ty_utils::borrow_not_supported)] BorrowNotSupported(#[primary_span] Span), diff --git a/compiler/rustc_typeck/src/errors.rs b/compiler/rustc_typeck/src/errors.rs index 6f00591d54e..44df47e2fa0 100644 --- a/compiler/rustc_typeck/src/errors.rs +++ b/compiler/rustc_typeck/src/errors.rs @@ -1,7 +1,7 @@ //! Errors emitted by typeck. use rustc_errors::IntoDiagnostic; 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_span::{symbol::Ident, Span, Symbol}; @@ -194,7 +194,7 @@ pub struct AddressOfTemporaryTaken { pub span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum AddReturnTypeSuggestion { #[suggestion( typeck::add_return_type_add, @@ -217,7 +217,7 @@ pub enum AddReturnTypeSuggestion { }, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum ExpectedReturnTypeLabel<'tcx> { #[label(typeck::expected_default_return_type)] Unit { diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.rs b/src/test/ui-fulldeps/internal-lints/diagnostics.rs index 93766de9a91..4c2c28dc336 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -15,7 +15,7 @@ use rustc_errors::{ AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, fluent }; -use rustc_macros::{Diagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; #[derive(Diagnostic)] @@ -25,7 +25,7 @@ struct DeriveSessionDiagnostic { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct Note { #[primary_span] diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index fd8128c31f8..80ea9082881 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -17,7 +17,7 @@ use rustc_span::symbol::Ident; use rustc_span::Span; extern crate rustc_macros; -use rustc_macros::{Diagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; extern crate rustc_middle; use rustc_middle::ty::Ty; @@ -462,7 +462,7 @@ struct NoApplicability { suggestion: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct Note; diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 812ca0c72bd..9fbe7b1f4c8 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -1,8 +1,8 @@ // 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, -// 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: // ignore-beta // ignore-stable @@ -17,9 +17,9 @@ extern crate rustc_macros; use rustc_errors::Applicability; use rustc_span::Span; -use rustc_macros::SessionSubdiagnostic; +use rustc_macros::Subdiagnostic; -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct A { #[primary_span] @@ -27,7 +27,7 @@ struct A { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum B { #[label(parser::add_paren)] A { @@ -43,14 +43,14 @@ enum B { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] //~^ ERROR label without `#[primary_span]` field struct C { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] //~^ ERROR `#[label]` is not a valid attribute struct D { @@ -59,7 +59,7 @@ struct D { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR `#[foo]` is not a valid attribute //~^^ ERROR cannot find attribute `foo` in this scope @@ -69,7 +69,7 @@ struct E { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label = "..."] //~^ ERROR `#[label = ...]` is not a valid attribute struct F { @@ -78,7 +78,7 @@ struct F { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(bug = "...")] //~^ ERROR `#[label(bug = ...)]` is not a valid attribute struct G { @@ -87,7 +87,7 @@ struct G { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label("...")] //~^ ERROR `#[label("...")]` is not a valid attribute struct H { @@ -96,7 +96,7 @@ struct H { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug = 4)] //~^ ERROR `#[label(slug = ...)]` is not a valid attribute struct J { @@ -105,7 +105,7 @@ struct J { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug("..."))] //~^ ERROR `#[label(slug(...))]` is not a valid attribute struct K { @@ -114,7 +114,7 @@ struct K { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug)] //~^ ERROR cannot find value `slug` in module `rustc_errors::fluent` //~^^ NOTE not found in `rustc_errors::fluent` @@ -124,7 +124,7 @@ struct L { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label()] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { @@ -133,7 +133,7 @@ struct M { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, code = "...")] //~^ ERROR `code` is not a valid nested attribute of a `label` attribute struct N { @@ -142,7 +142,7 @@ struct N { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, applicability = "machine-applicable")] //~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute struct O { @@ -151,7 +151,7 @@ struct O { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR unsupported type attribute for subdiagnostic enum @@ -164,7 +164,7 @@ enum P { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum Q { #[bar] //~^ ERROR `#[bar]` is not a valid attribute @@ -176,7 +176,7 @@ enum Q { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum R { #[bar = "..."] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -188,7 +188,7 @@ enum R { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum S { #[bar = 4] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -200,7 +200,7 @@ enum S { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum T { #[bar("...")] //~^ ERROR `#[bar(...)]` is not a valid attribute @@ -212,7 +212,7 @@ enum T { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum U { #[label(code = "...")] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute @@ -223,7 +223,7 @@ enum U { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum V { #[label(parser::add_paren)] A { @@ -239,7 +239,7 @@ enum V { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] //~^ ERROR label without `#[primary_span]` field struct W { @@ -248,7 +248,7 @@ struct W { span: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct X { #[primary_span] @@ -258,7 +258,7 @@ struct X { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct Y { #[primary_span] @@ -269,7 +269,7 @@ struct Y { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct Z { #[primary_span] @@ -280,7 +280,7 @@ struct Z { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AA { #[primary_span] @@ -291,7 +291,7 @@ struct AA { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AB { #[primary_span] @@ -300,14 +300,14 @@ struct AB { z: Z } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] union AC { //~^ ERROR unexpected unsupported untagged union span: u32, b: u64 } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] #[label(parser::add_paren)] struct AD { @@ -315,7 +315,7 @@ struct AD { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, parser::add_paren)] //~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute struct AE { @@ -323,7 +323,7 @@ struct AE { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AF { #[primary_span] @@ -334,14 +334,14 @@ struct AF { span_b: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] struct AG { //~^ ERROR subdiagnostic kind not specified #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AH { #[primary_span] @@ -351,7 +351,7 @@ struct AH { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AI { #[suggestion(parser::add_paren, code = "...")] A { @@ -371,7 +371,7 @@ enum AI { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...", code = "...")] //~^ ERROR specified multiple times //~^^ NOTE previously specified here @@ -382,7 +382,7 @@ struct AJ { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AK { #[primary_span] @@ -395,7 +395,7 @@ struct AK { applicability_b: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AL { #[primary_span] @@ -405,14 +405,14 @@ struct AL { applicability: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AM { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren)] //~^ ERROR suggestion without `code = "..."` struct AN { @@ -422,7 +422,7 @@ struct AN { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { @@ -430,31 +430,31 @@ struct AO { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[help(parser::add_paren)] struct AP { var: String } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct AQ; -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct AR { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] //~^ ERROR unsupported type attribute for subdiagnostic enum enum AT { @@ -466,7 +466,7 @@ enum AT { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] struct AU { #[primary_span] @@ -474,7 +474,7 @@ struct AU { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type struct AV { @@ -482,7 +482,7 @@ struct AV { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AW { #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] A { @@ -492,7 +492,7 @@ enum AW { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AX { #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] //~^ 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)] struct AY {} -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[warning(parser::add_paren)] struct AZ { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct BA { @@ -528,7 +528,7 @@ struct BA { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[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 @@ -536,7 +536,7 @@ struct BBa { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BBb { #[suggestion_part] @@ -544,7 +544,7 @@ struct BBb { span1: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] @@ -552,7 +552,7 @@ struct BBc { span1: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields struct BC { @@ -561,7 +561,7 @@ struct BC { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] struct BD { #[suggestion_part] @@ -581,7 +581,7 @@ struct BD { s2: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BE { #[suggestion_part(code = "...", code = ",,,")] @@ -590,7 +590,7 @@ struct BE { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BF { #[suggestion_part(code = "(")] @@ -599,7 +599,7 @@ struct BF { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] struct BG { #[applicability] @@ -610,7 +610,7 @@ struct BG { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] //~^ NOTE previously specified here struct BH { @@ -623,7 +623,7 @@ struct BH { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BI { #[suggestion_part(code = "")]