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