1use std::borrow::Cow;
4use std::path::PathBuf;
5
6use rustc_ast::token::{self, InvisibleOrigin, MetaVarKind, Token};
7use rustc_ast_pretty::pprust;
8use rustc_errors::codes::*;
9use rustc_errors::{
10 Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg,
11 Level, Subdiagnostic, SuggestionStyle, msg,
12};
13use rustc_macros::{Diagnostic, Subdiagnostic};
14use rustc_session::errors::ExprParenthesesNeeded;
15use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
16use rustc_span::{Ident, Span, Symbol};
17
18#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AmbiguousPlus
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousPlus { span: __binding_0, suggestion: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous `+` in a type")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
19#[diag("ambiguous `+` in a type")]
20pub(crate) struct AmbiguousPlus {
21 #[primary_span]
22 pub span: Span,
23 #[subdiagnostic]
24 pub suggestion: AddParen,
25}
26
27#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadTypePlus
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadTypePlus { span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a path on the left-hand side of `+`")));
diag.code(E0178);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
28#[diag("expected a path on the left-hand side of `+`", code = E0178)]
29pub(crate) struct BadTypePlus {
30 #[primary_span]
31 pub span: Span,
32 #[subdiagnostic]
33 pub sub: BadTypePlusSub,
34}
35
36#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddParen {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddParen { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_0 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_0));
suggestions.push((__binding_1, __code_1));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
37#[multipart_suggestion("try adding parentheses", applicability = "machine-applicable")]
38pub(crate) struct AddParen {
39 #[suggestion_part(code = "(")]
40 pub lo: Span,
41 #[suggestion_part(code = ")")]
42 pub hi: Span,
43}
44
45#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BadTypePlusSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BadTypePlusSub::AddParen { suggestion: __binding_0 } => {
__binding_0.add_to_diag(diag);
let mut sub_args = rustc_errors::DiagArgMap::default();
}
BadTypePlusSub::ForgotParen { 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("perhaps you forgot parentheses?")),
&sub_args);
diag.span_label(__binding_0, __message);
}
BadTypePlusSub::ExpectPath { 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("expected a path")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
46pub(crate) enum BadTypePlusSub {
47 AddParen {
48 #[subdiagnostic]
49 suggestion: AddParen,
50 },
51 #[label("perhaps you forgot parentheses?")]
52 ForgotParen {
53 #[primary_span]
54 span: Span,
55 },
56 #[label("expected a path")]
57 ExpectPath {
58 #[primary_span]
59 span: Span,
60 },
61}
62
63#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadQPathStage2
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadQPathStage2 { span: __binding_0, wrap: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing angle brackets in associated item path")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
64#[diag("missing angle brackets in associated item path")]
65pub(crate) struct BadQPathStage2 {
66 #[primary_span]
67 pub span: Span,
68 #[subdiagnostic]
69 pub wrap: WrapType,
70}
71
72#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplModifierInInherentImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitImplModifierInInherentImpl {
span: __binding_0,
modifier: __binding_1,
modifier_name: __binding_2,
modifier_span: __binding_3,
self_ty: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent impls cannot be {$modifier_name}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only trait implementations may be annotated with `{$modifier}`")));
;
diag.arg("modifier", __binding_1);
diag.arg("modifier_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$modifier_name} because of this")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent impl for this type")));
diag
}
}
}
}
};Diagnostic)]
73#[diag("inherent impls cannot be {$modifier_name}")]
74#[note("only trait implementations may be annotated with `{$modifier}`")]
75pub(crate) struct TraitImplModifierInInherentImpl {
76 #[primary_span]
77 pub span: Span,
78 pub modifier: &'static str,
79 pub modifier_name: &'static str,
80 #[label("{$modifier_name} because of this")]
81 pub modifier_span: Span,
82 #[label("inherent impl for this type")]
83 pub self_ty: Span,
84}
85
86#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapType {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapType { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_2 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_3 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_2));
suggestions.push((__binding_1, __code_3));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("types that don't start with an identifier need to be surrounded with angle brackets in qualified paths")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
87#[multipart_suggestion(
88 "types that don't start with an identifier need to be surrounded with angle brackets in qualified paths",
89 applicability = "machine-applicable"
90)]
91pub(crate) struct WrapType {
92 #[suggestion_part(code = "<")]
93 pub lo: Span,
94 #[suggestion_part(code = ">")]
95 pub hi: Span,
96}
97
98#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectSemicolon<'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 {
IncorrectSemicolon {
span: __binding_0, show_help: __binding_1, name: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected item, found `;`")));
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this semicolon")),
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name} declarations are not followed by a semicolon")));
}
diag
}
}
}
}
};Diagnostic)]
99#[diag("expected item, found `;`")]
100pub(crate) struct IncorrectSemicolon<'a> {
101 #[primary_span]
102 #[suggestion(
103 "remove this semicolon",
104 style = "verbose",
105 code = "",
106 applicability = "machine-applicable"
107 )]
108 pub span: Span,
109 #[help("{$name} declarations are not followed by a semicolon")]
110 pub show_help: bool,
111 pub name: &'a str,
112}
113
114#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectUseOfAwait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectUseOfAwait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `await`")));
let __code_5 =
[::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("`await` is not a method call, remove the parentheses")),
__code_5, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
115#[diag("incorrect use of `await`")]
116pub(crate) struct IncorrectUseOfAwait {
117 #[primary_span]
118 #[suggestion(
119 "`await` is not a method call, remove the parentheses",
120 style = "verbose",
121 code = "",
122 applicability = "machine-applicable"
123 )]
124 pub span: Span,
125}
126
127#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectUseOfUse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectUseOfUse { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `use`")));
let __code_6 =
[::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("`use` is not a method call, try removing the parentheses")),
__code_6, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
128#[diag("incorrect use of `use`")]
129pub(crate) struct IncorrectUseOfUse {
130 #[primary_span]
131 #[suggestion(
132 "`use` is not a method call, try removing the parentheses",
133 style = "verbose",
134 code = "",
135 applicability = "machine-applicable"
136 )]
137 pub span: Span,
138}
139
140#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AwaitSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AwaitSuggestion {
removal: __binding_0,
dot_await: __binding_1,
question_mark: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".await{0}", __binding_2))
});
suggestions.push((__binding_0, __code_7));
suggestions.push((__binding_1, __code_8));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`await` is a postfix operation")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
141#[multipart_suggestion("`await` is a postfix operation", applicability = "machine-applicable")]
142pub(crate) struct AwaitSuggestion {
143 #[suggestion_part(code = "")]
144 pub removal: Span,
145 #[suggestion_part(code = ".await{question_mark}")]
146 pub dot_await: Span,
147 pub question_mark: &'static str,
148}
149
150#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for IncorrectAwait
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectAwait { span: __binding_0, suggestion: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `await`")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
151#[diag("incorrect use of `await`")]
152pub(crate) struct IncorrectAwait {
153 #[primary_span]
154 pub span: Span,
155 #[subdiagnostic]
156 pub suggestion: AwaitSuggestion,
157}
158
159#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InInTypo where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InInTypo { span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected iterable, found keyword `in`")));
let __code_9 =
[::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 duplicated `in`")),
__code_9, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
160#[diag("expected iterable, found keyword `in`")]
161pub(crate) struct InInTypo {
162 #[primary_span]
163 pub span: Span,
164 #[suggestion(
165 "remove the duplicated `in`",
166 code = "",
167 style = "verbose",
168 applicability = "machine-applicable"
169 )]
170 pub sugg_span: Span,
171}
172
173#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidVariableDeclaration where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidVariableDeclaration {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid variable declaration")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
174#[diag("invalid variable declaration")]
175pub(crate) struct InvalidVariableDeclaration {
176 #[primary_span]
177 pub span: Span,
178 #[subdiagnostic]
179 pub sub: InvalidVariableDeclarationSub,
180}
181
182#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidVariableDeclarationSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidVariableDeclarationSub::SwitchMutLetOrder(__binding_0)
=> {
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let mut"))
})].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("switch the order of `mut` and `let`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_10, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidVariableDeclarationSub::MissingLet(__binding_0) => {
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let mut"))
})].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("missing keyword")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidVariableDeclarationSub::UseLetNotAuto(__binding_0) =>
{
let __code_12 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let"))
})].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("write `let` instead of `auto` to introduce a new variable")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_12, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidVariableDeclarationSub::UseLetNotVar(__binding_0) =>
{
let __code_13 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let"))
})].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("write `let` instead of `var` to introduce a new variable")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_13, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
183pub(crate) enum InvalidVariableDeclarationSub {
184 #[suggestion(
185 "switch the order of `mut` and `let`",
186 style = "verbose",
187 applicability = "maybe-incorrect",
188 code = "let mut"
189 )]
190 SwitchMutLetOrder(#[primary_span] Span),
191 #[suggestion(
192 "missing keyword",
193 applicability = "machine-applicable",
194 style = "verbose",
195 code = "let mut"
196 )]
197 MissingLet(#[primary_span] Span),
198 #[suggestion(
199 "write `let` instead of `auto` to introduce a new variable",
200 style = "verbose",
201 applicability = "machine-applicable",
202 code = "let"
203 )]
204 UseLetNotAuto(#[primary_span] Span),
205 #[suggestion(
206 "write `let` instead of `var` to introduce a new variable",
207 style = "verbose",
208 applicability = "machine-applicable",
209 code = "let"
210 )]
211 UseLetNotVar(#[primary_span] Span),
212}
213
214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SwitchRefBoxOrder where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SwitchRefBoxOrder { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order of `ref` and `box`")));
let __code_14 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("box ref"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("swap them")),
__code_14, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
215#[diag("switch the order of `ref` and `box`")]
216pub(crate) struct SwitchRefBoxOrder {
217 #[primary_span]
218 #[suggestion(
219 "swap them",
220 applicability = "machine-applicable",
221 style = "verbose",
222 code = "box ref"
223 )]
224 pub span: Span,
225}
226
227#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidComparisonOperator where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidComparisonOperator {
span: __binding_0, invalid: __binding_1, sub: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid comparison operator `{$invalid}`")));
;
diag.arg("invalid", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
228#[diag("invalid comparison operator `{$invalid}`")]
229pub(crate) struct InvalidComparisonOperator {
230 #[primary_span]
231 pub span: Span,
232 pub invalid: String,
233 #[subdiagnostic]
234 pub sub: InvalidComparisonOperatorSub,
235}
236
237#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidComparisonOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidComparisonOperatorSub::Correctable {
span: __binding_0,
invalid: __binding_1,
correct: __binding_2 } => {
let __code_15 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("invalid".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("correct".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$invalid}` is not a valid comparison operator, use `{$correct}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_15, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidComparisonOperatorSub::Spaceship(__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("`<=>` is not a valid comparison operator, use `std::cmp::Ordering`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
238pub(crate) enum InvalidComparisonOperatorSub {
239 #[suggestion(
240 "`{$invalid}` is not a valid comparison operator, use `{$correct}`",
241 style = "verbose",
242 applicability = "machine-applicable",
243 code = "{correct}"
244 )]
245 Correctable {
246 #[primary_span]
247 span: Span,
248 invalid: String,
249 correct: String,
250 },
251 #[label("`<=>` is not a valid comparison operator, use `std::cmp::Ordering`")]
252 Spaceship(#[primary_span] Span),
253}
254
255#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidLogicalOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidLogicalOperator {
span: __binding_0, incorrect: __binding_1, sub: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$incorrect}` is not a logical operator")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators")));
;
diag.arg("incorrect", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
256#[diag("`{$incorrect}` is not a logical operator")]
257#[note("unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators")]
258pub(crate) struct InvalidLogicalOperator {
259 #[primary_span]
260 pub span: Span,
261 pub incorrect: String,
262 #[subdiagnostic]
263 pub sub: InvalidLogicalOperatorSub,
264}
265
266#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidLogicalOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidLogicalOperatorSub::Conjunction(__binding_0) => {
let __code_16 =
[::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("use `&&` to perform logical conjunction")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidLogicalOperatorSub::Disjunction(__binding_0) => {
let __code_17 =
[::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("use `||` to perform logical disjunction")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
267pub(crate) enum InvalidLogicalOperatorSub {
268 #[suggestion(
269 "use `&&` to perform logical conjunction",
270 style = "verbose",
271 applicability = "machine-applicable",
272 code = "&&"
273 )]
274 Conjunction(#[primary_span] Span),
275 #[suggestion(
276 "use `||` to perform logical disjunction",
277 style = "verbose",
278 applicability = "machine-applicable",
279 code = "||"
280 )]
281 Disjunction(#[primary_span] Span),
282}
283
284#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TildeAsUnaryOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TildeAsUnaryOperator(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`~` cannot be used as a unary operator")));
let __code_18 =
[::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("use `!` to perform bitwise not")),
__code_18, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
285#[diag("`~` cannot be used as a unary operator")]
286pub(crate) struct TildeAsUnaryOperator(
287 #[primary_span]
288 #[suggestion(
289 "use `!` to perform bitwise not",
290 style = "verbose",
291 applicability = "machine-applicable",
292 code = "!"
293 )]
294 pub Span,
295);
296
297#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NotAsNegationOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NotAsNegationOperator {
negated: __binding_0,
negated_desc: __binding_1,
sub: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected {$negated_desc} after identifier")));
;
diag.arg("negated_desc", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
298#[diag("unexpected {$negated_desc} after identifier")]
299pub(crate) struct NotAsNegationOperator {
300 #[primary_span]
301 pub negated: Span,
302 pub negated_desc: String,
303 #[subdiagnostic]
304 pub sub: NotAsNegationOperatorSub,
305}
306
307#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NotAsNegationOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NotAsNegationOperatorSub::SuggestNotDefault(__binding_0) =>
{
let __code_19 =
[::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("use `!` to perform logical negation or bitwise not")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_19, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
NotAsNegationOperatorSub::SuggestNotBitwise(__binding_0) =>
{
let __code_20 =
[::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("use `!` to perform bitwise not")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_20, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
NotAsNegationOperatorSub::SuggestNotLogical(__binding_0) =>
{
let __code_21 =
[::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("use `!` to perform logical negation")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_21, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
308pub(crate) enum NotAsNegationOperatorSub {
309 #[suggestion(
310 "use `!` to perform logical negation or bitwise not",
311 style = "verbose",
312 applicability = "machine-applicable",
313 code = "!"
314 )]
315 SuggestNotDefault(#[primary_span] Span),
316
317 #[suggestion(
318 "use `!` to perform bitwise not",
319 style = "verbose",
320 applicability = "machine-applicable",
321 code = "!"
322 )]
323 SuggestNotBitwise(#[primary_span] Span),
324
325 #[suggestion(
326 "use `!` to perform logical negation",
327 style = "verbose",
328 applicability = "machine-applicable",
329 code = "!"
330 )]
331 SuggestNotLogical(#[primary_span] Span),
332}
333
334#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedLoopLabel where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedLoopLabel {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed loop label")));
let __code_22 =
[::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("use the correct loop label format")),
__code_22, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
335#[diag("malformed loop label")]
336pub(crate) struct MalformedLoopLabel {
337 #[primary_span]
338 pub span: Span,
339 #[suggestion(
340 "use the correct loop label format",
341 applicability = "machine-applicable",
342 code = "'",
343 style = "verbose"
344 )]
345 pub suggestion: Span,
346}
347
348#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeInBorrowExpression where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeInBorrowExpression {
span: __binding_0, lifetime_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow expressions cannot be annotated with lifetimes")));
let __code_23 =
[::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 lifetime annotation")),
__code_23, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("annotated with lifetime here")));
diag
}
}
}
}
};Diagnostic)]
349#[diag("borrow expressions cannot be annotated with lifetimes")]
350pub(crate) struct LifetimeInBorrowExpression {
351 #[primary_span]
352 pub span: Span,
353 #[suggestion(
354 "remove the lifetime annotation",
355 applicability = "machine-applicable",
356 code = "",
357 style = "verbose"
358 )]
359 #[label("annotated with lifetime here")]
360 pub lifetime_span: Span,
361}
362
363#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FieldExpressionWithGeneric where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FieldExpressionWithGeneric(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field expressions cannot have generic arguments")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
364#[diag("field expressions cannot have generic arguments")]
365pub(crate) struct FieldExpressionWithGeneric(#[primary_span] pub Span);
366
367#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroInvocationWithQualifiedPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroInvocationWithQualifiedPath(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot use qualified paths")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
368#[diag("macros cannot use qualified paths")]
369pub(crate) struct MacroInvocationWithQualifiedPath(#[primary_span] pub Span);
370
371#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterLabel where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterLabel {
span: __binding_0,
remove_label: __binding_1,
enclose_in_block: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `while`, `for`, `loop` or `{\"{\"}` after a label")));
let __code_24 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `while`, `for`, `loop` or `{\"{\"}` after a label")));
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the label")),
__code_24, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
372#[diag("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
373pub(crate) struct UnexpectedTokenAfterLabel {
374 #[primary_span]
375 #[label("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
376 pub span: Span,
377 #[suggestion("consider removing the label", style = "verbose", code = "")]
378 pub remove_label: Option<Span>,
379 #[subdiagnostic]
380 pub enclose_in_block: Option<UnexpectedTokenAfterLabelSugg>,
381}
382
383#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedTokenAfterLabelSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedTokenAfterLabelSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_25 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_26 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_25));
suggestions.push((__binding_1, __code_26));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider enclosing expression in a block")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
384#[multipart_suggestion(
385 "consider enclosing expression in a block",
386 applicability = "machine-applicable"
387)]
388pub(crate) struct UnexpectedTokenAfterLabelSugg {
389 #[suggestion_part(code = "{{ ")]
390 pub left: Span,
391 #[suggestion_part(code = " }}")]
392 pub right: Span,
393}
394
395#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RequireColonAfterLabeledExpression where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RequireColonAfterLabeledExpression {
span: __binding_0,
label: __binding_1,
label_end: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled expression must be followed by `:`")));
let __code_27 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": "))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labels are used before loops and blocks, allowing e.g., `break 'label` to them")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label")));
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `:` after the label")),
__code_27, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
396#[diag("labeled expression must be followed by `:`")]
397#[note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")]
398pub(crate) struct RequireColonAfterLabeledExpression {
399 #[primary_span]
400 pub span: Span,
401 #[label("the label")]
402 pub label: Span,
403 #[suggestion(
404 "add `:` after the label",
405 style = "verbose",
406 applicability = "machine-applicable",
407 code = ": "
408 )]
409 pub label_end: Span,
410}
411
412#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DoCatchSyntaxRemoved where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DoCatchSyntaxRemoved { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found removed `do catch` syntax")));
let __code_28 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("try"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("following RFC #2388, the new non-placeholder syntax is `try`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace with the new syntax")),
__code_28, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
413#[diag("found removed `do catch` syntax")]
414#[note("following RFC #2388, the new non-placeholder syntax is `try`")]
415pub(crate) struct DoCatchSyntaxRemoved {
416 #[primary_span]
417 #[suggestion(
418 "replace with the new syntax",
419 applicability = "machine-applicable",
420 code = "try",
421 style = "verbose"
422 )]
423 pub span: Span,
424}
425
426#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FloatLiteralRequiresIntegerPart where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FloatLiteralRequiresIntegerPart {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("float literals must have an integer part")));
let __code_29 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("0"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must have an integer part")),
__code_29, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
427#[diag("float literals must have an integer part")]
428pub(crate) struct FloatLiteralRequiresIntegerPart {
429 #[primary_span]
430 pub span: Span,
431 #[suggestion(
432 "must have an integer part",
433 applicability = "machine-applicable",
434 code = "0",
435 style = "verbose"
436 )]
437 pub suggestion: Span,
438}
439
440#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingSemicolonBeforeArray where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingSemicolonBeforeArray {
open_delim: __binding_0, semicolon: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found `[`")));
let __code_30 =
[::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("consider adding `;` here")),
__code_30, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
441#[diag("expected `;`, found `[`")]
442pub(crate) struct MissingSemicolonBeforeArray {
443 #[primary_span]
444 pub open_delim: Span,
445 #[suggestion(
446 "consider adding `;` here",
447 style = "verbose",
448 applicability = "maybe-incorrect",
449 code = ";"
450 )]
451 pub semicolon: Span,
452}
453
454#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingDotDot
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingDotDot {
token_span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `..`, found `...`")));
let __code_31 =
[::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("use `..` to fill in the rest of the fields")),
__code_31, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
455#[diag("expected `..`, found `...`")]
456pub(crate) struct MissingDotDot {
457 #[primary_span]
458 pub token_span: Span,
459 #[suggestion(
460 "use `..` to fill in the rest of the fields",
461 applicability = "maybe-incorrect",
462 code = "..",
463 style = "verbose"
464 )]
465 pub sugg_span: Span,
466}
467
468#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidBlockMacroSegment where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidBlockMacroSegment {
span: __binding_0, context: __binding_1, wrap: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use a `block` macro fragment here")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `block` fragment is within this context")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
469#[diag("cannot use a `block` macro fragment here")]
470pub(crate) struct InvalidBlockMacroSegment {
471 #[primary_span]
472 pub span: Span,
473 #[label("the `block` fragment is within this context")]
474 pub context: Span,
475 #[subdiagnostic]
476 pub wrap: WrapInExplicitBlock,
477}
478
479#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInExplicitBlock {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInExplicitBlock { lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_32 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_33 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_32));
suggestions.push((__binding_1, __code_33));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap this in another block")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
480#[multipart_suggestion("wrap this in another block", applicability = "machine-applicable")]
481pub(crate) struct WrapInExplicitBlock {
482 #[suggestion_part(code = "{{ ")]
483 pub lo: Span,
484 #[suggestion_part(code = " }}")]
485 pub hi: Span,
486}
487
488#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IfExpressionMissingThenBlock where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IfExpressionMissingThenBlock {
if_span: __binding_0,
missing_then_block_sub: __binding_1,
let_else_sub: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `if` expression is missing a block after the condition")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
489#[diag("this `if` expression is missing a block after the condition")]
490pub(crate) struct IfExpressionMissingThenBlock {
491 #[primary_span]
492 pub if_span: Span,
493 #[subdiagnostic]
494 pub missing_then_block_sub: IfExpressionMissingThenBlockSub,
495 #[subdiagnostic]
496 pub let_else_sub: Option<IfExpressionLetSomeSub>,
497}
498
499#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IfExpressionMissingThenBlockSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IfExpressionMissingThenBlockSub::UnfinishedCondition(__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 binary operation is possibly unfinished")),
&sub_args);
diag.span_help(__binding_0, __message);
}
IfExpressionMissingThenBlockSub::AddThenBlock(__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("add a block here")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
500pub(crate) enum IfExpressionMissingThenBlockSub {
501 #[help("this binary operation is possibly unfinished")]
502 UnfinishedCondition(#[primary_span] Span),
503 #[help("add a block here")]
504 AddThenBlock(#[primary_span] Span),
505}
506
507#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TernaryOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TernaryOperator {
span: __binding_0, sugg: __binding_1, no_sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("Rust has no ternary operator")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an `if-else` expression instead")));
}
diag
}
}
}
}
};Diagnostic)]
508#[diag("Rust has no ternary operator")]
509pub(crate) struct TernaryOperator {
510 #[primary_span]
511 pub span: Span,
512 #[subdiagnostic]
514 pub sugg: Option<TernaryOperatorSuggestion>,
515 #[help("use an `if-else` expression instead")]
517 pub no_sugg: bool,
518}
519
520#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TernaryOperatorSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TernaryOperatorSuggestion {
before_cond: __binding_0,
question: __binding_1,
colon: __binding_2,
end: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_34 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_35 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_36 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("}} else {{"))
});
let __code_37 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_34));
suggestions.push((__binding_1, __code_35));
suggestions.push((__binding_2, __code_36));
suggestions.push((__binding_3, __code_37));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an `if-else` expression instead")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::marker::Copy for TernaryOperatorSuggestion { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TernaryOperatorSuggestion {
#[inline]
fn clone(&self) -> TernaryOperatorSuggestion {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone)]
521#[multipart_suggestion(
522 "use an `if-else` expression instead",
523 applicability = "maybe-incorrect",
524 style = "verbose"
525)]
526pub(crate) struct TernaryOperatorSuggestion {
527 #[suggestion_part(code = "if ")]
528 pub before_cond: Span,
529 #[suggestion_part(code = "{{")]
530 pub question: Span,
531 #[suggestion_part(code = "}} else {{")]
532 pub colon: Span,
533 #[suggestion_part(code = " }}")]
534 pub end: Span,
535}
536
537#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IfExpressionLetSomeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IfExpressionLetSomeSub { if_span: __binding_0 } => {
let __code_38 =
[::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 the `if` if you meant to write a `let...else` statement")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_38, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
538#[suggestion(
539 "remove the `if` if you meant to write a `let...else` statement",
540 applicability = "maybe-incorrect",
541 code = "",
542 style = "verbose"
543)]
544pub(crate) struct IfExpressionLetSomeSub {
545 #[primary_span]
546 pub if_span: Span,
547}
548
549#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IfExpressionMissingCondition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IfExpressionMissingCondition {
if_span: __binding_0, block_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing condition for `if` expression")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected condition here")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if this block is the condition of the `if` expression, then it must be followed by another block")));
diag
}
}
}
}
};Diagnostic)]
550#[diag("missing condition for `if` expression")]
551pub(crate) struct IfExpressionMissingCondition {
552 #[primary_span]
553 #[label("expected condition here")]
554 pub if_span: Span,
555 #[label(
556 "if this block is the condition of the `if` expression, then it must be followed by another block"
557 )]
558 pub block_span: Span,
559}
560
561#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedExpressionFoundLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedExpressionFoundLet {
span: __binding_0,
reason: __binding_1,
missing_let: __binding_2,
comparison: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression, found `let` statement")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only supported directly in conditions of `if` and `while` expressions")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
562#[diag("expected expression, found `let` statement")]
563#[note("only supported directly in conditions of `if` and `while` expressions")]
564pub(crate) struct ExpectedExpressionFoundLet {
565 #[primary_span]
566 pub span: Span,
567 #[subdiagnostic]
568 pub reason: ForbiddenLetReason,
569 #[subdiagnostic]
570 pub missing_let: Option<MaybeMissingLet>,
571 #[subdiagnostic]
572 pub comparison: Option<MaybeComparison>,
573}
574
575#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LetChainMissingLet where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LetChainMissingLet {
span: __binding_0,
label_span: __binding_1,
rhs_span: __binding_2,
sug_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let-chain with missing `let`")));
let __code_39 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `let` expression, found assignment")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let expression later in the condition")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `let` before the expression")),
__code_39, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
576#[diag("let-chain with missing `let`")]
577pub(crate) struct LetChainMissingLet {
578 #[primary_span]
579 pub span: Span,
580 #[label("expected `let` expression, found assignment")]
581 pub label_span: Span,
582 #[label("let expression later in the condition")]
583 pub rhs_span: Span,
584 #[suggestion(
585 "add `let` before the expression",
586 applicability = "maybe-incorrect",
587 code = "let ",
588 style = "verbose"
589 )]
590 pub sug_span: Span,
591}
592
593#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for OrInLetChain
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OrInLetChain { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`||` operators are not supported in let chain conditions")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
594#[diag("`||` operators are not supported in let chain conditions")]
595pub(crate) struct OrInLetChain {
596 #[primary_span]
597 pub span: Span,
598}
599
600#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeMissingLet {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MaybeMissingLet { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_40 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
});
suggestions.push((__binding_0, __code_40));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to continue the let-chain")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::clone::Clone for MaybeMissingLet {
#[inline]
fn clone(&self) -> MaybeMissingLet {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeMissingLet { }Copy)]
601#[multipart_suggestion(
602 "you might have meant to continue the let-chain",
603 applicability = "maybe-incorrect",
604 style = "verbose"
605)]
606pub(crate) struct MaybeMissingLet {
607 #[suggestion_part(code = "let ")]
608 pub span: Span,
609}
610
611#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeComparison {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MaybeComparison { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_41 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
});
suggestions.push((__binding_0, __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("you might have meant to compare for equality")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::clone::Clone for MaybeComparison {
#[inline]
fn clone(&self) -> MaybeComparison {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeComparison { }Copy)]
612#[multipart_suggestion(
613 "you might have meant to compare for equality",
614 applicability = "maybe-incorrect",
615 style = "verbose"
616)]
617pub(crate) struct MaybeComparison {
618 #[suggestion_part(code = "=")]
619 pub span: Span,
620}
621
622#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedEqForLetExpr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedEqForLetExpr {
span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `=`, found `==`")));
let __code_42 =
[::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("consider using `=` here")),
__code_42, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
623#[diag("expected `=`, found `==`")]
624pub(crate) struct ExpectedEqForLetExpr {
625 #[primary_span]
626 pub span: Span,
627 #[suggestion(
628 "consider using `=` here",
629 applicability = "maybe-incorrect",
630 code = "=",
631 style = "verbose"
632 )]
633 pub sugg_span: Span,
634}
635
636#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedElseBlock where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedElseBlock {
first_tok_span: __binding_0,
first_tok: __binding_1,
else_span: __binding_2,
condition_start: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{\"{\"}`, found {$first_tok}")));
let __code_43 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
})].into_iter();
;
diag.arg("first_tok", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an `if` or a block after this `else`")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add an `if` if this is the condition of a chained `else if` statement")),
__code_43, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
637#[diag("expected `{\"{\"}`, found {$first_tok}")]
638pub(crate) struct ExpectedElseBlock {
639 #[primary_span]
640 pub first_tok_span: Span,
641 pub first_tok: String,
642 #[label("expected an `if` or a block after this `else`")]
643 pub else_span: Span,
644 #[suggestion(
645 "add an `if` if this is the condition of a chained `else if` statement",
646 applicability = "maybe-incorrect",
647 code = "if ",
648 style = "verbose"
649 )]
650 pub condition_start: Span,
651}
652
653#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedStructField where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedStructField {
span: __binding_0,
token: __binding_1,
ident_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected one of `,`, `:`, or `{\"}\"}`, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected one of `,`, `:`, or `{\"}\"}`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this struct field")));
diag
}
}
}
}
};Diagnostic)]
654#[diag("expected one of `,`, `:`, or `{\"}\"}`, found `{$token}`")]
655pub(crate) struct ExpectedStructField {
656 #[primary_span]
657 #[label("expected one of `,`, `:`, or `{\"}\"}`")]
658 pub span: Span,
659 pub token: Cow<'static, str>,
660 #[label("while parsing this struct field")]
661 pub ident_span: Span,
662}
663
664#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OuterAttributeNotAllowedOnIfElse where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OuterAttributeNotAllowedOnIfElse {
last: __binding_0,
branch_span: __binding_1,
ctx_span: __binding_2,
ctx: __binding_3,
attributes: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("outer attributes are not allowed on `if` and `else` branches")));
let __code_44 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("ctx", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the attributes are attached to this branch")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the branch belongs to this `{$ctx}`")));
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attributes")),
__code_44, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
665#[diag("outer attributes are not allowed on `if` and `else` branches")]
666pub(crate) struct OuterAttributeNotAllowedOnIfElse {
667 #[primary_span]
668 pub last: Span,
669
670 #[label("the attributes are attached to this branch")]
671 pub branch_span: Span,
672
673 #[label("the branch belongs to this `{$ctx}`")]
674 pub ctx_span: Span,
675 pub ctx: String,
676
677 #[suggestion(
678 "remove the attributes",
679 applicability = "machine-applicable",
680 code = "",
681 style = "verbose"
682 )]
683 pub attributes: Span,
684}
685
686#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingInInForLoop where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingInInForLoop { span: __binding_0, sub: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `in` in `for` loop")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
687#[diag("missing `in` in `for` loop")]
688pub(crate) struct MissingInInForLoop {
689 #[primary_span]
690 pub span: Span,
691 #[subdiagnostic]
692 pub sub: MissingInInForLoopSub,
693}
694
695#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingInInForLoopSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MissingInInForLoopSub::InNotOf(__binding_0) => {
let __code_45 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `in` here instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_45, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MissingInInForLoopSub::InNotEq(__binding_0) => {
let __code_46 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `in` here instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_46, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MissingInInForLoopSub::AddIn(__binding_0) => {
let __code_47 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" in "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding `in` here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_47, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
696pub(crate) enum MissingInInForLoopSub {
697 #[suggestion(
700 "try using `in` here instead",
701 style = "verbose",
702 applicability = "maybe-incorrect",
703 code = "in"
704 )]
705 InNotOf(#[primary_span] Span),
706 #[suggestion(
708 "try using `in` here instead",
709 style = "verbose",
710 applicability = "maybe-incorrect",
711 code = "in"
712 )]
713 InNotEq(#[primary_span] Span),
714 #[suggestion(
715 "try adding `in` here",
716 style = "verbose",
717 applicability = "maybe-incorrect",
718 code = " in "
719 )]
720 AddIn(#[primary_span] Span),
721}
722
723#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingExpressionInForLoop where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingExpressionInForLoop { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing expression to iterate on in `for` loop")));
let __code_48 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* expression */ "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding an expression to the `for` loop")),
__code_48, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
724#[diag("missing expression to iterate on in `for` loop")]
725pub(crate) struct MissingExpressionInForLoop {
726 #[primary_span]
727 #[suggestion(
728 "try adding an expression to the `for` loop",
729 code = "/* expression */ ",
730 applicability = "has-placeholders",
731 style = "verbose"
732 )]
733 pub span: Span,
734}
735
736#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopElseNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopElseNotSupported {
span: __binding_0,
loop_kind: __binding_1,
loop_kw: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$loop_kind}...else` loops are not supported")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run")));
;
diag.arg("loop_kind", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`else` is attached to this loop")));
diag
}
}
}
}
};Diagnostic)]
737#[diag("`{$loop_kind}...else` loops are not supported")]
738#[note(
739 "consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run"
740)]
741pub(crate) struct LoopElseNotSupported {
742 #[primary_span]
743 pub span: Span,
744 pub loop_kind: &'static str,
745 #[label("`else` is attached to this loop")]
746 pub loop_kw: Span,
747}
748
749#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingCommaAfterMatchArm where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingCommaAfterMatchArm { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,` following `match` arm")));
let __code_49 =
[::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("missing a comma here to end this `match` arm")),
__code_49, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
750#[diag("expected `,` following `match` arm")]
751pub(crate) struct MissingCommaAfterMatchArm {
752 #[primary_span]
753 #[suggestion(
754 "missing a comma here to end this `match` arm",
755 applicability = "machine-applicable",
756 code = ",",
757 style = "verbose"
758 )]
759 pub span: Span,
760}
761
762#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CatchAfterTry
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CatchAfterTry { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("keyword `catch` cannot follow a `try` block")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `match` on the result of the `try` block instead")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
763#[diag("keyword `catch` cannot follow a `try` block")]
764#[help("try using `match` on the result of the `try` block instead")]
765pub(crate) struct CatchAfterTry {
766 #[primary_span]
767 pub span: Span,
768}
769
770#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CommaAfterBaseStruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CommaAfterBaseStruct { span: __binding_0, comma: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use a comma after the base struct")));
let __code_50 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the base struct must always be the last field")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this comma")),
__code_50, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
771#[diag("cannot use a comma after the base struct")]
772#[note("the base struct must always be the last field")]
773pub(crate) struct CommaAfterBaseStruct {
774 #[primary_span]
775 pub span: Span,
776 #[suggestion(
777 "remove this comma",
778 style = "verbose",
779 applicability = "machine-applicable",
780 code = ""
781 )]
782 pub comma: Span,
783}
784
785#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for EqFieldInit
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EqFieldInit { span: __binding_0, eq: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `:`, found `=`")));
let __code_51 =
[::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("replace equals symbol with a colon")),
__code_51, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
786#[diag("expected `:`, found `=`")]
787pub(crate) struct EqFieldInit {
788 #[primary_span]
789 pub span: Span,
790 #[suggestion(
791 "replace equals symbol with a colon",
792 applicability = "machine-applicable",
793 code = ":",
794 style = "verbose"
795 )]
796 pub eq: Span,
797}
798
799#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DotDotDot
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDot { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: `...`")));
let __code_52 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
let __code_53 =
[::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("use `..` for an exclusive range")),
__code_52, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or `..=` for an inclusive range")),
__code_53, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
800#[diag("unexpected token: `...`")]
801pub(crate) struct DotDotDot {
802 #[primary_span]
803 #[suggestion(
804 "use `..` for an exclusive range",
805 applicability = "maybe-incorrect",
806 code = "..",
807 style = "verbose"
808 )]
809 #[suggestion(
810 "or `..=` for an inclusive range",
811 applicability = "maybe-incorrect",
812 code = "..=",
813 style = "verbose"
814 )]
815 pub span: Span,
816}
817
818#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LeftArrowOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LeftArrowOperator { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: `<-`")));
let __code_54 =
[::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("if you meant to write a comparison against a negative value, add a space in between `<` and `-`")),
__code_54, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
819#[diag("unexpected token: `<-`")]
820pub(crate) struct LeftArrowOperator {
821 #[primary_span]
822 #[suggestion(
823 "if you meant to write a comparison against a negative value, add a space in between `<` and `-`",
824 applicability = "maybe-incorrect",
825 code = "< -",
826 style = "verbose"
827 )]
828 pub span: Span,
829}
830
831#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for RemoveLet
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RemoveLet { span: __binding_0, suggestion: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected pattern, found `let`")));
let __code_55 =
[::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 unnecessary `let` keyword")),
__code_55, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
832#[diag("expected pattern, found `let`")]
833pub(crate) struct RemoveLet {
834 #[primary_span]
835 pub span: Span,
836 #[suggestion(
837 "remove the unnecessary `let` keyword",
838 applicability = "machine-applicable",
839 code = "",
840 style = "verbose"
841 )]
842 pub suggestion: Span,
843}
844
845#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UseEqInstead
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseEqInstead { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `==`")));
let __code_56 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `=` instead")),
__code_56, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
846#[diag("unexpected `==`")]
847pub(crate) struct UseEqInstead {
848 #[primary_span]
849 #[suggestion(
850 "try using `=` instead",
851 style = "verbose",
852 applicability = "machine-applicable",
853 code = "="
854 )]
855 pub span: Span,
856}
857
858#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseEmptyBlockNotSemi where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseEmptyBlockNotSemi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected { \"`{}`\" }, found `;`")));
let __code_57 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{}}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using { \"`{}`\" } instead")),
__code_57, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeAlways);
diag
}
}
}
}
};Diagnostic)]
859#[diag("expected { \"`{}`\" }, found `;`")]
860pub(crate) struct UseEmptyBlockNotSemi {
861 #[primary_span]
862 #[suggestion(
863 r#"try using { "`{}`" } instead"#,
864 style = "hidden",
865 applicability = "machine-applicable",
866 code = "{{}}"
867 )]
868 pub span: Span,
869}
870
871#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ComparisonInterpretedAsGeneric where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ComparisonInterpretedAsGeneric {
comparison: __binding_0,
r#type: __binding_1,
args: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`<` is interpreted as a start of generic arguments for `{$type}`, not a comparison")));
;
diag.arg("type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not interpreted as comparison")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as generic arguments")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
872#[diag("`<` is interpreted as a start of generic arguments for `{$type}`, not a comparison")]
873pub(crate) struct ComparisonInterpretedAsGeneric {
874 #[primary_span]
875 #[label("not interpreted as comparison")]
876 pub comparison: Span,
877 pub r#type: String,
878 #[label("interpreted as generic arguments")]
879 pub args: Span,
880 #[subdiagnostic]
881 pub suggestion: ComparisonInterpretedAsGenericSugg,
882}
883
884#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ComparisonInterpretedAsGenericSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ComparisonInterpretedAsGenericSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_58 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_59 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_58));
suggestions.push((__binding_1, __code_59));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try comparing the cast value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
885#[multipart_suggestion("try comparing the cast value", applicability = "machine-applicable")]
886pub(crate) struct ComparisonInterpretedAsGenericSugg {
887 #[suggestion_part(code = "(")]
888 pub left: Span,
889 #[suggestion_part(code = ")")]
890 pub right: Span,
891}
892
893#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ShiftInterpretedAsGeneric where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ShiftInterpretedAsGeneric {
shift: __binding_0,
r#type: __binding_1,
args: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`<<` is interpreted as a start of generic arguments for `{$type}`, not a shift")));
;
diag.arg("type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not interpreted as shift")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as generic arguments")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
894#[diag("`<<` is interpreted as a start of generic arguments for `{$type}`, not a shift")]
895pub(crate) struct ShiftInterpretedAsGeneric {
896 #[primary_span]
897 #[label("not interpreted as shift")]
898 pub shift: Span,
899 pub r#type: String,
900 #[label("interpreted as generic arguments")]
901 pub args: Span,
902 #[subdiagnostic]
903 pub suggestion: ShiftInterpretedAsGenericSugg,
904}
905
906#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ShiftInterpretedAsGenericSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ShiftInterpretedAsGenericSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_60 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_61 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_60));
suggestions.push((__binding_1, __code_61));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try shifting the cast value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
907#[multipart_suggestion("try shifting the cast value", applicability = "machine-applicable")]
908pub(crate) struct ShiftInterpretedAsGenericSugg {
909 #[suggestion_part(code = "(")]
910 pub left: Span,
911 #[suggestion_part(code = ")")]
912 pub right: Span,
913}
914
915#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FoundExprWouldBeStmt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FoundExprWouldBeStmt {
span: __binding_0,
token: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
916#[diag("expected expression, found `{$token}`")]
917pub(crate) struct FoundExprWouldBeStmt {
918 #[primary_span]
919 #[label("expected expression")]
920 pub span: Span,
921 pub token: Cow<'static, str>,
922 #[subdiagnostic]
923 pub suggestion: ExprParenthesesNeeded,
924}
925
926#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterExtraCharactersAfterClose where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterExtraCharactersAfterClose { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extra characters after frontmatter close are not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
927#[diag("extra characters after frontmatter close are not allowed")]
928pub(crate) struct FrontmatterExtraCharactersAfterClose {
929 #[primary_span]
930 pub span: Span,
931}
932
933#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidInfostring where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidInfostring { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid infostring for frontmatter")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter infostrings must be a single identifier immediately following the opening")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
934#[diag("invalid infostring for frontmatter")]
935#[note("frontmatter infostrings must be a single identifier immediately following the opening")]
936pub(crate) struct FrontmatterInvalidInfostring {
937 #[primary_span]
938 pub span: Span,
939}
940
941#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidOpeningPrecedingWhitespace where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidOpeningPrecedingWhitespace {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid preceding whitespace for frontmatter opening")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter opening should not be preceded by whitespace")));
diag
}
}
}
}
};Diagnostic)]
942#[diag("invalid preceding whitespace for frontmatter opening")]
943pub(crate) struct FrontmatterInvalidOpeningPrecedingWhitespace {
944 #[primary_span]
945 pub span: Span,
946 #[note("frontmatter opening should not be preceded by whitespace")]
947 pub note_span: Span,
948}
949
950#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterUnclosed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterUnclosed {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unclosed frontmatter")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter opening here was not closed")));
diag
}
}
}
}
};Diagnostic)]
951#[diag("unclosed frontmatter")]
952pub(crate) struct FrontmatterUnclosed {
953 #[primary_span]
954 pub span: Span,
955 #[note("frontmatter opening here was not closed")]
956 pub note_span: Span,
957}
958
959#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidClosingPrecedingWhitespace where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidClosingPrecedingWhitespace {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid preceding whitespace for frontmatter close")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter close should not be preceded by whitespace")));
diag
}
}
}
}
};Diagnostic)]
960#[diag("invalid preceding whitespace for frontmatter close")]
961pub(crate) struct FrontmatterInvalidClosingPrecedingWhitespace {
962 #[primary_span]
963 pub span: Span,
964 #[note("frontmatter close should not be preceded by whitespace")]
965 pub note_span: Span,
966}
967
968#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterLengthMismatch where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterLengthMismatch {
span: __binding_0,
opening: __binding_1,
close: __binding_2,
len_opening: __binding_3,
len_close: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter close does not match the opening")));
;
diag.arg("len_opening", __binding_3);
diag.arg("len_close", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the opening here has {$len_opening} dashes...")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...while the close has {$len_close} dashes")));
diag
}
}
}
}
};Diagnostic)]
969#[diag("frontmatter close does not match the opening")]
970pub(crate) struct FrontmatterLengthMismatch {
971 #[primary_span]
972 pub span: Span,
973 #[label("the opening here has {$len_opening} dashes...")]
974 pub opening: Span,
975 #[label("...while the close has {$len_close} dashes")]
976 pub close: Span,
977 pub len_opening: usize,
978 pub len_close: usize,
979}
980
981#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterTooManyDashes where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterTooManyDashes { len_opening: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("too many `-` symbols: frontmatter openings may be delimited by up to 255 `-` symbols, but found {$len_opening}")));
;
diag.arg("len_opening", __binding_0);
diag
}
}
}
}
};Diagnostic)]
982#[diag(
983 "too many `-` symbols: frontmatter openings may be delimited by up to 255 `-` symbols, but found {$len_opening}"
984)]
985pub(crate) struct FrontmatterTooManyDashes {
986 pub len_opening: usize,
987}
988
989#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BareCrFrontmatter where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BareCrFrontmatter { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in frontmatter")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
990#[diag("bare CR not allowed in frontmatter")]
991pub(crate) struct BareCrFrontmatter {
992 #[primary_span]
993 pub span: Span,
994}
995
996#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LeadingPlusNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LeadingPlusNotSupported {
span: __binding_0,
remove_plus: __binding_1,
add_parentheses: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("leading `+` is not supported")));
let __code_62 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `+`")));
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try removing the `+`")),
__code_62, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
997#[diag("leading `+` is not supported")]
998pub(crate) struct LeadingPlusNotSupported {
999 #[primary_span]
1000 #[label("unexpected `+`")]
1001 pub span: Span,
1002 #[suggestion(
1003 "try removing the `+`",
1004 style = "verbose",
1005 code = "",
1006 applicability = "machine-applicable"
1007 )]
1008 pub remove_plus: Option<Span>,
1009 #[subdiagnostic]
1010 pub add_parentheses: Option<ExprParenthesesNeeded>,
1011}
1012
1013#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesWithStructFields where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesWithStructFields {
span: __binding_0,
braces_for_struct: __binding_1,
no_fields_for_fn: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `struct` delimiters or `fn` call arguments")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1014#[diag("invalid `struct` delimiters or `fn` call arguments")]
1015pub(crate) struct ParenthesesWithStructFields {
1016 #[primary_span]
1017 pub span: Span,
1018 #[subdiagnostic]
1019 pub braces_for_struct: BracesForStructLiteral,
1020 #[subdiagnostic]
1021 pub no_fields_for_fn: NoFieldsForFnCall,
1022}
1023
1024#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BracesForStructLiteral {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BracesForStructLiteral {
r#type: __binding_0, first: __binding_1, second: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_63 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ "))
});
let __code_64 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_1, __code_63));
suggestions.push((__binding_2, __code_64));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("type".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$type}` is a struct, use braces as delimiters")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1025#[multipart_suggestion(
1026 "if `{$type}` is a struct, use braces as delimiters",
1027 applicability = "maybe-incorrect"
1028)]
1029pub(crate) struct BracesForStructLiteral {
1030 pub r#type: String,
1031 #[suggestion_part(code = " {{ ")]
1032 pub first: Span,
1033 #[suggestion_part(code = " }}")]
1034 pub second: Span,
1035}
1036
1037#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NoFieldsForFnCall {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoFieldsForFnCall { r#type: __binding_0, fields: __binding_1
} => {
let mut suggestions = Vec::new();
let __code_65 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_1 in __binding_1 {
suggestions.push((__binding_1, __code_65.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("type".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$type}` is a function, use the arguments directly")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1038#[multipart_suggestion(
1039 "if `{$type}` is a function, use the arguments directly",
1040 applicability = "maybe-incorrect"
1041)]
1042pub(crate) struct NoFieldsForFnCall {
1043 pub r#type: String,
1044 #[suggestion_part(code = "")]
1045 pub fields: Vec<Span>,
1046}
1047
1048#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LabeledLoopInBreak where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LabeledLoopInBreak { span: __binding_0, sub: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parentheses are required around this expression to avoid confusion with a labeled break expression")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1049#[diag(
1050 "parentheses are required around this expression to avoid confusion with a labeled break expression"
1051)]
1052pub(crate) struct LabeledLoopInBreak {
1053 #[primary_span]
1054 pub span: Span,
1055 #[subdiagnostic]
1056 pub sub: WrapInParentheses,
1057}
1058
1059#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInParentheses {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInParentheses::Expression {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_66 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_67 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_66));
suggestions.push((__binding_1, __code_67));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the expression in parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
WrapInParentheses::MacroArgs {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_68 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_69 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_68));
suggestions.push((__binding_1, __code_69));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use parentheses instead of braces for this macro")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1060pub(crate) enum WrapInParentheses {
1061 #[multipart_suggestion(
1062 "wrap the expression in parentheses",
1063 applicability = "machine-applicable"
1064 )]
1065 Expression {
1066 #[suggestion_part(code = "(")]
1067 left: Span,
1068 #[suggestion_part(code = ")")]
1069 right: Span,
1070 },
1071 #[multipart_suggestion(
1072 "use parentheses instead of braces for this macro",
1073 applicability = "machine-applicable"
1074 )]
1075 MacroArgs {
1076 #[suggestion_part(code = "(")]
1077 left: Span,
1078 #[suggestion_part(code = ")")]
1079 right: Span,
1080 },
1081}
1082
1083#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArrayBracketsInsteadOfBraces where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ArrayBracketsInsteadOfBraces {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a block expression, not an array")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1084#[diag("this is a block expression, not an array")]
1085pub(crate) struct ArrayBracketsInsteadOfBraces {
1086 #[primary_span]
1087 pub span: Span,
1088 #[subdiagnostic]
1089 pub sub: ArrayBracketsInsteadOfBracesSugg,
1090}
1091
1092#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ArrayBracketsInsteadOfBracesSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ArrayBracketsInsteadOfBracesSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_70 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("["))
});
let __code_71 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("]"))
});
suggestions.push((__binding_0, __code_70));
suggestions.push((__binding_1, __code_71));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to make an array, use square brackets instead of curly braces")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1093#[multipart_suggestion(
1094 "to make an array, use square brackets instead of curly braces",
1095 applicability = "maybe-incorrect"
1096)]
1097pub(crate) struct ArrayBracketsInsteadOfBracesSugg {
1098 #[suggestion_part(code = "[")]
1099 pub left: Span,
1100 #[suggestion_part(code = "]")]
1101 pub right: Span,
1102}
1103
1104#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MatchArmBodyWithoutBraces where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MatchArmBodyWithoutBraces {
statements: __binding_0,
arrow: __binding_1,
num_statements: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`match` arm body without braces")));
;
diag.arg("num_statements", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_statements ->\n [one] this statement is not surrounded by a body\n *[other] these statements are not surrounded by a body\n }")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing the `match` arm starting here")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1105#[diag("`match` arm body without braces")]
1106pub(crate) struct MatchArmBodyWithoutBraces {
1107 #[primary_span]
1108 #[label(
1109 "{$num_statements ->
1110 [one] this statement is not surrounded by a body
1111 *[other] these statements are not surrounded by a body
1112 }"
1113 )]
1114 pub statements: Span,
1115 #[label("while parsing the `match` arm starting here")]
1116 pub arrow: Span,
1117 pub num_statements: usize,
1118 #[subdiagnostic]
1119 pub sub: MatchArmBodyWithoutBracesSugg,
1120}
1121
1122#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeExtraEquals where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeExtraEquals { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `=` after inclusive range")));
let __code_72 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("..="))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive ranges end with a single equals sign (`..=`)")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` instead")),
__code_72, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1123#[diag("unexpected `=` after inclusive range")]
1124#[note("inclusive ranges end with a single equals sign (`..=`)")]
1125pub(crate) struct InclusiveRangeExtraEquals {
1126 #[primary_span]
1127 #[suggestion(
1128 "use `..=` instead",
1129 style = "verbose",
1130 code = "..=",
1131 applicability = "maybe-incorrect"
1132 )]
1133 pub span: Span,
1134}
1135
1136#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeMatchArrow where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeMatchArrow {
arrow: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `>` after inclusive range")));
let __code_73 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".. ="))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is parsed as an inclusive range `..=`")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a space between the pattern and `=>`")),
__code_73, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1137#[diag("unexpected `>` after inclusive range")]
1138pub(crate) struct InclusiveRangeMatchArrow {
1139 #[primary_span]
1140 pub arrow: Span,
1141 #[label("this is parsed as an inclusive range `..=`")]
1142 #[suggestion(
1143 "add a space between the pattern and `=>`",
1144 style = "verbose",
1145 code = ".. =",
1146 applicability = "machine-applicable"
1147 )]
1148 pub span: Span,
1149}
1150
1151#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeNoEnd where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeNoEnd { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive range with no end")));
let __code_74 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
diag.code(E0586);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..` instead")),
__code_74, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1152#[diag("inclusive range with no end", code = E0586)]
1153#[note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")]
1154pub(crate) struct InclusiveRangeNoEnd {
1155 #[primary_span]
1156 #[suggestion(
1157 "use `..` instead",
1158 code = "..",
1159 applicability = "machine-applicable",
1160 style = "verbose"
1161 )]
1162 pub span: Span,
1163}
1164
1165#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MatchArmBodyWithoutBracesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MatchArmBodyWithoutBracesSugg::AddBraces {
left: __binding_0,
right: __binding_1,
num_statements: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_75 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_76 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_75));
suggestions.push((__binding_1, __code_76));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("num_statements".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the {$num_statements ->\n [one] statement\n *[other] statements\n } with a body")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
MatchArmBodyWithoutBracesSugg::UseComma {
semicolon: __binding_0 } => {
let __code_77 =
[::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("replace `;` with `,` to end a `match` arm expression")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_77, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1166pub(crate) enum MatchArmBodyWithoutBracesSugg {
1167 #[multipart_suggestion(
1168 "surround the {$num_statements ->
1169 [one] statement
1170 *[other] statements
1171 } with a body",
1172 applicability = "machine-applicable"
1173 )]
1174 AddBraces {
1175 #[suggestion_part(code = "{{ ")]
1176 left: Span,
1177 #[suggestion_part(code = " }}")]
1178 right: Span,
1179 num_statements: usize,
1180 },
1181 #[suggestion(
1182 "replace `;` with `,` to end a `match` arm expression",
1183 code = ",",
1184 applicability = "machine-applicable",
1185 style = "verbose"
1186 )]
1187 UseComma {
1188 #[primary_span]
1189 semicolon: Span,
1190 },
1191}
1192
1193#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralNotAllowedHere where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralNotAllowedHere {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literals are not allowed here")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1194#[diag("struct literals are not allowed here")]
1195pub(crate) struct StructLiteralNotAllowedHere {
1196 #[primary_span]
1197 pub span: Span,
1198 #[subdiagnostic]
1199 pub sub: StructLiteralNotAllowedHereSugg,
1200}
1201
1202#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for StructLiteralNotAllowedHereSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
StructLiteralNotAllowedHereSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_78 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_79 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_78));
suggestions.push((__binding_1, __code_79));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the struct literal with parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1203#[multipart_suggestion(
1204 "surround the struct literal with parentheses",
1205 applicability = "machine-applicable"
1206)]
1207pub(crate) struct StructLiteralNotAllowedHereSugg {
1208 #[suggestion_part(code = "(")]
1209 pub left: Span,
1210 #[suggestion_part(code = ")")]
1211 pub right: Span,
1212}
1213
1214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidLiteralSuffixOnTupleIndex where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidLiteralSuffixOnTupleIndex {
span: __binding_0, suffix: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixes on a tuple index are invalid")));
;
diag.arg("suffix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
diag
}
}
}
}
};Diagnostic)]
1215#[diag("suffixes on a tuple index are invalid")]
1216pub(crate) struct InvalidLiteralSuffixOnTupleIndex {
1217 #[primary_span]
1218 #[label("invalid suffix `{$suffix}`")]
1219 pub span: Span,
1220 pub suffix: Symbol,
1221}
1222
1223#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonStringAbiLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonStringAbiLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-string ABI literal")));
let __code_80 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\"C\""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the ABI with a string literal")),
__code_80, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1224#[diag("non-string ABI literal")]
1225pub(crate) struct NonStringAbiLiteral {
1226 #[primary_span]
1227 #[suggestion(
1228 "specify the ABI with a string literal",
1229 code = "\"C\"",
1230 applicability = "maybe-incorrect",
1231 style = "verbose"
1232 )]
1233 pub span: Span,
1234}
1235
1236#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MismatchedClosingDelimiter where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MismatchedClosingDelimiter {
spans: __binding_0,
delimiter: __binding_1,
unmatched: __binding_2,
opening_candidate: __binding_3,
unclosed: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched closing delimiter: `{$delimiter}`")));
;
diag.arg("delimiter", __binding_1);
diag.span(__binding_0.clone());
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched closing delimiter")));
if let Some(__binding_3) = __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closing delimiter possibly meant for this")));
}
if let Some(__binding_4) = __binding_4 {
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unclosed delimiter")));
}
diag
}
}
}
}
};Diagnostic)]
1237#[diag("mismatched closing delimiter: `{$delimiter}`")]
1238pub(crate) struct MismatchedClosingDelimiter {
1239 #[primary_span]
1240 pub spans: Vec<Span>,
1241 pub delimiter: String,
1242 #[label("mismatched closing delimiter")]
1243 pub unmatched: Span,
1244 #[label("closing delimiter possibly meant for this")]
1245 pub opening_candidate: Option<Span>,
1246 #[label("unclosed delimiter")]
1247 pub unclosed: Option<Span>,
1248}
1249
1250#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectVisibilityRestriction where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectVisibilityRestriction {
span: __binding_0, inner_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect visibility restriction")));
let __code_81 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in {0}", __binding_1))
})].into_iter();
diag.code(E0704);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("some possible visibility restrictions are:\n `pub(crate)`: visible only on the current crate\n `pub(super)`: visible only in the current module's parent\n `pub(in path::to::module)`: visible only on the specified path")));
;
diag.arg("inner_str", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("make this visible only to module `{$inner_str}` with `in`")),
__code_81, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1251#[diag("incorrect visibility restriction", code = E0704)]
1252#[help(
1253 "some possible visibility restrictions are:
1254 `pub(crate)`: visible only on the current crate
1255 `pub(super)`: visible only in the current module's parent
1256 `pub(in path::to::module)`: visible only on the specified path"
1257)]
1258pub(crate) struct IncorrectVisibilityRestriction {
1259 #[primary_span]
1260 #[suggestion(
1261 "make this visible only to module `{$inner_str}` with `in`",
1262 code = "in {inner_str}",
1263 applicability = "machine-applicable",
1264 style = "verbose"
1265 )]
1266 pub span: Span,
1267 pub inner_str: String,
1268}
1269
1270#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectImplRestriction where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectImplRestriction {
span: __binding_0, inner_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect `impl` restriction")));
let __code_82 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in {0}", __binding_1))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("some possible `impl` restrictions are:\n `impl(crate)`: can only be implemented in the current crate\n `impl(super)`: can only be implemented in the parent module\n `impl(self)`: can only be implemented in current module\n `impl(in path::to::module)`: can only be implemented in the specified path")));
;
diag.arg("inner_str", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("help: use `in` to restrict implementations to the path `{$inner_str}`")),
__code_82, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1271#[diag("incorrect `impl` restriction")]
1272#[help(
1273 "some possible `impl` restrictions are:
1274 `impl(crate)`: can only be implemented in the current crate
1275 `impl(super)`: can only be implemented in the parent module
1276 `impl(self)`: can only be implemented in current module
1277 `impl(in path::to::module)`: can only be implemented in the specified path"
1278)]
1279pub(crate) struct IncorrectImplRestriction {
1280 #[primary_span]
1281 #[suggestion(
1282 "help: use `in` to restrict implementations to the path `{$inner_str}`",
1283 code = "in {inner_str}",
1284 applicability = "machine-applicable"
1285 )]
1286 pub span: Span,
1287 pub inner_str: String,
1288}
1289
1290#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectMutRestriction where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectMutRestriction {
span: __binding_0, inner_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect `mut` restriction")));
let __code_83 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in {0}", __binding_1))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("some possible `mut` restrictions are:\n `mut(crate)`: can only be mutated in the current crate\n `mut(super)`: can only be mutated in the parent module\n `mut(self)`: can only be mutated in current module\n `mut(in path::to::module)`: can only be mutated in the specified path")));
;
diag.arg("inner_str", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("help: use `in` to restrict mutations to the path `{$inner_str}`")),
__code_83, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1291#[diag("incorrect `mut` restriction")]
1292#[help(
1293 "some possible `mut` restrictions are:
1294 `mut(crate)`: can only be mutated in the current crate
1295 `mut(super)`: can only be mutated in the parent module
1296 `mut(self)`: can only be mutated in current module
1297 `mut(in path::to::module)`: can only be mutated in the specified path"
1298)]
1299pub(crate) struct IncorrectMutRestriction {
1300 #[primary_span]
1301 #[suggestion(
1302 "help: use `in` to restrict mutations to the path `{$inner_str}`",
1303 code = "in {inner_str}",
1304 applicability = "machine-applicable"
1305 )]
1306 pub span: Span,
1307 pub inner_str: String,
1308}
1309
1310#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssignmentElseNotAllowed where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssignmentElseNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("<assignment> ... else {\"{\"} ... {\"}\"} is not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1311#[diag("<assignment> ... else {\"{\"} ... {\"}\"} is not allowed")]
1312pub(crate) struct AssignmentElseNotAllowed {
1313 #[primary_span]
1314 pub span: Span,
1315}
1316
1317#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedStatementAfterOuterAttr where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedStatementAfterOuterAttr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected statement after outer attribute")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1318#[diag("expected statement after outer attribute")]
1319pub(crate) struct ExpectedStatementAfterOuterAttr {
1320 #[primary_span]
1321 pub span: Span,
1322}
1323
1324#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrWithoutWherePredicates where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrWithoutWherePredicates { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute without where predicates")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are only permitted when preceding predicates")));
diag
}
}
}
}
};Diagnostic)]
1325#[diag("attribute without where predicates")]
1326pub(crate) struct AttrWithoutWherePredicates {
1327 #[primary_span]
1328 #[label("attributes are only permitted when preceding predicates")]
1329 pub span: Span,
1330}
1331
1332#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocCommentDoesNotDocumentAnything where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocCommentDoesNotDocumentAnything {
span: __binding_0, missing_comma: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found a documentation comment that doesn't document anything")));
let __code_84 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(","))
})].into_iter();
diag.code(E0585);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doc comments must come before what they document, if a comment was intended use `//`")));
;
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("missing comma here")),
__code_84, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1333#[diag("found a documentation comment that doesn't document anything", code = E0585)]
1334#[help("doc comments must come before what they document, if a comment was intended use `//`")]
1335pub(crate) struct DocCommentDoesNotDocumentAnything {
1336 #[primary_span]
1337 pub span: Span,
1338 #[suggestion(
1339 "missing comma here",
1340 code = ",",
1341 applicability = "machine-applicable",
1342 style = "verbose"
1343 )]
1344 pub missing_comma: Option<Span>,
1345}
1346
1347#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstLetMutuallyExclusive where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstLetMutuallyExclusive { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` and `let` are mutually exclusive")));
let __code_85 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove `let`")),
__code_85, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1348#[diag("`const` and `let` are mutually exclusive")]
1349pub(crate) struct ConstLetMutuallyExclusive {
1350 #[primary_span]
1351 #[suggestion(
1352 "remove `let`",
1353 code = "const",
1354 applicability = "maybe-incorrect",
1355 style = "verbose"
1356 )]
1357 pub span: Span,
1358}
1359
1360#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidExpressionInLetElse where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidExpressionInLetElse {
span: __binding_0, operator: __binding_1, sugg: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `{$operator}` expression cannot be directly assigned in `let...else`")));
;
diag.arg("operator", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1361#[diag("a `{$operator}` expression cannot be directly assigned in `let...else`")]
1362pub(crate) struct InvalidExpressionInLetElse {
1363 #[primary_span]
1364 pub span: Span,
1365 pub operator: &'static str,
1366 #[subdiagnostic]
1367 pub sugg: WrapInParentheses,
1368}
1369
1370#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidCurlyInLetElse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidCurlyInLetElse { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("right curly brace `{\"}\"}` before `else` in a `let...else` statement not allowed")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1371#[diag("right curly brace `{\"}\"}` before `else` in a `let...else` statement not allowed")]
1372pub(crate) struct InvalidCurlyInLetElse {
1373 #[primary_span]
1374 pub span: Span,
1375 #[subdiagnostic]
1376 pub sugg: WrapInParentheses,
1377}
1378
1379#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CompoundAssignmentExpressionInLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CompoundAssignmentExpressionInLet {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reassign to an uninitialized variable")));
let __code_86 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to overwrite, remove the `let` binding")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initialize the variable")),
__code_86, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1380#[diag("can't reassign to an uninitialized variable")]
1381#[help("if you meant to overwrite, remove the `let` binding")]
1382pub(crate) struct CompoundAssignmentExpressionInLet {
1383 #[primary_span]
1384 pub span: Span,
1385 #[suggestion(
1386 "initialize the variable",
1387 style = "verbose",
1388 code = "",
1389 applicability = "maybe-incorrect"
1390 )]
1391 pub suggestion: Span,
1392}
1393
1394#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SuffixedLiteralInAttribute where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SuffixedLiteralInAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixed literals are not allowed in attributes")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1395#[diag("suffixed literals are not allowed in attributes")]
1396#[help(
1397 "instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)"
1398)]
1399pub(crate) struct SuffixedLiteralInAttribute {
1400 #[primary_span]
1401 pub span: Span,
1402}
1403
1404#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidMetaItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidMetaItem {
span: __binding_0,
descr: __binding_1,
quote_ident_sugg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected unsuffixed literal, found {$descr}")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1405#[diag("expected unsuffixed literal, found {$descr}")]
1406pub(crate) struct InvalidMetaItem {
1407 #[primary_span]
1408 pub span: Span,
1409 pub descr: String,
1410 #[subdiagnostic]
1411 pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
1412}
1413
1414#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidMetaItemQuoteIdentSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidMetaItemQuoteIdentSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_87 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_88 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_87));
suggestions.push((__binding_1, __code_88));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the identifier with quotation marks to make it into a string literal")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1415#[multipart_suggestion(
1416 "surround the identifier with quotation marks to make it into a string literal",
1417 applicability = "machine-applicable"
1418)]
1419pub(crate) struct InvalidMetaItemQuoteIdentSugg {
1420 #[suggestion_part(code = "\"")]
1421 pub before: Span,
1422 #[suggestion_part(code = "\"")]
1423 pub after: Span,
1424}
1425
1426#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggEscapeIdentifier {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggEscapeIdentifier {
span: __binding_0, ident_name: __binding_1 } => {
let __code_89 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("r#"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident_name".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("escape `{$ident_name}` to use it as an identifier")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_89, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1427#[suggestion(
1428 "escape `{$ident_name}` to use it as an identifier",
1429 style = "verbose",
1430 applicability = "maybe-incorrect",
1431 code = "r#"
1432)]
1433pub(crate) struct SuggEscapeIdentifier {
1434 #[primary_span]
1435 pub span: Span,
1436 pub ident_name: String,
1437}
1438
1439#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggRemoveComma {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggRemoveComma { span: __binding_0 } => {
let __code_90 =
[::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 comma")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_90, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1440#[suggestion(
1441 "remove this comma",
1442 applicability = "machine-applicable",
1443 code = "",
1444 style = "verbose"
1445)]
1446pub(crate) struct SuggRemoveComma {
1447 #[primary_span]
1448 pub span: Span,
1449}
1450
1451#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggAddMissingLetStmt {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggAddMissingLetStmt { span: __binding_0 } => {
let __code_91 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
})].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("you might have meant to introduce a new binding")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_91, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1452#[suggestion(
1453 "you might have meant to introduce a new binding",
1454 style = "verbose",
1455 applicability = "maybe-incorrect",
1456 code = "let "
1457)]
1458pub(crate) struct SuggAddMissingLetStmt {
1459 #[primary_span]
1460 pub span: Span,
1461}
1462
1463#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedIdentifierFound {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedIdentifierFound::ReservedIdentifier(__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("expected identifier, found reserved identifier")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedIdentifierFound::Keyword(__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("expected identifier, found keyword")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedIdentifierFound::ReservedKeyword(__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("expected identifier, found reserved keyword")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedIdentifierFound::DocComment(__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("expected identifier, found doc comment")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedIdentifierFound::MetaVar(__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("expected identifier, found metavariable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedIdentifierFound::Other(__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("expected identifier")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1464pub(crate) enum ExpectedIdentifierFound {
1465 #[label("expected identifier, found reserved identifier")]
1466 ReservedIdentifier(#[primary_span] Span),
1467 #[label("expected identifier, found keyword")]
1468 Keyword(#[primary_span] Span),
1469 #[label("expected identifier, found reserved keyword")]
1470 ReservedKeyword(#[primary_span] Span),
1471 #[label("expected identifier, found doc comment")]
1472 DocComment(#[primary_span] Span),
1473 #[label("expected identifier, found metavariable")]
1474 MetaVar(#[primary_span] Span),
1475 #[label("expected identifier")]
1476 Other(#[primary_span] Span),
1477}
1478
1479impl ExpectedIdentifierFound {
1480 pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
1481 (match token_descr {
1482 Some(TokenDescription::ReservedIdentifier) => {
1483 ExpectedIdentifierFound::ReservedIdentifier
1484 }
1485 Some(TokenDescription::Keyword) => ExpectedIdentifierFound::Keyword,
1486 Some(TokenDescription::ReservedKeyword) => ExpectedIdentifierFound::ReservedKeyword,
1487 Some(TokenDescription::DocComment) => ExpectedIdentifierFound::DocComment,
1488 Some(TokenDescription::MetaVar(_)) => ExpectedIdentifierFound::MetaVar,
1489 None => ExpectedIdentifierFound::Other,
1490 })(span)
1491 }
1492}
1493
1494pub(crate) struct ExpectedIdentifier {
1495 pub span: Span,
1496 pub token: Token,
1497 pub suggest_raw: Option<SuggEscapeIdentifier>,
1498 pub suggest_remove_comma: Option<SuggRemoveComma>,
1499 pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
1500}
1501
1502impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
1503 #[track_caller]
1504 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1505 let token_descr = TokenDescription::from_token(&self.token);
1506
1507 let mut add_token = true;
1508 let mut diag = Diag::new(
1509 dcx,
1510 level,
1511 match token_descr {
1512 Some(TokenDescription::ReservedIdentifier) => {
1513 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved identifier `{$token}`"))msg!("expected identifier, found reserved identifier `{$token}`")
1514 }
1515 Some(TokenDescription::Keyword) => {
1516 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword `{$token}`"))msg!("expected identifier, found keyword `{$token}`")
1517 }
1518 Some(TokenDescription::ReservedKeyword) => {
1519 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved keyword `{$token}`"))msg!("expected identifier, found reserved keyword `{$token}`")
1520 }
1521 Some(TokenDescription::DocComment) => {
1522 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found doc comment `{$token}`"))msg!("expected identifier, found doc comment `{$token}`")
1523 }
1524 Some(TokenDescription::MetaVar(_)) => {
1525 add_token = false;
1526 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found metavariable"))msg!("expected identifier, found metavariable")
1527 }
1528 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found `{$token}`"))msg!("expected identifier, found `{$token}`"),
1529 },
1530 );
1531 diag.span(self.span);
1532 if add_token {
1533 diag.arg("token", pprust::token_to_string(&self.token));
1534 }
1535
1536 if let Some(sugg) = self.suggest_raw {
1537 sugg.add_to_diag(&mut diag);
1538 }
1539
1540 ExpectedIdentifierFound::new(token_descr, self.span).add_to_diag(&mut diag);
1541
1542 if let Some(sugg) = self.suggest_remove_comma {
1543 sugg.add_to_diag(&mut diag);
1544 }
1545
1546 if let Some(help) = self.help_cannot_start_number {
1547 help.add_to_diag(&mut diag);
1548 }
1549
1550 diag
1551 }
1552}
1553
1554#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HelpIdentifierStartsWithNumber {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
HelpIdentifierStartsWithNumber { num_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("identifiers cannot start with a number")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1555#[help("identifiers cannot start with a number")]
1556pub(crate) struct HelpIdentifierStartsWithNumber {
1557 #[primary_span]
1558 pub num_span: Span,
1559}
1560
1561pub(crate) struct ExpectedSemi {
1562 pub span: Span,
1563 pub token: Token,
1564 pub unexpected_token_label: Option<Span>,
1565 pub sugg: ExpectedSemiSugg,
1566}
1567
1568impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
1569 #[track_caller]
1570 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1571 let token_descr = TokenDescription::from_token(&self.token);
1572
1573 let mut add_token = true;
1574 let mut diag = Diag::new(
1575 dcx,
1576 level,
1577 match token_descr {
1578 Some(TokenDescription::ReservedIdentifier) => {
1579 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved identifier `{$token}`"))msg!("expected `;`, found reserved identifier `{$token}`")
1580 }
1581 Some(TokenDescription::Keyword) => {
1582 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found keyword `{$token}`"))msg!("expected `;`, found keyword `{$token}`")
1583 }
1584 Some(TokenDescription::ReservedKeyword) => {
1585 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved keyword `{$token}`"))msg!("expected `;`, found reserved keyword `{$token}`")
1586 }
1587 Some(TokenDescription::DocComment) => {
1588 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found doc comment `{$token}`"))msg!("expected `;`, found doc comment `{$token}`")
1589 }
1590 Some(TokenDescription::MetaVar(_)) => {
1591 add_token = false;
1592 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found metavariable"))msg!("expected `;`, found metavariable")
1593 }
1594 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found `{$token}`"))msg!("expected `;`, found `{$token}`"),
1595 },
1596 );
1597 diag.span(self.span);
1598 if add_token {
1599 diag.arg("token", pprust::token_to_string(&self.token));
1600 }
1601
1602 if let Some(unexpected_token_label) = self.unexpected_token_label {
1603 diag.span_label(unexpected_token_label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token"))msg!("unexpected token"));
1604 }
1605
1606 self.sugg.add_to_diag(&mut diag);
1607
1608 diag
1609 }
1610}
1611
1612#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedSemiSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedSemiSugg::ChangeToSemi(__binding_0) => {
let __code_92 =
[::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("change this to `;`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_92, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
}
ExpectedSemiSugg::AddSemi(__binding_0) => {
let __code_93 =
[::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("add `;` here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_93, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
}
}
}
}
};Subdiagnostic)]
1613pub(crate) enum ExpectedSemiSugg {
1614 #[suggestion(
1615 "change this to `;`",
1616 code = ";",
1617 applicability = "machine-applicable",
1618 style = "short"
1619 )]
1620 ChangeToSemi(#[primary_span] Span),
1621 #[suggestion("add `;` here", code = ";", applicability = "machine-applicable", style = "short")]
1622 AddSemi(#[primary_span] Span),
1623}
1624
1625#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralBodyWithoutPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralBodyWithoutPath {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literal body without path")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1626#[diag("struct literal body without path")]
1627pub(crate) struct StructLiteralBodyWithoutPath {
1628 #[primary_span]
1629 pub span: Span,
1630 #[subdiagnostic]
1631 pub sugg: StructLiteralBodyWithoutPathSugg,
1632}
1633
1634#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for StructLiteralBodyWithoutPathSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
StructLiteralBodyWithoutPathSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_94 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ SomeStruct "))
});
let __code_95 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_94));
suggestions.push((__binding_1, __code_95));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have forgotten to add the struct literal inside the block")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1635#[multipart_suggestion(
1636 "you might have forgotten to add the struct literal inside the block",
1637 applicability = "has-placeholders"
1638)]
1639pub(crate) struct StructLiteralBodyWithoutPathSugg {
1640 #[suggestion_part(code = "{{ SomeStruct ")]
1641 pub before: Span,
1642 #[suggestion_part(code = " }}")]
1643 pub after: Span,
1644}
1645
1646#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnmatchedAngleBrackets where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnmatchedAngleBrackets {
span: __binding_0, num_extra_brackets: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_extra_brackets ->\n [one] unmatched angle bracket\n *[other] unmatched angle brackets\n }")));
let __code_96 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("num_extra_brackets", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_extra_brackets ->\n [one] remove extra angle bracket\n *[other] remove extra angle brackets\n }")),
__code_96, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1647#[diag(
1648 "{$num_extra_brackets ->
1649 [one] unmatched angle bracket
1650 *[other] unmatched angle brackets
1651 }"
1652)]
1653pub(crate) struct UnmatchedAngleBrackets {
1654 #[primary_span]
1655 #[suggestion(
1656 "{$num_extra_brackets ->
1657 [one] remove extra angle bracket
1658 *[other] remove extra angle brackets
1659 }",
1660 code = "",
1661 applicability = "machine-applicable",
1662 style = "verbose"
1663 )]
1664 pub span: Span,
1665 pub num_extra_brackets: usize,
1666}
1667
1668#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericParamsWithoutAngleBrackets where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericParamsWithoutAngleBrackets {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters without surrounding angle brackets")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1669#[diag("generic parameters without surrounding angle brackets")]
1670pub(crate) struct GenericParamsWithoutAngleBrackets {
1671 #[primary_span]
1672 pub span: Span,
1673 #[subdiagnostic]
1674 pub sugg: GenericParamsWithoutAngleBracketsSugg,
1675}
1676
1677#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsWithoutAngleBracketsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GenericParamsWithoutAngleBracketsSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_97 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_98 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_97));
suggestions.push((__binding_1, __code_98));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the type parameters with angle brackets")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1678#[multipart_suggestion(
1679 "surround the type parameters with angle brackets",
1680 applicability = "machine-applicable"
1681)]
1682pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
1683 #[suggestion_part(code = "<")]
1684 pub left: Span,
1685 #[suggestion_part(code = ">")]
1686 pub right: Span,
1687}
1688
1689#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ComparisonOperatorsCannotBeChained where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ComparisonOperatorsCannotBeChained {
span: __binding_0,
suggest_turbofish: __binding_1,
help_turbofish: __binding_2,
chaining_sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("comparison operators cannot be chained")));
let __code_99 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("::"))
})].into_iter();
;
diag.span(__binding_0.clone());
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")),
__code_99, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")));
}
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or use `(...)` if you meant to specify fn arguments")));
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
1690#[diag("comparison operators cannot be chained")]
1691pub(crate) struct ComparisonOperatorsCannotBeChained {
1692 #[primary_span]
1693 pub span: Vec<Span>,
1694 #[suggestion(
1695 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
1696 style = "verbose",
1697 code = "::",
1698 applicability = "maybe-incorrect"
1699 )]
1700 pub suggest_turbofish: Option<Span>,
1701 #[help("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")]
1702 #[help("or use `(...)` if you meant to specify fn arguments")]
1703 pub help_turbofish: bool,
1704 #[subdiagnostic]
1705 pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
1706}
1707
1708#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ComparisonOperatorsCannotBeChainedSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ComparisonOperatorsCannotBeChainedSugg::SplitComparison {
span: __binding_0, middle_term: __binding_1 } => {
let __code_100 =
[::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("split the comparison into two")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_100, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
ComparisonOperatorsCannotBeChainedSugg::Parenthesize {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_101 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_102 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_101));
suggestions.push((__binding_1, __code_102));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthesize the comparison")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1709pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
1710 #[suggestion(
1711 "split the comparison into two",
1712 style = "verbose",
1713 code = " && {middle_term}",
1714 applicability = "maybe-incorrect"
1715 )]
1716 SplitComparison {
1717 #[primary_span]
1718 span: Span,
1719 middle_term: String,
1720 },
1721 #[multipart_suggestion("parenthesize the comparison", applicability = "maybe-incorrect")]
1722 Parenthesize {
1723 #[suggestion_part(code = "(")]
1724 left: Span,
1725 #[suggestion_part(code = ")")]
1726 right: Span,
1727 },
1728}
1729
1730#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
QuestionMarkInType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
QuestionMarkInType { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `?` in type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`?` is only allowed on expressions, not types")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1731#[diag("invalid `?` in type")]
1732pub(crate) struct QuestionMarkInType {
1733 #[primary_span]
1734 #[label("`?` is only allowed on expressions, not types")]
1735 pub span: Span,
1736 #[subdiagnostic]
1737 pub sugg: QuestionMarkInTypeSugg,
1738}
1739
1740#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for QuestionMarkInTypeSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
QuestionMarkInTypeSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_103 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Option<"))
});
let __code_104 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_103));
suggestions.push((__binding_1, __code_104));
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 express that the type might not contain a value, use the `Option` wrapper type")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1741#[multipart_suggestion(
1742 "if you meant to express that the type might not contain a value, use the `Option` wrapper type",
1743 applicability = "machine-applicable"
1744)]
1745pub(crate) struct QuestionMarkInTypeSugg {
1746 #[suggestion_part(code = "Option<")]
1747 pub left: Span,
1748 #[suggestion_part(code = ">")]
1749 pub right: Span,
1750}
1751
1752#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesInForHead where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesInForHead { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected parentheses surrounding `for` loop head")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1753#[diag("unexpected parentheses surrounding `for` loop head")]
1754pub(crate) struct ParenthesesInForHead {
1755 #[primary_span]
1756 pub span: Vec<Span>,
1757 #[subdiagnostic]
1758 pub sugg: ParenthesesInForHeadSugg,
1759}
1760
1761#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesesInForHeadSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenthesesInForHeadSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_105 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_106 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
suggestions.push((__binding_0, __code_105));
suggestions.push((__binding_1, __code_106));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove parentheses in `for` loop")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1762#[multipart_suggestion("remove parentheses in `for` loop", applicability = "machine-applicable")]
1763pub(crate) struct ParenthesesInForHeadSugg {
1764 #[suggestion_part(code = " ")]
1765 pub left: Span,
1766 #[suggestion_part(code = " ")]
1767 pub right: Span,
1768}
1769
1770#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesInMatchPat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesInMatchPat { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected parentheses surrounding `match` arm pattern")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1771#[diag("unexpected parentheses surrounding `match` arm pattern")]
1772pub(crate) struct ParenthesesInMatchPat {
1773 #[primary_span]
1774 pub span: Vec<Span>,
1775 #[subdiagnostic]
1776 pub sugg: ParenthesesInMatchPatSugg,
1777}
1778
1779#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesesInMatchPatSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenthesesInMatchPatSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_107 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_108 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_107));
suggestions.push((__binding_1, __code_108));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove parentheses surrounding the pattern")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1780#[multipart_suggestion(
1781 "remove parentheses surrounding the pattern",
1782 applicability = "machine-applicable"
1783)]
1784pub(crate) struct ParenthesesInMatchPatSugg {
1785 #[suggestion_part(code = "")]
1786 pub left: Span,
1787 #[suggestion_part(code = "")]
1788 pub right: Span,
1789}
1790
1791#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocCommentOnParamType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocCommentOnParamType { 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 a function parameter's type")));
;
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)]
1792#[diag("documentation comments cannot be applied to a function parameter's type")]
1793pub(crate) struct DocCommentOnParamType {
1794 #[primary_span]
1795 #[label("doc comments are not allowed here")]
1796 pub span: Span,
1797}
1798
1799#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnParamType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnParamType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to a function parameter's type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
1800#[diag("attributes cannot be applied to a function parameter's type")]
1801pub(crate) struct AttributeOnParamType {
1802 #[primary_span]
1803 #[label("attributes are not allowed here")]
1804 pub span: Span,
1805}
1806
1807#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnType { span: __binding_0, fix_span: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to types")));
let __code_109 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove attribute from here")),
__code_109, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
1808#[diag("attributes cannot be applied to types")]
1809pub(crate) struct AttributeOnType {
1810 #[primary_span]
1811 #[label("attributes are not allowed here")]
1812 pub span: Span,
1813 #[suggestion(
1814 "remove attribute from here",
1815 code = "",
1816 applicability = "machine-applicable",
1817 style = "tool-only"
1818 )]
1819 pub fix_span: Span,
1820}
1821
1822#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnGenericArg where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnGenericArg {
span: __binding_0, fix_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to generic arguments")));
let __code_110 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove attribute from here")),
__code_110, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
1823#[diag("attributes cannot be applied to generic arguments")]
1824pub(crate) struct AttributeOnGenericArg {
1825 #[primary_span]
1826 #[label("attributes are not allowed here")]
1827 pub span: Span,
1828 #[suggestion(
1829 "remove attribute from here",
1830 code = "",
1831 applicability = "machine-applicable",
1832 style = "tool-only"
1833 )]
1834 pub fix_span: Span,
1835}
1836
1837#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnEmptyType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnEmptyType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied here")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
1838#[diag("attributes cannot be applied here")]
1839pub(crate) struct AttributeOnEmptyType {
1840 #[primary_span]
1841 #[label("attributes are not allowed here")]
1842 pub span: Span,
1843}
1844
1845#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternMethodParamWithoutBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternMethodParamWithoutBody { 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 methods without bodies")));
let __code_111 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
})].into_iter();
diag.code(E0642);
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("give this argument a name or use an underscore to ignore it")),
__code_111, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1846#[diag("patterns aren't allowed in methods without bodies", code = E0642)]
1847pub(crate) struct PatternMethodParamWithoutBody {
1848 #[primary_span]
1849 #[suggestion(
1850 "give this argument a name or use an underscore to ignore it",
1851 code = "_",
1852 applicability = "machine-applicable",
1853 style = "verbose"
1854 )]
1855 pub span: Span,
1856}
1857
1858#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfParamNotFirst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfParamNotFirst { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `self` parameter in function")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must be the first parameter of an associated function")));
diag
}
}
}
}
};Diagnostic)]
1859#[diag("unexpected `self` parameter in function")]
1860pub(crate) struct SelfParamNotFirst {
1861 #[primary_span]
1862 #[label("must be the first parameter of an associated function")]
1863 pub span: Span,
1864}
1865
1866#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstGenericWithoutBraces where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstGenericWithoutBraces {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expressions must be enclosed in braces to be used as const generic arguments")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1867#[diag("expressions must be enclosed in braces to be used as const generic arguments")]
1868pub(crate) struct ConstGenericWithoutBraces {
1869 #[primary_span]
1870 pub span: Span,
1871 #[subdiagnostic]
1872 pub sugg: ConstGenericWithoutBracesSugg,
1873}
1874
1875#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConstGenericWithoutBracesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConstGenericWithoutBracesSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_112 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_113 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_112));
suggestions.push((__binding_1, __code_113));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclose the `const` expression in braces")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1876#[multipart_suggestion(
1877 "enclose the `const` expression in braces",
1878 applicability = "machine-applicable"
1879)]
1880pub(crate) struct ConstGenericWithoutBracesSugg {
1881 #[suggestion_part(code = "{{ ")]
1882 pub left: Span,
1883 #[suggestion_part(code = " }}")]
1884 pub right: Span,
1885}
1886
1887#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedConstParamDeclaration where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedConstParamDeclaration {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `const` parameter declaration")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a `const` expression, not a parameter declaration")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1888#[diag("unexpected `const` parameter declaration")]
1889pub(crate) struct UnexpectedConstParamDeclaration {
1890 #[primary_span]
1891 #[label("expected a `const` expression, not a parameter declaration")]
1892 pub span: Span,
1893 #[subdiagnostic]
1894 pub sugg: Option<UnexpectedConstParamDeclarationSugg>,
1895}
1896
1897#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedConstParamDeclarationSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedConstParamDeclarationSugg::AddParam {
impl_generics: __binding_0,
incorrect_decl: __binding_1,
snippet: __binding_2,
ident: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_114 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", __binding_2))
});
let __code_115 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_114));
suggestions.push((__binding_1, __code_115));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` parameters must be declared for the `impl`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
UnexpectedConstParamDeclarationSugg::AppendParam {
impl_generics_end: __binding_0,
incorrect_decl: __binding_1,
snippet: __binding_2,
ident: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_116 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_117 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_116));
suggestions.push((__binding_1, __code_117));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` parameters must be declared for the `impl`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1898pub(crate) enum UnexpectedConstParamDeclarationSugg {
1899 #[multipart_suggestion(
1900 "`const` parameters must be declared for the `impl`",
1901 applicability = "machine-applicable"
1902 )]
1903 AddParam {
1904 #[suggestion_part(code = "<{snippet}>")]
1905 impl_generics: Span,
1906 #[suggestion_part(code = "{ident}")]
1907 incorrect_decl: Span,
1908 snippet: String,
1909 ident: String,
1910 },
1911 #[multipart_suggestion(
1912 "`const` parameters must be declared for the `impl`",
1913 applicability = "machine-applicable"
1914 )]
1915 AppendParam {
1916 #[suggestion_part(code = ", {snippet}")]
1917 impl_generics_end: Span,
1918 #[suggestion_part(code = "{ident}")]
1919 incorrect_decl: Span,
1920 snippet: String,
1921 ident: String,
1922 },
1923}
1924
1925#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedConstInGenericParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedConstInGenericParam {
span: __binding_0, to_remove: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected lifetime, type, or constant, found keyword `const`")));
let __code_118 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].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("the `const` keyword is only needed in the definition of the type")),
__code_118, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1926#[diag("expected lifetime, type, or constant, found keyword `const`")]
1927pub(crate) struct UnexpectedConstInGenericParam {
1928 #[primary_span]
1929 pub span: Span,
1930 #[suggestion(
1931 "the `const` keyword is only needed in the definition of the type",
1932 style = "verbose",
1933 code = "",
1934 applicability = "maybe-incorrect"
1935 )]
1936 pub to_remove: Option<Span>,
1937}
1938
1939#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncMoveOrderIncorrect where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncMoveOrderIncorrect { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the order of `move` and `async` is incorrect")));
let __code_119 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("async move"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try switching the order")),
__code_119, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1940#[diag("the order of `move` and `async` is incorrect")]
1941pub(crate) struct AsyncMoveOrderIncorrect {
1942 #[primary_span]
1943 #[suggestion(
1944 "try switching the order",
1945 style = "verbose",
1946 code = "async move",
1947 applicability = "maybe-incorrect"
1948 )]
1949 pub span: Span,
1950}
1951
1952#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncUseOrderIncorrect where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncUseOrderIncorrect { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the order of `use` and `async` is incorrect")));
let __code_120 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("async use"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try switching the order")),
__code_120, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1953#[diag("the order of `use` and `async` is incorrect")]
1954pub(crate) struct AsyncUseOrderIncorrect {
1955 #[primary_span]
1956 #[suggestion(
1957 "try switching the order",
1958 style = "verbose",
1959 code = "async use",
1960 applicability = "maybe-incorrect"
1961 )]
1962 pub span: Span,
1963}
1964
1965#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DoubleColonInBound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DoubleColonInBound { span: __binding_0, between: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `:` followed by trait or lifetime")));
let __code_121 =
[::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("use single colon")),
__code_121, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1966#[diag("expected `:` followed by trait or lifetime")]
1967pub(crate) struct DoubleColonInBound {
1968 #[primary_span]
1969 pub span: Span,
1970 #[suggestion(
1971 "use single colon",
1972 code = ": ",
1973 applicability = "machine-applicable",
1974 style = "verbose"
1975 )]
1976 pub between: Span,
1977}
1978
1979#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPtrWithGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPtrWithGenerics { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer types may not have generic parameters")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1980#[diag("function pointer types may not have generic parameters")]
1981pub(crate) struct FnPtrWithGenerics {
1982 #[primary_span]
1983 pub span: Span,
1984 #[subdiagnostic]
1985 pub sugg: Option<FnPtrWithGenericsSugg>,
1986}
1987
1988#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MisplacedReturnType {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MisplacedReturnType {
fn_params_end: __binding_0,
snippet: __binding_1,
ret_ty_span: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_122 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {0}", __binding_1))
});
let __code_123 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_122));
suggestions.push((__binding_2, __code_123));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place the return type after the function parameters")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1989#[multipart_suggestion(
1990 "place the return type after the function parameters",
1991 style = "verbose",
1992 applicability = "maybe-incorrect"
1993)]
1994pub(crate) struct MisplacedReturnType {
1995 #[suggestion_part(code = " {snippet}")]
1996 pub fn_params_end: Span,
1997 pub snippet: String,
1998 #[suggestion_part(code = "")]
1999 pub ret_ty_span: Span,
2000}
2001
2002#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FnPtrWithGenericsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FnPtrWithGenericsSugg {
left: __binding_0,
snippet: __binding_1,
right: __binding_2,
arity: __binding_3,
for_param_list_exists: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_124 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_125 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_124));
suggestions.push((__binding_2, __code_125));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("arity".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("for_param_list_exists".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the lifetime {$arity ->\n [one] parameter\n *[other] parameters\n } to {$for_param_list_exists ->\n [true] the\n *[false] a\n } `for` parameter list")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2003#[multipart_suggestion(
2004 "consider moving the lifetime {$arity ->
2005 [one] parameter
2006 *[other] parameters
2007 } to {$for_param_list_exists ->
2008 [true] the
2009 *[false] a
2010 } `for` parameter list",
2011 applicability = "maybe-incorrect"
2012)]
2013pub(crate) struct FnPtrWithGenericsSugg {
2014 #[suggestion_part(code = "{snippet}")]
2015 pub left: Span,
2016 pub snippet: String,
2017 #[suggestion_part(code = "")]
2018 pub right: Span,
2019 pub arity: usize,
2020 pub for_param_list_exists: bool,
2021}
2022
2023pub(crate) struct FnTraitMissingParen {
2024 pub span: Span,
2025}
2026
2027impl Subdiagnostic for FnTraitMissingParen {
2028 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
2029 diag.span_label(self.span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Fn` bounds require arguments in parentheses"))msg!("`Fn` bounds require arguments in parentheses"));
2030 diag.span_suggestion_short(
2031 self.span.shrink_to_hi(),
2032 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses"))msg!("try adding parentheses"),
2033 "()",
2034 Applicability::MachineApplicable,
2035 );
2036 }
2037}
2038
2039#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedIfWithIf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedIfWithIf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `if` in the condition expression")));
let __code_126 =
[::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 `if`")),
__code_126, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2040#[diag("unexpected `if` in the condition expression")]
2041pub(crate) struct UnexpectedIfWithIf(
2042 #[primary_span]
2043 #[suggestion(
2044 "remove the `if`",
2045 applicability = "machine-applicable",
2046 code = " ",
2047 style = "verbose"
2048 )]
2049 pub Span,
2050);
2051
2052#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnTypoWithImpl
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnTypoWithImpl { fn_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write `impl` instead of `fn`")));
let __code_127 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("impl"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `fn` with `impl` here")),
__code_127, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2053#[diag("you might have meant to write `impl` instead of `fn`")]
2054pub(crate) struct FnTypoWithImpl {
2055 #[primary_span]
2056 #[suggestion(
2057 "replace `fn` with `impl` here",
2058 applicability = "maybe-incorrect",
2059 code = "impl",
2060 style = "verbose"
2061 )]
2062 pub fn_span: Span,
2063}
2064
2065#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedFnPathFoundFnKeyword where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedFnPathFoundFnKeyword { fn_token_span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword `fn`")));
let __code_128 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Fn"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `Fn` to refer to the trait")),
__code_128, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2066#[diag("expected identifier, found keyword `fn`")]
2067pub(crate) struct ExpectedFnPathFoundFnKeyword {
2068 #[primary_span]
2069 #[suggestion(
2070 "use `Fn` to refer to the trait",
2071 applicability = "machine-applicable",
2072 code = "Fn",
2073 style = "verbose"
2074 )]
2075 pub fn_token_span: Span,
2076}
2077
2078#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPathFoundNamedParams where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPathFoundNamedParams { named_param_span: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support named parameters")));
let __code_129 =
[::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 parameter name")),
__code_129, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2079#[diag("`Trait(...)` syntax does not support named parameters")]
2080pub(crate) struct FnPathFoundNamedParams {
2081 #[primary_span]
2082 #[suggestion("remove the parameter name", applicability = "machine-applicable", code = "")]
2083 pub named_param_span: Span,
2084}
2085
2086#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathFoundCVariadicParams where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathFoundCVariadicParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support c_variadic parameters")));
let __code_130 =
[::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 `...`")),
__code_130, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2087#[diag("`Trait(...)` syntax does not support c_variadic parameters")]
2088pub(crate) struct PathFoundCVariadicParams {
2089 #[primary_span]
2090 #[suggestion("remove the `...`", applicability = "machine-applicable", code = "")]
2091 pub span: Span,
2092}
2093
2094#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathFoundAttributeInParams where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathFoundAttributeInParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support attributes in parameters")));
let __code_131 =
[::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 attributes")),
__code_131, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2095#[diag("`Trait(...)` syntax does not support attributes in parameters")]
2096pub(crate) struct PathFoundAttributeInParams {
2097 #[primary_span]
2098 #[suggestion("remove the attributes", applicability = "machine-applicable", code = "")]
2099 pub span: Span,
2100}
2101
2102#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathSingleColon where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathSingleColon { span: __binding_0, suggestion: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path separator must be a double colon")));
let __code_132 =
[::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("use a double colon instead")),
__code_132, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2103#[diag("path separator must be a double colon")]
2104pub(crate) struct PathSingleColon {
2105 #[primary_span]
2106 pub span: Span,
2107
2108 #[suggestion(
2109 "use a double colon instead",
2110 applicability = "machine-applicable",
2111 code = ":",
2112 style = "verbose"
2113 )]
2114 pub suggestion: Span,
2115}
2116
2117#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathTripleColon where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathTripleColon { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path separator must be a double colon")));
let __code_133 =
[::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("use a double colon instead")),
__code_133, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2118#[diag("path separator must be a double colon")]
2119pub(crate) struct PathTripleColon {
2120 #[primary_span]
2121 #[suggestion(
2122 "use a double colon instead",
2123 applicability = "maybe-incorrect",
2124 code = "",
2125 style = "verbose"
2126 )]
2127 pub span: Span,
2128}
2129
2130#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ColonAsSemi
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ColonAsSemi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("statements are terminated with a semicolon")));
let __code_134 =
[::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("use a semicolon instead")),
__code_134, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2131#[diag("statements are terminated with a semicolon")]
2132pub(crate) struct ColonAsSemi {
2133 #[primary_span]
2134 #[suggestion(
2135 "use a semicolon instead",
2136 applicability = "machine-applicable",
2137 code = ";",
2138 style = "verbose"
2139 )]
2140 pub span: Span,
2141}
2142
2143#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseBeforeTupleStructBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseBeforeTupleStructBody {
span: __binding_0,
name: __binding_1,
body: __binding_2,
sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed before tuple struct bodies")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected where clause")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this tuple struct")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the struct body")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
2144#[diag("where clauses are not allowed before tuple struct bodies")]
2145pub(crate) struct WhereClauseBeforeTupleStructBody {
2146 #[primary_span]
2147 #[label("unexpected where clause")]
2148 pub span: Span,
2149 #[label("while parsing this tuple struct")]
2150 pub name: Span,
2151 #[label("the struct body")]
2152 pub body: Span,
2153 #[subdiagnostic]
2154 pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
2155}
2156
2157#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
WhereClauseBeforeTupleStructBodySugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WhereClauseBeforeTupleStructBodySugg {
left: __binding_0, snippet: __binding_1, right: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_135 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_136 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_135));
suggestions.push((__binding_2, __code_136));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the body before the where clause")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2158#[multipart_suggestion(
2159 "move the body before the where clause",
2160 applicability = "machine-applicable"
2161)]
2162pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
2163 #[suggestion_part(code = "{snippet}")]
2164 pub left: Span,
2165 pub snippet: String,
2166 #[suggestion_part(code = "")]
2167 pub right: Span,
2168}
2169
2170#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsyncFnIn2015
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncFnIn2015 { span: __binding_0, help: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async fn` is not permitted in Rust 2015")));
diag.code(E0670);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to use `async fn`, switch to Rust 2018 or later")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2171#[diag("`async fn` is not permitted in Rust 2015", code = E0670)]
2172pub(crate) struct AsyncFnIn2015 {
2173 #[primary_span]
2174 #[label("to use `async fn`, switch to Rust 2018 or later")]
2175 pub span: Span,
2176 #[subdiagnostic]
2177 pub help: HelpUseLatestEdition,
2178}
2179
2180#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AsyncBlockIn2015 {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AsyncBlockIn2015 { 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("`async` blocks are only allowed in Rust 2018 or later")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
2181#[label("`async` blocks are only allowed in Rust 2018 or later")]
2182pub(crate) struct AsyncBlockIn2015 {
2183 #[primary_span]
2184 pub span: Span,
2185}
2186
2187#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncMoveBlockIn2015 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncMoveBlockIn2015 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async move` blocks are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2188#[diag("`async move` blocks are only allowed in Rust 2018 or later")]
2189pub(crate) struct AsyncMoveBlockIn2015 {
2190 #[primary_span]
2191 pub span: Span,
2192}
2193
2194#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncUseBlockIn2015 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncUseBlockIn2015 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async use` blocks are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2195#[diag("`async use` blocks are only allowed in Rust 2018 or later")]
2196pub(crate) struct AsyncUseBlockIn2015 {
2197 #[primary_span]
2198 pub span: Span,
2199}
2200
2201#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncBoundModifierIn2015 where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncBoundModifierIn2015 {
span: __binding_0, help: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` trait bounds are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2202#[diag("`async` trait bounds are only allowed in Rust 2018 or later")]
2203pub(crate) struct AsyncBoundModifierIn2015 {
2204 #[primary_span]
2205 pub span: Span,
2206 #[subdiagnostic]
2207 pub help: HelpUseLatestEdition,
2208}
2209
2210#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LetChainPre2024 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LetChainPre2024 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let chains are only allowed in Rust 2024 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2211#[diag("let chains are only allowed in Rust 2024 or later")]
2212pub(crate) struct LetChainPre2024 {
2213 #[primary_span]
2214 pub span: Span,
2215}
2216
2217#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfArgumentPointer where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfArgumentPointer { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot pass `self` by raw pointer")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot pass `self` by raw pointer")));
diag
}
}
}
}
};Diagnostic)]
2218#[diag("cannot pass `self` by raw pointer")]
2219pub(crate) struct SelfArgumentPointer {
2220 #[primary_span]
2221 #[label("cannot pass `self` by raw pointer")]
2222 pub span: Span,
2223}
2224
2225#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterDot where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterDot {
span: __binding_0, actual: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: {$actual}")));
;
diag.arg("actual", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2226#[diag("unexpected token: {$actual}")]
2227pub(crate) struct UnexpectedTokenAfterDot {
2228 #[primary_span]
2229 pub span: Span,
2230 pub actual: String,
2231}
2232
2233#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VisibilityNotFollowedByItem where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VisibilityNotFollowedByItem {
span: __binding_0, vis: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("visibility `{$vis}` is not followed by an item")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")));
;
diag.arg("vis", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the visibility")));
diag
}
}
}
}
};Diagnostic)]
2234#[diag("visibility `{$vis}` is not followed by an item")]
2235#[help("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")]
2236pub(crate) struct VisibilityNotFollowedByItem {
2237 #[primary_span]
2238 #[label("the visibility")]
2239 pub span: Span,
2240 pub vis: String,
2241}
2242
2243#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DefaultNotFollowedByItem where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DefaultNotFollowedByItem { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` is not followed by an item")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `default` qualifier")));
diag
}
}
}
}
};Diagnostic)]
2244#[diag("`default` is not followed by an item")]
2245#[note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")]
2246pub(crate) struct DefaultNotFollowedByItem {
2247 #[primary_span]
2248 #[label("the `default` qualifier")]
2249 pub span: Span,
2250}
2251
2252#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FinalNotFollowedByItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FinalNotFollowedByItem { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`final` is not followed by an item")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only associated functions in traits may be prefixed by `final`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `final` qualifier")));
diag
}
}
}
}
};Diagnostic)]
2253#[diag("`final` is not followed by an item")]
2254#[note("only associated functions in traits may be prefixed by `final`")]
2255pub(crate) struct FinalNotFollowedByItem {
2256 #[primary_span]
2257 #[label("the `final` qualifier")]
2258 pub span: Span,
2259}
2260
2261#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingKeywordForItemDefinition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingKeywordForItemDefinition::Enum {
span: __binding_0,
insert_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `enum` for enum definition")));
let __code_137 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("enum "))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `enum` here to parse `{$ident}` as an enum")),
__code_137, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
MissingKeywordForItemDefinition::EnumOrStruct {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `enum` or `struct` for enum or struct definition")));
;
diag.span(__binding_0);
diag
}
MissingKeywordForItemDefinition::Struct {
span: __binding_0,
insert_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `struct` for struct definition")));
let __code_138 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("struct "))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `struct` here to parse `{$ident}` as a struct")),
__code_138, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
MissingKeywordForItemDefinition::Function {
span: __binding_0,
insert_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `fn` for function definition")));
let __code_139 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("fn "))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `fn` here to parse `{$ident}` as a function")),
__code_139, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
MissingKeywordForItemDefinition::Method {
span: __binding_0,
insert_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `fn` for method definition")));
let __code_140 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("fn "))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `fn` here to parse `{$ident}` as a method")),
__code_140, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
MissingKeywordForItemDefinition::Ambiguous {
span: __binding_0, subdiag: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `fn` or `struct` for function or struct definition")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2262pub(crate) enum MissingKeywordForItemDefinition {
2263 #[diag("missing `enum` for enum definition")]
2264 Enum {
2265 #[primary_span]
2266 span: Span,
2267 #[suggestion(
2268 "add `enum` here to parse `{$ident}` as an enum",
2269 style = "verbose",
2270 applicability = "maybe-incorrect",
2271 code = "enum "
2272 )]
2273 insert_span: Span,
2274 ident: Ident,
2275 },
2276 #[diag("missing `enum` or `struct` for enum or struct definition")]
2277 EnumOrStruct {
2278 #[primary_span]
2279 span: Span,
2280 },
2281 #[diag("missing `struct` for struct definition")]
2282 Struct {
2283 #[primary_span]
2284 span: Span,
2285 #[suggestion(
2286 "add `struct` here to parse `{$ident}` as a struct",
2287 style = "verbose",
2288 applicability = "maybe-incorrect",
2289 code = "struct "
2290 )]
2291 insert_span: Span,
2292 ident: Ident,
2293 },
2294 #[diag("missing `fn` for function definition")]
2295 Function {
2296 #[primary_span]
2297 span: Span,
2298 #[suggestion(
2299 "add `fn` here to parse `{$ident}` as a function",
2300 style = "verbose",
2301 applicability = "maybe-incorrect",
2302 code = "fn "
2303 )]
2304 insert_span: Span,
2305 ident: Ident,
2306 },
2307 #[diag("missing `fn` for method definition")]
2308 Method {
2309 #[primary_span]
2310 span: Span,
2311 #[suggestion(
2312 "add `fn` here to parse `{$ident}` as a method",
2313 style = "verbose",
2314 applicability = "maybe-incorrect",
2315 code = "fn "
2316 )]
2317 insert_span: Span,
2318 ident: Ident,
2319 },
2320 #[diag("missing `fn` or `struct` for function or struct definition")]
2321 Ambiguous {
2322 #[primary_span]
2323 span: Span,
2324 #[subdiagnostic]
2325 subdiag: Option<AmbiguousMissingKwForItemSub>,
2326 },
2327}
2328
2329#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AmbiguousMissingKwForItemSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousMissingKwForItemSub::SuggestMacro {
span: __binding_0, snippet: __binding_1 } => {
let __code_141 =
[::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("if you meant to call a macro, try")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_141, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
AmbiguousMissingKwForItemSub::HelpMacro => {
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 call a macro, remove the `pub` and add a trailing `!` after the identifier")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2330pub(crate) enum AmbiguousMissingKwForItemSub {
2331 #[suggestion(
2332 "if you meant to call a macro, try",
2333 applicability = "maybe-incorrect",
2334 code = "{snippet}!",
2335 style = "verbose"
2336 )]
2337 SuggestMacro {
2338 #[primary_span]
2339 span: Span,
2340 snippet: String,
2341 },
2342 #[help(
2343 "if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier"
2344 )]
2345 HelpMacro,
2346}
2347
2348#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingFnParams where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingFnParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing parameters for function definition")));
let __code_142 =
[::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("add a parameter list")),
__code_142, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2349#[diag("missing parameters for function definition")]
2350pub(crate) struct MissingFnParams {
2351 #[primary_span]
2352 #[suggestion(
2353 "add a parameter list",
2354 code = "()",
2355 applicability = "machine-applicable",
2356 style = "verbose"
2357 )]
2358 pub span: Span,
2359}
2360
2361#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidPathSepInFnDefinition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidPathSepInFnDefinition { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid path separator in function definition")));
let __code_143 =
[::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 invalid path separator")),
__code_143, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2362#[diag("invalid path separator in function definition")]
2363pub(crate) struct InvalidPathSepInFnDefinition {
2364 #[primary_span]
2365 #[suggestion(
2366 "remove invalid path separator",
2367 code = "",
2368 applicability = "machine-applicable",
2369 style = "verbose"
2370 )]
2371 pub span: Span,
2372}
2373
2374#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingTraitInTraitImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingTraitInTraitImpl {
span: __binding_0, for_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing trait in a trait impl")));
let __code_144 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" Trait "))
})].into_iter();
let __code_145 =
[::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("add a trait here")),
__code_144, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for an inherent impl, drop this `for`")),
__code_145, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2375#[diag("missing trait in a trait impl")]
2376pub(crate) struct MissingTraitInTraitImpl {
2377 #[primary_span]
2378 #[suggestion(
2379 "add a trait here",
2380 code = " Trait ",
2381 applicability = "has-placeholders",
2382 style = "verbose"
2383 )]
2384 pub span: Span,
2385 #[suggestion(
2386 "for an inherent impl, drop this `for`",
2387 code = "",
2388 applicability = "maybe-incorrect",
2389 style = "verbose"
2390 )]
2391 pub for_span: Span,
2392}
2393
2394#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingForInTraitImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingForInTraitImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `for` in a trait impl")));
let __code_146 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" for "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `for` here")),
__code_146, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2395#[diag("missing `for` in a trait impl")]
2396pub(crate) struct MissingForInTraitImpl {
2397 #[primary_span]
2398 #[suggestion(
2399 "add `for` here",
2400 style = "verbose",
2401 code = " for ",
2402 applicability = "machine-applicable"
2403 )]
2404 pub span: Span,
2405}
2406
2407#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedTraitInTraitImplFoundType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedTraitInTraitImplFoundType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a trait, found type")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2408#[diag("expected a trait, found type")]
2409pub(crate) struct ExpectedTraitInTraitImplFoundType {
2410 #[primary_span]
2411 pub span: Span,
2412}
2413
2414#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExtraImplKeywordInTraitImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExtraImplKeywordInTraitImpl {
extra_impl_kw: __binding_0, impl_trait_span: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `impl` keyword")));
let __code_147 =
[::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 extra `impl`")),
__code_147, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::HideCodeInline);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is parsed as an `impl Trait` type, but a trait is expected at this position")));
diag
}
}
}
}
};Diagnostic)]
2415#[diag("unexpected `impl` keyword")]
2416pub(crate) struct ExtraImplKeywordInTraitImpl {
2417 #[primary_span]
2418 #[suggestion(
2419 "remove the extra `impl`",
2420 code = "",
2421 applicability = "maybe-incorrect",
2422 style = "short"
2423 )]
2424 pub extra_impl_kw: Span,
2425 #[note("this is parsed as an `impl Trait` type, but a trait is expected at this position")]
2426 pub impl_trait_span: Span,
2427}
2428
2429#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BoundsNotAllowedOnTraitAliases where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoundsNotAllowedOnTraitAliases { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds are not allowed on trait aliases")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2430#[diag("bounds are not allowed on trait aliases")]
2431pub(crate) struct BoundsNotAllowedOnTraitAliases {
2432 #[primary_span]
2433 pub span: Span,
2434}
2435
2436#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitAliasCannotBeAuto where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitAliasCannotBeAuto { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `auto`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `auto`")));
diag
}
}
}
}
};Diagnostic)]
2437#[diag("trait aliases cannot be `auto`")]
2438pub(crate) struct TraitAliasCannotBeAuto {
2439 #[primary_span]
2440 #[label("trait aliases cannot be `auto`")]
2441 pub span: Span,
2442}
2443
2444#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitAliasCannotBeUnsafe where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitAliasCannotBeUnsafe { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `unsafe`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `unsafe`")));
diag
}
}
}
}
};Diagnostic)]
2445#[diag("trait aliases cannot be `unsafe`")]
2446pub(crate) struct TraitAliasCannotBeUnsafe {
2447 #[primary_span]
2448 #[label("trait aliases cannot be `unsafe`")]
2449 pub span: Span,
2450}
2451
2452#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitAliasCannotBeImplRestricted where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitAliasCannotBeImplRestricted { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `impl`-restricted")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `impl`-restricted")));
diag
}
}
}
}
};Diagnostic)]
2453#[diag("trait aliases cannot be `impl`-restricted")]
2454pub(crate) struct TraitAliasCannotBeImplRestricted {
2455 #[primary_span]
2456 #[label("trait aliases cannot be `impl`-restricted")]
2457 pub span: Span,
2458}
2459
2460#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssociatedStaticItemNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssociatedStaticItemNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated `static` items are not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2461#[diag("associated `static` items are not allowed")]
2462pub(crate) struct AssociatedStaticItemNotAllowed {
2463 #[primary_span]
2464 pub span: Span,
2465}
2466
2467#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternCrateNameWithDashes where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExternCrateNameWithDashes {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate name using dashes are not valid in `extern crate` statements")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dash-separated idents are not valid")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2468#[diag("crate name using dashes are not valid in `extern crate` statements")]
2469pub(crate) struct ExternCrateNameWithDashes {
2470 #[primary_span]
2471 #[label("dash-separated idents are not valid")]
2472 pub span: Span,
2473 #[subdiagnostic]
2474 pub sugg: ExternCrateNameWithDashesSugg,
2475}
2476
2477#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExternCrateNameWithDashesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExternCrateNameWithDashesSugg { dashes: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_148 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_148.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if the original crate name uses dashes you need to use underscores in the code")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2478#[multipart_suggestion(
2479 "if the original crate name uses dashes you need to use underscores in the code",
2480 applicability = "machine-applicable"
2481)]
2482pub(crate) struct ExternCrateNameWithDashesSugg {
2483 #[suggestion_part(code = "_")]
2484 pub dashes: Vec<Span>,
2485}
2486
2487#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternItemCannotBeConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExternItemCannotBeConst {
ident_span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern items cannot be `const`")));
let __code_149 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("static "))
})].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.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("try using a static value")),
__code_149, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
2488#[diag("extern items cannot be `const`")]
2489#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
2490pub(crate) struct ExternItemCannotBeConst {
2491 #[primary_span]
2492 pub ident_span: Span,
2493 #[suggestion(
2494 "try using a static value",
2495 code = "static ",
2496 applicability = "machine-applicable",
2497 style = "verbose"
2498 )]
2499 pub const_span: Option<Span>,
2500}
2501
2502#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstGlobalCannotBeMutable where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstGlobalCannotBeMutable {
ident_span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const globals cannot be mutable")));
let __code_150 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("static"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot be mutable")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might want to declare a static instead")),
__code_150, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2503#[diag("const globals cannot be mutable")]
2504pub(crate) struct ConstGlobalCannotBeMutable {
2505 #[primary_span]
2506 #[label("cannot be mutable")]
2507 pub ident_span: Span,
2508 #[suggestion(
2509 "you might want to declare a static instead",
2510 code = "static",
2511 style = "verbose",
2512 applicability = "maybe-incorrect"
2513 )]
2514 pub const_span: Span,
2515}
2516
2517#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingConstType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingConstType {
span: __binding_0, kind: __binding_1, colon: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing type for `{$kind}` item")));
let __code_151 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} <type>",
__binding_2))
})].into_iter();
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a type for the item")),
__code_151, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2518#[diag("missing type for `{$kind}` item")]
2519pub(crate) struct MissingConstType {
2520 #[primary_span]
2521 #[suggestion(
2522 "provide a type for the item",
2523 code = "{colon} <type>",
2524 style = "verbose",
2525 applicability = "has-placeholders"
2526 )]
2527 pub span: Span,
2528
2529 pub kind: &'static str,
2530 pub colon: &'static str,
2531}
2532
2533#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EnumStructMutuallyExclusive where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EnumStructMutuallyExclusive { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`enum` and `struct` are mutually exclusive")));
let __code_152 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("enum"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `enum struct` with")),
__code_152, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2534#[diag("`enum` and `struct` are mutually exclusive")]
2535pub(crate) struct EnumStructMutuallyExclusive {
2536 #[primary_span]
2537 #[suggestion(
2538 "replace `enum struct` with",
2539 code = "enum",
2540 style = "verbose",
2541 applicability = "machine-applicable"
2542 )]
2543 pub span: Span,
2544}
2545
2546#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterStructName where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterStructName::ReservedIdentifier {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::Keyword {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::ReservedKeyword {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::DocComment {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::MetaVar { span: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::Other {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
}
}
}
};Diagnostic)]
2547pub(crate) enum UnexpectedTokenAfterStructName {
2548 #[diag(
2549 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`"
2550 )]
2551 ReservedIdentifier {
2552 #[primary_span]
2553 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2554 span: Span,
2555 token: Cow<'static, str>,
2556 },
2557 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")]
2558 Keyword {
2559 #[primary_span]
2560 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2561 span: Span,
2562 token: Cow<'static, str>,
2563 },
2564 #[diag(
2565 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`"
2566 )]
2567 ReservedKeyword {
2568 #[primary_span]
2569 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2570 span: Span,
2571 token: Cow<'static, str>,
2572 },
2573 #[diag(
2574 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`"
2575 )]
2576 DocComment {
2577 #[primary_span]
2578 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2579 span: Span,
2580 token: Cow<'static, str>,
2581 },
2582 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")]
2583 MetaVar {
2584 #[primary_span]
2585 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2586 span: Span,
2587 },
2588 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")]
2589 Other {
2590 #[primary_span]
2591 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2592 span: Span,
2593 token: Cow<'static, str>,
2594 },
2595}
2596
2597impl UnexpectedTokenAfterStructName {
2598 pub(crate) fn new(span: Span, orig_token: Token) -> Self {
2599 let token = pprust::token_to_string(&orig_token);
2600 match TokenDescription::from_token(&orig_token) {
2601 Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
2602 Some(TokenDescription::Keyword) => Self::Keyword { span, token },
2603 Some(TokenDescription::ReservedKeyword) => Self::ReservedKeyword { span, token },
2604 Some(TokenDescription::DocComment) => Self::DocComment { span, token },
2605 Some(TokenDescription::MetaVar(_)) => Self::MetaVar { span },
2606 None => Self::Other { span, token },
2607 }
2608 }
2609}
2610
2611#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedSelfInGenericParameters where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedSelfInGenericParameters { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected keyword `Self` in generic parameters")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you cannot use `Self` as a generic parameter because it is reserved for associated items")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2612#[diag("unexpected keyword `Self` in generic parameters")]
2613#[note("you cannot use `Self` as a generic parameter because it is reserved for associated items")]
2614pub(crate) struct UnexpectedSelfInGenericParameters {
2615 #[primary_span]
2616 pub span: Span,
2617}
2618
2619#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedDefaultValueForLifetimeInGenericParameters where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedDefaultValueForLifetimeInGenericParameters {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected default lifetime parameter")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters cannot have default values")));
diag
}
}
}
}
};Diagnostic)]
2620#[diag("unexpected default lifetime parameter")]
2621pub(crate) struct UnexpectedDefaultValueForLifetimeInGenericParameters {
2622 #[primary_span]
2623 #[label("lifetime parameters cannot have default values")]
2624 pub span: Span,
2625}
2626
2627#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MultipleWhereClauses where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MultipleWhereClauses {
span: __binding_0,
previous: __binding_1,
between: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define duplicate `where` clauses on an item")));
let __code_153 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(","))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous `where` clause starts here")));
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider joining the two `where` clauses into one")),
__code_153, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2628#[diag("cannot define duplicate `where` clauses on an item")]
2629pub(crate) struct MultipleWhereClauses {
2630 #[primary_span]
2631 pub span: Span,
2632 #[label("previous `where` clause starts here")]
2633 pub previous: Span,
2634 #[suggestion(
2635 "consider joining the two `where` clauses into one",
2636 style = "verbose",
2637 code = ",",
2638 applicability = "maybe-incorrect"
2639 )]
2640 pub between: Span,
2641}
2642
2643#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedNonterminal where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedNonterminal::Item(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an item keyword")));
;
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Statement(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a statement")));
;
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Ident {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected ident, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Lifetime {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a lifetime, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2644pub(crate) enum UnexpectedNonterminal {
2645 #[diag("expected an item keyword")]
2646 Item(#[primary_span] Span),
2647 #[diag("expected a statement")]
2648 Statement(#[primary_span] Span),
2649 #[diag("expected ident, found `{$token}`")]
2650 Ident {
2651 #[primary_span]
2652 span: Span,
2653 token: Cow<'static, str>,
2654 },
2655 #[diag("expected a lifetime, found `{$token}`")]
2656 Lifetime {
2657 #[primary_span]
2658 span: Span,
2659 token: Cow<'static, str>,
2660 },
2661}
2662
2663#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TopLevelOrPatternNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TopLevelOrPatternNotAllowed::LetBinding {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`let` bindings require top-level or-patterns in parentheses")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
TopLevelOrPatternNotAllowed::FunctionParameter {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function parameters require top-level or-patterns in parentheses")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2664pub(crate) enum TopLevelOrPatternNotAllowed {
2665 #[diag("`let` bindings require top-level or-patterns in parentheses")]
2666 LetBinding {
2667 #[primary_span]
2668 span: Span,
2669 #[subdiagnostic]
2670 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2671 },
2672 #[diag("function parameters require top-level or-patterns in parentheses")]
2673 FunctionParameter {
2674 #[primary_span]
2675 span: Span,
2676 #[subdiagnostic]
2677 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2678 },
2679}
2680
2681#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeRawIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeRawIdent { span: __binding_0, ident: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` cannot be a raw identifier")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2682#[diag("`{$ident}` cannot be a raw identifier")]
2683pub(crate) struct CannotBeRawIdent {
2684 #[primary_span]
2685 pub span: Span,
2686 pub ident: Symbol,
2687}
2688
2689#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeRawLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeRawLifetime { span: __binding_0, ident: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` cannot be a raw lifetime")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2690#[diag("`{$ident}` cannot be a raw lifetime")]
2691pub(crate) struct CannotBeRawLifetime {
2692 #[primary_span]
2693 pub span: Span,
2694 pub ident: Symbol,
2695}
2696
2697#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
KeywordLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
KeywordLifetime { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes cannot use keyword names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2698#[diag("lifetimes cannot use keyword names")]
2699pub(crate) struct KeywordLifetime {
2700 #[primary_span]
2701 pub span: Span,
2702}
2703
2704#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for KeywordLabel
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
KeywordLabel { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labels cannot use keyword names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2705#[diag("labels cannot use keyword names")]
2706pub(crate) struct KeywordLabel {
2707 #[primary_span]
2708 pub span: Span,
2709}
2710
2711#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CrDocComment
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CrDocComment { span: __binding_0, block: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in {$block ->\n [true] block doc-comment\n *[false] doc-comment\n }")));
;
diag.arg("block", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2712#[diag(
2713 "bare CR not allowed in {$block ->
2714 [true] block doc-comment
2715 *[false] doc-comment
2716 }"
2717)]
2718pub(crate) struct CrDocComment {
2719 #[primary_span]
2720 pub span: Span,
2721 pub block: bool,
2722}
2723
2724#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NoDigitsLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NoDigitsLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no valid digits found for number")));
diag.code(E0768);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2725#[diag("no valid digits found for number", code = E0768)]
2726pub(crate) struct NoDigitsLiteral {
2727 #[primary_span]
2728 pub span: Span,
2729}
2730
2731#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidDigitLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidDigitLiteral { span: __binding_0, base: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid digit for a base {$base} literal")));
;
diag.arg("base", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2732#[diag("invalid digit for a base {$base} literal")]
2733pub(crate) struct InvalidDigitLiteral {
2734 #[primary_span]
2735 pub span: Span,
2736 pub base: u32,
2737}
2738
2739#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmptyExponentFloat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EmptyExponentFloat { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected at least one digit in exponent")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2740#[diag("expected at least one digit in exponent")]
2741pub(crate) struct EmptyExponentFloat {
2742 #[primary_span]
2743 pub span: Span,
2744}
2745
2746#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FloatLiteralUnsupportedBase where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FloatLiteralUnsupportedBase {
span: __binding_0, base: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$base} float literal is not supported")));
;
diag.arg("base", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2747#[diag("{$base} float literal is not supported")]
2748pub(crate) struct FloatLiteralUnsupportedBase {
2749 #[primary_span]
2750 pub span: Span,
2751 pub base: &'static str,
2752}
2753
2754#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownPrefix<'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 {
UnknownPrefix {
span: __binding_0, prefix: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefix `{$prefix}` is unknown")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefixed identifiers and literals are reserved since Rust 2021")));
;
diag.arg("prefix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown prefix")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
2755#[diag("prefix `{$prefix}` is unknown")]
2756#[note("prefixed identifiers and literals are reserved since Rust 2021")]
2757pub(crate) struct UnknownPrefix<'a> {
2758 #[primary_span]
2759 #[label("unknown prefix")]
2760 pub span: Span,
2761 pub prefix: &'a str,
2762 #[subdiagnostic]
2763 pub sugg: Option<UnknownPrefixSugg>,
2764}
2765
2766#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for MacroExpandsToAdtField<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroExpandsToAdtField { adt_ty: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("adt_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot expand to {$adt_ty} fields")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2767#[note("macros cannot expand to {$adt_ty} fields")]
2768pub(crate) struct MacroExpandsToAdtField<'a> {
2769 pub adt_ty: &'a str,
2770}
2771
2772#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownPrefixSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownPrefixSugg::UseBr(__binding_0) => {
let __code_154 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("br"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `br` for a raw byte string")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_154, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::UseCr(__binding_0) => {
let __code_155 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("cr"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `cr` for a raw C-string")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_155, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::Whitespace(__binding_0) => {
let __code_156 =
[::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("consider inserting whitespace here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_156, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::MeantStr {
start: __binding_0, end: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_157 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_158 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_157));
suggestions.push((__binding_1, __code_158));
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 write a string literal, use double quotes")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2773pub(crate) enum UnknownPrefixSugg {
2774 #[suggestion(
2775 "use `br` for a raw byte string",
2776 code = "br",
2777 applicability = "maybe-incorrect",
2778 style = "verbose"
2779 )]
2780 UseBr(#[primary_span] Span),
2781 #[suggestion(
2782 "use `cr` for a raw C-string",
2783 code = "cr",
2784 applicability = "maybe-incorrect",
2785 style = "verbose"
2786 )]
2787 UseCr(#[primary_span] Span),
2788 #[suggestion(
2789 "consider inserting whitespace here",
2790 code = " ",
2791 applicability = "maybe-incorrect",
2792 style = "verbose"
2793 )]
2794 Whitespace(#[primary_span] Span),
2795 #[multipart_suggestion(
2796 "if you meant to write a string literal, use double quotes",
2797 applicability = "maybe-incorrect",
2798 style = "verbose"
2799 )]
2800 MeantStr {
2801 #[suggestion_part(code = "\"")]
2802 start: Span,
2803 #[suggestion_part(code = "\"")]
2804 end: Span,
2805 },
2806}
2807
2808#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReservedMultihash where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedMultihash { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reserved multi-hash token is forbidden")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sequences of two or more # are reserved for future use since Rust 2024")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2809#[diag("reserved multi-hash token is forbidden")]
2810#[note("sequences of two or more # are reserved for future use since Rust 2024")]
2811pub(crate) struct ReservedMultihash {
2812 #[primary_span]
2813 pub span: Span,
2814 #[subdiagnostic]
2815 pub sugg: Option<GuardedStringSugg>,
2816}
2817#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ReservedString
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedString { span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid string literal")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unprefixed guarded string literals are reserved for future use since Rust 2024")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2818#[diag("invalid string literal")]
2819#[note("unprefixed guarded string literals are reserved for future use since Rust 2024")]
2820pub(crate) struct ReservedString {
2821 #[primary_span]
2822 pub span: Span,
2823 #[subdiagnostic]
2824 pub sugg: Option<GuardedStringSugg>,
2825}
2826#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GuardedStringSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GuardedStringSugg(__binding_0) => {
let __code_159 =
[::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("consider inserting whitespace here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_159, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2827#[suggestion(
2828 "consider inserting whitespace here",
2829 code = " ",
2830 applicability = "maybe-incorrect",
2831 style = "verbose"
2832)]
2833pub(crate) struct GuardedStringSugg(#[primary_span] pub Span);
2834
2835#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TooManyHashes
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TooManyHashes { span: __binding_0, num: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}")));
;
diag.arg("num", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2836#[diag(
2837 "too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}"
2838)]
2839pub(crate) struct TooManyHashes {
2840 #[primary_span]
2841 pub span: Span,
2842 pub num: u32,
2843}
2844
2845#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownTokenStart where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownTokenStart {
span: __binding_0,
escaped: __binding_1,
sugg: __binding_2,
null: __binding_3,
repeat: __binding_4,
invisible: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown start of token: {$escaped}")));
;
diag.arg("escaped", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used")));
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if __binding_5 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invisible characters like '{$escaped}' are not usually visible in text editors")));
}
diag
}
}
}
}
};Diagnostic)]
2846#[diag("unknown start of token: {$escaped}")]
2847pub(crate) struct UnknownTokenStart {
2848 #[primary_span]
2849 pub span: Span,
2850 pub escaped: String,
2851 #[subdiagnostic]
2852 pub sugg: Option<TokenSubstitution>,
2853 #[help(
2854 "source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
2855 )]
2856 pub null: bool,
2857 #[subdiagnostic]
2858 pub repeat: Option<UnknownTokenRepeat>,
2859 #[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
2860 pub invisible: bool,
2861}
2862
2863#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TokenSubstitution {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TokenSubstitution::DirectedQuotes {
span: __binding_0,
suggestion: __binding_1,
ascii_str: __binding_2,
ascii_name: __binding_3 } => {
let __code_160 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ascii_str".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("ascii_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("Unicode characters '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '{$ascii_str}' ({$ascii_name}), but are not")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_160, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
TokenSubstitution::Other {
span: __binding_0,
suggestion: __binding_1,
ch: __binding_2,
u_name: __binding_3,
ascii_str: __binding_4,
ascii_name: __binding_5 } => {
let __code_161 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ch".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("u_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("ascii_str".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
sub_args.insert("ascii_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_161, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2864pub(crate) enum TokenSubstitution {
2865 #[suggestion(
2866 "Unicode characters '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '{$ascii_str}' ({$ascii_name}), but are not",
2867 code = "{suggestion}",
2868 applicability = "maybe-incorrect",
2869 style = "verbose"
2870 )]
2871 DirectedQuotes {
2872 #[primary_span]
2873 span: Span,
2874 suggestion: String,
2875 ascii_str: &'static str,
2876 ascii_name: &'static str,
2877 },
2878 #[suggestion(
2879 "Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not",
2880 code = "{suggestion}",
2881 applicability = "maybe-incorrect",
2882 style = "verbose"
2883 )]
2884 Other {
2885 #[primary_span]
2886 span: Span,
2887 suggestion: String,
2888 ch: String,
2889 u_name: &'static str,
2890 ascii_str: &'static str,
2891 ascii_name: &'static str,
2892 },
2893}
2894
2895#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownTokenRepeat {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownTokenRepeat { repeats: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("repeats".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("character appears {$repeats ->\n [one] once more\n *[other] {$repeats} more times\n }")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2896#[note(
2897 "character appears {$repeats ->
2898 [one] once more
2899 *[other] {$repeats} more times
2900 }"
2901)]
2902pub(crate) struct UnknownTokenRepeat {
2903 pub repeats: usize,
2904}
2905
2906#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnescapeError
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnescapeError::InvalidUnicodeEscape {
span: __binding_0, surrogate: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid unicode character escape")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode escape must {$surrogate ->\n [true] not be a surrogate\n *[false] be at most 10FFFF\n }")));
;
diag.arg("surrogate", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid escape")));
diag
}
UnescapeError::EscapeOnlyChar {
span: __binding_0,
char_span: __binding_1,
escaped_sugg: __binding_2,
escaped_msg: __binding_3,
byte: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$byte ->\n [true] byte\n *[false] character\n } constant must be escaped: `{$escaped_msg}`")));
let __code_162 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
;
diag.arg("escaped_msg", __binding_3);
diag.arg("byte", __binding_4);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("escape the character")),
__code_162, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
UnescapeError::BareCr {
span: __binding_0, double_quotes: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$double_quotes ->\n [true] bare CR not allowed in string, use `\\r` instead\n *[false] character constant must be escaped: `\\r`\n }")));
let __code_163 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\\r"))
})].into_iter();
;
diag.arg("double_quotes", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("escape the character")),
__code_163, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
UnescapeError::BareCrRawString(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in raw string")));
;
diag.span(__binding_0);
diag
}
UnescapeError::TooShortHexEscape(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("numeric character escape is too short")));
;
diag.span(__binding_0);
diag
}
UnescapeError::InvalidCharInEscape {
span: __binding_0, is_hex: __binding_1, ch: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character in {$is_hex ->\n [true] numeric character\n *[false] unicode\n } escape: `{$ch}`")));
;
diag.arg("is_hex", __binding_1);
diag.arg("ch", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character in {$is_hex ->\n [true] numeric character\n *[false] unicode\n } escape")));
diag
}
UnescapeError::LeadingUnderscoreUnicodeEscape {
span: __binding_0, ch: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid start of unicode escape: `_`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid start of unicode escape")));
diag
}
UnescapeError::OverlongUnicodeEscape(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overlong unicode escape")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must have at most 6 hex digits")));
diag
}
UnescapeError::UnclosedUnicodeEscape(__binding_0,
__binding_1) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unterminated unicode escape")));
let __code_164 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("}}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing a closing `{\"}\"}`")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("terminate the unicode escape")),
__code_164, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
UnescapeError::NoBraceInUnicodeEscape {
span: __binding_0, label: __binding_1, sub: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect unicode escape sequence")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect unicode escape sequence")));
}
diag.subdiagnostic(__binding_2);
diag
}
UnescapeError::UnicodeEscapeInByte(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode escape in byte string")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode escape sequences cannot be used as a byte or in a byte string")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode escape in byte string")));
diag
}
UnescapeError::EmptyUnicodeEscape(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("empty unicode escape")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this escape must have at least 1 hex digit")));
diag
}
UnescapeError::ZeroChars(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("empty character literal")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("empty character literal")));
diag
}
UnescapeError::LoneSlash(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid trailing slash in literal")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid trailing slash in literal")));
diag
}
UnescapeError::UnskippedWhitespace {
span: __binding_0, char_span: __binding_1, ch: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("whitespace symbol '{$ch}' is not skipped")));
;
diag.arg("ch", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("whitespace symbol '{$ch}' is not skipped")));
diag
}
UnescapeError::MultipleSkippedLinesWarning(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple lines skipped by escaped newline")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("skipping everything up to and including this point")));
diag
}
UnescapeError::MoreThanOneChar {
span: __binding_0,
note: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("character literal may only contain one codepoint")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag.subdiagnostic(__binding_2);
diag
}
UnescapeError::NulInCStr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("null characters in C string literals are not supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2907pub(crate) enum UnescapeError {
2908 #[diag("invalid unicode character escape")]
2909 #[help(
2910 "unicode escape must {$surrogate ->
2911 [true] not be a surrogate
2912 *[false] be at most 10FFFF
2913 }"
2914 )]
2915 InvalidUnicodeEscape {
2916 #[primary_span]
2917 #[label("invalid escape")]
2918 span: Span,
2919 surrogate: bool,
2920 },
2921 #[diag(
2922 "{$byte ->
2923 [true] byte
2924 *[false] character
2925 } constant must be escaped: `{$escaped_msg}`"
2926 )]
2927 EscapeOnlyChar {
2928 #[primary_span]
2929 span: Span,
2930 #[suggestion(
2931 "escape the character",
2932 applicability = "machine-applicable",
2933 code = "{escaped_sugg}",
2934 style = "verbose"
2935 )]
2936 char_span: Span,
2937 escaped_sugg: String,
2938 escaped_msg: String,
2939 byte: bool,
2940 },
2941 #[diag(
2942 r#"{$double_quotes ->
2943 [true] bare CR not allowed in string, use `\r` instead
2944 *[false] character constant must be escaped: `\r`
2945 }"#
2946 )]
2947 BareCr {
2948 #[primary_span]
2949 #[suggestion(
2950 "escape the character",
2951 applicability = "machine-applicable",
2952 code = "\\r",
2953 style = "verbose"
2954 )]
2955 span: Span,
2956 double_quotes: bool,
2957 },
2958 #[diag("bare CR not allowed in raw string")]
2959 BareCrRawString(#[primary_span] Span),
2960 #[diag("numeric character escape is too short")]
2961 TooShortHexEscape(#[primary_span] Span),
2962 #[diag(
2963 "invalid character in {$is_hex ->
2964 [true] numeric character
2965 *[false] unicode
2966 } escape: `{$ch}`"
2967 )]
2968 InvalidCharInEscape {
2969 #[primary_span]
2970 #[label(
2971 "invalid character in {$is_hex ->
2972 [true] numeric character
2973 *[false] unicode
2974 } escape"
2975 )]
2976 span: Span,
2977 is_hex: bool,
2978 ch: String,
2979 },
2980 #[diag("invalid start of unicode escape: `_`")]
2981 LeadingUnderscoreUnicodeEscape {
2982 #[primary_span]
2983 #[label("invalid start of unicode escape")]
2984 span: Span,
2985 ch: String,
2986 },
2987 #[diag("overlong unicode escape")]
2988 OverlongUnicodeEscape(
2989 #[primary_span]
2990 #[label("must have at most 6 hex digits")]
2991 Span,
2992 ),
2993 #[diag("unterminated unicode escape")]
2994 UnclosedUnicodeEscape(
2995 #[primary_span]
2996 #[label(r#"missing a closing `{"}"}`"#)]
2997 Span,
2998 #[suggestion(
2999 "terminate the unicode escape",
3000 code = "}}",
3001 applicability = "maybe-incorrect",
3002 style = "verbose"
3003 )]
3004 Span,
3005 ),
3006 #[diag("incorrect unicode escape sequence")]
3007 NoBraceInUnicodeEscape {
3008 #[primary_span]
3009 span: Span,
3010 #[label("incorrect unicode escape sequence")]
3011 label: Option<Span>,
3012 #[subdiagnostic]
3013 sub: NoBraceUnicodeSub,
3014 },
3015 #[diag("unicode escape in byte string")]
3016 #[help("unicode escape sequences cannot be used as a byte or in a byte string")]
3017 UnicodeEscapeInByte(
3018 #[primary_span]
3019 #[label("unicode escape in byte string")]
3020 Span,
3021 ),
3022 #[diag("empty unicode escape")]
3023 EmptyUnicodeEscape(
3024 #[primary_span]
3025 #[label("this escape must have at least 1 hex digit")]
3026 Span,
3027 ),
3028 #[diag("empty character literal")]
3029 ZeroChars(
3030 #[primary_span]
3031 #[label("empty character literal")]
3032 Span,
3033 ),
3034 #[diag("invalid trailing slash in literal")]
3035 LoneSlash(
3036 #[primary_span]
3037 #[label("invalid trailing slash in literal")]
3038 Span,
3039 ),
3040 #[diag("whitespace symbol '{$ch}' is not skipped")]
3041 UnskippedWhitespace {
3042 #[primary_span]
3043 span: Span,
3044 #[label("whitespace symbol '{$ch}' is not skipped")]
3045 char_span: Span,
3046 ch: String,
3047 },
3048 #[diag("multiple lines skipped by escaped newline")]
3049 MultipleSkippedLinesWarning(
3050 #[primary_span]
3051 #[label("skipping everything up to and including this point")]
3052 Span,
3053 ),
3054 #[diag("character literal may only contain one codepoint")]
3055 MoreThanOneChar {
3056 #[primary_span]
3057 span: Span,
3058 #[subdiagnostic]
3059 note: Option<MoreThanOneCharNote>,
3060 #[subdiagnostic]
3061 suggestion: MoreThanOneCharSugg,
3062 },
3063 #[diag("null characters in C string literals are not supported")]
3064 NulInCStr {
3065 #[primary_span]
3066 span: Span,
3067 },
3068}
3069
3070#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoreThanOneCharSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoreThanOneCharSugg::NormalizedForm {
span: __binding_0, ch: __binding_1, normalized: __binding_2
} => {
let __code_165 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ch".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("consider using the normalized form `{$ch}` of this character")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_165, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::RemoveNonPrinting {
span: __binding_0, ch: __binding_1 } => {
let __code_166 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ch".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("consider removing the non-printing characters")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_166, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::QuotesFull {
span: __binding_0, is_byte: __binding_1, sugg: __binding_2 }
=> {
let __code_167 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("is_byte".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("if you meant to write a {$is_byte ->\n [true] byte string\n *[false] string\n } literal, use double quotes")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_167, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::Quotes {
start: __binding_0,
end: __binding_1,
is_byte: __binding_2,
prefix: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_168 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}\"", __binding_3))
});
let __code_169 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_168));
suggestions.push((__binding_1, __code_169));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("is_byte".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a {$is_byte ->\n [true] byte string\n *[false] string\n } literal, use double quotes")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3071pub(crate) enum MoreThanOneCharSugg {
3072 #[suggestion(
3073 "consider using the normalized form `{$ch}` of this character",
3074 code = "{normalized}",
3075 applicability = "machine-applicable",
3076 style = "verbose"
3077 )]
3078 NormalizedForm {
3079 #[primary_span]
3080 span: Span,
3081 ch: String,
3082 normalized: String,
3083 },
3084 #[suggestion(
3085 "consider removing the non-printing characters",
3086 code = "{ch}",
3087 applicability = "maybe-incorrect",
3088 style = "verbose"
3089 )]
3090 RemoveNonPrinting {
3091 #[primary_span]
3092 span: Span,
3093 ch: String,
3094 },
3095 #[suggestion(
3096 "if you meant to write a {$is_byte ->
3097 [true] byte string
3098 *[false] string
3099 } literal, use double quotes",
3100 code = "{sugg}",
3101 applicability = "machine-applicable",
3102 style = "verbose"
3103 )]
3104 QuotesFull {
3105 #[primary_span]
3106 span: Span,
3107 is_byte: bool,
3108 sugg: String,
3109 },
3110 #[multipart_suggestion(
3111 "if you meant to write a {$is_byte ->
3112 [true] byte string
3113 *[false] string
3114 } literal, use double quotes",
3115 applicability = "machine-applicable"
3116 )]
3117 Quotes {
3118 #[suggestion_part(code = "{prefix}\"")]
3119 start: Span,
3120 #[suggestion_part(code = "\"")]
3121 end: Span,
3122 is_byte: bool,
3123 prefix: &'static str,
3124 },
3125}
3126
3127#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoreThanOneCharNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoreThanOneCharNote::AllCombining {
span: __binding_0,
chr: __binding_1,
len: __binding_2,
escaped_marks: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("chr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("len".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("escaped_marks".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `{$chr}` is followed by the combining {$len ->\n [one] mark\n *[other] marks\n } `{$escaped_marks}`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
MoreThanOneCharNote::NonPrinting {
span: __binding_0, escaped: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("escaped".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("there are non-printing characters, the full sequence is `{$escaped}`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
3128pub(crate) enum MoreThanOneCharNote {
3129 #[note(
3130 "this `{$chr}` is followed by the combining {$len ->
3131 [one] mark
3132 *[other] marks
3133 } `{$escaped_marks}`"
3134 )]
3135 AllCombining {
3136 #[primary_span]
3137 span: Span,
3138 chr: String,
3139 len: usize,
3140 escaped_marks: String,
3141 },
3142 #[note("there are non-printing characters, the full sequence is `{$escaped}`")]
3143 NonPrinting {
3144 #[primary_span]
3145 span: Span,
3146 escaped: String,
3147 },
3148}
3149
3150#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NoBraceUnicodeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoBraceUnicodeSub::Suggestion {
span: __binding_0, suggestion: __binding_1 } => {
let __code_170 =
[::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("format of unicode escape sequences uses braces")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_170, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
NoBraceUnicodeSub::Help => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format of unicode escape sequences is `\\u{\"{...}\"}`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
3151pub(crate) enum NoBraceUnicodeSub {
3152 #[suggestion(
3153 "format of unicode escape sequences uses braces",
3154 code = "{suggestion}",
3155 applicability = "maybe-incorrect",
3156 style = "verbose"
3157 )]
3158 Suggestion {
3159 #[primary_span]
3160 span: Span,
3161 suggestion: String,
3162 },
3163 #[help(r#"format of unicode escape sequences is `\u{"{...}"}`"#)]
3164 Help,
3165}
3166
3167#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInParens {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInParens { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_171 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_172 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_171));
suggestions.push((__binding_1, __code_172));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the pattern in parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3168#[multipart_suggestion("wrap the pattern in parentheses", applicability = "machine-applicable")]
3169pub(crate) struct WrapInParens {
3170 #[suggestion_part(code = "(")]
3171 pub(crate) lo: Span,
3172 #[suggestion_part(code = ")")]
3173 pub(crate) hi: Span,
3174}
3175
3176#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TopLevelOrPatternNotAllowedSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TopLevelOrPatternNotAllowedSugg::RemoveLeadingVert {
span: __binding_0 } => {
let __code_173 =
[::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 the `|`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_173, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
TopLevelOrPatternNotAllowedSugg::WrapInParens {
span: __binding_0, suggestion: __binding_1 } => {
__binding_1.add_to_diag(diag);
let mut sub_args = rustc_errors::DiagArgMap::default();
}
}
}
}
};Subdiagnostic)]
3177pub(crate) enum TopLevelOrPatternNotAllowedSugg {
3178 #[suggestion(
3179 "remove the `|`",
3180 code = "",
3181 applicability = "machine-applicable",
3182 style = "tool-only"
3183 )]
3184 RemoveLeadingVert {
3185 #[primary_span]
3186 span: Span,
3187 },
3188 WrapInParens {
3189 #[primary_span]
3190 span: Span,
3191 #[subdiagnostic]
3192 suggestion: WrapInParens,
3193 },
3194}
3195
3196#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedVertVertBeforeFunctionParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedVertVertBeforeFunctionParam { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `||` before function parameter")));
let __code_174 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatives in or-patterns are separated with `|`, not `||`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `||`")),
__code_174, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3197#[diag("unexpected `||` before function parameter")]
3198#[note("alternatives in or-patterns are separated with `|`, not `||`")]
3199pub(crate) struct UnexpectedVertVertBeforeFunctionParam {
3200 #[primary_span]
3201 #[suggestion(
3202 "remove the `||`",
3203 code = "",
3204 applicability = "machine-applicable",
3205 style = "verbose"
3206 )]
3207 pub span: Span,
3208}
3209
3210#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedVertVertInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedVertVertInPattern {
span: __binding_0, start: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token `||` in pattern")));
let __code_175 =
[::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("use a single `|` to separate multiple alternative patterns")),
__code_175, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this or-pattern starting here")));
}
diag
}
}
}
}
};Diagnostic)]
3211#[diag("unexpected token `||` in pattern")]
3212pub(crate) struct UnexpectedVertVertInPattern {
3213 #[primary_span]
3214 #[suggestion(
3215 "use a single `|` to separate multiple alternative patterns",
3216 code = "|",
3217 applicability = "machine-applicable",
3218 style = "verbose"
3219 )]
3220 pub span: Span,
3221 #[label("while parsing this or-pattern starting here")]
3222 pub start: Option<Span>,
3223}
3224
3225#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TrailingVertSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TrailingVertSuggestion {
span: __binding_0, token: __binding_1 } => {
let __code_176 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("token".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("a trailing `{$token}` is not allowed in an or-pattern")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_176, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
3226#[suggestion(
3227 "a trailing `{$token}` is not allowed in an or-pattern",
3228 code = "",
3229 applicability = "machine-applicable",
3230 style = "tool-only"
3231)]
3232pub(crate) struct TrailingVertSuggestion {
3233 #[primary_span]
3234 pub span: Span,
3235 pub token: Cow<'static, str>,
3236}
3237
3238#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TrailingVertNotAllowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TrailingVertNotAllowed {
span: __binding_0,
suggestion: __binding_1,
start: __binding_2,
token: __binding_3,
note_double_vert: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a trailing `{$token}` is not allowed in an or-pattern")));
;
diag.arg("token", __binding_3);
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this or-pattern starting here")));
}
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatives in or-patterns are separated with `|`, not `||`")));
}
diag
}
}
}
}
};Diagnostic)]
3239#[diag("a trailing `{$token}` is not allowed in an or-pattern")]
3240pub(crate) struct TrailingVertNotAllowed {
3241 #[primary_span]
3242 pub span: Span,
3243 #[subdiagnostic]
3244 pub suggestion: TrailingVertSuggestion,
3245 #[label("while parsing this or-pattern starting here")]
3246 pub start: Option<Span>,
3247 pub token: Cow<'static, str>,
3248 #[note("alternatives in or-patterns are separated with `|`, not `||`")]
3249 pub note_double_vert: bool,
3250}
3251
3252#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotRestPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotRestPattern {
span: __binding_0,
suggestion: __binding_1,
var_args: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `...`")));
let __code_177 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a valid pattern")));
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for a rest pattern, use `..` instead of `...`")),
__code_177, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list")));
}
diag
}
}
}
}
};Diagnostic)]
3253#[diag("unexpected `...`")]
3254pub(crate) struct DotDotDotRestPattern {
3255 #[primary_span]
3256 #[label("not a valid pattern")]
3257 pub span: Span,
3258 #[suggestion(
3259 "for a rest pattern, use `..` instead of `...`",
3260 style = "verbose",
3261 code = "..",
3262 applicability = "machine-applicable"
3263 )]
3264 pub suggestion: Option<Span>,
3265 #[note(
3266 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3267 )]
3268 pub var_args: Option<()>,
3269}
3270
3271#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternOnWrongSideOfAt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternOnWrongSideOfAt {
whole_span: __binding_0,
whole_pat: __binding_1,
pattern: __binding_2,
binding: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern on wrong side of `@`")));
let __code_178 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order")),
__code_178, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern on the left, should be on the right")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("binding on the right, should be on the left")));
diag
}
}
}
}
};Diagnostic)]
3272#[diag("pattern on wrong side of `@`")]
3273pub(crate) struct PatternOnWrongSideOfAt {
3274 #[primary_span]
3275 #[suggestion(
3276 "switch the order",
3277 code = "{whole_pat}",
3278 applicability = "machine-applicable",
3279 style = "verbose"
3280 )]
3281 pub whole_span: Span,
3282 pub whole_pat: String,
3283 #[label("pattern on the left, should be on the right")]
3284 pub pattern: Span,
3285 #[label("binding on the right, should be on the left")]
3286 pub binding: Span,
3287}
3288
3289#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedBindingLeftOfAt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedBindingLeftOfAt {
whole_span: __binding_0, lhs: __binding_1, rhs: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("left-hand side of `@` must be a binding")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as a pattern, not a binding")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("also a pattern")));
diag
}
}
}
}
};Diagnostic)]
3290#[diag("left-hand side of `@` must be a binding")]
3291#[note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")]
3292pub(crate) struct ExpectedBindingLeftOfAt {
3293 #[primary_span]
3294 pub whole_span: Span,
3295 #[label("interpreted as a pattern, not a binding")]
3296 pub lhs: Span,
3297 #[label("also a pattern")]
3298 pub rhs: Span,
3299}
3300
3301#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenRangeSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenRangeSuggestion { lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_179 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_180 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_179));
suggestions.push((__binding_1, __code_180));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses to clarify the precedence")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3302#[multipart_suggestion(
3303 "add parentheses to clarify the precedence",
3304 applicability = "machine-applicable"
3305)]
3306pub(crate) struct ParenRangeSuggestion {
3307 #[suggestion_part(code = "(")]
3308 pub lo: Span,
3309 #[suggestion_part(code = ")")]
3310 pub hi: Span,
3311}
3312
3313#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousRangePattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousRangePattern {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the range pattern here has ambiguous interpretation")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3314#[diag("the range pattern here has ambiguous interpretation")]
3315pub(crate) struct AmbiguousRangePattern {
3316 #[primary_span]
3317 pub span: Span,
3318 #[subdiagnostic]
3319 pub suggestion: ParenRangeSuggestion,
3320}
3321
3322#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedLifetimeInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedLifetimeInPattern {
span: __binding_0,
symbol: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected lifetime `{$symbol}` in pattern")));
let __code_181 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("symbol", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime")),
__code_181, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3323#[diag("unexpected lifetime `{$symbol}` in pattern")]
3324pub(crate) struct UnexpectedLifetimeInPattern {
3325 #[primary_span]
3326 pub span: Span,
3327 pub symbol: Symbol,
3328 #[suggestion(
3329 "remove the lifetime",
3330 code = "",
3331 applicability = "machine-applicable",
3332 style = "verbose"
3333 )]
3334 pub suggestion: Span,
3335}
3336
3337#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidMutInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidMutInPattern::NestedIdent {
span: __binding_0, pat: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` must be attached to each individual binding")));
let __code_182 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` may be followed by `variable` and `variable @ pattern`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `mut` to each binding")),
__code_182, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
InvalidMutInPattern::NonIdent { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` must be followed by a named binding")));
let __code_183 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` may be followed by `variable` and `variable @ pattern`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `mut` prefix")),
__code_183, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3338pub(crate) enum InvalidMutInPattern {
3339 #[diag("`mut` must be attached to each individual binding")]
3340 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3341 NestedIdent {
3342 #[primary_span]
3343 #[suggestion(
3344 "add `mut` to each binding",
3345 code = "{pat}",
3346 applicability = "machine-applicable",
3347 style = "verbose"
3348 )]
3349 span: Span,
3350 pat: String,
3351 },
3352 #[diag("`mut` must be followed by a named binding")]
3353 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3354 NonIdent {
3355 #[primary_span]
3356 #[suggestion(
3357 "remove the `mut` prefix",
3358 code = "",
3359 applicability = "machine-applicable",
3360 style = "verbose"
3361 )]
3362 span: Span,
3363 },
3364}
3365
3366#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RepeatedMutInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RepeatedMutInPattern {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` on a binding may not be repeated")));
let __code_184 =
[::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 additional `mut`s")),
__code_184, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3367#[diag("`mut` on a binding may not be repeated")]
3368pub(crate) struct RepeatedMutInPattern {
3369 #[primary_span]
3370 pub span: Span,
3371 #[suggestion(
3372 "remove the additional `mut`s",
3373 code = "",
3374 applicability = "machine-applicable",
3375 style = "verbose"
3376 )]
3377 pub suggestion: Span,
3378}
3379
3380#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotRangeToPatternNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotRangeToPatternNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range-to patterns with `...` are not allowed")));
let __code_185 =
[::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("use `..=` instead")),
__code_185, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3381#[diag("range-to patterns with `...` are not allowed")]
3382pub(crate) struct DotDotDotRangeToPatternNotAllowed {
3383 #[primary_span]
3384 #[suggestion(
3385 "use `..=` instead",
3386 style = "verbose",
3387 code = "..=",
3388 applicability = "machine-applicable"
3389 )]
3390 pub span: Span,
3391}
3392
3393#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EnumPatternInsteadOfIdentifier where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EnumPatternInsteadOfIdentifier { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found enum pattern")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3394#[diag("expected identifier, found enum pattern")]
3395pub(crate) struct EnumPatternInsteadOfIdentifier {
3396 #[primary_span]
3397 pub span: Span,
3398}
3399
3400#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtDotDotInStructPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtDotDotInStructPattern {
span: __binding_0, remove: __binding_1, ident: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`@ ..` is not supported in struct patterns")));
let __code_186 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bind to each field separately or, if you don't need them, just remove `{$ident} @`")),
__code_186, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3401#[diag("`@ ..` is not supported in struct patterns")]
3402pub(crate) struct AtDotDotInStructPattern {
3403 #[primary_span]
3404 pub span: Span,
3405 #[suggestion(
3406 "bind to each field separately or, if you don't need them, just remove `{$ident} @`",
3407 code = "",
3408 style = "verbose",
3409 applicability = "machine-applicable"
3410 )]
3411 pub remove: Span,
3412 pub ident: Ident,
3413}
3414
3415#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtInStructPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtInStructPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `@` in struct pattern")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct patterns use `field: pattern` syntax to bind to fields")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3416#[diag("unexpected `@` in struct pattern")]
3417#[note("struct patterns use `field: pattern` syntax to bind to fields")]
3418#[help(
3419 "consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended"
3420)]
3421pub(crate) struct AtInStructPattern {
3422 #[primary_span]
3423 pub span: Span,
3424}
3425
3426#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotForRemainingFields where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotForRemainingFields {
span: __binding_0, token_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected field pattern, found `{$token_str}`")));
let __code_187 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
;
diag.arg("token_str", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to omit remaining fields, use `..`")),
__code_187, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3427#[diag("expected field pattern, found `{$token_str}`")]
3428pub(crate) struct DotDotDotForRemainingFields {
3429 #[primary_span]
3430 #[suggestion(
3431 "to omit remaining fields, use `..`",
3432 code = "..",
3433 style = "verbose",
3434 applicability = "machine-applicable"
3435 )]
3436 pub span: Span,
3437 pub token_str: Cow<'static, str>,
3438}
3439
3440#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedCommaAfterPatternField where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedCommaAfterPatternField { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3441#[diag("expected `,`")]
3442pub(crate) struct ExpectedCommaAfterPatternField {
3443 #[primary_span]
3444 pub span: Span,
3445}
3446
3447#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedExpressionInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedExpressionInPattern {
span: __binding_0, is_bound: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected {$is_bound ->\n [true] a pattern range bound\n *[false] a pattern\n }, found an expression")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>")));
;
diag.arg("is_bound", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a pattern")));
diag
}
}
}
}
};Diagnostic)]
3448#[diag(
3449 "expected {$is_bound ->
3450 [true] a pattern range bound
3451 *[false] a pattern
3452 }, found an expression"
3453)]
3454#[note(
3455 "arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>"
3456)]
3457pub(crate) struct UnexpectedExpressionInPattern {
3458 #[primary_span]
3460 #[label("not a pattern")]
3461 pub span: Span,
3462 pub is_bound: bool,
3464}
3465
3466#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedExpressionInPatternSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedExpressionInPatternSugg::CreateGuard {
ident_span: __binding_0,
pat_hi: __binding_1,
ident: __binding_2,
expr: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_188 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
let __code_189 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if {1} == {0}",
__binding_3, __binding_2))
});
suggestions.push((__binding_0, __code_188));
suggestions.push((__binding_1, __code_189));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the expression to a match arm guard")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
UnexpectedExpressionInPatternSugg::UpdateGuard {
ident_span: __binding_0,
guard_lo: __binding_1,
guard_hi: __binding_2,
guard_hi_paren: __binding_3,
ident: __binding_4,
expr: __binding_5 } => {
let mut suggestions = Vec::new();
let __code_190 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
let __code_191 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_192 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1} && {2} == {0}",
__binding_5, __binding_3, __binding_4))
});
suggestions.push((__binding_0, __code_190));
if let Some(__binding_1) = __binding_1 {
suggestions.push((__binding_1, __code_191));
}
suggestions.push((__binding_2, __code_192));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the expression to the match arm guard")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
UnexpectedExpressionInPatternSugg::Const {
stmt_lo: __binding_0,
ident_span: __binding_1,
ident: __binding_2,
expr: __binding_3,
indentation: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_193 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{2}const {1}: /* Type */ = {0};\n",
__binding_3, __binding_2, __binding_4))
});
let __code_194 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_193));
suggestions.push((__binding_1, __code_194));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider extracting the expression into a `const`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3467pub(crate) enum UnexpectedExpressionInPatternSugg {
3468 #[multipart_suggestion(
3469 "consider moving the expression to a match arm guard",
3470 applicability = "maybe-incorrect"
3471 )]
3472 CreateGuard {
3473 #[suggestion_part(code = "{ident}")]
3475 ident_span: Span,
3476 #[suggestion_part(code = " if {ident} == {expr}")]
3478 pat_hi: Span,
3479 ident: String,
3481 expr: String,
3483 },
3484
3485 #[multipart_suggestion(
3486 "consider moving the expression to the match arm guard",
3487 applicability = "maybe-incorrect"
3488 )]
3489 UpdateGuard {
3490 #[suggestion_part(code = "{ident}")]
3492 ident_span: Span,
3493 #[suggestion_part(code = "(")]
3495 guard_lo: Option<Span>,
3496 #[suggestion_part(code = "{guard_hi_paren} && {ident} == {expr}")]
3498 guard_hi: Span,
3499 guard_hi_paren: &'static str,
3501 ident: String,
3503 expr: String,
3505 },
3506
3507 #[multipart_suggestion(
3508 "consider extracting the expression into a `const`",
3509 applicability = "has-placeholders"
3510 )]
3511 Const {
3512 #[suggestion_part(code = "{indentation}const {ident}: /* Type */ = {expr};\n")]
3514 stmt_lo: Span,
3515 #[suggestion_part(code = "{ident}")]
3517 ident_span: Span,
3518 ident: String,
3520 expr: String,
3522 indentation: String,
3524 },
3525}
3526
3527#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedParenInRangePat where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedParenInRangePat {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range pattern bounds cannot have parentheses")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3528#[diag("range pattern bounds cannot have parentheses")]
3529pub(crate) struct UnexpectedParenInRangePat {
3530 #[primary_span]
3531 pub span: Vec<Span>,
3532 #[subdiagnostic]
3533 pub sugg: UnexpectedParenInRangePatSugg,
3534}
3535
3536#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedParenInRangePatSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedParenInRangePatSugg {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_195 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_196 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_195));
suggestions.push((__binding_1, __code_196));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove these parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3537#[multipart_suggestion("remove these parentheses", applicability = "machine-applicable")]
3538pub(crate) struct UnexpectedParenInRangePatSugg {
3539 #[suggestion_part(code = "")]
3540 pub start_span: Span,
3541 #[suggestion_part(code = "")]
3542 pub end_span: Span,
3543}
3544
3545#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnTypesUseThinArrow where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReturnTypesUseThinArrow {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return types are denoted using `->`")));
let __code_197 =
[::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("use `->` instead")),
__code_197, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3546#[diag("return types are denoted using `->`")]
3547pub(crate) struct ReturnTypesUseThinArrow {
3548 #[primary_span]
3549 pub span: Span,
3550 #[suggestion(
3551 "use `->` instead",
3552 style = "verbose",
3553 code = " -> ",
3554 applicability = "machine-applicable"
3555 )]
3556 pub suggestion: Span,
3557}
3558
3559#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NeedPlusAfterTraitObjectLifetime where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NeedPlusAfterTraitObjectLifetime {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes must be followed by `+` to form a trait object type")));
let __code_198 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" + /* Trait */"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a trait bound after the potential lifetime bound")),
__code_198, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3560#[diag("lifetimes must be followed by `+` to form a trait object type")]
3561pub(crate) struct NeedPlusAfterTraitObjectLifetime {
3562 #[primary_span]
3563 pub span: Span,
3564 #[suggestion(
3565 "consider adding a trait bound after the potential lifetime bound",
3566 code = " + /* Trait */",
3567 applicability = "has-placeholders"
3568 )]
3569 pub suggestion: Span,
3570}
3571
3572#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedMutOrConstInRawPointerType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedMutOrConstInRawPointerType {
span: __binding_0, after_asterisk: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `mut` or `const` keyword in raw pointer type")));
let __code_199 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("mut "))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `mut` or `const` here")),
__code_199, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3573#[diag("expected `mut` or `const` keyword in raw pointer type")]
3574pub(crate) struct ExpectedMutOrConstInRawPointerType {
3575 #[primary_span]
3576 pub span: Span,
3577 #[suggestion(
3578 "add `mut` or `const` here",
3579 code("mut ", "const "),
3580 applicability = "has-placeholders",
3581 style = "verbose"
3582 )]
3583 pub after_asterisk: Span,
3584}
3585
3586#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeAfterMut where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeAfterMut {
span: __binding_0,
suggest_lifetime: __binding_1,
snippet: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime must precede `mut`")));
let __code_200 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&{0} mut", __binding_2))
})].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("place the lifetime before `mut`")),
__code_200, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
3587#[diag("lifetime must precede `mut`")]
3588pub(crate) struct LifetimeAfterMut {
3589 #[primary_span]
3590 pub span: Span,
3591 #[suggestion(
3592 "place the lifetime before `mut`",
3593 code = "&{snippet} mut",
3594 applicability = "maybe-incorrect",
3595 style = "verbose"
3596 )]
3597 pub suggest_lifetime: Option<Span>,
3598 pub snippet: String,
3599}
3600
3601#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DynAfterMut
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DynAfterMut { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` must precede `dyn`")));
let __code_201 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&mut dyn"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place `mut` before `dyn`")),
__code_201, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3602#[diag("`mut` must precede `dyn`")]
3603pub(crate) struct DynAfterMut {
3604 #[primary_span]
3605 #[suggestion(
3606 "place `mut` before `dyn`",
3607 code = "&mut dyn",
3608 applicability = "machine-applicable",
3609 style = "verbose"
3610 )]
3611 pub span: Span,
3612}
3613
3614#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPointerCannotBeConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPointerCannotBeConst {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `fn` pointer type cannot be `const`")));
let __code_202 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("allowed qualifiers are: `unsafe` and `extern`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` because of this")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `const` qualifier")),
__code_202, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3615#[diag("an `fn` pointer type cannot be `const`")]
3616#[note("allowed qualifiers are: `unsafe` and `extern`")]
3617pub(crate) struct FnPointerCannotBeConst {
3618 #[primary_span]
3619 #[label("`const` because of this")]
3620 pub span: Span,
3621 #[suggestion(
3622 "remove the `const` qualifier",
3623 code = "",
3624 applicability = "maybe-incorrect",
3625 style = "verbose"
3626 )]
3627 pub suggestion: Span,
3628}
3629
3630#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPointerCannotBeAsync where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPointerCannotBeAsync {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `fn` pointer type cannot be `async`")));
let __code_203 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("allowed qualifiers are: `unsafe` and `extern`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` because of this")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `async` qualifier")),
__code_203, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3631#[diag("an `fn` pointer type cannot be `async`")]
3632#[note("allowed qualifiers are: `unsafe` and `extern`")]
3633pub(crate) struct FnPointerCannotBeAsync {
3634 #[primary_span]
3635 #[label("`async` because of this")]
3636 pub span: Span,
3637 #[suggestion(
3638 "remove the `async` qualifier",
3639 code = "",
3640 applicability = "maybe-incorrect",
3641 style = "verbose"
3642 )]
3643 pub suggestion: Span,
3644}
3645
3646#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NestedCVariadicType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NestedCVariadicType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic type `...` may not be nested inside another type")));
diag.code(E0743);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3647#[diag("C-variadic type `...` may not be nested inside another type", code = E0743)]
3648pub(crate) struct NestedCVariadicType {
3649 #[primary_span]
3650 pub span: Span,
3651}
3652
3653#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidCVariadicType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidCVariadicType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `...`")));
diag.note(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)]
3654#[diag("unexpected `...`")]
3655#[note(
3656 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3657)]
3658pub(crate) struct InvalidCVariadicType {
3659 #[primary_span]
3660 pub span: Span,
3661}
3662
3663#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidDynKeyword where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidDynKeyword {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `dyn` keyword")));
let __code_204 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`dyn` is only needed at the start of a trait `+`-separated list")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this keyword")),
__code_204, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3664#[diag("invalid `dyn` keyword")]
3665#[help("`dyn` is only needed at the start of a trait `+`-separated list")]
3666pub(crate) struct InvalidDynKeyword {
3667 #[primary_span]
3668 pub span: Span,
3669 #[suggestion(
3670 "remove this keyword",
3671 code = "",
3672 applicability = "machine-applicable",
3673 style = "verbose"
3674 )]
3675 pub suggestion: Span,
3676}
3677
3678#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HelpUseLatestEdition {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
HelpUseLatestEdition::Cargo { edition: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("edition".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("set `edition = \"{$edition}\"` in `Cargo.toml`")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
&sub_args);
diag.note(__message);
}
HelpUseLatestEdition::Standalone { edition: __binding_0 } =>
{
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("edition".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pass `--edition {$edition}` to `rustc`")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
3679pub(crate) enum HelpUseLatestEdition {
3680 #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
3681 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3682 Cargo { edition: Edition },
3683 #[help("pass `--edition {$edition}` to `rustc`")]
3684 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3685 Standalone { edition: Edition },
3686}
3687
3688impl HelpUseLatestEdition {
3689 pub(crate) fn new() -> Self {
3690 let edition = LATEST_STABLE_EDITION;
3691 if rustc_session::utils::was_invoked_from_cargo() {
3692 Self::Cargo { edition }
3693 } else {
3694 Self::Standalone { edition }
3695 }
3696 }
3697}
3698
3699#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BoxSyntaxRemoved where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoxSyntaxRemoved { span: __binding_0, sugg: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`box_syntax` has been removed")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3700#[diag("`box_syntax` has been removed")]
3701pub(crate) struct BoxSyntaxRemoved {
3702 #[primary_span]
3703 pub span: Span,
3704 #[subdiagnostic]
3705 pub sugg: AddBoxNew,
3706}
3707
3708#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddBoxNew {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddBoxNew { box_kw_and_lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_205 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new("))
});
let __code_206 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_205));
suggestions.push((__binding_1, __code_206));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `Box::new()` instead")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
3709#[multipart_suggestion(
3710 "use `Box::new()` instead",
3711 applicability = "machine-applicable",
3712 style = "verbose"
3713)]
3714pub(crate) struct AddBoxNew {
3715 #[suggestion_part(code = "Box::new(")]
3716 pub box_kw_and_lo: Span,
3717 #[suggestion_part(code = ")")]
3718 pub hi: Span,
3719}
3720
3721#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BadReturnTypeNotationOutput where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadReturnTypeNotationOutput {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type not allowed with return type notation")));
let __code_207 =
[::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 return type")),
__code_207, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3722#[diag("return type not allowed with return type notation")]
3723pub(crate) struct BadReturnTypeNotationOutput {
3724 #[primary_span]
3725 pub span: Span,
3726 #[suggestion(
3727 "remove the return type",
3728 code = "",
3729 applicability = "maybe-incorrect",
3730 style = "verbose"
3731 )]
3732 pub suggestion: Span,
3733}
3734
3735#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BadAssocTypeBounds where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadAssocTypeBounds { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on associated types do not belong here")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("belongs in `where` clause")));
diag
}
}
}
}
};Diagnostic)]
3736#[diag("bounds on associated types do not belong here")]
3737pub(crate) struct BadAssocTypeBounds {
3738 #[primary_span]
3739 #[label("belongs in `where` clause")]
3740 pub span: Span,
3741}
3742
3743#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrAfterGeneric where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrAfterGeneric { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trailing attribute after generic parameter")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes must go before parameters")));
diag
}
}
}
}
};Diagnostic)]
3744#[diag("trailing attribute after generic parameter")]
3745pub(crate) struct AttrAfterGeneric {
3746 #[primary_span]
3747 #[label("attributes must go before parameters")]
3748 pub span: Span,
3749}
3750
3751#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrWithoutGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrWithoutGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute without generic parameters")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are only permitted when preceding parameters")));
diag
}
}
}
}
};Diagnostic)]
3752#[diag("attribute without generic parameters")]
3753pub(crate) struct AttrWithoutGenerics {
3754 #[primary_span]
3755 #[label("attributes are only permitted when preceding parameters")]
3756 pub span: Span,
3757}
3758
3759#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereOnGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereOnGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters on `where` clauses are reserved for future use")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("currently unsupported")));
diag
}
}
}
}
};Diagnostic)]
3760#[diag("generic parameters on `where` clauses are reserved for future use")]
3761pub(crate) struct WhereOnGenerics {
3762 #[primary_span]
3763 #[label("currently unsupported")]
3764 pub span: Span,
3765}
3766
3767#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for GenericsInPath
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericsInPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected generic arguments in path")));
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
3768#[diag("unexpected generic arguments in path")]
3769pub(crate) struct GenericsInPath {
3770 #[primary_span]
3771 pub span: Vec<Span>,
3772}
3773
3774#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeInEqConstraint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeInEqConstraint {
span: __binding_0,
lifetime: __binding_1,
binding_label: __binding_2,
colon_sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes are not permitted in this context")));
let __code_208 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": "))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}`")));
;
diag.arg("lifetime", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime is not allowed here")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this introduces an associated item binding")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a bound here")),
__code_208, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3775#[diag("lifetimes are not permitted in this context")]
3776#[help("if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}`")]
3777pub(crate) struct LifetimeInEqConstraint {
3778 #[primary_span]
3779 #[label("lifetime is not allowed here")]
3780 pub span: Span,
3781 pub lifetime: Ident,
3782 #[label("this introduces an associated item binding")]
3783 pub binding_label: Span,
3784 #[suggestion(
3785 "you might have meant to write a bound here",
3786 style = "verbose",
3787 applicability = "maybe-incorrect",
3788 code = ": "
3789 )]
3790 pub colon_sugg: Span,
3791}
3792
3793#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ModifierLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModifierLifetime { span: __binding_0, modifier: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$modifier}` may only modify trait bounds, not lifetime bounds")));
let __code_209 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("modifier", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `{$modifier}`")),
__code_209, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
3794#[diag("`{$modifier}` may only modify trait bounds, not lifetime bounds")]
3795pub(crate) struct ModifierLifetime {
3796 #[primary_span]
3797 #[suggestion(
3798 "remove the `{$modifier}`",
3799 style = "tool-only",
3800 applicability = "maybe-incorrect",
3801 code = ""
3802 )]
3803 pub span: Span,
3804 pub modifier: &'static str,
3805}
3806
3807#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnderscoreLiteralSuffix where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnderscoreLiteralSuffix { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("underscore literal suffix is not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3808#[diag("underscore literal suffix is not allowed")]
3809pub(crate) struct UnderscoreLiteralSuffix {
3810 #[primary_span]
3811 pub span: Span,
3812}
3813
3814#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedLabelFoundIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedLabelFoundIdent {
span: __binding_0, start: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a label, found an identifier")));
let __code_210 =
[::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("labels start with a tick")),
__code_210, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3815#[diag("expected a label, found an identifier")]
3816pub(crate) struct ExpectedLabelFoundIdent {
3817 #[primary_span]
3818 pub span: Span,
3819 #[suggestion(
3820 "labels start with a tick",
3821 code = "'",
3822 applicability = "machine-applicable",
3823 style = "verbose"
3824 )]
3825 pub start: Span,
3826}
3827
3828#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InappropriateDefault where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InappropriateDefault {
span: __binding_0, article: __binding_1, descr: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$article} {$descr} cannot be `default`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only associated `fn`, `const`, and `type` items can be `default`")));
;
diag.arg("article", __binding_1);
diag.arg("descr", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` because of this")));
diag
}
}
}
}
};Diagnostic)]
3829#[diag("{$article} {$descr} cannot be `default`")]
3830#[note("only associated `fn`, `const`, and `type` items can be `default`")]
3831pub(crate) struct InappropriateDefault {
3832 #[primary_span]
3833 #[label("`default` because of this")]
3834 pub span: Span,
3835 pub article: &'static str,
3836 pub descr: &'static str,
3837}
3838
3839#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RecoverImportAsUse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RecoverImportAsUse {
span: __binding_0, token_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected item, found {$token_name}")));
let __code_211 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("use"))
})].into_iter();
;
diag.arg("token_name", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items are imported using the `use` keyword")),
__code_211, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3840#[diag("expected item, found {$token_name}")]
3841pub(crate) struct RecoverImportAsUse {
3842 #[primary_span]
3843 #[suggestion(
3844 "items are imported using the `use` keyword",
3845 code = "use",
3846 applicability = "machine-applicable",
3847 style = "verbose"
3848 )]
3849 pub span: Span,
3850 pub token_name: String,
3851}
3852
3853#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InappropriateFinal where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InappropriateFinal {
span: __binding_0, article: __binding_1, descr: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$article} {$descr} cannot be `final`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only associated functions in traits can be `final`")));
;
diag.arg("article", __binding_1);
diag.arg("descr", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`final` because of this")));
diag
}
}
}
}
};Diagnostic)]
3854#[diag("{$article} {$descr} cannot be `final`")]
3855#[note("only associated functions in traits can be `final`")]
3856pub(crate) struct InappropriateFinal {
3857 #[primary_span]
3858 #[label("`final` because of this")]
3859 pub span: Span,
3860 pub article: &'static str,
3861 pub descr: &'static str,
3862}
3863
3864#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SingleColonImportPath where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SingleColonImportPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `::`, found `:`")));
let __code_212 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("::"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import paths are delimited using `::`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use double colon")),
__code_212, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3865#[diag("expected `::`, found `:`")]
3866#[note("import paths are delimited using `::`")]
3867pub(crate) struct SingleColonImportPath {
3868 #[primary_span]
3869 #[suggestion(
3870 "use double colon",
3871 code = "::",
3872 applicability = "machine-applicable",
3873 style = "verbose"
3874 )]
3875 pub span: Span,
3876}
3877
3878#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadItemKind
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadItemKind {
span: __binding_0,
descr: __binding_1,
ctx: __binding_2,
help: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} is not supported in {$ctx}")));
;
diag.arg("descr", __binding_1);
diag.arg("ctx", __binding_2);
diag.span(__binding_0);
if __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the {$descr} out to a nearby module scope")));
}
diag
}
}
}
}
};Diagnostic)]
3879#[diag("{$descr} is not supported in {$ctx}")]
3880pub(crate) struct BadItemKind {
3881 #[primary_span]
3882 pub span: Span,
3883 pub descr: &'static str,
3884 pub ctx: &'static str,
3885 #[help("consider moving the {$descr} out to a nearby module scope")]
3886 pub help: bool,
3887}
3888
3889#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroRulesMissingBang where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroRulesMissingBang { span: __binding_0, hi: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `!` after `macro_rules`")));
let __code_213 =
[::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("add a `!`")),
__code_213, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3890#[diag("expected `!` after `macro_rules`")]
3891pub(crate) struct MacroRulesMissingBang {
3892 #[primary_span]
3893 pub span: Span,
3894 #[suggestion("add a `!`", code = "!", applicability = "machine-applicable", style = "verbose")]
3895 pub hi: Span,
3896}
3897
3898#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroNameRemoveBang where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroNameRemoveBang { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro names aren't followed by a `!`")));
let __code_214 =
[::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 `!`")),
__code_214, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
3899#[diag("macro names aren't followed by a `!`")]
3900pub(crate) struct MacroNameRemoveBang {
3901 #[primary_span]
3902 #[suggestion(
3903 "remove the `!`",
3904 code = "",
3905 applicability = "machine-applicable",
3906 style = "short"
3907 )]
3908 pub span: Span,
3909}
3910
3911#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MacroRulesVisibility<'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 {
MacroRulesVisibility { span: __binding_0, vis: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't qualify macro_rules invocation with `{$vis}`")));
let __code_215 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#[macro_export]"))
})].into_iter();
;
diag.arg("vis", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try exporting the macro")),
__code_215, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3912#[diag("can't qualify macro_rules invocation with `{$vis}`")]
3913pub(crate) struct MacroRulesVisibility<'a> {
3914 #[primary_span]
3915 #[suggestion(
3916 "try exporting the macro",
3917 code = "#[macro_export]",
3918 applicability = "maybe-incorrect",
3919 style = "verbose"
3920 )]
3921 pub span: Span,
3922 pub vis: &'a str,
3923}
3924
3925#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MacroInvocationVisibility<'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 {
MacroInvocationVisibility {
span: __binding_0, vis: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't qualify macro invocation with `pub`")));
let __code_216 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adjusting the macro to put `{$vis}` inside the invocation")));
;
diag.arg("vis", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the visibility")),
__code_216, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3926#[diag("can't qualify macro invocation with `pub`")]
3927#[help("try adjusting the macro to put `{$vis}` inside the invocation")]
3928pub(crate) struct MacroInvocationVisibility<'a> {
3929 #[primary_span]
3930 #[suggestion(
3931 "remove the visibility",
3932 code = "",
3933 applicability = "machine-applicable",
3934 style = "verbose"
3935 )]
3936 pub span: Span,
3937 pub vis: &'a str,
3938}
3939
3940#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NestedAdt<'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 {
NestedAdt {
span: __binding_0,
item: __binding_1,
keyword: __binding_2,
kw_str: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kw_str}` definition cannot be nested inside `{$keyword}`")));
let __code_217 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("keyword", __binding_2);
diag.arg("kw_str", __binding_3);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider creating a new `{$kw_str}` definition instead of nesting")),
__code_217, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3941#[diag("`{$kw_str}` definition cannot be nested inside `{$keyword}`")]
3942pub(crate) struct NestedAdt<'a> {
3943 #[primary_span]
3944 pub span: Span,
3945 #[suggestion(
3946 "consider creating a new `{$kw_str}` definition instead of nesting",
3947 code = "",
3948 applicability = "maybe-incorrect",
3949 style = "verbose"
3950 )]
3951 pub item: Span,
3952 pub keyword: &'a str,
3953 pub kw_str: Cow<'a, str>,
3954}
3955
3956#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionBodyEqualsExpr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FunctionBodyEqualsExpr {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function body cannot be `= expression;`")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3957#[diag("function body cannot be `= expression;`")]
3958pub(crate) struct FunctionBodyEqualsExpr {
3959 #[primary_span]
3960 pub span: Span,
3961 #[subdiagnostic]
3962 pub sugg: FunctionBodyEqualsExprSugg,
3963}
3964
3965#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FunctionBodyEqualsExprSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FunctionBodyEqualsExprSugg {
eq: __binding_0, semi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_218 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_219 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_218));
suggestions.push((__binding_1, __code_219));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the expression with `{\"{\"}` and `{\"}\"}` instead of `=` and `;`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3966#[multipart_suggestion(
3967 r#"surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`"#,
3968 applicability = "machine-applicable"
3969)]
3970pub(crate) struct FunctionBodyEqualsExprSugg {
3971 #[suggestion_part(code = "{{")]
3972 pub eq: Span,
3973 #[suggestion_part(code = " }}")]
3974 pub semi: Span,
3975}
3976
3977#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BoxNotPat
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoxNotPat {
span: __binding_0,
kw: __binding_1,
lo: __binding_2,
descr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected pattern, found {$descr}")));
let __code_220 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("r#"))
})].into_iter();
;
diag.arg("descr", __binding_3);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`box` is a reserved keyword")));
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("escape `box` to use it as an identifier")),
__code_220, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3978#[diag("expected pattern, found {$descr}")]
3979pub(crate) struct BoxNotPat {
3980 #[primary_span]
3981 pub span: Span,
3982 #[note("`box` is a reserved keyword")]
3983 pub kw: Span,
3984 #[suggestion(
3985 "escape `box` to use it as an identifier",
3986 code = "r#",
3987 applicability = "maybe-incorrect",
3988 style = "verbose"
3989 )]
3990 pub lo: Span,
3991 pub descr: String,
3992}
3993
3994#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnmatchedAngle
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnmatchedAngle { span: __binding_0, plural: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unmatched angle {$plural ->\n [true] brackets\n *[false] bracket\n }")));
let __code_221 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("plural", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove extra angle {$plural ->\n [true] brackets\n *[false] bracket\n }")),
__code_221, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3995#[diag(
3996 "unmatched angle {$plural ->
3997 [true] brackets
3998 *[false] bracket
3999 }"
4000)]
4001pub(crate) struct UnmatchedAngle {
4002 #[primary_span]
4003 #[suggestion(
4004 "remove extra angle {$plural ->
4005 [true] brackets
4006 *[false] bracket
4007 }",
4008 code = "",
4009 applicability = "machine-applicable",
4010 style = "verbose"
4011 )]
4012 pub span: Span,
4013 pub plural: bool,
4014}
4015
4016#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingPlusBounds where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingPlusBounds {
span: __binding_0, hi: __binding_1, sym: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `+` between lifetime and {$sym}")));
let __code_222 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" +"))
})].into_iter();
;
diag.arg("sym", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `+`")),
__code_222, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4017#[diag("expected `+` between lifetime and {$sym}")]
4018pub(crate) struct MissingPlusBounds {
4019 #[primary_span]
4020 pub span: Span,
4021 #[suggestion("add `+`", code = " +", applicability = "maybe-incorrect", style = "verbose")]
4022 pub hi: Span,
4023 pub sym: Symbol,
4024}
4025
4026#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectParensTraitBounds where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectParensTraitBounds {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect parentheses around trait bounds")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
4027#[diag("incorrect parentheses around trait bounds")]
4028pub(crate) struct IncorrectParensTraitBounds {
4029 #[primary_span]
4030 pub span: Vec<Span>,
4031 #[subdiagnostic]
4032 pub sugg: IncorrectParensTraitBoundsSugg,
4033}
4034
4035#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IncorrectParensTraitBoundsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IncorrectParensTraitBoundsSugg {
wrong_span: __binding_0, new_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_223 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_224 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
suggestions.push((__binding_0, __code_223));
suggestions.push((__binding_1, __code_224));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fix the parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4036#[multipart_suggestion("fix the parentheses", applicability = "machine-applicable")]
4037pub(crate) struct IncorrectParensTraitBoundsSugg {
4038 #[suggestion_part(code = " ")]
4039 pub wrong_span: Span,
4040 #[suggestion_part(code = "(")]
4041 pub new_span: Span,
4042}
4043
4044#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
KwBadCase<'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 {
KwBadCase {
span: __binding_0, kw: __binding_1, case: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("keyword `{$kw}` is written in the wrong case")));
let __code_225 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("kw", __binding_1);
diag.arg("case", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("write it in {$case}")),
__code_225, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4045#[diag("keyword `{$kw}` is written in the wrong case")]
4046pub(crate) struct KwBadCase<'a> {
4047 #[primary_span]
4048 #[suggestion(
4049 "write it in {$case}",
4050 code = "{kw}",
4051 style = "verbose",
4052 applicability = "machine-applicable"
4053 )]
4054 pub span: Span,
4055 pub kw: &'a str,
4056 pub case: Case,
4057}
4058
4059pub(crate) enum Case {
4060 Upper,
4061 Lower,
4062 Mixed,
4063}
4064
4065impl IntoDiagArg for Case {
4066 fn into_diag_arg(self, path: &mut Option<PathBuf>) -> DiagArgValue {
4067 match self {
4068 Case::Upper => "uppercase",
4069 Case::Lower => "lowercase",
4070 Case::Mixed => "the correct case",
4071 }
4072 .into_diag_arg(path)
4073 }
4074}
4075
4076#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownBuiltinConstruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownBuiltinConstruct {
span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `builtin #` construct `{$name}`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4077#[diag("unknown `builtin #` construct `{$name}`")]
4078pub(crate) struct UnknownBuiltinConstruct {
4079 #[primary_span]
4080 pub span: Span,
4081 pub name: Ident,
4082}
4083
4084#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedBuiltinIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedBuiltinIdent { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier after `builtin #`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4085#[diag("expected identifier after `builtin #`")]
4086pub(crate) struct ExpectedBuiltinIdent {
4087 #[primary_span]
4088 pub span: Span,
4089}
4090
4091#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticWithGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StaticWithGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("static items may not have generic parameters")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4092#[diag("static items may not have generic parameters")]
4093pub(crate) struct StaticWithGenerics {
4094 #[primary_span]
4095 pub span: Span,
4096}
4097
4098#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseBeforeConstBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseBeforeConstBody {
span: __binding_0,
name: __binding_1,
body: __binding_2,
sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed before const item bodies")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected where clause")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this const item")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item body")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
4099#[diag("where clauses are not allowed before const item bodies")]
4100pub(crate) struct WhereClauseBeforeConstBody {
4101 #[primary_span]
4102 #[label("unexpected where clause")]
4103 pub span: Span,
4104 #[label("while parsing this const item")]
4105 pub name: Span,
4106 #[label("the item body")]
4107 pub body: Span,
4108 #[subdiagnostic]
4109 pub sugg: Option<WhereClauseBeforeConstBodySugg>,
4110}
4111
4112#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WhereClauseBeforeConstBodySugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WhereClauseBeforeConstBodySugg {
left: __binding_0, snippet: __binding_1, right: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_226 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("= {0} ", __binding_1))
});
let __code_227 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_226));
suggestions.push((__binding_2, __code_227));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the body before the where clause")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4113#[multipart_suggestion(
4114 "move the body before the where clause",
4115 applicability = "machine-applicable"
4116)]
4117pub(crate) struct WhereClauseBeforeConstBodySugg {
4118 #[suggestion_part(code = "= {snippet} ")]
4119 pub left: Span,
4120 pub snippet: String,
4121 #[suggestion_part(code = "")]
4122 pub right: Span,
4123}
4124
4125#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericArgsInPatRequireTurbofishSyntax where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericArgsInPatRequireTurbofishSyntax {
span: __binding_0, suggest_turbofish: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic args in patterns require the turbofish syntax")));
let __code_228 =
[::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("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")),
__code_228, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4126#[diag("generic args in patterns require the turbofish syntax")]
4127pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
4128 #[primary_span]
4129 pub span: Span,
4130 #[suggestion(
4131 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
4132 style = "verbose",
4133 code = "::",
4134 applicability = "maybe-incorrect"
4135 )]
4136 pub suggest_turbofish: Span,
4137}
4138
4139#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
TransposeDynOrImpl<'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 {
TransposeDynOrImpl {
span: __binding_0, kw: __binding_1, sugg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` expected after `{$kw}`, not before")));
;
diag.arg("kw", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
4140#[diag("`for<...>` expected after `{$kw}`, not before")]
4141pub(crate) struct TransposeDynOrImpl<'a> {
4142 #[primary_span]
4143 pub span: Span,
4144 pub kw: &'a str,
4145 #[subdiagnostic]
4146 pub sugg: TransposeDynOrImplSugg<'a>,
4147}
4148
4149#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for TransposeDynOrImplSugg<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TransposeDynOrImplSugg {
removal_span: __binding_0,
insertion_span: __binding_1,
kw: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_229 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_230 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_2))
});
suggestions.push((__binding_0, __code_229));
suggestions.push((__binding_1, __code_230));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("kw".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move `{$kw}` before the `for<...>`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4150#[multipart_suggestion("move `{$kw}` before the `for<...>`", applicability = "machine-applicable")]
4151pub(crate) struct TransposeDynOrImplSugg<'a> {
4152 #[suggestion_part(code = "")]
4153 pub removal_span: Span,
4154 #[suggestion_part(code = "{kw} ")]
4155 pub insertion_span: Span,
4156 pub kw: &'a str,
4157}
4158
4159#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArrayIndexInOffsetOf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ArrayIndexInOffsetOf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("array indexing not supported in offset_of")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4160#[diag("array indexing not supported in offset_of")]
4161pub(crate) struct ArrayIndexInOffsetOf(#[primary_span] pub Span);
4162
4163#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidOffsetOf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidOffsetOf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("offset_of expects dot-separated field and variant names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4164#[diag("offset_of expects dot-separated field and variant names")]
4165pub(crate) struct InvalidOffsetOf(#[primary_span] pub Span);
4166
4167#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsyncImpl
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` trait implementations are unsupported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4168#[diag("`async` trait implementations are unsupported")]
4169pub(crate) struct AsyncImpl {
4170 #[primary_span]
4171 pub span: Span,
4172}
4173
4174#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ExprRArrowCall
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExprRArrowCall { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`->` is not valid syntax for field accesses and method calls")));
let __code_231 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("."))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `.` operator will automatically dereference the value, except if the value is a raw pointer")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `.` instead")),
__code_231, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4175#[diag("`->` is not valid syntax for field accesses and method calls")]
4176#[help(
4177 "the `.` operator will automatically dereference the value, except if the value is a raw pointer"
4178)]
4179pub(crate) struct ExprRArrowCall {
4180 #[primary_span]
4181 #[suggestion(
4182 "try using `.` instead",
4183 style = "verbose",
4184 applicability = "machine-applicable",
4185 code = "."
4186 )]
4187 pub span: Span,
4188}
4189
4190#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotRangeAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotRangeAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed on range expressions starting with `..`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4191#[diag("attributes are not allowed on range expressions starting with `..`")]
4192pub(crate) struct DotDotRangeAttribute {
4193 #[primary_span]
4194 pub span: Span,
4195}
4196
4197#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BinderBeforeModifiers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BinderBeforeModifiers {
binder_span: __binding_0, modifiers_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` binder should be placed before trait bound modifiers")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place the `for<...>` binder before any modifiers")));
diag
}
}
}
}
};Diagnostic)]
4198#[diag("`for<...>` binder should be placed before trait bound modifiers")]
4199pub(crate) struct BinderBeforeModifiers {
4200 #[primary_span]
4201 pub binder_span: Span,
4202 #[label("place the `for<...>` binder before any modifiers")]
4203 pub modifiers_span: Span,
4204}
4205
4206#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BinderAndPolarity where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BinderAndPolarity {
polarity_span: __binding_0,
binder_span: __binding_1,
polarity: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")));
;
diag.arg("polarity", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")));
diag
}
}
}
}
};Diagnostic)]
4207#[diag("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")]
4208pub(crate) struct BinderAndPolarity {
4209 #[primary_span]
4210 pub polarity_span: Span,
4211 #[label("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")]
4212 pub binder_span: Span,
4213 pub polarity: &'static str,
4214}
4215
4216#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PolarityAndModifiers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PolarityAndModifiers {
polarity_span: __binding_0,
modifiers_span: __binding_1,
polarity: __binding_2,
modifiers_concatenated: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")));
;
diag.arg("polarity", __binding_2);
diag.arg("modifiers_concatenated", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait")));
diag
}
}
}
}
};Diagnostic)]
4217#[diag("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")]
4218pub(crate) struct PolarityAndModifiers {
4219 #[primary_span]
4220 pub polarity_span: Span,
4221 #[label(
4222 "there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait"
4223 )]
4224 pub modifiers_span: Span,
4225 pub polarity: &'static str,
4226 pub modifiers_concatenated: String,
4227}
4228
4229#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectTypeOnSelf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectTypeOnSelf {
span: __binding_0, move_self_modifier: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type not allowed for shorthand `self` parameter")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
4230#[diag("type not allowed for shorthand `self` parameter")]
4231pub(crate) struct IncorrectTypeOnSelf {
4232 #[primary_span]
4233 pub span: Span,
4234 #[subdiagnostic]
4235 pub move_self_modifier: MoveSelfModifier,
4236}
4237
4238#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoveSelfModifier {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoveSelfModifier {
removal_span: __binding_0,
insertion_span: __binding_1,
modifier: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_232 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_233 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_232));
suggestions.push((__binding_1, __code_233));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the modifiers on `self` to the type")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4239#[multipart_suggestion(
4240 "move the modifiers on `self` to the type",
4241 applicability = "machine-applicable"
4242)]
4243pub(crate) struct MoveSelfModifier {
4244 #[suggestion_part(code = "")]
4245 pub removal_span: Span,
4246 #[suggestion_part(code = "{modifier}")]
4247 pub insertion_span: Span,
4248 pub modifier: String,
4249}
4250
4251#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AsmUnsupportedOperand<'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 {
AsmUnsupportedOperand {
span: __binding_0,
symbol: __binding_1,
macro_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$symbol}` operand cannot be used with `{$macro_name}!`")));
;
diag.arg("symbol", __binding_1);
diag.arg("macro_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it")));
diag
}
}
}
}
};Diagnostic)]
4252#[diag("the `{$symbol}` operand cannot be used with `{$macro_name}!`")]
4253pub(crate) struct AsmUnsupportedOperand<'a> {
4254 #[primary_span]
4255 #[label(
4256 "the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it"
4257 )]
4258 pub(crate) span: Span,
4259 pub(crate) symbol: &'a str,
4260 pub(crate) macro_name: &'static str,
4261}
4262
4263#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmUnderscoreInput where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmUnderscoreInput { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("_ cannot be used for input operands")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4264#[diag("_ cannot be used for input operands")]
4265pub(crate) struct AsmUnderscoreInput {
4266 #[primary_span]
4267 pub(crate) span: Span,
4268}
4269
4270#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsmSymNoPath
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmSymNoPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a path for argument to `sym`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4271#[diag("expected a path for argument to `sym`")]
4272pub(crate) struct AsmSymNoPath {
4273 #[primary_span]
4274 pub(crate) span: Span,
4275}
4276
4277#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmRequiresTemplate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmRequiresTemplate { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requires at least a template string argument")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4278#[diag("requires at least a template string argument")]
4279pub(crate) struct AsmRequiresTemplate {
4280 #[primary_span]
4281 pub(crate) span: Span,
4282}
4283
4284#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedComma where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedComma { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected token: `,`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,`")));
diag
}
}
}
}
};Diagnostic)]
4285#[diag("expected token: `,`")]
4286pub(crate) struct AsmExpectedComma {
4287 #[primary_span]
4288 #[label("expected `,`")]
4289 pub(crate) span: Span,
4290}
4291
4292#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedOther where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedOther {
span: __binding_0, is_inline_asm: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected operand, {$is_inline_asm ->\n [false] options\n *[true] clobber_abi, options\n }, or additional template string")));
;
diag.arg("is_inline_asm", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected operand, {$is_inline_asm ->\n [false] options\n *[true] clobber_abi, options\n }, or additional template string")));
diag
}
}
}
}
};Diagnostic)]
4293#[diag(
4294 "expected operand, {$is_inline_asm ->
4295 [false] options
4296 *[true] clobber_abi, options
4297 }, or additional template string"
4298)]
4299pub(crate) struct AsmExpectedOther {
4300 #[primary_span]
4301 #[label(
4302 "expected operand, {$is_inline_asm ->
4303 [false] options
4304 *[true] clobber_abi, options
4305 }, or additional template string"
4306 )]
4307 pub(crate) span: Span,
4308 pub(crate) is_inline_asm: bool,
4309}
4310
4311#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NonABI where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonABI { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one abi must be provided as an argument to `clobber_abi`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4312#[diag("at least one abi must be provided as an argument to `clobber_abi`")]
4313pub(crate) struct NonABI {
4314 #[primary_span]
4315 pub(crate) span: Span,
4316}
4317
4318#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedStringLiteral where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedStringLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected string literal")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a string literal")));
diag
}
}
}
}
};Diagnostic)]
4319#[diag("expected string literal")]
4320pub(crate) struct AsmExpectedStringLiteral {
4321 #[primary_span]
4322 #[label("not a string literal")]
4323 pub(crate) span: Span,
4324}
4325
4326#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedRegisterClassOrExplicitRegister where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedRegisterClassOrExplicitRegister { span: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected register class or explicit register")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4327#[diag("expected register class or explicit register")]
4328pub(crate) struct ExpectedRegisterClassOrExplicitRegister {
4329 #[primary_span]
4330 pub(crate) span: Span,
4331}
4332
4333#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
HiddenUnicodeCodepointsDiag where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
HiddenUnicodeCodepointsDiag {
label: __binding_0,
count: __binding_1,
span_label: __binding_2,
labels: __binding_3,
sub: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode codepoint changing visible direction of text present in {$label}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen")));
;
diag.arg("label", __binding_0);
diag.arg("count", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this {$label} contains {$count ->\n [one] an invisible\n *[other] invisible\n } unicode text flow control {$count ->\n [one] codepoint\n *[other] codepoints\n }")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag.subdiagnostic(__binding_4);
diag
}
}
}
}
};Diagnostic)]
4334#[diag("unicode codepoint changing visible direction of text present in {$label}")]
4335#[note(
4336 "these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen"
4337)]
4338pub(crate) struct HiddenUnicodeCodepointsDiag {
4339 pub label: String,
4340 pub count: usize,
4341 #[label(
4342 "this {$label} contains {$count ->
4343 [one] an invisible
4344 *[other] invisible
4345 } unicode text flow control {$count ->
4346 [one] codepoint
4347 *[other] codepoints
4348 }"
4349 )]
4350 pub span_label: Span,
4351 #[subdiagnostic]
4352 pub labels: Option<HiddenUnicodeCodepointsDiagLabels>,
4353 #[subdiagnostic]
4354 pub sub: HiddenUnicodeCodepointsDiagSub,
4355}
4356
4357pub(crate) struct HiddenUnicodeCodepointsDiagLabels {
4358 pub spans: Vec<(char, Span)>,
4359}
4360
4361impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
4362 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4363 for (c, span) in self.spans {
4364 diag.span_label(span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"));
4365 }
4366 }
4367}
4368
4369pub(crate) enum HiddenUnicodeCodepointsDiagSub {
4370 Escape { spans: Vec<(char, Span)> },
4371 NoEscape { spans: Vec<(char, Span)>, is_doc_comment: bool },
4372}
4373
4374impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
4376 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4377 match self {
4378 HiddenUnicodeCodepointsDiagSub::Escape { spans } => {
4379 diag.multipart_suggestion_with_style(
4380 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them"))msg!("if their presence wasn't intentional, you can remove them"),
4381 spans.iter().map(|(_, span)| (*span, "".to_string())).collect(),
4382 Applicability::MachineApplicable,
4383 SuggestionStyle::HideCodeAlways,
4384 );
4385 diag.multipart_suggestion(
4386 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you want to keep them but make them visible in your source code, you can escape them"))msg!("if you want to keep them but make them visible in your source code, you can escape them"),
4387 spans
4388 .into_iter()
4389 .map(|(c, span)| {
4390 let c = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}");
4391 (span, c[1..c.len() - 1].to_string())
4392 })
4393 .collect(),
4394 Applicability::MachineApplicable,
4395 );
4396 }
4397 HiddenUnicodeCodepointsDiagSub::NoEscape { spans, is_doc_comment } => {
4398 diag.arg(
4402 "escaped",
4403 spans
4404 .into_iter()
4405 .map(|(c, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"))
4406 .collect::<Vec<String>>()
4407 .join(", "),
4408 );
4409 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them"))msg!("if their presence wasn't intentional, you can remove them"));
4410 if is_doc_comment {
4411 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you need to keep them and make them explicit in source, rewrite this doc comment as a `#[doc = \"...\"]` attribute and use Unicode escapes such as {$escaped}"))msg!(r#"if you need to keep them and make them explicit in source, rewrite this doc comment as a `#[doc = "..."]` attribute and use Unicode escapes such as {$escaped}"#));
4412 } else {
4413 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you want to keep them but make them visible in your source code, you can escape them: {$escaped}"))msg!("if you want to keep them but make them visible in your source code, you can escape them: {$escaped}"));
4414 }
4415 }
4416 }
4417 }
4418}
4419
4420#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VarargsWithoutPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VarargsWithoutPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing pattern for `...` argument")));
let __code_234 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_: ..."))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("name the argument, or use `_` to continue ignoring it")),
__code_234, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4421#[diag("missing pattern for `...` argument")]
4422pub(crate) struct VarargsWithoutPattern {
4423 #[suggestion(
4424 "name the argument, or use `_` to continue ignoring it",
4425 code = "_: ...",
4426 applicability = "machine-applicable"
4427 )]
4428 pub span: Span,
4429}
4430
4431#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImplReuseInherentImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ImplReuseInherentImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only trait impls can be reused")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4432#[diag("only trait impls can be reused")]
4433pub(crate) struct ImplReuseInherentImpl {
4434 #[primary_span]
4435 pub span: Span,
4436}
4437
4438#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralPlaceholderPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralPlaceholderPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("placeholder `_` is not allowed for the path in struct literals")));
let __code_235 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* Type */"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not allowed in struct literals")));
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace it with the correct type")),
__code_235, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4439#[diag("placeholder `_` is not allowed for the path in struct literals")]
4440pub(crate) struct StructLiteralPlaceholderPath {
4441 #[primary_span]
4442 #[label("not allowed in struct literals")]
4443 #[suggestion(
4444 "replace it with the correct type",
4445 applicability = "has-placeholders",
4446 code = "/* Type */",
4447 style = "verbose"
4448 )]
4449 pub span: Span,
4450}
4451
4452#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralWithoutPathLate where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralWithoutPathLate {
span: __binding_0, suggestion_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literal body without path")));
let __code_236 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* Type */ "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct name missing for struct literal")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the correct type")),
__code_236, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4453#[diag("struct literal body without path")]
4454pub(crate) struct StructLiteralWithoutPathLate {
4455 #[primary_span]
4456 #[label("struct name missing for struct literal")]
4457 pub span: Span,
4458 #[suggestion(
4459 "add the correct type",
4460 applicability = "has-placeholders",
4461 code = "/* Type */ ",
4462 style = "verbose"
4463 )]
4464 pub suggestion_span: Span,
4465}
4466
4467#[derive(#[automatically_derived]
impl ::core::clone::Clone for ForbiddenLetReason {
#[inline]
fn clone(&self) -> ForbiddenLetReason {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ForbiddenLetReason { }Copy, const _: () =
{
impl rustc_errors::Subdiagnostic for ForbiddenLetReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ForbiddenLetReason::OtherForbidden => {}
ForbiddenLetReason::NotSupportedOr(__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("`||` operators are not supported in let chain expressions")),
&sub_args);
diag.span_note(__binding_0, __message);
}
ForbiddenLetReason::NotSupportedParentheses(__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("`let`s wrapped in parentheses are not supported in a context with let chains")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
4469pub(crate) enum ForbiddenLetReason {
4470 OtherForbidden,
4472 #[note("`||` operators are not supported in let chain expressions")]
4474 NotSupportedOr(#[primary_span] Span),
4475 #[note("`let`s wrapped in parentheses are not supported in a context with let chains")]
4480 NotSupportedParentheses(#[primary_span] Span),
4481}
4482
4483#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MisspelledKw {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "MisspelledKw",
"similar_kw", &self.similar_kw, "span", &self.span,
"is_incorrect_case", &&self.is_incorrect_case)
}
}Debug, const _: () =
{
impl rustc_errors::Subdiagnostic for MisspelledKw {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MisspelledKw {
similar_kw: __binding_0,
span: __binding_1,
is_incorrect_case: __binding_2 } => {
let __code_237 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_0))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("similar_kw".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("is_incorrect_case".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_incorrect_case ->\n [true] write keyword `{$similar_kw}` in lowercase\n *[false] there is a keyword `{$similar_kw}` with a similar name\n }")),
&sub_args);
diag.span_suggestions_with_style(__binding_1, __message,
__code_237, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};rustc_macros::Subdiagnostic)]
4484#[suggestion(
4485 "{$is_incorrect_case ->
4486 [true] write keyword `{$similar_kw}` in lowercase
4487 *[false] there is a keyword `{$similar_kw}` with a similar name
4488 }",
4489 applicability = "machine-applicable",
4490 code = "{similar_kw}",
4491 style = "verbose"
4492)]
4493pub(crate) struct MisspelledKw {
4494 pub similar_kw: String,
4497 #[primary_span]
4498 pub span: Span,
4499 pub is_incorrect_case: bool,
4500}
4501
4502#[derive(#[automatically_derived]
impl ::core::clone::Clone for TokenDescription {
#[inline]
fn clone(&self) -> TokenDescription {
let _: ::core::clone::AssertParamIsClone<MetaVarKind>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TokenDescription { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for TokenDescription {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TokenDescription::ReservedIdentifier =>
::core::fmt::Formatter::write_str(f, "ReservedIdentifier"),
TokenDescription::Keyword =>
::core::fmt::Formatter::write_str(f, "Keyword"),
TokenDescription::ReservedKeyword =>
::core::fmt::Formatter::write_str(f, "ReservedKeyword"),
TokenDescription::DocComment =>
::core::fmt::Formatter::write_str(f, "DocComment"),
TokenDescription::MetaVar(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"MetaVar", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for TokenDescription {
#[inline]
fn eq(&self, other: &TokenDescription) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(TokenDescription::MetaVar(__self_0),
TokenDescription::MetaVar(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TokenDescription {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<MetaVarKind>;
}
}Eq)]
4503pub(super) enum TokenDescription {
4504 ReservedIdentifier,
4505 Keyword,
4506 ReservedKeyword,
4507 DocComment,
4508
4509 MetaVar(MetaVarKind),
4514}
4515
4516impl TokenDescription {
4517 pub(super) fn from_token(token: &Token) -> Option<Self> {
4518 match token.kind {
4519 _ if token.is_special_ident() => Some(TokenDescription::ReservedIdentifier),
4520 _ if token.is_used_keyword() => Some(TokenDescription::Keyword),
4521 _ if token.is_unused_keyword() => Some(TokenDescription::ReservedKeyword),
4522 token::DocComment(..) => Some(TokenDescription::DocComment),
4523 token::OpenInvisible(InvisibleOrigin::MetaVar(kind)) => {
4524 Some(TokenDescription::MetaVar(kind))
4525 }
4526 _ => None,
4527 }
4528 }
4529}
4530
4531#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BreakWithLabelAndLoop where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BreakWithLabelAndLoop { sub: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4532#[diag(
4533 "this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression"
4534)]
4535pub(crate) struct BreakWithLabelAndLoop {
4536 #[subdiagnostic]
4537 pub sub: BreakWithLabelAndLoopSub,
4538}
4539
4540#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BreakWithLabelAndLoopSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BreakWithLabelAndLoopSub {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_238 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_239 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_238));
suggestions.push((__binding_1, __code_239));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap this expression in parentheses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4541#[multipart_suggestion("wrap this expression in parentheses", applicability = "machine-applicable")]
4542pub(crate) struct BreakWithLabelAndLoopSub {
4543 #[suggestion_part(code = "(")]
4544 pub left: Span,
4545 #[suggestion_part(code = ")")]
4546 pub right: Span,
4547}
4548
4549#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for RawPrefix
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RawPrefix { label: __binding_0, suggestion: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefix `'r` is reserved")));
let __code_240 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reserved prefix")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("insert whitespace here to avoid this being parsed as a prefix in Rust 2021")),
__code_240, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4550#[diag("prefix `'r` is reserved")]
4551pub(crate) struct RawPrefix {
4552 #[label("reserved prefix")]
4553 pub label: Span,
4554 #[suggestion(
4555 "insert whitespace here to avoid this being parsed as a prefix in Rust 2021",
4556 code = " ",
4557 applicability = "machine-applicable"
4558 )]
4559 pub suggestion: Span,
4560}
4561
4562#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnicodeTextFlow where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnicodeTextFlow {
comment_span: __binding_0,
characters: __binding_1,
suggestions: __binding_2,
num_codepoints: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode codepoint changing visible direction of text present in comment")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen")));
;
diag.arg("num_codepoints", __binding_3);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_codepoints ->\n [1] this comment contains an invisible unicode text flow control codepoint\n *[other] this comment contains invisible unicode text flow control codepoints\n }")));
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
4563#[diag("unicode codepoint changing visible direction of text present in comment")]
4564#[note(
4565 "these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen"
4566)]
4567pub(crate) struct UnicodeTextFlow {
4568 #[label(
4569 "{$num_codepoints ->
4570 [1] this comment contains an invisible unicode text flow control codepoint
4571 *[other] this comment contains invisible unicode text flow control codepoints
4572 }"
4573 )]
4574 pub comment_span: Span,
4575 #[subdiagnostic]
4576 pub characters: Vec<UnicodeCharNoteSub>,
4577 #[subdiagnostic]
4578 pub suggestions: Option<UnicodeTextFlowSuggestion>,
4579
4580 pub num_codepoints: usize,
4581}
4582
4583#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnicodeCharNoteSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnicodeCharNoteSub { span: __binding_0, c_debug: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("c_debug".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("{$c_debug}")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
4584#[label("{$c_debug}")]
4585pub(crate) struct UnicodeCharNoteSub {
4586 #[primary_span]
4587 pub span: Span,
4588 pub c_debug: String,
4589}
4590
4591#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnicodeTextFlowSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnicodeTextFlowSuggestion { spans: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_241 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_241.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeAlways);
}
}
}
}
};Subdiagnostic)]
4592#[multipart_suggestion(
4593 "if their presence wasn't intentional, you can remove them",
4594 applicability = "machine-applicable",
4595 style = "hidden"
4596)]
4597pub(crate) struct UnicodeTextFlowSuggestion {
4598 #[suggestion_part(code = "")]
4599 pub spans: Vec<Span>,
4600}
4601
4602#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ReservedPrefix
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedPrefix {
label: __binding_0,
suggestion: __binding_1,
prefix: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefix `{$prefix}` is unknown")));
let __code_242 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.arg("prefix", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown prefix")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("insert whitespace here to avoid this being parsed as a prefix in Rust 2021")),
__code_242, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4603#[diag("prefix `{$prefix}` is unknown")]
4604pub(crate) struct ReservedPrefix {
4605 #[label("unknown prefix")]
4606 pub label: Span,
4607 #[suggestion(
4608 "insert whitespace here to avoid this being parsed as a prefix in Rust 2021",
4609 code = " ",
4610 applicability = "machine-applicable"
4611 )]
4612 pub suggestion: Span,
4613
4614 pub prefix: String,
4615}
4616
4617#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReservedStringLint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedStringLint { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("will be parsed as a guarded string in Rust 2024")));
let __code_243 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("insert whitespace here to avoid this being parsed as a guarded string in Rust 2024")),
__code_243, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4618#[diag("will be parsed as a guarded string in Rust 2024")]
4619pub(crate) struct ReservedStringLint {
4620 #[suggestion(
4621 "insert whitespace here to avoid this being parsed as a guarded string in Rust 2024",
4622 code = " ",
4623 applicability = "machine-applicable"
4624 )]
4625 pub suggestion: Span,
4626}
4627
4628#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReservedMultihashLint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedMultihashLint { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reserved token in Rust 2024")));
let __code_244 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024")),
__code_244, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4629#[diag("reserved token in Rust 2024")]
4630pub(crate) struct ReservedMultihashLint {
4631 #[suggestion(
4632 "insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024",
4633 code = " ",
4634 applicability = "machine-applicable"
4635 )]
4636 pub suggestion: Span,
4637}
4638
4639#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UseDoubleColonSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UseDoubleColonSuggestion { colon: __binding_0 } => {
let __code_245 =
[::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("if you meant to write a path, use a double colon")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_245, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4640#[suggestion(
4641 "if you meant to write a path, use a double colon",
4642 code = "::",
4643 applicability = "maybe-incorrect"
4644)]
4645pub(crate) struct UseDoubleColonSuggestion {
4646 #[primary_span]
4647 pub colon: Span,
4648}
4649
4650#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UseRegularStructSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UseRegularStructSuggestion {
open: __binding_0,
close: __binding_1,
semicolon: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_246 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ "))
});
let __code_247 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
let __code_248 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_246));
suggestions.push((__binding_1, __code_247));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_248));
}
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 create a regular struct, use curly braces")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4651#[multipart_suggestion(
4652 "if you meant to create a regular struct, use curly braces",
4653 applicability = "maybe-incorrect"
4654)]
4655pub(crate) struct UseRegularStructSuggestion {
4656 #[suggestion_part(code = " {{ ")]
4657 pub open: Span,
4658 #[suggestion_part(code = " }}")]
4659 pub close: Span,
4660 #[suggestion_part(code = "")]
4661 pub semicolon: Option<Span>,
4662}