Skip to main content

rustc_attr_parsing/
session_diagnostics.rs

1use std::num::IntErrorKind;
2
3use rustc_errors::codes::*;
4use rustc_errors::{
5    Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
6};
7use rustc_hir::AttrPath;
8use rustc_hir::attrs::{MirDialect, MirPhase};
9use rustc_macros::{Diagnostic, Subdiagnostic};
10use rustc_span::{Span, Symbol};
11use rustc_target::spec::TargetTuple;
12
13use crate::AttributeTemplate;
14use crate::context::Suggestion;
15
16#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BothFfiConstAndPure where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BothFfiConstAndPure { attr_span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[ffi_const]` function cannot be `#[ffi_pure]`")));
                        diag.code(E0757);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
17#[diag("`#[ffi_const]` function cannot be `#[ffi_pure]`", code = E0757)]
18pub(crate) struct BothFfiConstAndPure {
19    #[primary_span]
20    pub attr_span: Span,
21}
22
23#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAliasEmpty<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAliasEmpty { span: __binding_0, attr_str: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$attr_str} attribute cannot have empty value")));
                        ;
                        diag.arg("attr_str", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
24#[diag("{$attr_str} attribute cannot have empty value")]
25pub(crate) struct DocAliasEmpty<'a> {
26    #[primary_span]
27    pub span: Span,
28    pub attr_str: &'a str,
29}
30
31#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAliasBadChar<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAliasBadChar {
                        span: __binding_0, attr_str: __binding_1, char_: __binding_2
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$char_} character isn't allowed in {$attr_str}")));
                        ;
                        diag.arg("attr_str", __binding_1);
                        diag.arg("char_", __binding_2);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
32#[diag("{$char_} character isn't allowed in {$attr_str}")]
33pub(crate) struct DocAliasBadChar<'a> {
34    #[primary_span]
35    pub span: Span,
36    pub attr_str: &'a str,
37    pub char_: char,
38}
39
40#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAliasStartEnd<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAliasStartEnd { span: __binding_0, attr_str: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$attr_str} cannot start or end with ' '")));
                        ;
                        diag.arg("attr_str", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
41#[diag("{$attr_str} cannot start or end with ' '")]
42pub(crate) struct DocAliasStartEnd<'a> {
43    #[primary_span]
44    pub span: Span,
45    pub attr_str: &'a str,
46}
47
48#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            CguFieldsMissing<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CguFieldsMissing {
                        span: __binding_0, name: __binding_1, field: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name})]` is missing a `{$field}` argument")));
                        ;
                        diag.arg("name", __binding_1);
                        diag.arg("field", __binding_2);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
49#[diag("`#[{$name})]` is missing a `{$field}` argument")]
50pub(crate) struct CguFieldsMissing<'a> {
51    #[primary_span]
52    pub span: Span,
53    pub name: &'a AttrPath,
54    pub field: Symbol,
55}
56
57#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAttrNotCrateLevel where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAttrNotCrateLevel {
                        span: __binding_0, attr_name: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#![doc({$attr_name} = \"...\")]` isn't allowed as a crate-level attribute")));
                        ;
                        diag.arg("attr_name", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
58#[diag("`#![doc({$attr_name} = \"...\")]` isn't allowed as a crate-level attribute")]
59pub(crate) struct DocAttrNotCrateLevel {
60    #[primary_span]
61    pub span: Span,
62    pub attr_name: Symbol,
63}
64
65#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DocKeywordNotKeyword where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocKeywordNotKeyword {
                        span: __binding_0, keyword: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nonexistent keyword `{$keyword}` used in `#[doc(keyword = \"...\")]`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only existing keywords are allowed in core/std")));
                        ;
                        diag.arg("keyword", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
66#[diag("nonexistent keyword `{$keyword}` used in `#[doc(keyword = \"...\")]`")]
67#[help("only existing keywords are allowed in core/std")]
68pub(crate) struct DocKeywordNotKeyword {
69    #[primary_span]
70    pub span: Span,
71    pub keyword: Symbol,
72}
73
74#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAttributeNotAttribute where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAttributeNotAttribute {
                        span: __binding_0, attribute: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nonexistent builtin attribute `{$attribute}` used in `#[doc(attribute = \"...\")]`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only existing builtin attributes are allowed in core/std")));
                        ;
                        diag.arg("attribute", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
75#[diag("nonexistent builtin attribute `{$attribute}` used in `#[doc(attribute = \"...\")]`")]
76#[help("only existing builtin attributes are allowed in core/std")]
77pub(crate) struct DocAttributeNotAttribute {
78    #[primary_span]
79    pub span: Span,
80    pub attribute: Symbol,
81}
82
83#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TargetFeatureOnLangItem where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    TargetFeatureOnLangItem {
                        attr_span: __binding_0,
                        kind: __binding_1,
                        item_span: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[target_feature]` cannot be applied to a {$kind ->\n        [panic_handler] `#[panic_handler]`\n        *[other] lang item\n    } function")));
                        ;
                        diag.arg("kind", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind ->\n            [panic_handler] `#[panic_handler]`\n            *[other] lang item\n        } function is not allowed to have `#[target_feature]`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
84#[diag(
85    "`#[target_feature]` cannot be applied to a {$kind ->
86        [panic_handler] `#[panic_handler]`
87        *[other] lang item
88    } function"
89)]
90pub(crate) struct TargetFeatureOnLangItem {
91    #[primary_span]
92    pub attr_span: Span,
93    pub kind: Symbol,
94    #[label(
95        "{$kind ->
96            [panic_handler] `#[panic_handler]`
97            *[other] lang item
98        } function is not allowed to have `#[target_feature]`"
99    )]
100    pub item_span: Span,
101}
102
103#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingSince
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MissingSince { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing 'since'")));
                        diag.code(E0542);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
104#[diag("missing 'since'", code = E0542)]
105pub(crate) struct MissingSince {
106    #[primary_span]
107    pub span: Span,
108}
109
110#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingNote
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MissingNote { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing 'note'")));
                        diag.code(E0543);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
111#[diag("missing 'note'", code = E0543)]
112pub(crate) struct MissingNote {
113    #[primary_span]
114    pub span: Span,
115}
116
117#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MultipleStabilityLevels where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MultipleStabilityLevels { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple stability levels")));
                        diag.code(E0544);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
118#[diag("multiple stability levels", code = E0544)]
119pub(crate) struct MultipleStabilityLevels {
120    #[primary_span]
121    pub span: Span,
122}
123
124#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidIssueString where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidIssueString { span: __binding_0, cause: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`issue` must be a non-zero numeric string or \"none\"")));
                        diag.code(E0545);
                        ;
                        diag.span(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
125#[diag("`issue` must be a non-zero numeric string or \"none\"", code = E0545)]
126pub(crate) struct InvalidIssueString {
127    #[primary_span]
128    pub span: Span,
129
130    #[subdiagnostic]
131    pub cause: Option<InvalidIssueStringCause>,
132}
133
134// The error kinds of `IntErrorKind` are duplicated here in order to allow the messages to be
135// translatable.
136#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidIssueStringCause {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidIssueStringCause::MustNotBeZero { span: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`issue` must not be \"0\", use \"none\" instead")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    InvalidIssueStringCause::Empty { span: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot parse integer from empty string")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    InvalidIssueStringCause::InvalidDigit { span: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid digit found in string")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    InvalidIssueStringCause::PosOverflow { span: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("number too large to fit in target type")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    InvalidIssueStringCause::NegOverflow { span: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("number too small to fit in target type")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
137pub(crate) enum InvalidIssueStringCause {
138    #[label("`issue` must not be \"0\", use \"none\" instead")]
139    MustNotBeZero {
140        #[primary_span]
141        span: Span,
142    },
143
144    #[label("cannot parse integer from empty string")]
145    Empty {
146        #[primary_span]
147        span: Span,
148    },
149
150    #[label("invalid digit found in string")]
151    InvalidDigit {
152        #[primary_span]
153        span: Span,
154    },
155
156    #[label("number too large to fit in target type")]
157    PosOverflow {
158        #[primary_span]
159        span: Span,
160    },
161
162    #[label("number too small to fit in target type")]
163    NegOverflow {
164        #[primary_span]
165        span: Span,
166    },
167}
168
169impl InvalidIssueStringCause {
170    pub(crate) fn from_int_error_kind(span: Span, kind: &IntErrorKind) -> Option<Self> {
171        match kind {
172            IntErrorKind::Empty => Some(Self::Empty { span }),
173            IntErrorKind::InvalidDigit => Some(Self::InvalidDigit { span }),
174            IntErrorKind::PosOverflow => Some(Self::PosOverflow { span }),
175            IntErrorKind::NegOverflow => Some(Self::NegOverflow { span }),
176            IntErrorKind::Zero => Some(Self::MustNotBeZero { span }),
177            _ => None,
178        }
179    }
180}
181
182#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingFeature
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MissingFeature { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing 'feature'")));
                        diag.code(E0546);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
183#[diag("missing 'feature'", code = E0546)]
184pub(crate) struct MissingFeature {
185    #[primary_span]
186    pub span: Span,
187}
188
189#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NonIdentFeature where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NonIdentFeature { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("'feature' is not an identifier")));
                        diag.code(E0546);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
190#[diag("'feature' is not an identifier", code = E0546)]
191pub(crate) struct NonIdentFeature {
192    #[primary_span]
193    pub span: Span,
194}
195
196#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingIssue
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MissingIssue { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing 'issue'")));
                        diag.code(E0547);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
197#[diag("missing 'issue'", code = E0547)]
198pub(crate) struct MissingIssue {
199    #[primary_span]
200    pub span: Span,
201}
202
203#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RustcPromotablePairing where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RustcPromotablePairing { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute")));
                        diag.code(E0717);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
204#[diag("`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute", code = E0717)]
205pub(crate) struct RustcPromotablePairing {
206    #[primary_span]
207    pub span: Span,
208}
209
210#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RustcAllowedUnstablePairing where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RustcAllowedUnstablePairing { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute")));
                        diag.code(E0789);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
211#[diag("`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute", code = E0789)]
212pub(crate) struct RustcAllowedUnstablePairing {
213    #[primary_span]
214    pub span: Span,
215}
216
217#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DeprecatedItemSuggestion where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DeprecatedItemSuggestion {
                        span: __binding_0,
                        is_nightly: __binding_1,
                        details: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suggestions on deprecated items are unstable")));
                        ;
                        diag.span(__binding_0);
                        if __binding_1 {
                            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(deprecated_suggestion)]` to the crate root")));
                        }
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see #94785 for more details")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
218#[diag("suggestions on deprecated items are unstable")]
219pub(crate) struct DeprecatedItemSuggestion {
220    #[primary_span]
221    pub span: Span,
222
223    #[help("add `#![feature(deprecated_suggestion)]` to the crate root")]
224    pub is_nightly: bool,
225
226    #[note("see #94785 for more details")]
227    pub details: (),
228}
229
230#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExpectedSingleVersionLiteral where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectedSingleVersionLiteral { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected single version literal")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
231#[diag("expected single version literal")]
232pub(crate) struct ExpectedSingleVersionLiteral {
233    #[primary_span]
234    pub span: Span,
235}
236
237#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExpectedVersionLiteral where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectedVersionLiteral { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a version literal")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
238#[diag("expected a version literal")]
239pub(crate) struct ExpectedVersionLiteral {
240    #[primary_span]
241    pub span: Span,
242}
243
244#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExpectsFeatureList where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectsFeatureList { span: __binding_0, name: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` expects a list of feature names")));
                        ;
                        diag.arg("name", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
245#[diag("`{$name}` expects a list of feature names")]
246pub(crate) struct ExpectsFeatureList {
247    #[primary_span]
248    pub span: Span,
249
250    pub name: String,
251}
252
253#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExpectsFeatures where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectsFeatures { span: __binding_0, name: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` expects feature names")));
                        ;
                        diag.arg("name", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
254#[diag("`{$name}` expects feature names")]
255pub(crate) struct ExpectsFeatures {
256    #[primary_span]
257    pub span: Span,
258
259    pub name: String,
260}
261
262#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InvalidSince
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidSince { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("'since' must be a Rust version number, such as \"1.31.0\"")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
263#[diag("'since' must be a Rust version number, such as \"1.31.0\"")]
264pub(crate) struct InvalidSince {
265    #[primary_span]
266    pub span: Span,
267}
268
269#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownVersionLiteral where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnknownVersionLiteral { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown version literal format, assuming it refers to a future version")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
270#[diag("unknown version literal format, assuming it refers to a future version")]
271pub(crate) struct UnknownVersionLiteral {
272    #[primary_span]
273    pub span: Span,
274}
275
276// FIXME(jdonszelmann) duplicated from `rustc_passes`, remove once `check_attr` is integrated.
277#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnusedMultiple
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnusedMultiple {
                        this: __binding_0, other: __binding_1, name: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `{$name}` attributes")));
                        let __code_18 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        ;
                        diag.arg("name", __binding_2);
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
                            __code_18, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute also specified here")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
278#[diag("multiple `{$name}` attributes")]
279pub(crate) struct UnusedMultiple {
280    #[primary_span]
281    #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
282    pub this: Span,
283    #[note("attribute also specified here")]
284    pub other: Span,
285    pub name: Symbol,
286}
287
288#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            EmptyExportName where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    EmptyExportName { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`export_name` may not be empty")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
289#[diag("`export_name` may not be empty")]
290pub(crate) struct EmptyExportName {
291    #[primary_span]
292    pub span: Span,
293}
294
295#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NullOnExport
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NullOnExport { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`export_name` may not contain null characters")));
                        diag.code(E0648);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
296#[diag("`export_name` may not contain null characters", code = E0648)]
297pub(crate) struct NullOnExport {
298    #[primary_span]
299    pub span: Span,
300}
301
302#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NullOnLinkSection where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NullOnLinkSection { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`link_section` may not contain null characters")));
                        diag.code(E0648);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
303#[diag("`link_section` may not contain null characters", code = E0648)]
304pub(crate) struct NullOnLinkSection {
305    #[primary_span]
306    pub span: Span,
307}
308
309#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NullOnLinkName
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NullOnLinkName { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link name may not contain null characters")));
                        diag.code(E0648);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
310#[diag("link name may not contain null characters", code = E0648)]
311pub(crate) struct NullOnLinkName {
312    #[primary_span]
313    pub span: Span,
314}
315
316#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NullOnObjcClass where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NullOnObjcClass { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`objc::class!` may not contain null characters")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
317#[diag("`objc::class!` may not contain null characters")]
318pub(crate) struct NullOnObjcClass {
319    #[primary_span]
320    pub span: Span,
321}
322
323#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NullOnObjcSelector where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NullOnObjcSelector { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`objc::selector!` may not contain null characters")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
324#[diag("`objc::selector!` may not contain null characters")]
325pub(crate) struct NullOnObjcSelector {
326    #[primary_span]
327    pub span: Span,
328}
329
330#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ObjcClassExpectedStringLiteral where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ObjcClassExpectedStringLiteral { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`objc::class!` expected a string literal")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
331#[diag("`objc::class!` expected a string literal")]
332pub(crate) struct ObjcClassExpectedStringLiteral {
333    #[primary_span]
334    pub span: Span,
335}
336
337#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ObjcSelectorExpectedStringLiteral where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ObjcSelectorExpectedStringLiteral { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`objc::selector!` expected a string literal")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
338#[diag("`objc::selector!` expected a string literal")]
339pub(crate) struct ObjcSelectorExpectedStringLiteral {
340    #[primary_span]
341    pub span: Span,
342}
343
344#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            EmptyConfusables where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    EmptyConfusables { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected at least one confusable name")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
345#[diag("expected at least one confusable name")]
346pub(crate) struct EmptyConfusables {
347    #[primary_span]
348    pub span: Span,
349}
350
351#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InvalidTarget
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidTarget {
                        span: __binding_0,
                        name: __binding_1,
                        target: __binding_2,
                        applied: __binding_3,
                        only: __binding_4,
                        attribute_args: __binding_5,
                        help: __binding_6,
                        previously_accepted: __binding_7,
                        on_macro_call: __binding_8 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}{$attribute_args}]` attribute cannot be used on {$target}")));
                        let __code_19 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}{$attribute_args}]` can {$only}be applied to {$applied}")));
                        ;
                        diag.arg("name", __binding_1);
                        diag.arg("target", __binding_2);
                        diag.arg("applied", __binding_3);
                        diag.arg("only", __binding_4);
                        diag.arg("attribute_args", __binding_5);
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attribute")),
                            __code_19, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::CompletelyHidden);
                        if let Some(__binding_6) = __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        if __binding_7 {
                            diag.warn(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!")));
                        }
                        if __binding_8 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
352#[help("`#[{$name}{$attribute_args}]` can {$only}be applied to {$applied}")]
353#[diag("`#[{$name}{$attribute_args}]` attribute cannot be used on {$target}")]
354pub(crate) struct InvalidTarget {
355    #[primary_span]
356    #[suggestion(
357        "remove the attribute",
358        code = "",
359        applicability = "machine-applicable",
360        style = "tool-only"
361    )]
362    pub span: Span,
363    pub name: AttrPath,
364    pub target: &'static str,
365    pub applied: DiagArgValue,
366    pub only: &'static str,
367    pub attribute_args: String,
368    #[subdiagnostic]
369    pub help: Option<InvalidTargetHelp>,
370    #[warning(
371        "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
372    )]
373    pub previously_accepted: bool,
374    #[note(
375        "placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute"
376    )]
377    pub on_macro_call: bool,
378}
379
380#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidTargetHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidTargetHelp::UseRustcAlign => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `#[rustc_align(...)]` instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                    InvalidTargetHelp::UseRustcAlignStatic => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `#[rustc_align_static(...)]` instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
381pub(crate) enum InvalidTargetHelp {
382    #[help("use `#[rustc_align(...)]` instead")]
383    UseRustcAlign,
384    #[help("use `#[rustc_align_static(...)]` instead")]
385    UseRustcAlignStatic,
386}
387
388#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidAlignmentValue where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidAlignmentValue {
                        span: __binding_0, error_part: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid alignment value: {$error_part}")));
                        diag.code(E0589);
                        ;
                        diag.arg("error_part", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
389#[diag("invalid alignment value: {$error_part}", code = E0589)]
390pub(crate) struct InvalidAlignmentValue {
391    #[primary_span]
392    pub span: Span,
393    pub error_part: String,
394}
395
396#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnstableFeatureBoundIncompatibleStability where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnstableFeatureBoundIncompatibleStability {
                        span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item annotated with `#[unstable_feature_bound]` should not be stable")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
397#[diag("item annotated with `#[unstable_feature_bound]` should not be stable")]
398#[help(
399    "if this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`"
400)]
401pub(crate) struct UnstableFeatureBoundIncompatibleStability {
402    #[primary_span]
403    pub span: Span,
404}
405
406#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NakedFunctionIncompatibleAttribute where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NakedFunctionIncompatibleAttribute {
                        span: __binding_0,
                        naked_span: __binding_1,
                        attr: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute incompatible with `#[unsafe(naked)]`")));
                        diag.code(E0736);
                        ;
                        diag.arg("attr", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function marked with `#[unsafe(naked)]` here")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
407#[diag("attribute incompatible with `#[unsafe(naked)]`", code = E0736)]
408pub(crate) struct NakedFunctionIncompatibleAttribute {
409    #[primary_span]
410    #[label("the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`")]
411    pub span: Span,
412    #[label("function marked with `#[unsafe(naked)]` here")]
413    pub naked_span: Span,
414    pub attr: String,
415}
416
417#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            LinkOrdinalOutOfRange where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LinkOrdinalOutOfRange {
                        span: __binding_0, ordinal: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ordinal value in `link_ordinal` is too large: `{$ordinal}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the value may not exceed `u16::MAX`")));
                        ;
                        diag.arg("ordinal", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
418#[diag("ordinal value in `link_ordinal` is too large: `{$ordinal}`")]
419#[note("the value may not exceed `u16::MAX`")]
420pub(crate) struct LinkOrdinalOutOfRange {
421    #[primary_span]
422    pub span: Span,
423    pub ordinal: u128,
424}
425
426#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RustcScalableVectorCountOutOfRange where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RustcScalableVectorCountOutOfRange {
                        span: __binding_0, n: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("element count in `rustc_scalable_vector` is too large: `{$n}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the value may not exceed `u16::MAX`")));
                        ;
                        diag.arg("n", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
427#[diag("element count in `rustc_scalable_vector` is too large: `{$n}`")]
428#[note("the value may not exceed `u16::MAX`")]
429pub(crate) struct RustcScalableVectorCountOutOfRange {
430    #[primary_span]
431    pub span: Span,
432    pub n: u128,
433}
434
435#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AttributeRequiresOpt where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AttributeRequiresOpt { span: __binding_0, opt: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute requires {$opt} to be enabled")));
                        ;
                        diag.arg("opt", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
436#[diag("attribute requires {$opt} to be enabled")]
437pub(crate) struct AttributeRequiresOpt {
438    #[primary_span]
439    pub span: Span,
440    pub opt: &'static str,
441}
442
443pub(crate) enum AttributeParseErrorReason<'a> {
444    ExpectedNoArgs,
445    ExpectedStringLiteral {
446        byte_string: Option<Span>,
447    },
448    ExpectedFilenameLiteral,
449    ExpectedIntegerLiteral,
450    ExpectedIntegerLiteralInRange {
451        lower_bound: isize,
452        upper_bound: isize,
453    },
454    ExpectedAtLeastOneArgument,
455    ExpectedArgument,
456    ExpectedSingleArgument,
457    ExpectedList,
458    ExpectedListOrNoArgs,
459    ExpectedListWithNumArgsOrMore {
460        args: usize,
461    },
462    ExpectedNameValueOrNoArgs,
463    ExpectedNonEmptyStringLiteral,
464    ExpectedNotLiteral,
465    ExpectedNameValue(Option<Symbol>),
466    MissingNameValue(Symbol),
467    DuplicateKey(Symbol),
468    ExpectedSpecificArgument {
469        possibilities: &'a [Symbol],
470        strings: bool,
471        /// Should we tell the user to write a list when they didn't?
472        list: bool,
473    },
474    ExpectedIdentifier,
475}
476
477/// A description of a thing that can be parsed using an attribute parser.
478#[derive(#[automatically_derived]
impl ::core::marker::Copy for ParsedDescription { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParsedDescription {
    #[inline]
    fn clone(&self) -> ParsedDescription { *self }
}Clone)]
479pub enum ParsedDescription {
480    /// Used when parsing attributes.
481    Attribute,
482    /// Used when parsing some macros, such as the `cfg!()` macro.
483    Macro,
484}
485
486pub(crate) struct AttributeParseError<'a> {
487    pub(crate) span: Span,
488    pub(crate) attr_span: Span,
489    pub(crate) template: AttributeTemplate,
490    pub(crate) path: AttrPath,
491    pub(crate) description: ParsedDescription,
492    pub(crate) reason: AttributeParseErrorReason<'a>,
493    pub(crate) suggestions: AttributeParseErrorSuggestions,
494}
495
496pub(crate) enum AttributeParseErrorSuggestions {
497    CreatedByTemplate(Vec<String>),
498    CreatedByParser(Vec<Suggestion>),
499}
500
501impl<'a> AttributeParseError<'a> {
502    fn render_expected_specific_argument<G>(
503        &self,
504        diag: &mut Diag<'_, G>,
505        possibilities: &[Symbol],
506        strings: bool,
507    ) where
508        G: EmissionGuarantee,
509    {
510        let quote = if strings { '"' } else { '`' };
511        match possibilities {
512            &[] => {}
513            &[x] => {
514                diag.span_label(
515                    self.span,
516                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("the only valid argument here is {0}{1}{0}",
                quote, x))
    })format!("the only valid argument here is {quote}{x}{quote}"),
517                );
518            }
519            [first, second] => {
520                diag.span_label(
521                    self.span,
522                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("valid arguments are {0}{1}{0} or {0}{2}{0}",
                quote, first, second))
    })format!("valid arguments are {quote}{first}{quote} or {quote}{second}{quote}"),
523                );
524            }
525            [first @ .., second_to_last, last] => {
526                let mut res = String::new();
527                for i in first {
528                    res.push_str(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1}{0}, ", quote, i))
    })format!("{quote}{i}{quote}, "));
529                }
530                res.push_str(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1}{0} or {0}{2}{0}", quote,
                second_to_last, last))
    })format!("{quote}{second_to_last}{quote} or {quote}{last}{quote}"));
531
532                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("valid arguments are {0}", res))
    })format!("valid arguments are {res}"));
533            }
534        }
535    }
536
537    fn render_expected_specific_argument_list<G>(
538        &self,
539        diag: &mut Diag<'_, G>,
540        possibilities: &[Symbol],
541        strings: bool,
542    ) where
543        G: EmissionGuarantee,
544    {
545        let description = self.description();
546
547        let quote = if strings { '"' } else { '`' };
548        match possibilities {
549            &[] => {}
550            &[x] => {
551                diag.span_label(
552                    self.span,
553                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("this {0} is only valid with {1}{2}{1} as an argument",
                description, quote, x))
    })format!(
554                        "this {description} is only valid with {quote}{x}{quote} as an argument"
555                    ),
556                );
557            }
558            [first, second] => {
559                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("this {0} is only valid with either {1}{2}{1} or {1}{3}{1} as an argument",
                description, quote, first, second))
    })format!("this {description} is only valid with either {quote}{first}{quote} or {quote}{second}{quote} as an argument"));
560            }
561            [first @ .., second_to_last, last] => {
562                let mut res = String::new();
563                for i in first {
564                    res.push_str(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1}{0}, ", quote, i))
    })format!("{quote}{i}{quote}, "));
565                }
566                res.push_str(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1}{0} or {0}{2}{0}", quote,
                second_to_last, last))
    })format!("{quote}{second_to_last}{quote} or {quote}{last}{quote}"));
567
568                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("this {0} is only valid with one of the following arguments: {1}",
                description, res))
    })format!("this {description} is only valid with one of the following arguments: {res}"));
569            }
570        }
571    }
572
573    fn render_suggestions<G>(&self, diag: &mut Diag<'_, G>)
574    where
575        G: EmissionGuarantee,
576    {
577        let description = self.description();
578
579        match &self.suggestions {
580            AttributeParseErrorSuggestions::CreatedByTemplate(suggestions) => {
581                diag.span_suggestions(
582                        self.attr_span,
583                        if suggestions.len() == 1 {
584                            "must be of the form".to_string()
585                        } else {
586                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("try changing it to one of the following valid forms of the {0}",
                description))
    })format!(
587                                "try changing it to one of the following valid forms of the {description}"
588                            )
589                        },
590                        suggestions.iter().cloned(),
591                        Applicability::HasPlaceholders,
592                    );
593            }
594
595            AttributeParseErrorSuggestions::CreatedByParser(suggestions) => {
596                for Suggestion { msg, sp, code } in suggestions {
597                    diag.span_suggestion_verbose(
598                        *sp,
599                        msg.to_string(),
600                        code.to_string(),
601                        Applicability::MaybeIncorrect,
602                    );
603                }
604            }
605        }
606    }
607
608    fn description(&self) -> &'static str {
609        match self.description {
610            ParsedDescription::Attribute => "attribute",
611            ParsedDescription::Macro => "macro",
612        }
613    }
614}
615
616impl AttributeParseErrorSuggestions {
617    fn len(&self) -> usize {
618        match self {
619            AttributeParseErrorSuggestions::CreatedByTemplate(items) => items.len(),
620            AttributeParseErrorSuggestions::CreatedByParser(items) => items.len(),
621        }
622    }
623}
624
625impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
626    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
627        let name = self.path.to_string();
628
629        let description = self.description();
630
631        let mut diag = Diag::new(dcx, level, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("malformed `{0}` {1} input", name,
                description))
    })format!("malformed `{name}` {description} input"));
632        diag.span(self.attr_span);
633        diag.code(E0539);
634        match &self.reason {
635            AttributeParseErrorReason::ExpectedStringLiteral { byte_string } => {
636                if let Some(start_point_span) = byte_string {
637                    diag.span_suggestion(
638                        *start_point_span,
639                        "consider removing the prefix",
640                        "",
641                        Applicability::MaybeIncorrect,
642                    );
643                    diag.note("expected a normal string literal, not a byte string literal");
644
645                    // Avoid emitting an "attribute must be of the form" suggestion, as the
646                    // attribute is likely to be well-formed already.
647                    return diag;
648                } else {
649                    diag.span_label(self.span, "expected a string literal here");
650                }
651            }
652            AttributeParseErrorReason::ExpectedFilenameLiteral => {
653                diag.span_label(self.span, "expected a filename string literal here");
654            }
655            AttributeParseErrorReason::ExpectedIntegerLiteral => {
656                diag.span_label(self.span, "expected an integer literal here");
657            }
658            AttributeParseErrorReason::ExpectedIntegerLiteralInRange {
659                lower_bound,
660                upper_bound,
661            } => {
662                diag.span_label(
663                    self.span,
664                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected an integer literal in the range of {0}..={1}",
                lower_bound, upper_bound))
    })format!(
665                        "expected an integer literal in the range of {lower_bound}..={upper_bound}"
666                    ),
667                );
668            }
669            AttributeParseErrorReason::ExpectedSingleArgument => {
670                diag.span_label(self.span, "expected a single argument here");
671                diag.code(E0805);
672            }
673            AttributeParseErrorReason::ExpectedArgument => {
674                diag.span_label(self.span, "expected an argument here");
675                diag.code(E0805);
676            }
677            AttributeParseErrorReason::ExpectedAtLeastOneArgument => {
678                diag.span_label(self.span, "expected at least 1 argument here");
679            }
680            AttributeParseErrorReason::ExpectedList => {
681                diag.span_label(self.span, "expected this to be a list");
682            }
683            AttributeParseErrorReason::ExpectedListOrNoArgs => {
684                diag.span_label(self.span, "expected a list or no arguments here");
685            }
686            AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args } => {
687                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected {0} or more items", args))
    })format!("expected {args} or more items"));
688            }
689            AttributeParseErrorReason::ExpectedNameValueOrNoArgs => {
690                diag.span_label(self.span, "didn't expect a list here");
691            }
692            AttributeParseErrorReason::ExpectedNonEmptyStringLiteral => {
693                diag.span_label(self.span, "string is not allowed to be empty");
694            }
695            AttributeParseErrorReason::DuplicateKey(key) => {
696                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("found `{0}` used as a key more than once",
                key))
    })format!("found `{key}` used as a key more than once"));
697                diag.code(E0538);
698            }
699            AttributeParseErrorReason::ExpectedNotLiteral => {
700                diag.span_label(self.span, "didn't expect a literal here");
701                diag.code(E0565);
702            }
703            AttributeParseErrorReason::ExpectedNoArgs => {
704                diag.span_label(self.span, "didn't expect any arguments here");
705                diag.code(E0565);
706            }
707            AttributeParseErrorReason::ExpectedNameValue(None) => {
708                // If the span is the entire attribute, the suggestion we add below this match already contains enough information
709                if self.span != self.attr_span {
710                    diag.span_label(
711                        self.span,
712                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected this to be of the form `... = \"...\"`"))
    })format!("expected this to be of the form `... = \"...\"`"),
713                    );
714                }
715            }
716            AttributeParseErrorReason::ExpectedNameValue(Some(name)) => {
717                diag.span_label(
718                    self.span,
719                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected this to be of the form `{0} = \"...\"`",
                name))
    })format!("expected this to be of the form `{name} = \"...\"`"),
720                );
721            }
722            AttributeParseErrorReason::MissingNameValue(name) => {
723                diag.span_label(self.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("missing argument `{0} = \"...\"`",
                name))
    })format!("missing argument `{name} = \"...\"`"));
724            }
725            AttributeParseErrorReason::ExpectedSpecificArgument {
726                possibilities,
727                strings,
728                list: false,
729            } => {
730                self.render_expected_specific_argument(&mut diag, *possibilities, *strings);
731            }
732            AttributeParseErrorReason::ExpectedSpecificArgument {
733                possibilities,
734                strings,
735                list: true,
736            } => {
737                self.render_expected_specific_argument_list(&mut diag, *possibilities, *strings);
738            }
739            AttributeParseErrorReason::ExpectedIdentifier => {
740                diag.span_label(self.span, "expected a valid identifier here");
741                diag.code(E0565);
742            }
743        }
744
745        if let Some(link) = self.template.docs {
746            diag.note(::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("for more information, visit <{0}>",
                link))
    })format!("for more information, visit <{link}>"));
747        }
748
749        if self.suggestions.len() < 4 {
750            self.render_suggestions(&mut diag);
751        }
752
753        diag
754    }
755}
756
757#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidAttrUnsafe where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidAttrUnsafe { span: __binding_0, name: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` is not an unsafe attribute")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extraneous unsafe is not allowed in attributes")));
                        ;
                        diag.arg("name", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is not an unsafe attribute")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
758#[diag("`{$name}` is not an unsafe attribute")]
759#[note("extraneous unsafe is not allowed in attributes")]
760pub(crate) struct InvalidAttrUnsafe {
761    #[primary_span]
762    #[label("this is not an unsafe attribute")]
763    pub span: Span,
764    pub name: AttrPath,
765}
766
767#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsafeAttrOutsideUnsafe where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsafeAttrOutsideUnsafe {
                        span: __binding_0, suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe attribute used without unsafe")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of unsafe attribute")));
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
768#[diag("unsafe attribute used without unsafe")]
769pub(crate) struct UnsafeAttrOutsideUnsafe {
770    #[primary_span]
771    #[label("usage of unsafe attribute")]
772    pub span: Span,
773    #[subdiagnostic]
774    pub suggestion: Option<UnsafeAttrOutsideUnsafeSuggestion>,
775}
776
777#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnsafeAttrOutsideUnsafeSuggestion
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnsafeAttrOutsideUnsafeSuggestion {
                        left: __binding_0, right: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_20 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("unsafe("))
                                });
                        let __code_21 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_20));
                        suggestions.push((__binding_1, __code_21));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the attribute in `unsafe(...)`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
778#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
779pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
780    #[suggestion_part(code = "unsafe(")]
781    pub left: Span,
782    #[suggestion_part(code = ")")]
783    pub right: Span,
784}
785
786#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MetaBadDelim
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MetaBadDelim { span: __binding_0, sugg: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrong meta list delimiters")));
                        ;
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
787#[diag("wrong meta list delimiters")]
788pub(crate) struct MetaBadDelim {
789    #[primary_span]
790    pub span: Span,
791    #[subdiagnostic]
792    pub sugg: MetaBadDelimSugg,
793}
794
795#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for MetaBadDelimSugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    MetaBadDelimSugg { open: __binding_0, close: __binding_1 }
                        => {
                        let mut suggestions = Vec::new();
                        let __code_22 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_23 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_22));
                        suggestions.push((__binding_1, __code_23));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the delimiters should be `(` and `)`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
796#[multipart_suggestion(
797    "the delimiters should be `(` and `)`",
798    applicability = "machine-applicable"
799)]
800pub(crate) struct MetaBadDelimSugg {
801    #[suggestion_part(code = "(")]
802    pub open: Span,
803    #[suggestion_part(code = ")")]
804    pub close: Span,
805}
806
807#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidMetaItem where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidMetaItem {
                        span: __binding_0,
                        descr: __binding_1,
                        quote_ident_sugg: __binding_2,
                        remove_neg_sugg: __binding_3,
                        label: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a literal (`1u8`, `1.0f32`, `\"string\"`, etc.) here, found {$descr}")));
                        ;
                        diag.arg("descr", __binding_1);
                        diag.span(__binding_0);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.span_label(__binding_4,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr}s are not allowed here")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
808#[diag("expected a literal (`1u8`, `1.0f32`, `\"string\"`, etc.) here, found {$descr}")]
809pub(crate) struct InvalidMetaItem {
810    #[primary_span]
811    pub span: Span,
812    pub descr: String,
813    #[subdiagnostic]
814    pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
815    #[subdiagnostic]
816    pub remove_neg_sugg: Option<InvalidMetaItemRemoveNegSugg>,
817    #[label("{$descr}s are not allowed here")]
818    pub label: Option<Span>,
819}
820
821#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidMetaItemQuoteIdentSugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidMetaItemQuoteIdentSugg {
                        before: __binding_0, after: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_24 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("\""))
                                });
                        let __code_25 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("\""))
                                });
                        suggestions.push((__binding_0, __code_24));
                        suggestions.push((__binding_1, __code_25));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the identifier with quotation marks to make it into a string literal")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
822#[multipart_suggestion(
823    "surround the identifier with quotation marks to make it into a string literal",
824    applicability = "machine-applicable"
825)]
826pub(crate) struct InvalidMetaItemQuoteIdentSugg {
827    #[suggestion_part(code = "\"")]
828    pub before: Span,
829    #[suggestion_part(code = "\"")]
830    pub after: Span,
831}
832
833#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidMetaItemRemoveNegSugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidMetaItemRemoveNegSugg { negative_sign: __binding_0 }
                        => {
                        let mut suggestions = Vec::new();
                        let __code_26 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_26));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative numbers are not literals, try removing the `-` sign")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
834#[multipart_suggestion(
835    "negative numbers are not literals, try removing the `-` sign",
836    applicability = "machine-applicable"
837)]
838pub(crate) struct InvalidMetaItemRemoveNegSugg {
839    #[suggestion_part(code = "")]
840    pub negative_sign: Span,
841}
842
843#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SuffixedLiteralInAttribute where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SuffixedLiteralInAttribute { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixed literals are not allowed in attributes")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
844#[diag("suffixed literals are not allowed in attributes")]
845#[help(
846    "instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)"
847)]
848pub(crate) struct SuffixedLiteralInAttribute {
849    #[primary_span]
850    pub span: Span,
851}
852
853#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for EmptyLinkName
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    EmptyLinkName { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link name must not be empty")));
                        diag.code(E0454);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("empty link name")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
854#[diag("link name must not be empty", code = E0454)]
855pub(crate) struct EmptyLinkName {
856    #[primary_span]
857    #[label("empty link name")]
858    pub span: Span,
859}
860
861#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            LinkFrameworkApple where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LinkFrameworkApple { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link kind `framework` is only supported on Apple targets")));
                        diag.code(E0455);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
862#[diag("link kind `framework` is only supported on Apple targets", code = E0455)]
863pub(crate) struct LinkFrameworkApple {
864    #[primary_span]
865    pub span: Span,
866}
867
868#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IncompatibleWasmLink where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    IncompatibleWasmLink { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`wasm_import_module` is incompatible with other arguments in `#[link]` attributes")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
869#[diag("`wasm_import_module` is incompatible with other arguments in `#[link]` attributes")]
870pub(crate) struct IncompatibleWasmLink {
871    #[primary_span]
872    pub span: Span,
873}
874
875#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            LinkRequiresName where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LinkRequiresName { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[link]` attribute requires a `name = \"string\"` argument")));
                        diag.code(E0459);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `name` argument")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
876#[diag("`#[link]` attribute requires a `name = \"string\"` argument", code = E0459)]
877pub(crate) struct LinkRequiresName {
878    #[primary_span]
879    #[label("missing `name` argument")]
880    pub span: Span,
881}
882
883#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RawDylibOnlyWindows where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RawDylibOnlyWindows { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link kind `raw-dylib` is only supported on Windows targets")));
                        diag.code(E0455);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
884#[diag("link kind `raw-dylib` is only supported on Windows targets", code = E0455)]
885pub(crate) struct RawDylibOnlyWindows {
886    #[primary_span]
887    pub span: Span,
888}
889
890#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidLinkModifier where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidLinkModifier { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
891#[diag(
892    "invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols"
893)]
894pub(crate) struct InvalidLinkModifier {
895    #[primary_span]
896    pub span: Span,
897}
898
899#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MultipleModifiers where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MultipleModifiers { span: __binding_0, modifier: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `{$modifier}` modifiers in a single `modifiers` argument")));
                        ;
                        diag.arg("modifier", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
900#[diag("multiple `{$modifier}` modifiers in a single `modifiers` argument")]
901pub(crate) struct MultipleModifiers {
902    #[primary_span]
903    pub span: Span,
904    pub modifier: Symbol,
905}
906
907#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ImportNameTypeX86 where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ImportNameTypeX86 { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import name type is only supported on x86")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
908#[diag("import name type is only supported on x86")]
909pub(crate) struct ImportNameTypeX86 {
910    #[primary_span]
911    pub span: Span,
912}
913
914#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BundleNeedsStatic where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BundleNeedsStatic { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linking modifier `bundle` is only compatible with `static` linking kind")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
915#[diag("linking modifier `bundle` is only compatible with `static` linking kind")]
916pub(crate) struct BundleNeedsStatic {
917    #[primary_span]
918    pub span: Span,
919}
920
921#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExportSymbolsNeedsStatic where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExportSymbolsNeedsStatic { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linking modifier `export-symbols` is only compatible with `static` linking kind")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
922#[diag("linking modifier `export-symbols` is only compatible with `static` linking kind")]
923pub(crate) struct ExportSymbolsNeedsStatic {
924    #[primary_span]
925    pub span: Span,
926}
927
928#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            WholeArchiveNeedsStatic where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    WholeArchiveNeedsStatic { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linking modifier `whole-archive` is only compatible with `static` linking kind")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
929#[diag("linking modifier `whole-archive` is only compatible with `static` linking kind")]
930pub(crate) struct WholeArchiveNeedsStatic {
931    #[primary_span]
932    pub span: Span,
933}
934
935#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AsNeededCompatibility where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AsNeededCompatibility { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linking modifier `as-needed` is only compatible with `dylib`, `framework` and `raw-dylib` linking kinds")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
936#[diag(
937    "linking modifier `as-needed` is only compatible with `dylib`, `framework` and `raw-dylib` linking kinds"
938)]
939pub(crate) struct AsNeededCompatibility {
940    #[primary_span]
941    pub span: Span,
942}
943
944#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ImportNameTypeRaw where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ImportNameTypeRaw { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import name type can only be used with link kind `raw-dylib`")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
945#[diag("import name type can only be used with link kind `raw-dylib`")]
946pub(crate) struct ImportNameTypeRaw {
947    #[primary_span]
948    pub span: Span,
949}
950
951#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            LimitInvalid<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LimitInvalid {
                        span: __binding_0,
                        value_span: __binding_1,
                        error_str: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`limit` must be a non-negative integer")));
                        ;
                        diag.arg("error_str", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$error_str}")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
952#[diag("`limit` must be a non-negative integer")]
953pub(crate) struct LimitInvalid<'a> {
954    #[primary_span]
955    pub span: Span,
956    #[label("{$error_str}")]
957    pub value_span: Span,
958    pub error_str: &'a str,
959}
960
961#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CfgAttrBadDelim where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CfgAttrBadDelim { span: __binding_0, sugg: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrong `cfg_attr` delimiters")));
                        ;
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
962#[diag("wrong `cfg_attr` delimiters")]
963pub(crate) struct CfgAttrBadDelim {
964    #[primary_span]
965    pub span: Span,
966    #[subdiagnostic]
967    pub sugg: MetaBadDelimSugg,
968}
969
970#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DocAliasMalformed where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DocAliasMalformed { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doc alias attribute expects a string `#[doc(alias = \"a\")]` or a list of strings `#[doc(alias(\"a\", \"b\"))]`")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
971#[diag(
972    "doc alias attribute expects a string `#[doc(alias = \"a\")]` or a list of strings `#[doc(alias(\"a\", \"b\"))]`"
973)]
974pub(crate) struct DocAliasMalformed {
975    #[primary_span]
976    pub span: Span,
977}
978
979#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownLangItem where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnknownLangItem { span: __binding_0, name: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("definition of an unknown lang item: `{$name}`")));
                        diag.code(E0522);
                        ;
                        diag.arg("name", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("definition of unknown lang item `{$name}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
980#[diag("definition of an unknown lang item: `{$name}`", code = E0522)]
981pub(crate) struct UnknownLangItem {
982    #[primary_span]
983    #[label("definition of unknown lang item `{$name}`")]
984    pub span: Span,
985    pub name: Symbol,
986}
987
988#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedInstructionSet<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedInstructionSet {
                        span: __binding_0,
                        instruction_set: __binding_1,
                        current_target: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target `{$current_target}` does not support `#[instruction_set({$instruction_set}::*)]`")));
                        ;
                        diag.arg("instruction_set", __binding_1);
                        diag.arg("current_target", __binding_2);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
989#[diag("target `{$current_target}` does not support `#[instruction_set({$instruction_set}::*)]`")]
990pub(crate) struct UnsupportedInstructionSet<'a> {
991    #[primary_span]
992    pub span: Span,
993    pub instruction_set: Symbol,
994    pub current_target: &'a TargetTuple,
995}
996
997#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CustomMirPhaseRequiresDialect where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CustomMirPhaseRequiresDialect {
                        attr_span: __binding_0, phase_span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`dialect` key required")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`phase` argument requires a `dialect` argument")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
998#[diag("`dialect` key required")]
999pub(crate) struct CustomMirPhaseRequiresDialect {
1000    #[primary_span]
1001    pub attr_span: Span,
1002    #[label("`phase` argument requires a `dialect` argument")]
1003    pub phase_span: Span,
1004}
1005
1006#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CustomMirIncompatibleDialectAndPhase where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CustomMirIncompatibleDialectAndPhase {
                        dialect: __binding_0,
                        phase: __binding_1,
                        attr_span: __binding_2,
                        dialect_span: __binding_3,
                        phase_span: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$dialect} dialect is not compatible with the {$phase} phase")));
                        ;
                        diag.arg("dialect", __binding_0);
                        diag.arg("phase", __binding_1);
                        diag.span(__binding_2);
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this dialect...")));
                        diag.span_label(__binding_4,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... is not compatible with this phase")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1007#[diag("the {$dialect} dialect is not compatible with the {$phase} phase")]
1008pub(crate) struct CustomMirIncompatibleDialectAndPhase {
1009    pub dialect: MirDialect,
1010    pub phase: MirPhase,
1011    #[primary_span]
1012    pub attr_span: Span,
1013    #[label("this dialect...")]
1014    pub dialect_span: Span,
1015    #[label("... is not compatible with this phase")]
1016    pub phase_span: Span,
1017}
1018
1019#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnstableAttrForAlreadyStableFeature where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnstableAttrForAlreadyStableFeature {
                        attr_span: __binding_0, item_span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't mark as unstable using an already stable feature")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this feature is already stable")));
                        diag.span_help(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the attribute")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the stability attribute annotates this item")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1020#[diag("can't mark as unstable using an already stable feature")]
1021pub(crate) struct UnstableAttrForAlreadyStableFeature {
1022    #[primary_span]
1023    #[label("this feature is already stable")]
1024    #[help("consider removing the attribute")]
1025    pub attr_span: Span,
1026    #[label("the stability attribute annotates this item")]
1027    pub item_span: Span,
1028}
1029
1030#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidMachoSection where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidMachoSection {
                        name_span: __binding_0, reason: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid Mach-O section specifier")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a valid Mach-O section specifier")));
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1031#[diag("invalid Mach-O section specifier")]
1032pub(crate) struct InvalidMachoSection {
1033    #[primary_span]
1034    #[label("not a valid Mach-O section specifier")]
1035    pub name_span: Span,
1036    #[subdiagnostic]
1037    pub reason: InvalidMachoSectionReason,
1038}
1039
1040#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidMachoSectionReason {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidMachoSectionReason::MissingSection => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a Mach-O section specifier requires a segment and a section, separated by a comma")),
                                &sub_args);
                        diag.note(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an example of a valid Mach-O section specifier is `__TEXT,__cstring`")),
                                &sub_args);
                        diag.help(__message);
                    }
                    InvalidMachoSectionReason::SectionTooLong {
                        section: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("section".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("section name `{$section}` is longer than 16 bytes")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1041pub(crate) enum InvalidMachoSectionReason {
1042    #[note("a Mach-O section specifier requires a segment and a section, separated by a comma")]
1043    #[help("an example of a valid Mach-O section specifier is `__TEXT,__cstring`")]
1044    MissingSection,
1045    #[note("section name `{$section}` is longer than 16 bytes")]
1046    SectionTooLong { section: String },
1047}
1048
1049#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizeInvalidStatic where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizeInvalidStatic {
                        span: __binding_0, field: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[sanitize({$field} = ...)]` attribute cannot be used on statics")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[sanitize]` can be used on statics if only the address is sanitized")));
                        ;
                        diag.arg("field", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1050#[diag("`#[sanitize({$field} = ...)]` attribute cannot be used on statics")]
1051#[help("`#[sanitize]` can be used on statics if only the address is sanitized")]
1052pub(crate) struct SanitizeInvalidStatic {
1053    #[primary_span]
1054    pub span: Span,
1055    pub field: &'static str,
1056}
1057
1058#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ExpectedComma
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectedComma { span: __binding_0, additional: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute items not separated with `,`")));
                        let __code_27 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(","))
                                            })].into_iter();
                        ;
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding `,` here")),
                            __code_27, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1059#[diag("attribute items not separated with `,`")]
1060pub(crate) struct ExpectedComma {
1061    #[primary_span]
1062    #[suggestion(
1063        "try adding `,` here",
1064        code = ",",
1065        applicability = "maybe-incorrect",
1066        style = "short"
1067    )]
1068    pub span: Span,
1069    #[subdiagnostic]
1070    pub additional: Vec<AdditionalCommaSuggestion>,
1071}
1072
1073#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for AdditionalCommaSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AdditionalCommaSuggestion { span: __binding_0 } => {
                        let __code_28 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(","))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding `,` here")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_28, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                    }
                }
            }
        }
    };Subdiagnostic)]
1074#[suggestion("try adding `,` here", code = ",", applicability = "maybe-incorrect", style = "short")]
1075pub(crate) struct AdditionalCommaSuggestion {
1076    #[primary_span]
1077    pub span: Span,
1078}
1079
1080#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedDuplicate where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnusedDuplicate {
                        this: __binding_0, other: __binding_1, warning: __binding_2
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
                        let __code_29 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
                            __code_29, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute also specified here")));
                        if __binding_2 {
                            diag.warn(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1081#[diag("unused attribute")]
1082pub(crate) struct UnusedDuplicate {
1083    #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
1084    pub this: Span,
1085    #[note("attribute also specified here")]
1086    pub other: Span,
1087    #[warning(
1088        "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
1089    )]
1090    pub warning: bool,
1091}