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_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 },

View file

@ -71,7 +71,7 @@ pub struct InvalidVisibility {
pub note: Option<InvalidVisibilityNote>,
}
#[derive(SessionSubdiagnostic)]
#[derive(Subdiagnostic)]
pub enum InvalidVisibilityNote {
#[note(ast_passes::individual_impl_items)]
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
// 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<IncorrectReprFormatGenericCause<'a>>,
}
#[derive(SessionSubdiagnostic)]
#[derive(Subdiagnostic)]
pub(crate) enum IncorrectReprFormatGenericCause<'a> {
#[suggestion(attr::suggestion, code = "{name}({int})", applicability = "machine-applicable")]
Int {

View file

@ -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 @@ fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
}
}
#[derive(SessionSubdiagnostic)]
#[derive(Subdiagnostic)]
pub(crate) enum RequireStaticErr {
#[note(borrowck::used_impl_require_static)]
UsedImpl {

View file

@ -268,14 +268,14 @@ pub fn fallback_fluent_bundle(
/// 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`

View file

@ -176,8 +176,9 @@ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
}
/// 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 @@ pub fn tool_only_span_suggestion(
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

View file

@ -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 {

View file

@ -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),

View file

@ -404,7 +404,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
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;

View file

@ -9,7 +9,7 @@
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()
}

View file

@ -98,19 +98,19 @@ fn span(&self) -> Option<proc_macro2::Span> {
}
/// 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 @@ pub(crate) fn into_tokens(self) -> TokenStream {
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 @@ pub(crate) fn into_tokens(self) -> TokenStream {
}
}
let mut builder = SessionSubdiagnosticDeriveBuilder {
let mut builder = SubdiagnosticDeriveBuilder {
diag: &diag,
variant,
span,
@ -178,10 +178,10 @@ fn add_to_diagnostic(self, #diag: &mut rustc_errors::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
/// 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 @@ fn from_iter<T: IntoIterator<Item = &'a SubdiagnosticKind>>(kinds: T) -> Self {
}
}
impl<'a> SessionSubdiagnosticDeriveBuilder<'a> {
impl<'a> SubdiagnosticDeriveBuilder<'a> {
fn identify_kind(&mut self) -> Result<Vec<(SubdiagnosticKind, Path)>, DiagnosticDeriveError> {
let mut kind_slugs = vec![];

View file

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

View file

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

View file

@ -20,7 +20,7 @@
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")]

View file

@ -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 MacroUse {
#[diag(passes::plugin_registrar)]
pub struct PluginRegistrar;
#[derive(SessionSubdiagnostic)]
#[derive(Subdiagnostic)]
pub enum UnusedNote {
#[note(passes::unused_empty_lints_note)]
EmptyList { name: Symbol },

View file

@ -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 {

View file

@ -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]

View file

@ -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,

View file

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

View file

@ -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),

View file

@ -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 {

View file

@ -15,7 +15,7 @@
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]

View file

@ -17,7 +17,7 @@
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;

View file

@ -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 @@
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 = "")]