1use rustc_abi::ExternAbi;
4use rustc_ast::ParamKindOrd;
5use rustc_errors::codes::*;
6use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
7use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
8use rustc_span::{Ident, Span, Symbol};
9
10#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VisibilityNotPermitted where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VisibilityNotPermitted {
span: __binding_0,
note: __binding_1,
remove_qualifier_sugg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("visibility qualifiers are not permitted here")));
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0449);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the qualifier")),
__code_0, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
11#[diag("visibility qualifiers are not permitted here", code = E0449)]
12pub(crate) struct VisibilityNotPermitted {
13 #[primary_span]
14 pub span: Span,
15 #[subdiagnostic]
16 pub note: VisibilityNotPermittedNote,
17 #[suggestion("remove the qualifier", code = "", applicability = "machine-applicable")]
18 pub remove_qualifier_sugg: Span,
19}
20
21#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VisibilityNotPermittedNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VisibilityNotPermittedNote::EnumVariant => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enum variants and their fields always share the visibility of the enum they are in")));
diag.note(__message);
diag.restore_args();
}
VisibilityNotPermittedNote::TraitImpl => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait items always share the visibility of their trait")));
diag.note(__message);
diag.restore_args();
}
VisibilityNotPermittedNote::IndividualImplItems => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place qualifiers on individual impl items instead")));
diag.note(__message);
diag.restore_args();
}
VisibilityNotPermittedNote::IndividualForeignItems => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place qualifiers on individual foreign items instead")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
22pub(crate) enum VisibilityNotPermittedNote {
23 #[note("enum variants and their fields always share the visibility of the enum they are in")]
24 EnumVariant,
25 #[note("trait items always share the visibility of their trait")]
26 TraitImpl,
27 #[note("place qualifiers on individual impl items instead")]
28 IndividualImplItems,
29 #[note("place qualifiers on individual foreign items instead")]
30 IndividualForeignItems,
31}
32#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ImplFnConst
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ImplFnConst {
span: __binding_0, parent_constness: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("redundant `const` fn marker in const impl")));
let __code_1 =
[::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("remove the `const`")),
__code_1, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this declares all associated functions implicitly const")));
diag
}
}
}
}
};Diagnostic)]
33#[diag("redundant `const` fn marker in const impl")]
34pub(crate) struct ImplFnConst {
35 #[primary_span]
36 #[suggestion("remove the `const`", code = "", applicability = "machine-applicable")]
37 pub span: Span,
38 #[label("this declares all associated functions implicitly const")]
39 pub parent_constness: Span,
40}
41
42#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TraitFnConst
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitFnConst {
span: __binding_0,
in_impl: __binding_1,
const_context_label: __binding_2,
remove_const_sugg: __binding_3,
requires_multiple_changes: __binding_4,
make_impl_const_sugg: __binding_5,
make_trait_const_sugg: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions in {$in_impl ->\n [true] trait impls\n *[false] traits\n } cannot be declared const")));
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
diag.code(E0379);
;
diag.arg("in_impl", __binding_1);
diag.arg("requires_multiple_changes", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions in {$in_impl ->\n [true] trait impls\n *[false] traits\n } cannot be const")));
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this declares all associated functions implicitly const")));
}
diag.span_suggestions_with_style(__binding_3.0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `const`{$requires_multiple_changes ->\n [true] {\" ...\"}\n *[false] {\"\"}\n }")),
__code_2, __binding_3.1,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_5) = __binding_5 {
diag.span_suggestions_with_style(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... and declare the impl to be const instead")),
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
if let Some(__binding_6) = __binding_6 {
diag.span_suggestions_with_style(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... and declare the trait to be const instead")),
__code_4, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
43#[diag("functions in {$in_impl ->
44 [true] trait impls
45 *[false] traits
46 } cannot be declared const", code = E0379)]
47pub(crate) struct TraitFnConst {
48 #[primary_span]
49 #[label(
50 "functions in {$in_impl ->
51 [true] trait impls
52 *[false] traits
53 } cannot be const"
54 )]
55 pub span: Span,
56 pub in_impl: bool,
57 #[label("this declares all associated functions implicitly const")]
58 pub const_context_label: Option<Span>,
59 #[suggestion(
60 "remove the `const`{$requires_multiple_changes ->
61 [true] {\" ...\"}
62 *[false] {\"\"}
63 }",
64 code = ""
65 )]
66 pub remove_const_sugg: (Span, Applicability),
67 pub requires_multiple_changes: bool,
68 #[suggestion(
69 "... and declare the impl to be const instead",
70 code = "const ",
71 applicability = "maybe-incorrect"
72 )]
73 pub make_impl_const_sugg: Option<Span>,
74 #[suggestion(
75 "... and declare the trait to be const instead",
76 code = "const ",
77 applicability = "maybe-incorrect"
78 )]
79 pub make_trait_const_sugg: Option<Span>,
80}
81
82#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncFnInConstTraitOrTraitImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncFnInConstTraitOrTraitImpl {
async_keyword: __binding_0,
context: __binding_1,
const_keyword: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("async functions are not allowed in `const` {$context ->\n [trait_impl] trait impls\n [impl] impls\n *[trait] traits\n }")));
;
diag.arg("context", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated functions of `const` cannot be declared `async`")));
diag
}
}
}
}
};Diagnostic)]
83#[diag(
84 "async functions are not allowed in `const` {$context ->
85 [trait_impl] trait impls
86 [impl] impls
87 *[trait] traits
88 }"
89)]
90pub(crate) struct AsyncFnInConstTraitOrTraitImpl {
91 #[primary_span]
92 pub async_keyword: Span,
93 pub context: &'static str,
94 #[label("associated functions of `const` cannot be declared `async`")]
95 pub const_keyword: Span,
96}
97
98#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ForbiddenBound
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ForbiddenBound { spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds cannot be used in this context")));
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
99#[diag("bounds cannot be used in this context")]
100pub(crate) struct ForbiddenBound {
101 #[primary_span]
102 pub spans: Vec<Span>,
103}
104
105#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ForbiddenConstParam where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ForbiddenConstParam { const_param_spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("late-bound const parameters cannot be used currently")));
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
106#[diag("late-bound const parameters cannot be used currently")]
107pub(crate) struct ForbiddenConstParam {
108 #[primary_span]
109 pub const_param_spans: Vec<Span>,
110}
111
112#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnParamTooMany
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnParamTooMany {
span: __binding_0, max_num_args: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function can not have more than {$max_num_args} arguments")));
;
diag.arg("max_num_args", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
113#[diag("function can not have more than {$max_num_args} arguments")]
114pub(crate) struct FnParamTooMany {
115 #[primary_span]
116 pub span: Span,
117 pub max_num_args: usize,
118}
119
120#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnParamCVarArgsNotLast where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnParamCVarArgsNotLast { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` must be the last argument of a C-variadic function")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
121#[diag("`...` must be the last argument of a C-variadic function")]
122pub(crate) struct FnParamCVarArgsNotLast {
123 #[primary_span]
124 pub span: Span,
125}
126
127#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnParamDocComment where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnParamDocComment { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("documentation comments cannot be applied to function parameters")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doc comments are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
128#[diag("documentation comments cannot be applied to function parameters")]
129pub(crate) struct FnParamDocComment {
130 #[primary_span]
131 #[label("doc comments are not allowed here")]
132 pub span: Span,
133}
134
135#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnParamForbiddenAttr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnParamForbiddenAttr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
136#[diag(
137 "allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters"
138)]
139pub(crate) struct FnParamForbiddenAttr {
140 #[primary_span]
141 pub span: Span,
142}
143
144#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnParamForbiddenSelf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnParamForbiddenSelf { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`self` parameter is only allowed in associated functions")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated functions are those in `impl` or `trait` definitions")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not semantically valid as function parameter")));
diag
}
}
}
}
};Diagnostic)]
145#[diag("`self` parameter is only allowed in associated functions")]
146#[note("associated functions are those in `impl` or `trait` definitions")]
147pub(crate) struct FnParamForbiddenSelf {
148 #[primary_span]
149 #[label("not semantically valid as function parameter")]
150 pub span: Span,
151}
152
153#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ForbiddenDefault where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ForbiddenDefault { span: __binding_0, def_span: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` is only allowed on items in trait impls")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` because of this")));
diag
}
}
}
}
};Diagnostic)]
154#[diag("`default` is only allowed on items in trait impls")]
155pub(crate) struct ForbiddenDefault {
156 #[primary_span]
157 pub span: Span,
158 #[label("`default` because of this")]
159 pub def_span: Span,
160}
161
162#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocConstWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssocConstWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated constant in `impl` without body")));
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" = <expr>;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the constant")),
__code_5, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
163#[diag("associated constant in `impl` without body")]
164pub(crate) struct AssocConstWithoutBody {
165 #[primary_span]
166 pub span: Span,
167 #[suggestion(
168 "provide a definition for the constant",
169 code = " = <expr>;",
170 applicability = "has-placeholders"
171 )]
172 pub replace_span: Span,
173}
174
175#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocFnWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssocFnWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated function in `impl` without body")));
let __code_6 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ <body> }}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the function")),
__code_6, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
176#[diag("associated function in `impl` without body")]
177pub(crate) struct AssocFnWithoutBody {
178 #[primary_span]
179 pub span: Span,
180 #[suggestion(
181 "provide a definition for the function",
182 code = " {{ <body> }}",
183 applicability = "has-placeholders"
184 )]
185 pub replace_span: Span,
186}
187
188#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocTypeWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssocTypeWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated type in `impl` without body")));
let __code_7 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" = <type>;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the type")),
__code_7, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
189#[diag("associated type in `impl` without body")]
190pub(crate) struct AssocTypeWithoutBody {
191 #[primary_span]
192 pub span: Span,
193 #[suggestion(
194 "provide a definition for the type",
195 code = " = <type>;",
196 applicability = "has-placeholders"
197 )]
198 pub replace_span: Span,
199}
200
201#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("free constant item without body")));
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" = <expr>;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the constant")),
__code_8, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
202#[diag("free constant item without body")]
203pub(crate) struct ConstWithoutBody {
204 #[primary_span]
205 pub span: Span,
206 #[suggestion(
207 "provide a definition for the constant",
208 code = " = <expr>;",
209 applicability = "has-placeholders"
210 )]
211 pub replace_span: Span,
212}
213
214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StaticWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("free static item without body")));
let __code_9 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" = <expr>;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the static")),
__code_9, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
215#[diag("free static item without body")]
216pub(crate) struct StaticWithoutBody {
217 #[primary_span]
218 pub span: Span,
219 #[suggestion(
220 "provide a definition for the static",
221 code = " = <expr>;",
222 applicability = "has-placeholders"
223 )]
224 pub replace_span: Span,
225}
226
227#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TyAliasWithoutBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TyAliasWithoutBody {
span: __binding_0, replace_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("free type alias without body")));
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" = <type>;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the type")),
__code_10, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
228#[diag("free type alias without body")]
229pub(crate) struct TyAliasWithoutBody {
230 #[primary_span]
231 pub span: Span,
232 #[suggestion(
233 "provide a definition for the type",
234 code = " = <type>;",
235 applicability = "has-placeholders"
236 )]
237 pub replace_span: Span,
238}
239
240#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnWithoutBody
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnWithoutBody {
span: __binding_0,
replace_span: __binding_1,
extern_block_suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("free function without a body")));
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ <body> }}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a definition for the function")),
__code_11, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
241#[diag("free function without a body")]
242pub(crate) struct FnWithoutBody {
243 #[primary_span]
244 pub span: Span,
245 #[suggestion(
246 "provide a definition for the function",
247 code = " {{ <body> }}",
248 applicability = "has-placeholders"
249 )]
250 pub replace_span: Span,
251 #[subdiagnostic]
252 pub extern_block_suggestion: Option<ExternBlockSuggestion>,
253}
254
255#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExternBlockSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExternBlockSuggestion::Implicit {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_12 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("extern {{"))
});
let __code_13 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_12));
suggestions.push((__binding_1, __code_13));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to declare an externally defined function, use an `extern` block")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
ExternBlockSuggestion::Explicit {
start_span: __binding_0,
end_span: __binding_1,
abi: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_14 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("extern \"{0}\" {{",
__binding_2))
});
let __code_15 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_14));
suggestions.push((__binding_1, __code_15));
diag.store_args();
diag.arg("abi", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to declare an externally defined function, use an `extern` block")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
256pub(crate) enum ExternBlockSuggestion {
257 #[multipart_suggestion(
258 "if you meant to declare an externally defined function, use an `extern` block",
259 applicability = "maybe-incorrect"
260 )]
261 Implicit {
262 #[suggestion_part(code = "extern {{")]
263 start_span: Span,
264 #[suggestion_part(code = " }}")]
265 end_span: Span,
266 },
267 #[multipart_suggestion(
268 "if you meant to declare an externally defined function, use an `extern` block",
269 applicability = "maybe-incorrect"
270 )]
271 Explicit {
272 #[suggestion_part(code = "extern \"{abi}\" {{")]
273 start_span: Span,
274 #[suggestion_part(code = " }}")]
275 end_span: Span,
276 abi: Symbol,
277 },
278}
279
280#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidSafetyOnExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidSafetyOnExtern {
item_span: __binding_0, block: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items in `extern` blocks without an `unsafe` qualifier cannot have safety qualifiers")));
let __code_16 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe "))
})].into_iter();
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `unsafe` to this `extern` block")),
__code_16, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
281#[diag("items in `extern` blocks without an `unsafe` qualifier cannot have safety qualifiers")]
282pub(crate) struct InvalidSafetyOnExtern {
283 #[primary_span]
284 pub item_span: Span,
285 #[suggestion(
286 "add `unsafe` to this `extern` block",
287 code = "unsafe ",
288 applicability = "machine-applicable",
289 style = "verbose"
290 )]
291 pub block: Option<Span>,
292}
293
294#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidSafetyOnItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidSafetyOnItem { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items outside of `unsafe extern {\"{ }\"}` cannot be declared with `safe` safety qualifier")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
295#[diag(
296 "items outside of `unsafe extern {\"{ }\"}` cannot be declared with `safe` safety qualifier"
297)]
298pub(crate) struct InvalidSafetyOnItem {
299 #[primary_span]
300 pub span: Span,
301}
302
303#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidSafetyOnFnPtr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidSafetyOnFnPtr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointers cannot be declared with `safe` safety qualifier")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
304#[diag("function pointers cannot be declared with `safe` safety qualifier")]
305pub(crate) struct InvalidSafetyOnFnPtr {
306 #[primary_span]
307 pub span: Span,
308}
309
310#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnsafeStatic
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeStatic { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("static items cannot be declared with `unsafe` safety qualifier outside of `extern` block")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
311#[diag("static items cannot be declared with `unsafe` safety qualifier outside of `extern` block")]
312pub(crate) struct UnsafeStatic {
313 #[primary_span]
314 pub span: Span,
315}
316
317#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BoundInContext<'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 {
BoundInContext { span: __binding_0, ctx: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on `type`s in {$ctx} have no effect")));
;
diag.arg("ctx", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
318#[diag("bounds on `type`s in {$ctx} have no effect")]
319pub(crate) struct BoundInContext<'a> {
320 #[primary_span]
321 pub span: Span,
322 pub ctx: &'a str,
323}
324
325#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ExternTypesCannotHave<'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 {
ExternTypesCannotHave {
span: __binding_0,
descr: __binding_1,
remove_descr: __binding_2,
block_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`type`s inside `extern` blocks cannot have {$descr}")));
let __code_17 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")));
;
diag.arg("descr", __binding_1);
diag.arg("remove_descr", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the {$remove_descr}")),
__code_17, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` block begins here")));
diag
}
}
}
}
};Diagnostic)]
326#[diag("`type`s inside `extern` blocks cannot have {$descr}")]
327#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
328pub(crate) struct ExternTypesCannotHave<'a> {
329 #[primary_span]
330 #[suggestion("remove the {$remove_descr}", code = "", applicability = "maybe-incorrect")]
331 pub span: Span,
332 pub descr: &'a str,
333 pub remove_descr: &'a str,
334 #[label("`extern` block begins here")]
335 pub block_span: Span,
336}
337
338#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BodyInExtern<'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 {
BodyInExtern {
span: __binding_0,
body: __binding_1,
block: __binding_2,
kind: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect `{$kind}` inside `extern` block")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")));
;
diag.arg("kind", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot have a body")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the invalid body")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` blocks define existing foreign {$kind}s and {$kind}s inside of them cannot have a body")));
diag
}
}
}
}
};Diagnostic)]
339#[diag("incorrect `{$kind}` inside `extern` block")]
340#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
341pub(crate) struct BodyInExtern<'a> {
342 #[primary_span]
343 #[label("cannot have a body")]
344 pub span: Span,
345 #[label("the invalid body")]
346 pub body: Span,
347 #[label(
348 "`extern` blocks define existing foreign {$kind}s and {$kind}s inside of them cannot have a body"
349 )]
350 pub block: Span,
351 pub kind: &'a str,
352}
353
354#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnBodyInExtern
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnBodyInExtern {
span: __binding_0, body: __binding_1, block: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect function inside `extern` block")));
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot have a body")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the invalid body")),
__code_18, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` blocks define existing foreign functions and functions inside of them cannot have a body")));
diag
}
}
}
}
};Diagnostic)]
355#[diag("incorrect function inside `extern` block")]
356#[help(
357 "you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block"
358)]
359#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
360pub(crate) struct FnBodyInExtern {
361 #[primary_span]
362 #[label("cannot have a body")]
363 pub span: Span,
364 #[suggestion("remove the invalid body", code = ";", applicability = "maybe-incorrect")]
365 pub body: Span,
366 #[label(
367 "`extern` blocks define existing foreign functions and functions inside of them cannot have a body"
368 )]
369 pub block: Span,
370}
371
372#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnQualifierInExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnQualifierInExtern {
span: __binding_0, block: __binding_1, kw: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions in `extern` blocks cannot have `{$kw}` qualifier")));
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("kw", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `{$kw}` qualifier")),
__code_19, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in this `extern` block")));
diag
}
}
}
}
};Diagnostic)]
373#[diag("functions in `extern` blocks cannot have `{$kw}` qualifier")]
374pub(crate) struct FnQualifierInExtern {
375 #[primary_span]
376 #[suggestion("remove the `{$kw}` qualifier", code = "", applicability = "maybe-incorrect")]
377 pub span: Span,
378 #[label("in this `extern` block")]
379 pub block: Span,
380 pub kw: &'static str,
381}
382
383#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternItemAscii where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExternItemAscii { span: __binding_0, block: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items in `extern` blocks cannot use non-ascii identifiers")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this limitation may be lifted in the future; see issue #83942 <https://github.com/rust-lang/rust/issues/83942> for more information")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in this `extern` block")));
diag
}
}
}
}
};Diagnostic)]
384#[diag("items in `extern` blocks cannot use non-ascii identifiers")]
385#[note(
386 "this limitation may be lifted in the future; see issue #83942 <https://github.com/rust-lang/rust/issues/83942> for more information"
387)]
388pub(crate) struct ExternItemAscii {
389 #[primary_span]
390 pub span: Span,
391 #[label("in this `extern` block")]
392 pub block: Span,
393}
394
395#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CVariadicNoExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CVariadicNoExtern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` is not supported for non-extern functions")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
396#[diag("`...` is not supported for non-extern functions")]
397#[help(
398 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
399)]
400pub(crate) struct CVariadicNoExtern {
401 #[primary_span]
402 pub span: Span,
403}
404
405#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CVariadicMustBeUnsafe where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CVariadicMustBeUnsafe {
span: __binding_0, unsafe_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with a C variable argument list must be unsafe")));
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the `unsafe` keyword to this definition")),
__code_20, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
406#[diag("functions with a C variable argument list must be unsafe")]
407pub(crate) struct CVariadicMustBeUnsafe {
408 #[primary_span]
409 pub span: Span,
410
411 #[suggestion(
412 "add the `unsafe` keyword to this definition",
413 applicability = "maybe-incorrect",
414 code = "unsafe ",
415 style = "verbose"
416 )]
417 pub unsafe_span: Span,
418}
419
420#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CVariadicBadExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CVariadicBadExtern {
span: __binding_0,
abi: __binding_1,
extern_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` is not supported for `extern \"{$abi}\"` functions")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern \"{$abi}\"` because of this")));
diag
}
}
}
}
};Diagnostic)]
421#[diag("`...` is not supported for `extern \"{$abi}\"` functions")]
422#[help(
423 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
424)]
425pub(crate) struct CVariadicBadExtern {
426 #[primary_span]
427 pub span: Span,
428 pub abi: &'static str,
429 #[label("`extern \"{$abi}\"` because of this")]
430 pub extern_span: Span,
431}
432
433#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CVariadicBadNakedExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CVariadicBadNakedExtern {
span: __binding_0,
abi: __binding_1,
extern_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` is not supported for `extern \"{$abi}\"` naked functions")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic function must have a compatible calling convention")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern \"{$abi}\"` because of this")));
diag
}
}
}
}
};Diagnostic)]
434#[diag("`...` is not supported for `extern \"{$abi}\"` naked functions")]
435#[help("C-variadic function must have a compatible calling convention")]
436pub(crate) struct CVariadicBadNakedExtern {
437 #[primary_span]
438 pub span: Span,
439 pub abi: &'static str,
440 #[label("`extern \"{$abi}\"` because of this")]
441 pub extern_span: Span,
442}
443
444#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ItemUnderscore<'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 {
ItemUnderscore { span: __binding_0, kind: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kind}` items in this context need a name")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`_` is not a valid name for this `{$kind}` item")));
diag
}
}
}
}
};Diagnostic)]
445#[diag("`{$kind}` items in this context need a name")]
446pub(crate) struct ItemUnderscore<'a> {
447 #[primary_span]
448 #[label("`_` is not a valid name for this `{$kind}` item")]
449 pub span: Span,
450 pub kind: &'a str,
451}
452
453#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NoMangleAscii
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NoMangleAscii { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[no_mangle]` requires ASCII identifier")));
diag.code(E0754);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
454#[diag("`#[no_mangle]` requires ASCII identifier", code = E0754)]
455pub(crate) struct NoMangleAscii {
456 #[primary_span]
457 pub span: Span,
458}
459
460#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ModuleNonAscii
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModuleNonAscii { span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trying to load file for module `{$name}` with non-ascii identifier name")));
diag.code(E0754);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the `#[path]` attribute to specify filesystem path")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
461#[diag("trying to load file for module `{$name}` with non-ascii identifier name", code = E0754)]
462#[help("consider using the `#[path]` attribute to specify filesystem path")]
463pub(crate) struct ModuleNonAscii {
464 #[primary_span]
465 pub span: Span,
466 pub name: Symbol,
467}
468
469#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AutoTraitGeneric where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AutoTraitGeneric { span: __binding_0, ident: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot have generic parameters")));
let __code_21 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0567);
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the parameters")),
__code_21, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto trait cannot have generic parameters")));
diag
}
}
}
}
};Diagnostic)]
470#[diag("auto traits cannot have generic parameters", code = E0567)]
471pub(crate) struct AutoTraitGeneric {
472 #[primary_span]
473 #[suggestion(
474 "remove the parameters",
475 code = "",
476 applicability = "machine-applicable",
477 style = "tool-only"
478 )]
479 pub span: Span,
480 #[label("auto trait cannot have generic parameters")]
481 pub ident: Span,
482}
483
484#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AutoTraitBounds where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AutoTraitBounds {
span: __binding_0, removal: __binding_1, ident: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot have super traits or lifetime bounds")));
let __code_22 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0568);
;
diag.span(__binding_0.clone());
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the super traits or lifetime bounds")),
__code_22, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot have super traits or lifetime bounds")));
diag
}
}
}
}
};Diagnostic)]
485#[diag("auto traits cannot have super traits or lifetime bounds", code = E0568)]
486pub(crate) struct AutoTraitBounds {
487 #[primary_span]
488 pub span: Vec<Span>,
489 #[suggestion(
490 "remove the super traits or lifetime bounds",
491 code = "",
492 applicability = "machine-applicable",
493 style = "tool-only"
494 )]
495 pub removal: Span,
496 #[label("auto traits cannot have super traits or lifetime bounds")]
497 pub ident: Span,
498}
499
500#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AutoTraitItems
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AutoTraitItems {
spans: __binding_0, total: __binding_1, ident: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot have associated items")));
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0380);
;
diag.span(__binding_0.clone());
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the associated items")),
__code_23, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot have associated items")));
diag
}
}
}
}
};Diagnostic)]
501#[diag("auto traits cannot have associated items", code = E0380)]
502pub(crate) struct AutoTraitItems {
503 #[primary_span]
504 pub spans: Vec<Span>,
505 #[suggestion(
506 "remove the associated items",
507 code = "",
508 applicability = "machine-applicable",
509 style = "tool-only"
510 )]
511 pub total: Span,
512 #[label("auto traits cannot have associated items")]
513 pub ident: Span,
514}
515
516#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ConstAutoTrait
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstAutoTrait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("auto traits cannot be const")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `const` keyword")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
517#[diag("auto traits cannot be const")]
518#[help("remove the `const` keyword")]
519pub(crate) struct ConstAutoTrait {
520 #[primary_span]
521 pub span: Span,
522}
523
524#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArgsBeforeConstraint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ArgsBeforeConstraint {
arg_spans: __binding_0,
constraints: __binding_1,
args: __binding_2,
data: __binding_3,
suggestion: __binding_4,
constraint_len: __binding_5,
args_len: __binding_6,
constraint_spans: __binding_7,
arg_spans2: __binding_8 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic arguments must come before the first constraint")));
let __code_24 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
})].into_iter();
;
diag.arg("suggestion", __binding_4);
diag.arg("constraint_len", __binding_5);
diag.arg("args_len", __binding_6);
diag.span(__binding_0.clone());
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$constraint_len ->\n [one] constraint\n *[other] constraints\n }")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic {$args_len ->\n [one] argument\n *[other] arguments\n }")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the {$constraint_len ->\n [one] constraint\n *[other] constraints\n } after the generic {$args_len ->\n [one] argument\n *[other] arguments\n }")),
__code_24, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.subdiagnostic(__binding_7);
diag.subdiagnostic(__binding_8);
diag
}
}
}
}
};Diagnostic)]
525#[diag("generic arguments must come before the first constraint")]
526pub(crate) struct ArgsBeforeConstraint {
527 #[primary_span]
528 pub arg_spans: Vec<Span>,
529 #[label(
530 "{$constraint_len ->
531 [one] constraint
532 *[other] constraints
533 }"
534 )]
535 pub constraints: Span,
536 #[label(
537 "generic {$args_len ->
538 [one] argument
539 *[other] arguments
540 }"
541 )]
542 pub args: Span,
543 #[suggestion(
544 "move the {$constraint_len ->
545 [one] constraint
546 *[other] constraints
547 } after the generic {$args_len ->
548 [one] argument
549 *[other] arguments
550 }",
551 code = "{suggestion}",
552 applicability = "machine-applicable",
553 style = "verbose"
554 )]
555 pub data: Span,
556 pub suggestion: String,
557 pub constraint_len: usize,
558 pub args_len: usize,
559 #[subdiagnostic]
560 pub constraint_spans: EmptyLabelManySpans,
561 #[subdiagnostic]
562 pub arg_spans2: EmptyLabelManySpans,
563}
564
565pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);
566
567impl Subdiagnostic for EmptyLabelManySpans {
569 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
570 diag.span_labels(self.0, "");
571 }
572}
573
574#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternFnPointer where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternFnPointer { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns aren't allowed in function pointer types")));
diag.code(E0561);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
575#[diag("patterns aren't allowed in function pointer types", code = E0561)]
576pub(crate) struct PatternFnPointer {
577 #[primary_span]
578 pub span: Span,
579}
580
581#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitObjectBound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitObjectBound { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only a single explicit lifetime bound is permitted")));
diag.code(E0226);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
582#[diag("only a single explicit lifetime bound is permitted", code = E0226)]
583pub(crate) struct TraitObjectBound {
584 #[primary_span]
585 pub span: Span,
586}
587
588#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NestedImplTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NestedImplTrait {
span: __binding_0, outer: __binding_1, inner: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nested `impl Trait` is not allowed")));
diag.code(E0666);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("outer `impl Trait`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nested `impl Trait` here")));
diag
}
}
}
}
};Diagnostic)]
589#[diag("nested `impl Trait` is not allowed", code = E0666)]
590pub(crate) struct NestedImplTrait {
591 #[primary_span]
592 pub span: Span,
593 #[label("outer `impl Trait`")]
594 pub outer: Span,
595 #[label("nested `impl Trait` here")]
596 pub inner: Span,
597}
598
599#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtLeastOneTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtLeastOneTrait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one trait must be specified")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
600#[diag("at least one trait must be specified")]
601pub(crate) struct AtLeastOneTrait {
602 #[primary_span]
603 pub span: Span,
604}
605
606#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OutOfOrderParams<'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 {
OutOfOrderParams {
spans: __binding_0,
sugg_span: __binding_1,
param_ord: __binding_2,
max_param: __binding_3,
ordered_params: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$param_ord} parameters must be declared prior to {$max_param} parameters")));
let __code_25 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
})].into_iter();
;
diag.arg("param_ord", __binding_2);
diag.arg("max_param", __binding_3);
diag.arg("ordered_params", __binding_4);
diag.span(__binding_0.clone());
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reorder the parameters: lifetimes, then consts and types")),
__code_25, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
607#[diag("{$param_ord} parameters must be declared prior to {$max_param} parameters")]
608pub(crate) struct OutOfOrderParams<'a> {
609 #[primary_span]
610 pub spans: Vec<Span>,
611 #[suggestion(
612 "reorder the parameters: lifetimes, then consts and types",
613 code = "{ordered_params}",
614 applicability = "machine-applicable"
615 )]
616 pub sugg_span: Span,
617 pub param_ord: &'a ParamKindOrd,
618 pub max_param: &'a ParamKindOrd,
619 pub ordered_params: &'a str,
620}
621
622#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ObsoleteAuto
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ObsoleteAuto { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait for .. {\"{}\"}` is an obsolete syntax")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `auto trait Trait {\"{}\"}` instead")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
623#[diag("`impl Trait for .. {\"{}\"}` is an obsolete syntax")]
624#[help("use `auto trait Trait {\"{}\"}` instead")]
625pub(crate) struct ObsoleteAuto {
626 #[primary_span]
627 pub span: Span,
628}
629
630#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeNegativeImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeNegativeImpl {
span: __binding_0,
negative: __binding_1,
r#unsafe: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative impls cannot be unsafe")));
diag.code(E0198);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative because of this")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe because of this")));
diag
}
}
}
}
};Diagnostic)]
631#[diag("negative impls cannot be unsafe", code = E0198)]
632pub(crate) struct UnsafeNegativeImpl {
633 #[primary_span]
634 pub span: Span,
635 #[label("negative because of this")]
636 pub negative: Span,
637 #[label("unsafe because of this")]
638 pub r#unsafe: Span,
639}
640
641#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnsafeItem
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeItem { span: __binding_0, kind: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} cannot be declared unsafe")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
642#[diag("{$kind} cannot be declared unsafe")]
643pub(crate) struct UnsafeItem {
644 #[primary_span]
645 pub span: Span,
646 pub kind: &'static str,
647}
648
649#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingUnsafeOnExtern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingUnsafeOnExtern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern blocks must be unsafe")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
650#[diag("extern blocks must be unsafe")]
651pub(crate) struct MissingUnsafeOnExtern {
652 #[primary_span]
653 pub span: Span,
654}
655
656#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
MissingUnsafeOnExternLint {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MissingUnsafeOnExternLint { suggestion: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern blocks should be unsafe")));
;
let __code_26 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe "))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs `unsafe` before the extern keyword")),
__code_26, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
657#[diag("extern blocks should be unsafe")]
658pub(crate) struct MissingUnsafeOnExternLint {
659 #[suggestion(
660 "needs `unsafe` before the extern keyword",
661 code = "unsafe ",
662 applicability = "machine-applicable"
663 )]
664 pub suggestion: Span,
665}
666
667#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FieldlessUnion
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FieldlessUnion { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unions cannot have zero fields")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
668#[diag("unions cannot have zero fields")]
669pub(crate) struct FieldlessUnion {
670 #[primary_span]
671 pub span: Span,
672}
673
674#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseAfterTypeAlias where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseAfterTypeAlias {
span: __binding_0, help: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed after the type for type aliases")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information")));
;
diag.span(__binding_0);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(lazy_type_alias)]` to the crate attributes to enable")));
}
diag
}
}
}
}
};Diagnostic)]
675#[diag("where clauses are not allowed after the type for type aliases")]
676#[note("see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information")]
677pub(crate) struct WhereClauseAfterTypeAlias {
678 #[primary_span]
679 pub span: Span,
680 #[help("add `#![feature(lazy_type_alias)]` to the crate attributes to enable")]
681 pub help: bool,
682}
683
684#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseBeforeTypeAlias where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseBeforeTypeAlias {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed before the type for type aliases")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
685#[diag("where clauses are not allowed before the type for type aliases")]
686#[note("see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information")]
687pub(crate) struct WhereClauseBeforeTypeAlias {
688 #[primary_span]
689 pub span: Span,
690 #[subdiagnostic]
691 pub sugg: WhereClauseBeforeTypeAliasSugg,
692}
693
694#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WhereClauseBeforeTypeAliasSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WhereClauseBeforeTypeAliasSugg::Remove { span: __binding_0 }
=> {
let __code_27 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this `where`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_27, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
WhereClauseBeforeTypeAliasSugg::Move {
left: __binding_0, snippet: __binding_1, right: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_28 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_29 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
suggestions.push((__binding_0, __code_28));
suggestions.push((__binding_2, __code_29));
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move it to the end of the type declaration")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
695pub(crate) enum WhereClauseBeforeTypeAliasSugg {
696 #[suggestion("remove this `where`", applicability = "machine-applicable", code = "")]
697 Remove {
698 #[primary_span]
699 span: Span,
700 },
701 #[multipart_suggestion(
702 "move it to the end of the type declaration",
703 applicability = "machine-applicable",
704 style = "verbose"
705 )]
706 Move {
707 #[suggestion_part(code = "")]
708 left: Span,
709 snippet: String,
710 #[suggestion_part(code = "{snippet}")]
711 right: Span,
712 },
713}
714
715#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericDefaultTrailing where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericDefaultTrailing { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters with a default must be trailing")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
716#[diag("generic parameters with a default must be trailing")]
717pub(crate) struct GenericDefaultTrailing {
718 #[primary_span]
719 pub span: Span,
720}
721
722#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NestedLifetimes where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NestedLifetimes { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nested quantification of lifetimes")));
diag.code(E0316);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
723#[diag("nested quantification of lifetimes", code = E0316)]
724pub(crate) struct NestedLifetimes {
725 #[primary_span]
726 pub span: Span,
727}
728
729#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstBoundTraitObject where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstBoundTraitObject { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const trait bounds are not allowed in trait object types")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
730#[diag("const trait bounds are not allowed in trait object types")]
731pub(crate) struct ConstBoundTraitObject {
732 #[primary_span]
733 pub span: Span,
734}
735
736#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TildeConstDisallowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TildeConstDisallowed {
span: __binding_0, reason: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`[const]` is not allowed here")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
739#[diag("`[const]` is not allowed here")]
740pub(crate) struct TildeConstDisallowed {
741 #[primary_span]
742 pub span: Span,
743 #[subdiagnostic]
744 pub reason: TildeConstReason,
745}
746
747#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TildeConstReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TildeConstReason::Closure => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closures cannot have `[const]` trait bounds")));
diag.note(__message);
diag.restore_args();
}
TildeConstReason::Function { ident: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this function is not `const`, so it cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::Trait { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this trait is not `const`, so it cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::TraitImpl { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this impl is not `const`, so it cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::Impl { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent impls cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::TraitAssocTy { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated types in non-`const` traits cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::TraitImplAssocTy { span: __binding_0 } =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated types in non-const impls cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::InherentAssocTy { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent associated types cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::Struct { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("structs cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::Enum { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enums cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::Union { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unions cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::AnonConst { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("anonymous constants cannot have `[const]` trait bounds")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TildeConstReason::TraitObject => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait objects cannot have `[const]` trait bounds")));
diag.note(__message);
diag.restore_args();
}
TildeConstReason::Item => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this item cannot have `[const]` trait bounds")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::marker::Copy for TildeConstReason { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TildeConstReason {
#[inline]
fn clone(&self) -> TildeConstReason {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone)]
748pub(crate) enum TildeConstReason {
749 #[note("closures cannot have `[const]` trait bounds")]
750 Closure,
751 #[note("this function is not `const`, so it cannot have `[const]` trait bounds")]
752 Function {
753 #[primary_span]
754 ident: Span,
755 },
756 #[note("this trait is not `const`, so it cannot have `[const]` trait bounds")]
757 Trait {
758 #[primary_span]
759 span: Span,
760 },
761 #[note("this impl is not `const`, so it cannot have `[const]` trait bounds")]
762 TraitImpl {
763 #[primary_span]
764 span: Span,
765 },
766 #[note("inherent impls cannot have `[const]` trait bounds")]
767 Impl {
768 #[primary_span]
769 span: Span,
770 },
771 #[note("associated types in non-`const` traits cannot have `[const]` trait bounds")]
772 TraitAssocTy {
773 #[primary_span]
774 span: Span,
775 },
776 #[note("associated types in non-const impls cannot have `[const]` trait bounds")]
777 TraitImplAssocTy {
778 #[primary_span]
779 span: Span,
780 },
781 #[note("inherent associated types cannot have `[const]` trait bounds")]
782 InherentAssocTy {
783 #[primary_span]
784 span: Span,
785 },
786 #[note("structs cannot have `[const]` trait bounds")]
787 Struct {
788 #[primary_span]
789 span: Span,
790 },
791 #[note("enums cannot have `[const]` trait bounds")]
792 Enum {
793 #[primary_span]
794 span: Span,
795 },
796 #[note("unions cannot have `[const]` trait bounds")]
797 Union {
798 #[primary_span]
799 span: Span,
800 },
801 #[note("anonymous constants cannot have `[const]` trait bounds")]
802 AnonConst {
803 #[primary_span]
804 span: Span,
805 },
806 #[note("trait objects cannot have `[const]` trait bounds")]
807 TraitObject,
808 #[note("this item cannot have `[const]` trait bounds")]
809 Item,
810}
811
812#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstAndCoroutine where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstAndCoroutine {
spans: __binding_0,
const_span: __binding_1,
coroutine_span: __binding_2,
span: __binding_3,
coroutine_kind: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions cannot be both `const` and `{$coroutine_kind}`")));
;
diag.arg("coroutine_kind", __binding_4);
diag.span(__binding_0.clone());
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` because of this")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$coroutine_kind}` because of this")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{\"\"}")));
diag
}
}
}
}
};Diagnostic)]
813#[diag("functions cannot be both `const` and `{$coroutine_kind}`")]
814pub(crate) struct ConstAndCoroutine {
815 #[primary_span]
816 pub spans: Vec<Span>,
817 #[label("`const` because of this")]
818 pub const_span: Span,
819 #[label("`{$coroutine_kind}` because of this")]
820 pub coroutine_span: Span,
821 #[label("{\"\"}")]
822 pub span: Span,
823 pub coroutine_kind: &'static str,
824}
825
826#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstAndCVariadic where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstAndCVariadic {
spans: __binding_0,
const_span: __binding_1,
variadic_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions cannot be both `const` and C-variadic")));
;
diag.span(__binding_0.clone());
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` because of this")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic because of this")));
diag
}
}
}
}
};Diagnostic)]
827#[diag("functions cannot be both `const` and C-variadic")]
828pub(crate) struct ConstAndCVariadic {
829 #[primary_span]
830 pub spans: Vec<Span>,
831 #[label("`const` because of this")]
832 pub const_span: Span,
833 #[label("C-variadic because of this")]
834 pub variadic_span: Span,
835}
836
837#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoroutineAndCVariadic where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CoroutineAndCVariadic {
spans: __binding_0,
coroutine_kind: __binding_1,
coroutine_span: __binding_2,
variadic_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions cannot be both `{$coroutine_kind}` and C-variadic")));
;
diag.arg("coroutine_kind", __binding_1);
diag.span(__binding_0.clone());
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$coroutine_kind}` because of this")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic because of this")));
diag
}
}
}
}
};Diagnostic)]
838#[diag("functions cannot be both `{$coroutine_kind}` and C-variadic")]
839pub(crate) struct CoroutineAndCVariadic {
840 #[primary_span]
841 pub spans: Vec<Span>,
842 pub coroutine_kind: &'static str,
843 #[label("`{$coroutine_kind}` because of this")]
844 pub coroutine_span: Span,
845 #[label("C-variadic because of this")]
846 pub variadic_span: Span,
847}
848
849#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
CVariadicNotSupported<'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 {
CVariadicNotSupported {
variadic_span: __binding_0, target: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$target}` target does not support c-variadic functions")));
;
diag.arg("target", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
850#[diag("the `{$target}` target does not support c-variadic functions")]
851pub(crate) struct CVariadicNotSupported<'a> {
852 #[primary_span]
853 pub variadic_span: Span,
854 pub target: &'a str,
855}
856
857#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternInForeign where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternInForeign { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns aren't allowed in foreign function declarations")));
diag.code(E0130);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern not allowed in foreign function")));
diag
}
}
}
}
};Diagnostic)]
858#[diag("patterns aren't allowed in foreign function declarations", code = E0130)]
859pub(crate) struct PatternInForeign {
861 #[primary_span]
862 #[label("pattern not allowed in foreign function")]
863 pub span: Span,
864}
865
866#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternInBodiless where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternInBodiless { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns aren't allowed in functions without bodies")));
diag.code(E0642);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern not allowed in function without body")));
diag
}
}
}
}
};Diagnostic)]
867#[diag("patterns aren't allowed in functions without bodies", code = E0642)]
868pub(crate) struct PatternInBodiless {
870 #[primary_span]
871 #[label("pattern not allowed in function without body")]
872 pub span: Span,
873}
874
875#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EqualityInWhere where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EqualityInWhere {
span: __binding_0, assoc: __binding_1, assoc2: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("equality constraints are not yet supported in `where` clauses")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
876#[diag("equality constraints are not yet supported in `where` clauses")]
877#[note("see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information")]
878pub(crate) struct EqualityInWhere {
879 #[primary_span]
880 #[label("not supported")]
881 pub span: Span,
882 #[subdiagnostic]
883 pub assoc: Option<AssociatedSuggestion>,
884 #[subdiagnostic]
885 pub assoc2: Option<AssociatedSuggestion2>,
886}
887
888#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssociatedSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssociatedSuggestion {
span: __binding_0,
ident: __binding_1,
param: __binding_2,
path: __binding_3 } => {
let __code_30 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}: {1}", __binding_2,
__binding_3))
})].into_iter();
diag.store_args();
diag.arg("ident", __binding_1);
diag.arg("param", __binding_2);
diag.arg("path", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$ident}` is an associated type you're trying to set, use the associated type binding syntax")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_30, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
889#[suggestion(
890 "if `{$ident}` is an associated type you're trying to set, use the associated type binding syntax",
891 code = "{param}: {path}",
892 style = "verbose",
893 applicability = "maybe-incorrect"
894)]
895pub(crate) struct AssociatedSuggestion {
896 #[primary_span]
897 pub span: Span,
898 pub ident: Ident,
899 pub param: Ident,
900 pub path: String,
901}
902
903#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssociatedSuggestion2 {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssociatedSuggestion2 {
span: __binding_0,
args: __binding_1,
predicate: __binding_2,
trait_segment: __binding_3,
potential_assoc: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_31 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_32 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_31));
suggestions.push((__binding_2, __code_32));
diag.store_args();
diag.arg("args", __binding_1);
diag.arg("trait_segment", __binding_3);
diag.arg("potential_assoc", __binding_4);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$trait_segment}::{$potential_assoc}` is an associated type you're trying to set, use the associated type binding syntax")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
904#[multipart_suggestion(
905 "if `{$trait_segment}::{$potential_assoc}` is an associated type you're trying to set, use the associated type binding syntax",
906 applicability = "maybe-incorrect"
907)]
908pub(crate) struct AssociatedSuggestion2 {
909 #[suggestion_part(code = "{args}")]
910 pub span: Span,
911 pub args: String,
912 #[suggestion_part(code = "")]
913 pub predicate: Span,
914 pub trait_segment: Ident,
915 pub potential_assoc: Ident,
916}
917
918#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FeatureOnNonNightly where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FeatureOnNonNightly {
span: __binding_0,
channel: __binding_1,
stable_features: __binding_2,
sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#![feature]` may not be used on the {$channel} release channel")));
let __code_33 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0554);
;
diag.arg("channel", __binding_1);
diag.span(__binding_0);
for __binding_2 in __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attribute")),
__code_33, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
919#[diag("`#![feature]` may not be used on the {$channel} release channel", code = E0554)]
920pub(crate) struct FeatureOnNonNightly {
921 #[primary_span]
922 pub span: Span,
923 pub channel: &'static str,
924 #[subdiagnostic]
925 pub stable_features: Vec<StableFeature>,
926 #[suggestion("remove the attribute", code = "", applicability = "machine-applicable")]
927 pub sugg: Option<Span>,
928}
929
930#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for StableFeature {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
StableFeature { name: __binding_0, since: __binding_1 } => {
diag.store_args();
diag.arg("name", __binding_0);
diag.arg("since", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
931#[help(
932 "the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable"
933)]
934pub(crate) struct StableFeature {
935 pub name: Symbol,
936 pub since: Symbol,
937}
938
939#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncompatibleFeatures where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncompatibleFeatures {
spans: __binding_0, f1: __binding_1, f2: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$f1}` and `{$f2}` are incompatible, using them at the same time is not allowed")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove one of these features")));
;
diag.arg("f1", __binding_1);
diag.arg("f2", __binding_2);
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
940#[diag("`{$f1}` and `{$f2}` are incompatible, using them at the same time is not allowed")]
941#[help("remove one of these features")]
942pub(crate) struct IncompatibleFeatures {
943 #[primary_span]
944 pub spans: Vec<Span>,
945 pub f1: Symbol,
946 pub f2: Symbol,
947}
948
949#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingDependentFeatures where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingDependentFeatures {
parent_span: __binding_0,
parent: __binding_1,
missing: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$parent}` requires {$missing} to be enabled")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enable all of these features")));
;
diag.arg("parent", __binding_1);
diag.arg("missing", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
950#[diag("`{$parent}` requires {$missing} to be enabled")]
951#[help("enable all of these features")]
952pub(crate) struct MissingDependentFeatures {
953 #[primary_span]
954 pub parent_span: Span,
955 pub parent: Symbol,
956 pub missing: String,
957}
958
959#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NegativeBoundUnsupported where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NegativeBoundUnsupported { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative bounds are not supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
960#[diag("negative bounds are not supported")]
961pub(crate) struct NegativeBoundUnsupported {
962 #[primary_span]
963 pub span: Span,
964}
965
966#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstraintOnNegativeBound where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstraintOnNegativeBound { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated type constraints not allowed on negative bounds")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
967#[diag("associated type constraints not allowed on negative bounds")]
968pub(crate) struct ConstraintOnNegativeBound {
969 #[primary_span]
970 pub span: Span,
971}
972
973#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NegativeBoundWithParentheticalNotation where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NegativeBoundWithParentheticalNotation { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthetical notation may not be used for negative bounds")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
974#[diag("parenthetical notation may not be used for negative bounds")]
975pub(crate) struct NegativeBoundWithParentheticalNotation {
976 #[primary_span]
977 pub span: Span,
978}
979
980#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MatchArmWithNoBody where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MatchArmWithNoBody {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`match` arm with no body")));
let __code_34 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" => {{ todo!() }}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a body after the pattern")),
__code_34, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
981#[diag("`match` arm with no body")]
982pub(crate) struct MatchArmWithNoBody {
983 #[primary_span]
984 pub span: Span,
985 #[suggestion(
989 "add a body after the pattern",
990 code = " => {{ todo!() }}",
991 applicability = "has-placeholders",
992 style = "verbose"
993 )]
994 pub suggestion: Span,
995}
996
997#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PreciseCapturingNotAllowedHere where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PreciseCapturingNotAllowedHere {
span: __binding_0, loc: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`use<...>` precise capturing syntax not allowed in {$loc}")));
;
diag.arg("loc", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
998#[diag("`use<...>` precise capturing syntax not allowed in {$loc}")]
999pub(crate) struct PreciseCapturingNotAllowedHere {
1000 #[primary_span]
1001 pub span: Span,
1002 pub loc: &'static str,
1003}
1004
1005#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicatePreciseCapturing where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DuplicatePreciseCapturing {
bound1: __binding_0, bound2: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate `use<...>` precise capturing syntax")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second `use<...>` here")));
diag
}
}
}
}
};Diagnostic)]
1006#[diag("duplicate `use<...>` precise capturing syntax")]
1007pub(crate) struct DuplicatePreciseCapturing {
1008 #[primary_span]
1009 pub bound1: Span,
1010 #[label("second `use<...>` here")]
1011 pub bound2: Span,
1012}
1013
1014#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingAbi
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingAbi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` declarations without an explicit ABI are disallowed")));
let __code_35 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("extern \"<abi>\""))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prior to Rust 2024, a default ABI was inferred")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify an ABI")),
__code_35, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1015#[diag("`extern` declarations without an explicit ABI are disallowed")]
1016#[help("prior to Rust 2024, a default ABI was inferred")]
1017pub(crate) struct MissingAbi {
1018 #[primary_span]
1019 #[suggestion("specify an ABI", code = "extern \"<abi>\"", applicability = "has-placeholders")]
1020 pub span: Span,
1021}
1022
1023#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for MissingAbiSugg {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MissingAbiSugg { span: __binding_0, default_abi: __binding_1
} => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` declarations without an explicit ABI are deprecated")));
;
let __code_36 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("extern {0}",
__binding_1))
})].into_iter();
diag.arg("default_abi", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the {$default_abi} ABI")),
__code_36, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
1024#[diag("`extern` declarations without an explicit ABI are deprecated")]
1025pub(crate) struct MissingAbiSugg {
1026 #[suggestion(
1027 "explicitly specify the {$default_abi} ABI",
1028 code = "extern {default_abi}",
1029 applicability = "machine-applicable"
1030 )]
1031 pub span: Span,
1032 pub default_abi: ExternAbi,
1033}
1034
1035#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiCustomSafeForeignFunction where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiCustomSafeForeignFunction {
span: __binding_0, safe_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("foreign functions with the \"custom\" ABI cannot be safe")));
let __code_37 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `safe` keyword from this definition")),
__code_37, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1036#[diag("foreign functions with the \"custom\" ABI cannot be safe")]
1037pub(crate) struct AbiCustomSafeForeignFunction {
1038 #[primary_span]
1039 pub span: Span,
1040
1041 #[suggestion(
1042 "remove the `safe` keyword from this definition",
1043 applicability = "maybe-incorrect",
1044 code = "",
1045 style = "verbose"
1046 )]
1047 pub safe_span: Span,
1048}
1049
1050#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiCustomSafeFunction where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiCustomSafeFunction {
span: __binding_0,
abi: __binding_1,
unsafe_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"custom\" ABI must be unsafe")));
let __code_38 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe "))
})].into_iter();
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the `unsafe` keyword to this definition")),
__code_38, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1051#[diag("functions with the \"custom\" ABI must be unsafe")]
1052pub(crate) struct AbiCustomSafeFunction {
1053 #[primary_span]
1054 pub span: Span,
1055 pub abi: ExternAbi,
1056
1057 #[suggestion(
1058 "add the `unsafe` keyword to this definition",
1059 applicability = "maybe-incorrect",
1060 code = "unsafe ",
1061 style = "verbose"
1062 )]
1063 pub unsafe_span: Span,
1064}
1065
1066#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiCannotBeCoroutine where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiCannotBeCoroutine {
span: __binding_0,
abi: __binding_1,
coroutine_kind_span: __binding_2,
coroutine_kind_str: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the {$abi} ABI cannot be `{$coroutine_kind_str}`")));
let __code_39 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("abi", __binding_1);
diag.arg("coroutine_kind_str", __binding_3);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `{$coroutine_kind_str}` keyword from this definition")),
__code_39, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1067#[diag("functions with the {$abi} ABI cannot be `{$coroutine_kind_str}`")]
1068pub(crate) struct AbiCannotBeCoroutine {
1069 #[primary_span]
1070 pub span: Span,
1071 pub abi: ExternAbi,
1072
1073 #[suggestion(
1074 "remove the `{$coroutine_kind_str}` keyword from this definition",
1075 applicability = "maybe-incorrect",
1076 code = "",
1077 style = "verbose"
1078 )]
1079 pub coroutine_kind_span: Span,
1080 pub coroutine_kind_str: &'static str,
1081}
1082
1083#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiMustNotHaveParametersOrReturnType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiMustNotHaveParametersOrReturnType {
spans: __binding_0,
abi: __binding_1,
suggestion_span: __binding_2,
symbol: __binding_3,
padding: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid signature for `extern {$abi}` function")));
let __code_40 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}fn {1}()",
__binding_4, __binding_3))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the {$abi} ABI cannot have any parameters or return type")));
;
diag.arg("abi", __binding_1);
diag.arg("symbol", __binding_3);
diag.arg("padding", __binding_4);
diag.span(__binding_0.clone());
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the parameters and return type")),
__code_40, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1084#[diag("invalid signature for `extern {$abi}` function")]
1085#[note("functions with the {$abi} ABI cannot have any parameters or return type")]
1086pub(crate) struct AbiMustNotHaveParametersOrReturnType {
1087 #[primary_span]
1088 pub spans: Vec<Span>,
1089 pub abi: ExternAbi,
1090
1091 #[suggestion(
1092 "remove the parameters and return type",
1093 applicability = "maybe-incorrect",
1094 code = "{padding}fn {symbol}()",
1095 style = "verbose"
1096 )]
1097 pub suggestion_span: Span,
1098 pub symbol: Symbol,
1099 pub padding: &'static str,
1100}
1101
1102#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiMustNotHaveReturnType where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiMustNotHaveReturnType {
span: __binding_0, abi: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid signature for `extern {$abi}` function")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the {$abi} ABI cannot have a return type")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the return type")));
diag
}
}
}
}
};Diagnostic)]
1103#[diag("invalid signature for `extern {$abi}` function")]
1104#[note("functions with the {$abi} ABI cannot have a return type")]
1105pub(crate) struct AbiMustNotHaveReturnType {
1106 #[primary_span]
1107 #[help("remove the return type")]
1108 pub span: Span,
1109 pub abi: ExternAbi,
1110}
1111
1112#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiX86Interrupt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiX86Interrupt {
spans: __binding_0, param_count: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid signature for `extern \"x86-interrupt\"` function")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"x86-interrupt\" ABI must be have either 1 or 2 parameters (but found {$param_count})")));
;
diag.arg("param_count", __binding_1);
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
1113#[diag("invalid signature for `extern \"x86-interrupt\"` function")]
1114#[note(
1115 "functions with the \"x86-interrupt\" ABI must be have either 1 or 2 parameters (but found {$param_count})"
1116)]
1117pub(crate) struct AbiX86Interrupt {
1118 #[primary_span]
1119 pub spans: Vec<Span>,
1120 pub param_count: usize,
1121}
1122
1123#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ScalableVectorNotTupleStruct where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ScalableVectorNotTupleStruct { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("scalable vectors must be tuple structs")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1124#[diag("scalable vectors must be tuple structs")]
1125pub(crate) struct ScalableVectorNotTupleStruct {
1126 #[primary_span]
1127 pub span: Span,
1128}