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#[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#[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 EmptySection
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 {
EmptySection { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`section` may not be empty")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
296#[diag("`section` may not be empty")]
297pub(crate) struct EmptySection {
298 #[primary_span]
299 pub span: Span,
300}
301
302#[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)]
303#[diag("`export_name` may not contain null characters", code = E0648)]
304pub(crate) struct NullOnExport {
305 #[primary_span]
306 pub span: Span,
307}
308
309#[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)]
310#[diag("`link_section` may not contain null characters", code = E0648)]
311pub(crate) struct NullOnLinkSection {
312 #[primary_span]
313 pub span: Span,
314}
315
316#[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)]
317#[diag("link name may not contain null characters", code = E0648)]
318pub(crate) struct NullOnLinkName {
319 #[primary_span]
320 pub span: Span,
321}
322
323#[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)]
324#[diag("`objc::class!` may not contain null characters")]
325pub(crate) struct NullOnObjcClass {
326 #[primary_span]
327 pub span: Span,
328}
329
330#[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)]
331#[diag("`objc::selector!` may not contain null characters")]
332pub(crate) struct NullOnObjcSelector {
333 #[primary_span]
334 pub span: Span,
335}
336
337#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NullOnSection
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 {
NullOnSection { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`section` may not contain null characters")));
diag.code(E0648);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
338#[diag("`section` may not contain null characters", code = E0648)]
339pub(crate) struct NullOnSection {
340 #[primary_span]
341 pub span: Span,
342}
343
344#[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)]
345#[diag("`objc::class!` expected a string literal")]
346pub(crate) struct ObjcClassExpectedStringLiteral {
347 #[primary_span]
348 pub span: Span,
349}
350
351#[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)]
352#[diag("`objc::selector!` expected a string literal")]
353pub(crate) struct ObjcSelectorExpectedStringLiteral {
354 #[primary_span]
355 pub span: Span,
356}
357
358#[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)]
359#[diag("expected at least one confusable name")]
360pub(crate) struct EmptyConfusables {
361 #[primary_span]
362 pub span: Span,
363}
364
365#[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)]
366#[help("`#[{$name}{$attribute_args}]` can {$only}be applied to {$applied}")]
367#[diag("`#[{$name}{$attribute_args}]` attribute cannot be used on {$target}")]
368pub(crate) struct InvalidTarget {
369 #[primary_span]
370 #[suggestion(
371 "remove the attribute",
372 code = "",
373 applicability = "machine-applicable",
374 style = "tool-only"
375 )]
376 pub span: Span,
377 pub name: AttrPath,
378 pub target: &'static str,
379 pub applied: DiagArgValue,
380 pub only: &'static str,
381 pub attribute_args: String,
382 #[subdiagnostic]
383 pub help: Option<InvalidTargetHelp>,
384 #[warning(
385 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
386 )]
387 pub previously_accepted: bool,
388 #[note(
389 "placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute"
390 )]
391 pub on_macro_call: bool,
392}
393
394#[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)]
395pub(crate) enum InvalidTargetHelp {
396 #[help("use `#[rustc_align(...)]` instead")]
397 UseRustcAlign,
398 #[help("use `#[rustc_align_static(...)]` instead")]
399 UseRustcAlignStatic,
400}
401
402#[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)]
403#[diag("invalid alignment value: {$error_part}", code = E0589)]
404pub(crate) struct InvalidAlignmentValue {
405 #[primary_span]
406 pub span: Span,
407 pub error_part: String,
408}
409
410#[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)]
411#[diag("item annotated with `#[unstable_feature_bound]` should not be stable")]
412#[help(
413 "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]`"
414)]
415pub(crate) struct UnstableFeatureBoundIncompatibleStability {
416 #[primary_span]
417 pub span: Span,
418}
419
420#[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)]
421#[diag("attribute incompatible with `#[unsafe(naked)]`", code = E0736)]
422pub(crate) struct NakedFunctionIncompatibleAttribute {
423 #[primary_span]
424 #[label("the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`")]
425 pub span: Span,
426 #[label("function marked with `#[unsafe(naked)]` here")]
427 pub naked_span: Span,
428 pub attr: String,
429}
430
431#[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)]
432#[diag("ordinal value in `link_ordinal` is too large: `{$ordinal}`")]
433#[note("the value may not exceed `u16::MAX`")]
434pub(crate) struct LinkOrdinalOutOfRange {
435 #[primary_span]
436 pub span: Span,
437 pub ordinal: u128,
438}
439
440#[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)]
441#[diag("element count in `rustc_scalable_vector` is too large: `{$n}`")]
442#[note("the value may not exceed `u16::MAX`")]
443pub(crate) struct RustcScalableVectorCountOutOfRange {
444 #[primary_span]
445 pub span: Span,
446 pub n: u128,
447}
448
449#[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)]
450#[diag("attribute requires {$opt} to be enabled")]
451pub(crate) struct AttributeRequiresOpt {
452 #[primary_span]
453 pub span: Span,
454 pub opt: &'static str,
455}
456
457pub(crate) enum AttributeParseErrorReason<'a> {
458 ExpectedNoArgs,
459 ExpectedStringLiteral {
460 byte_string: Option<Span>,
461 },
462 ExpectedFilenameLiteral,
463 ExpectedIntegerLiteral,
464 ExpectedIntegerLiteralInRange {
465 lower_bound: isize,
466 upper_bound: isize,
467 },
468 ExpectedAtLeastOneArgument,
469 ExpectedArgument,
470 ExpectedSingleArgument,
471 ExpectedList,
472 ExpectedListOrNoArgs,
473 ExpectedListWithNumArgsOrMore {
474 args: usize,
475 },
476 ExpectedNameValueOrNoArgs,
477 ExpectedNonEmptyStringLiteral,
478 ExpectedNotLiteral,
479 ExpectedNameValue(Option<Symbol>),
480 MissingNameValue(Symbol),
481 DuplicateKey(Symbol),
482 ExpectedSpecificArgument {
483 possibilities: &'a [Symbol],
484 strings: bool,
485 list: bool,
487 },
488 ExpectedIdentifier,
489}
490
491#[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)]
493pub enum ParsedDescription {
494 Attribute,
496 Macro,
498}
499
500pub(crate) struct AttributeParseError<'a> {
501 pub(crate) span: Span,
502 pub(crate) attr_span: Span,
503 pub(crate) template: AttributeTemplate,
504 pub(crate) path: AttrPath,
505 pub(crate) description: ParsedDescription,
506 pub(crate) reason: AttributeParseErrorReason<'a>,
507 pub(crate) suggestions: AttributeParseErrorSuggestions,
508}
509
510pub(crate) enum AttributeParseErrorSuggestions {
511 CreatedByTemplate(Vec<String>),
512 CreatedByParser(Vec<Suggestion>),
513}
514
515impl<'a> AttributeParseError<'a> {
516 fn render_expected_specific_argument<G>(
517 &self,
518 diag: &mut Diag<'_, G>,
519 possibilities: &[Symbol],
520 strings: bool,
521 ) where
522 G: EmissionGuarantee,
523 {
524 let quote = if strings { '"' } else { '`' };
525 match possibilities {
526 &[] => {}
527 &[x] => {
528 diag.span_label(
529 self.span,
530 ::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}"),
531 );
532 }
533 [first, second] => {
534 diag.span_label(
535 self.span,
536 ::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}"),
537 );
538 }
539 [first @ .., second_to_last, last] => {
540 let mut res = String::new();
541 for i in first {
542 res.push_str(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{0}, ", quote, i))
})format!("{quote}{i}{quote}, "));
543 }
544 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}"));
545
546 diag.span_label(self.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("valid arguments are {0}", res))
})format!("valid arguments are {res}"));
547 }
548 }
549 }
550
551 fn render_expected_specific_argument_list<G>(
552 &self,
553 diag: &mut Diag<'_, G>,
554 possibilities: &[Symbol],
555 strings: bool,
556 ) where
557 G: EmissionGuarantee,
558 {
559 let description = self.description();
560
561 let quote = if strings { '"' } else { '`' };
562 match possibilities {
563 &[] => {}
564 &[x] => {
565 diag.span_label(
566 self.span,
567 ::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!(
568 "this {description} is only valid with {quote}{x}{quote} as an argument"
569 ),
570 );
571 }
572 [first, second] => {
573 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"));
574 }
575 [first @ .., second_to_last, last] => {
576 let mut res = String::new();
577 for i in first {
578 res.push_str(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{0}, ", quote, i))
})format!("{quote}{i}{quote}, "));
579 }
580 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}"));
581
582 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}"));
583 }
584 }
585 }
586
587 fn render_suggestions<G>(&self, diag: &mut Diag<'_, G>)
588 where
589 G: EmissionGuarantee,
590 {
591 let description = self.description();
592
593 match &self.suggestions {
594 AttributeParseErrorSuggestions::CreatedByTemplate(suggestions) => {
595 diag.span_suggestions(
596 self.attr_span,
597 if suggestions.len() == 1 {
598 "must be of the form".to_string()
599 } else {
600 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("try changing it to one of the following valid forms of the {0}",
description))
})format!(
601 "try changing it to one of the following valid forms of the {description}"
602 )
603 },
604 suggestions.iter().cloned(),
605 Applicability::HasPlaceholders,
606 );
607 }
608
609 AttributeParseErrorSuggestions::CreatedByParser(suggestions) => {
610 for Suggestion { msg, sp, code } in suggestions {
611 diag.span_suggestion_verbose(
612 *sp,
613 msg.to_string(),
614 code.to_string(),
615 Applicability::MaybeIncorrect,
616 );
617 }
618 }
619 }
620 }
621
622 fn description(&self) -> &'static str {
623 match self.description {
624 ParsedDescription::Attribute => "attribute",
625 ParsedDescription::Macro => "macro",
626 }
627 }
628}
629
630impl AttributeParseErrorSuggestions {
631 fn len(&self) -> usize {
632 match self {
633 AttributeParseErrorSuggestions::CreatedByTemplate(items) => items.len(),
634 AttributeParseErrorSuggestions::CreatedByParser(items) => items.len(),
635 }
636 }
637}
638
639impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
640 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
641 let name = self.path.to_string();
642
643 let description = self.description();
644
645 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"));
646 diag.span(self.attr_span);
647 diag.code(E0539);
648 match &self.reason {
649 AttributeParseErrorReason::ExpectedStringLiteral { byte_string } => {
650 if let Some(start_point_span) = byte_string {
651 diag.span_suggestion(
652 *start_point_span,
653 "consider removing the prefix",
654 "",
655 Applicability::MaybeIncorrect,
656 );
657 diag.note("expected a normal string literal, not a byte string literal");
658
659 return diag;
662 } else {
663 diag.span_label(self.span, "expected a string literal here");
664 }
665 }
666 AttributeParseErrorReason::ExpectedFilenameLiteral => {
667 diag.span_label(self.span, "expected a filename string literal here");
668 }
669 AttributeParseErrorReason::ExpectedIntegerLiteral => {
670 diag.span_label(self.span, "expected an integer literal here");
671 }
672 AttributeParseErrorReason::ExpectedIntegerLiteralInRange {
673 lower_bound,
674 upper_bound,
675 } => {
676 diag.span_label(
677 self.span,
678 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("expected an integer literal in the range of {0}..={1}",
lower_bound, upper_bound))
})format!(
679 "expected an integer literal in the range of {lower_bound}..={upper_bound}"
680 ),
681 );
682 }
683 AttributeParseErrorReason::ExpectedSingleArgument => {
684 diag.span_label(self.span, "expected a single argument here");
685 diag.code(E0805);
686 }
687 AttributeParseErrorReason::ExpectedArgument => {
688 diag.span_label(self.span, "expected an argument here");
689 diag.code(E0805);
690 }
691 AttributeParseErrorReason::ExpectedAtLeastOneArgument => {
692 diag.span_label(self.span, "expected at least 1 argument here");
693 }
694 AttributeParseErrorReason::ExpectedList => {
695 diag.span_label(self.span, "expected this to be a list");
696 }
697 AttributeParseErrorReason::ExpectedListOrNoArgs => {
698 diag.span_label(self.span, "expected a list or no arguments here");
699 }
700 AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args } => {
701 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"));
702 }
703 AttributeParseErrorReason::ExpectedNameValueOrNoArgs => {
704 diag.span_label(self.span, "didn't expect a list here");
705 }
706 AttributeParseErrorReason::ExpectedNonEmptyStringLiteral => {
707 diag.span_label(self.span, "string is not allowed to be empty");
708 }
709 AttributeParseErrorReason::DuplicateKey(key) => {
710 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"));
711 diag.code(E0538);
712 }
713 AttributeParseErrorReason::ExpectedNotLiteral => {
714 diag.span_label(self.span, "didn't expect a literal here");
715 diag.code(E0565);
716 }
717 AttributeParseErrorReason::ExpectedNoArgs => {
718 diag.span_label(self.span, "didn't expect any arguments here");
719 diag.code(E0565);
720 }
721 AttributeParseErrorReason::ExpectedNameValue(None) => {
722 if self.span != self.attr_span {
724 diag.span_label(
725 self.span,
726 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("expected this to be of the form `... = \"...\"`"))
})format!("expected this to be of the form `... = \"...\"`"),
727 );
728 }
729 }
730 AttributeParseErrorReason::ExpectedNameValue(Some(name)) => {
731 diag.span_label(
732 self.span,
733 ::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} = \"...\"`"),
734 );
735 }
736 AttributeParseErrorReason::MissingNameValue(name) => {
737 diag.span_label(self.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("missing argument `{0} = \"...\"`",
name))
})format!("missing argument `{name} = \"...\"`"));
738 }
739 AttributeParseErrorReason::ExpectedSpecificArgument {
740 possibilities,
741 strings,
742 list: false,
743 } => {
744 self.render_expected_specific_argument(&mut diag, *possibilities, *strings);
745 }
746 AttributeParseErrorReason::ExpectedSpecificArgument {
747 possibilities,
748 strings,
749 list: true,
750 } => {
751 self.render_expected_specific_argument_list(&mut diag, *possibilities, *strings);
752 }
753 AttributeParseErrorReason::ExpectedIdentifier => {
754 diag.span_label(self.span, "expected a valid identifier here");
755 diag.code(E0565);
756 }
757 }
758
759 if let Some(link) = self.template.docs {
760 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("for more information, visit <{0}>",
link))
})format!("for more information, visit <{link}>"));
761 }
762
763 if self.suggestions.len() < 4 {
764 self.render_suggestions(&mut diag);
765 }
766
767 diag
768 }
769}
770
771#[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)]
772#[diag("`{$name}` is not an unsafe attribute")]
773#[note("extraneous unsafe is not allowed in attributes")]
774pub(crate) struct InvalidAttrUnsafe {
775 #[primary_span]
776 #[label("this is not an unsafe attribute")]
777 pub span: Span,
778 pub name: AttrPath,
779}
780
781#[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)]
782#[diag("unsafe attribute used without unsafe")]
783pub(crate) struct UnsafeAttrOutsideUnsafe {
784 #[primary_span]
785 #[label("usage of unsafe attribute")]
786 pub span: Span,
787 #[subdiagnostic]
788 pub suggestion: Option<UnsafeAttrOutsideUnsafeSuggestion>,
789}
790
791#[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)]
792#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
793pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
794 #[suggestion_part(code = "unsafe(")]
795 pub left: Span,
796 #[suggestion_part(code = ")")]
797 pub right: Span,
798}
799
800#[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)]
801#[diag("wrong meta list delimiters")]
802pub(crate) struct MetaBadDelim {
803 #[primary_span]
804 pub span: Span,
805 #[subdiagnostic]
806 pub sugg: MetaBadDelimSugg,
807}
808
809#[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)]
810#[multipart_suggestion(
811 "the delimiters should be `(` and `)`",
812 applicability = "machine-applicable"
813)]
814pub(crate) struct MetaBadDelimSugg {
815 #[suggestion_part(code = "(")]
816 pub open: Span,
817 #[suggestion_part(code = ")")]
818 pub close: Span,
819}
820
821#[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)]
822#[diag("expected a literal (`1u8`, `1.0f32`, `\"string\"`, etc.) here, found {$descr}")]
823pub(crate) struct InvalidMetaItem {
824 #[primary_span]
825 pub span: Span,
826 pub descr: String,
827 #[subdiagnostic]
828 pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
829 #[subdiagnostic]
830 pub remove_neg_sugg: Option<InvalidMetaItemRemoveNegSugg>,
831 #[label("{$descr}s are not allowed here")]
832 pub label: Option<Span>,
833}
834
835#[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)]
836#[multipart_suggestion(
837 "surround the identifier with quotation marks to make it into a string literal",
838 applicability = "machine-applicable"
839)]
840pub(crate) struct InvalidMetaItemQuoteIdentSugg {
841 #[suggestion_part(code = "\"")]
842 pub before: Span,
843 #[suggestion_part(code = "\"")]
844 pub after: Span,
845}
846
847#[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)]
848#[multipart_suggestion(
849 "negative numbers are not literals, try removing the `-` sign",
850 applicability = "machine-applicable"
851)]
852pub(crate) struct InvalidMetaItemRemoveNegSugg {
853 #[suggestion_part(code = "")]
854 pub negative_sign: Span,
855}
856
857#[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)]
858#[diag("suffixed literals are not allowed in attributes")]
859#[help(
860 "instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)"
861)]
862pub(crate) struct SuffixedLiteralInAttribute {
863 #[primary_span]
864 pub span: Span,
865}
866
867#[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)]
868#[diag("link name must not be empty", code = E0454)]
869pub(crate) struct EmptyLinkName {
870 #[primary_span]
871 #[label("empty link name")]
872 pub span: Span,
873}
874
875#[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)]
876#[diag("link kind `framework` is only supported on Apple targets", code = E0455)]
877pub(crate) struct LinkFrameworkApple {
878 #[primary_span]
879 pub span: Span,
880}
881
882#[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)]
883#[diag("`wasm_import_module` is incompatible with other arguments in `#[link]` attributes")]
884pub(crate) struct IncompatibleWasmLink {
885 #[primary_span]
886 pub span: Span,
887}
888
889#[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)]
890#[diag("`#[link]` attribute requires a `name = \"string\"` argument", code = E0459)]
891pub(crate) struct LinkRequiresName {
892 #[primary_span]
893 #[label("missing `name` argument")]
894 pub span: Span,
895}
896
897#[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)]
898#[diag("link kind `raw-dylib` is only supported on Windows targets", code = E0455)]
899pub(crate) struct RawDylibOnlyWindows {
900 #[primary_span]
901 pub span: Span,
902}
903
904#[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)]
905#[diag(
906 "invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols"
907)]
908pub(crate) struct InvalidLinkModifier {
909 #[primary_span]
910 pub span: Span,
911}
912
913#[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)]
914#[diag("multiple `{$modifier}` modifiers in a single `modifiers` argument")]
915pub(crate) struct MultipleModifiers {
916 #[primary_span]
917 pub span: Span,
918 pub modifier: Symbol,
919}
920
921#[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)]
922#[diag("import name type is only supported on x86")]
923pub(crate) struct ImportNameTypeX86 {
924 #[primary_span]
925 pub span: Span,
926}
927
928#[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)]
929#[diag("linking modifier `bundle` is only compatible with `static` linking kind")]
930pub(crate) struct BundleNeedsStatic {
931 #[primary_span]
932 pub span: Span,
933}
934
935#[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)]
936#[diag("linking modifier `export-symbols` is only compatible with `static` linking kind")]
937pub(crate) struct ExportSymbolsNeedsStatic {
938 #[primary_span]
939 pub span: Span,
940}
941
942#[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)]
943#[diag("linking modifier `whole-archive` is only compatible with `static` linking kind")]
944pub(crate) struct WholeArchiveNeedsStatic {
945 #[primary_span]
946 pub span: Span,
947}
948
949#[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)]
950#[diag(
951 "linking modifier `as-needed` is only compatible with `dylib`, `framework` and `raw-dylib` linking kinds"
952)]
953pub(crate) struct AsNeededCompatibility {
954 #[primary_span]
955 pub span: Span,
956}
957
958#[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)]
959#[diag("import name type can only be used with link kind `raw-dylib`")]
960pub(crate) struct ImportNameTypeRaw {
961 #[primary_span]
962 pub span: Span,
963}
964
965#[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)]
966#[diag("`limit` must be a non-negative integer")]
967pub(crate) struct LimitInvalid<'a> {
968 #[primary_span]
969 pub span: Span,
970 #[label("{$error_str}")]
971 pub value_span: Span,
972 pub error_str: &'a str,
973}
974
975#[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)]
976#[diag("wrong `cfg_attr` delimiters")]
977pub(crate) struct CfgAttrBadDelim {
978 #[primary_span]
979 pub span: Span,
980 #[subdiagnostic]
981 pub sugg: MetaBadDelimSugg,
982}
983
984#[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)]
985#[diag(
986 "doc alias attribute expects a string `#[doc(alias = \"a\")]` or a list of strings `#[doc(alias(\"a\", \"b\"))]`"
987)]
988pub(crate) struct DocAliasMalformed {
989 #[primary_span]
990 pub span: Span,
991}
992
993#[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)]
994#[diag("definition of an unknown lang item: `{$name}`", code = E0522)]
995pub(crate) struct UnknownLangItem {
996 #[primary_span]
997 #[label("definition of unknown lang item `{$name}`")]
998 pub span: Span,
999 pub name: Symbol,
1000}
1001
1002#[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)]
1003#[diag("target `{$current_target}` does not support `#[instruction_set({$instruction_set}::*)]`")]
1004pub(crate) struct UnsupportedInstructionSet<'a> {
1005 #[primary_span]
1006 pub span: Span,
1007 pub instruction_set: Symbol,
1008 pub current_target: &'a TargetTuple,
1009}
1010
1011#[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)]
1012#[diag("`dialect` key required")]
1013pub(crate) struct CustomMirPhaseRequiresDialect {
1014 #[primary_span]
1015 pub attr_span: Span,
1016 #[label("`phase` argument requires a `dialect` argument")]
1017 pub phase_span: Span,
1018}
1019
1020#[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)]
1021#[diag("the {$dialect} dialect is not compatible with the {$phase} phase")]
1022pub(crate) struct CustomMirIncompatibleDialectAndPhase {
1023 pub dialect: MirDialect,
1024 pub phase: MirPhase,
1025 #[primary_span]
1026 pub attr_span: Span,
1027 #[label("this dialect...")]
1028 pub dialect_span: Span,
1029 #[label("... is not compatible with this phase")]
1030 pub phase_span: Span,
1031}
1032
1033#[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)]
1034#[diag("can't mark as unstable using an already stable feature")]
1035pub(crate) struct UnstableAttrForAlreadyStableFeature {
1036 #[primary_span]
1037 #[label("this feature is already stable")]
1038 #[help("consider removing the attribute")]
1039 pub attr_span: Span,
1040 #[label("the stability attribute annotates this item")]
1041 pub item_span: Span,
1042}
1043
1044#[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)]
1045#[diag("invalid Mach-O section specifier")]
1046pub(crate) struct InvalidMachoSection {
1047 #[primary_span]
1048 #[label("not a valid Mach-O section specifier")]
1049 pub name_span: Span,
1050 #[subdiagnostic]
1051 pub reason: InvalidMachoSectionReason,
1052}
1053
1054#[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)]
1055pub(crate) enum InvalidMachoSectionReason {
1056 #[note("a Mach-O section specifier requires a segment and a section, separated by a comma")]
1057 #[help("an example of a valid Mach-O section specifier is `__TEXT,__cstring`")]
1058 MissingSection,
1059 #[note("section name `{$section}` is longer than 16 bytes")]
1060 SectionTooLong { section: String },
1061}
1062
1063#[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)]
1064#[diag("`#[sanitize({$field} = ...)]` attribute cannot be used on statics")]
1065#[help("`#[sanitize]` can be used on statics if only the address is sanitized")]
1066pub(crate) struct SanitizeInvalidStatic {
1067 #[primary_span]
1068 pub span: Span,
1069 pub field: &'static str,
1070}
1071
1072#[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)]
1073#[diag("attribute items not separated with `,`")]
1074pub(crate) struct ExpectedComma {
1075 #[primary_span]
1076 #[suggestion(
1077 "try adding `,` here",
1078 code = ",",
1079 applicability = "maybe-incorrect",
1080 style = "short"
1081 )]
1082 pub span: Span,
1083 #[subdiagnostic]
1084 pub additional: Vec<AdditionalCommaSuggestion>,
1085}
1086
1087#[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)]
1088#[suggestion("try adding `,` here", code = ",", applicability = "maybe-incorrect", style = "short")]
1089pub(crate) struct AdditionalCommaSuggestion {
1090 #[primary_span]
1091 pub span: Span,
1092}
1093
1094#[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)]
1095#[diag("unused attribute")]
1096pub(crate) struct UnusedDuplicate {
1097 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
1098 pub this: Span,
1099 #[note("attribute also specified here")]
1100 pub other: Span,
1101 #[warning(
1102 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
1103 )]
1104 pub warning: bool,
1105}