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