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