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