1use std::borrow::Cow;
4use std::path::PathBuf;
5
6use rustc_ast::token::{self, InvisibleOrigin, MetaVarKind, Token};
7use rustc_ast::util::parser::ExprPrecedence;
8use rustc_ast::{Path, Visibility};
9use rustc_errors::codes::*;
10use rustc_errors::{
11 Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg,
12 Level, Subdiagnostic, SuggestionStyle, msg,
13};
14use rustc_macros::{Diagnostic, Subdiagnostic};
15use rustc_session::errors::ExprParenthesesNeeded;
16use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
17use rustc_span::{Ident, Span, Symbol};
18
19#[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)]
20#[diag("ambiguous `+` in a type")]
21pub(crate) struct AmbiguousPlus {
22 #[primary_span]
23 pub span: Span,
24 #[subdiagnostic]
25 pub suggestion: AddParen,
26}
27
28#[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)]
29#[diag("expected a path on the left-hand side of `+`", code = E0178)]
30pub(crate) struct BadTypePlus {
31 #[primary_span]
32 pub span: Span,
33 #[subdiagnostic]
34 pub sub: BadTypePlusSub,
35}
36
37#[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)]
38#[multipart_suggestion("try adding parentheses", applicability = "machine-applicable")]
39pub(crate) struct AddParen {
40 #[suggestion_part(code = "(")]
41 pub lo: Span,
42 #[suggestion_part(code = ")")]
43 pub hi: Span,
44}
45
46#[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)]
47pub(crate) enum BadTypePlusSub {
48 AddParen {
49 #[subdiagnostic]
50 suggestion: AddParen,
51 },
52 #[label("perhaps you forgot parentheses?")]
53 ForgotParen {
54 #[primary_span]
55 span: Span,
56 },
57 #[label("expected a path")]
58 ExpectPath {
59 #[primary_span]
60 span: Span,
61 },
62}
63
64#[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)]
65#[diag("missing angle brackets in associated item path")]
66pub(crate) struct BadQPathStage2 {
67 #[primary_span]
68 pub span: Span,
69 #[subdiagnostic]
70 pub wrap: WrapType,
71}
72
73#[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)]
74#[diag("inherent impls cannot be {$modifier_name}")]
75#[note("only trait implementations may be annotated with `{$modifier}`")]
76pub(crate) struct TraitImplModifierInInherentImpl {
77 #[primary_span]
78 pub span: Span,
79 pub modifier: &'static str,
80 pub modifier_name: &'static str,
81 #[label("{$modifier_name} because of this")]
82 pub modifier_span: Span,
83 #[label("inherent impl for this type")]
84 pub self_ty: Span,
85}
86
87#[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)]
88#[multipart_suggestion(
89 "types that don't start with an identifier need to be surrounded with angle brackets in qualified paths",
90 applicability = "machine-applicable"
91)]
92pub(crate) struct WrapType {
93 #[suggestion_part(code = "<")]
94 pub lo: Span,
95 #[suggestion_part(code = ">")]
96 pub hi: Span,
97}
98
99#[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)]
100#[diag("expected item, found `;`")]
101pub(crate) struct IncorrectSemicolon<'a> {
102 #[primary_span]
103 #[suggestion(
104 "remove this semicolon",
105 style = "verbose",
106 code = "",
107 applicability = "machine-applicable"
108 )]
109 pub span: Span,
110 #[help("{$name} declarations are not followed by a semicolon")]
111 pub show_help: bool,
112 pub name: &'a str,
113}
114
115#[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)]
116#[diag("incorrect use of `await`")]
117pub(crate) struct IncorrectUseOfAwait {
118 #[primary_span]
119 #[suggestion(
120 "`await` is not a method call, remove the parentheses",
121 style = "verbose",
122 code = "",
123 applicability = "machine-applicable"
124 )]
125 pub span: Span,
126}
127
128#[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)]
129#[diag("incorrect use of `use`")]
130pub(crate) struct IncorrectUseOfUse {
131 #[primary_span]
132 #[suggestion(
133 "`use` is not a method call, try removing the parentheses",
134 style = "verbose",
135 code = "",
136 applicability = "machine-applicable"
137 )]
138 pub span: Span,
139}
140
141#[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();
sub_args.insert("question_mark".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("`await` is a postfix operation")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
142#[multipart_suggestion("`await` is a postfix operation", applicability = "machine-applicable")]
143pub(crate) struct AwaitSuggestion {
144 #[suggestion_part(code = "")]
145 pub removal: Span,
146 #[suggestion_part(code = ".await{question_mark}")]
147 pub dot_await: Span,
148 pub question_mark: &'static str,
149}
150
151#[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)]
152#[diag("incorrect use of `await`")]
153pub(crate) struct IncorrectAwait {
154 #[primary_span]
155 pub span: Span,
156 #[subdiagnostic]
157 pub suggestion: AwaitSuggestion,
158}
159
160#[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)]
161#[diag("expected iterable, found keyword `in`")]
162pub(crate) struct InInTypo {
163 #[primary_span]
164 pub span: Span,
165 #[suggestion(
166 "remove the duplicated `in`",
167 code = "",
168 style = "verbose",
169 applicability = "machine-applicable"
170 )]
171 pub sugg_span: Span,
172}
173
174#[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)]
175#[diag("invalid variable declaration")]
176pub(crate) struct InvalidVariableDeclaration {
177 #[primary_span]
178 pub span: Span,
179 #[subdiagnostic]
180 pub sub: InvalidVariableDeclarationSub,
181}
182
183#[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)]
184pub(crate) enum InvalidVariableDeclarationSub {
185 #[suggestion(
186 "switch the order of `mut` and `let`",
187 style = "verbose",
188 applicability = "maybe-incorrect",
189 code = "let mut"
190 )]
191 SwitchMutLetOrder(#[primary_span] Span),
192 #[suggestion(
193 "missing keyword",
194 applicability = "machine-applicable",
195 style = "verbose",
196 code = "let mut"
197 )]
198 MissingLet(#[primary_span] Span),
199 #[suggestion(
200 "write `let` instead of `auto` to introduce a new variable",
201 style = "verbose",
202 applicability = "machine-applicable",
203 code = "let"
204 )]
205 UseLetNotAuto(#[primary_span] Span),
206 #[suggestion(
207 "write `let` instead of `var` to introduce a new variable",
208 style = "verbose",
209 applicability = "machine-applicable",
210 code = "let"
211 )]
212 UseLetNotVar(#[primary_span] Span),
213}
214
215#[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)]
216#[diag("switch the order of `ref` and `box`")]
217pub(crate) struct SwitchRefBoxOrder {
218 #[primary_span]
219 #[suggestion(
220 "swap them",
221 applicability = "machine-applicable",
222 style = "verbose",
223 code = "box ref"
224 )]
225 pub span: Span,
226}
227
228#[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)]
229#[diag("invalid comparison operator `{$invalid}`")]
230pub(crate) struct InvalidComparisonOperator {
231 #[primary_span]
232 pub span: Span,
233 pub invalid: String,
234 #[subdiagnostic]
235 pub sub: InvalidComparisonOperatorSub,
236}
237
238#[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)]
239pub(crate) enum InvalidComparisonOperatorSub {
240 #[suggestion(
241 "`{$invalid}` is not a valid comparison operator, use `{$correct}`",
242 style = "verbose",
243 applicability = "machine-applicable",
244 code = "{correct}"
245 )]
246 Correctable {
247 #[primary_span]
248 span: Span,
249 invalid: String,
250 correct: String,
251 },
252 #[label("`<=>` is not a valid comparison operator, use `std::cmp::Ordering`")]
253 Spaceship(#[primary_span] Span),
254}
255
256#[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)]
257#[diag("`{$incorrect}` is not a logical operator")]
258#[note("unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators")]
259pub(crate) struct InvalidLogicalOperator {
260 #[primary_span]
261 pub span: Span,
262 pub incorrect: String,
263 #[subdiagnostic]
264 pub sub: InvalidLogicalOperatorSub,
265}
266
267#[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)]
268pub(crate) enum InvalidLogicalOperatorSub {
269 #[suggestion(
270 "use `&&` to perform logical conjunction",
271 style = "verbose",
272 applicability = "machine-applicable",
273 code = "&&"
274 )]
275 Conjunction(#[primary_span] Span),
276 #[suggestion(
277 "use `||` to perform logical disjunction",
278 style = "verbose",
279 applicability = "machine-applicable",
280 code = "||"
281 )]
282 Disjunction(#[primary_span] Span),
283}
284
285#[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)]
286#[diag("`~` cannot be used as a unary operator")]
287pub(crate) struct TildeAsUnaryOperator(
288 #[primary_span]
289 #[suggestion(
290 "use `!` to perform bitwise not",
291 style = "verbose",
292 applicability = "machine-applicable",
293 code = "!"
294 )]
295 pub Span,
296);
297
298#[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)]
299#[diag("unexpected {$negated_desc} after identifier")]
300pub(crate) struct NotAsNegationOperator {
301 #[primary_span]
302 pub negated: Span,
303 pub negated_desc: String,
304 #[subdiagnostic]
305 pub sub: NotAsNegationOperatorSub,
306}
307
308#[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)]
309pub(crate) enum NotAsNegationOperatorSub {
310 #[suggestion(
311 "use `!` to perform logical negation or bitwise not",
312 style = "verbose",
313 applicability = "machine-applicable",
314 code = "!"
315 )]
316 SuggestNotDefault(#[primary_span] Span),
317
318 #[suggestion(
319 "use `!` to perform bitwise not",
320 style = "verbose",
321 applicability = "machine-applicable",
322 code = "!"
323 )]
324 SuggestNotBitwise(#[primary_span] Span),
325
326 #[suggestion(
327 "use `!` to perform logical negation",
328 style = "verbose",
329 applicability = "machine-applicable",
330 code = "!"
331 )]
332 SuggestNotLogical(#[primary_span] Span),
333}
334
335#[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)]
336#[diag("malformed loop label")]
337pub(crate) struct MalformedLoopLabel {
338 #[primary_span]
339 pub span: Span,
340 #[suggestion(
341 "use the correct loop label format",
342 applicability = "machine-applicable",
343 code = "'",
344 style = "verbose"
345 )]
346 pub suggestion: Span,
347}
348
349#[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)]
350#[diag("borrow expressions cannot be annotated with lifetimes")]
351pub(crate) struct LifetimeInBorrowExpression {
352 #[primary_span]
353 pub span: Span,
354 #[suggestion(
355 "remove the lifetime annotation",
356 applicability = "machine-applicable",
357 code = "",
358 style = "verbose"
359 )]
360 #[label("annotated with lifetime here")]
361 pub lifetime_span: Span,
362}
363
364#[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)]
365#[diag("field expressions cannot have generic arguments")]
366pub(crate) struct FieldExpressionWithGeneric(#[primary_span] pub Span);
367
368#[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)]
369#[diag("macros cannot use qualified paths")]
370pub(crate) struct MacroInvocationWithQualifiedPath(#[primary_span] pub Span);
371
372#[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)]
373#[diag("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
374pub(crate) struct UnexpectedTokenAfterLabel {
375 #[primary_span]
376 #[label("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
377 pub span: Span,
378 #[suggestion("consider removing the label", style = "verbose", code = "")]
379 pub remove_label: Option<Span>,
380 #[subdiagnostic]
381 pub enclose_in_block: Option<UnexpectedTokenAfterLabelSugg>,
382}
383
384#[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)]
385#[multipart_suggestion(
386 "consider enclosing expression in a block",
387 applicability = "machine-applicable"
388)]
389pub(crate) struct UnexpectedTokenAfterLabelSugg {
390 #[suggestion_part(code = "{{ ")]
391 pub left: Span,
392 #[suggestion_part(code = " }}")]
393 pub right: Span,
394}
395
396#[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)]
397#[diag("labeled expression must be followed by `:`")]
398#[note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")]
399pub(crate) struct RequireColonAfterLabeledExpression {
400 #[primary_span]
401 pub span: Span,
402 #[label("the label")]
403 pub label: Span,
404 #[suggestion(
405 "add `:` after the label",
406 style = "verbose",
407 applicability = "machine-applicable",
408 code = ": "
409 )]
410 pub label_end: Span,
411}
412
413#[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)]
414#[diag("found removed `do catch` syntax")]
415#[note("following RFC #2388, the new non-placeholder syntax is `try`")]
416pub(crate) struct DoCatchSyntaxRemoved {
417 #[primary_span]
418 #[suggestion(
419 "replace with the new syntax",
420 applicability = "machine-applicable",
421 code = "try",
422 style = "verbose"
423 )]
424 pub span: Span,
425}
426
427#[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)]
428#[diag("float literals must have an integer part")]
429pub(crate) struct FloatLiteralRequiresIntegerPart {
430 #[primary_span]
431 pub span: Span,
432 #[suggestion(
433 "must have an integer part",
434 applicability = "machine-applicable",
435 code = "0",
436 style = "verbose"
437 )]
438 pub suggestion: Span,
439}
440
441#[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)]
442#[diag("expected `;`, found `[`")]
443pub(crate) struct MissingSemicolonBeforeArray {
444 #[primary_span]
445 pub open_delim: Span,
446 #[suggestion(
447 "consider adding `;` here",
448 style = "verbose",
449 applicability = "maybe-incorrect",
450 code = ";"
451 )]
452 pub semicolon: Span,
453}
454
455#[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)]
456#[diag("expected `..`, found `...`")]
457pub(crate) struct MissingDotDot {
458 #[primary_span]
459 pub token_span: Span,
460 #[suggestion(
461 "use `..` to fill in the rest of the fields",
462 applicability = "maybe-incorrect",
463 code = "..",
464 style = "verbose"
465 )]
466 pub sugg_span: Span,
467}
468
469#[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)]
470#[diag("cannot use a `block` macro fragment here")]
471pub(crate) struct InvalidBlockMacroSegment {
472 #[primary_span]
473 pub span: Span,
474 #[label("the `block` fragment is within this context")]
475 pub context: Span,
476 #[subdiagnostic]
477 pub wrap: WrapInExplicitBlock,
478}
479
480#[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)]
481#[multipart_suggestion("wrap this in another block", applicability = "machine-applicable")]
482pub(crate) struct WrapInExplicitBlock {
483 #[suggestion_part(code = "{{ ")]
484 pub lo: Span,
485 #[suggestion_part(code = " }}")]
486 pub hi: Span,
487}
488
489#[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)]
490#[diag("this `if` expression is missing a block after the condition")]
491pub(crate) struct IfExpressionMissingThenBlock {
492 #[primary_span]
493 pub if_span: Span,
494 #[subdiagnostic]
495 pub missing_then_block_sub: IfExpressionMissingThenBlockSub,
496 #[subdiagnostic]
497 pub let_else_sub: Option<IfExpressionLetSomeSub>,
498}
499
500#[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)]
501pub(crate) enum IfExpressionMissingThenBlockSub {
502 #[help("this binary operation is possibly unfinished")]
503 UnfinishedCondition(#[primary_span] Span),
504 #[help("add a block here")]
505 AddThenBlock(#[primary_span] Span),
506}
507
508#[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)]
509#[diag("Rust has no ternary operator")]
510pub(crate) struct TernaryOperator {
511 #[primary_span]
512 pub span: Span,
513 #[subdiagnostic]
515 pub sugg: Option<TernaryOperatorSuggestion>,
516 #[help("use an `if-else` expression instead")]
518 pub no_sugg: bool,
519}
520
521#[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)]
522#[multipart_suggestion(
523 "use an `if-else` expression instead",
524 applicability = "maybe-incorrect",
525 style = "verbose"
526)]
527pub(crate) struct TernaryOperatorSuggestion {
528 #[suggestion_part(code = "if ")]
529 pub before_cond: Span,
530 #[suggestion_part(code = "{{")]
531 pub question: Span,
532 #[suggestion_part(code = "}} else {{")]
533 pub colon: Span,
534 #[suggestion_part(code = " }}")]
535 pub end: Span,
536}
537
538#[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)]
539#[suggestion(
540 "remove the `if` if you meant to write a `let...else` statement",
541 applicability = "maybe-incorrect",
542 code = "",
543 style = "verbose"
544)]
545pub(crate) struct IfExpressionLetSomeSub {
546 #[primary_span]
547 pub if_span: Span,
548}
549
550#[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)]
551#[diag("missing condition for `if` expression")]
552pub(crate) struct IfExpressionMissingCondition {
553 #[primary_span]
554 #[label("expected condition here")]
555 pub if_span: Span,
556 #[label(
557 "if this block is the condition of the `if` expression, then it must be followed by another block"
558 )]
559 pub block_span: Span,
560}
561
562#[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)]
563#[diag("expected expression, found `let` statement")]
564#[note("only supported directly in conditions of `if` and `while` expressions")]
565pub(crate) struct ExpectedExpressionFoundLet {
566 #[primary_span]
567 pub span: Span,
568 #[subdiagnostic]
569 pub reason: ForbiddenLetReason,
570 #[subdiagnostic]
571 pub missing_let: Option<MaybeMissingLet>,
572 #[subdiagnostic]
573 pub comparison: Option<MaybeComparison>,
574}
575
576#[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)]
577#[diag("let-chain with missing `let`")]
578pub(crate) struct LetChainMissingLet {
579 #[primary_span]
580 pub span: Span,
581 #[label("expected `let` expression, found assignment")]
582 pub label_span: Span,
583 #[label("let expression later in the condition")]
584 pub rhs_span: Span,
585 #[suggestion(
586 "add `let` before the expression",
587 applicability = "maybe-incorrect",
588 code = "let ",
589 style = "verbose"
590 )]
591 pub sug_span: Span,
592}
593
594#[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)]
595#[diag("`||` operators are not supported in let chain conditions")]
596pub(crate) struct OrInLetChain {
597 #[primary_span]
598 pub span: Span,
599}
600
601#[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)]
602#[multipart_suggestion(
603 "you might have meant to continue the let-chain",
604 applicability = "maybe-incorrect",
605 style = "verbose"
606)]
607pub(crate) struct MaybeMissingLet {
608 #[suggestion_part(code = "let ")]
609 pub span: Span,
610}
611
612#[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)]
613#[multipart_suggestion(
614 "you might have meant to compare for equality",
615 applicability = "maybe-incorrect",
616 style = "verbose"
617)]
618pub(crate) struct MaybeComparison {
619 #[suggestion_part(code = "=")]
620 pub span: Span,
621}
622
623#[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)]
624#[diag("expected `=`, found `==`")]
625pub(crate) struct ExpectedEqForLetExpr {
626 #[primary_span]
627 pub span: Span,
628 #[suggestion(
629 "consider using `=` here",
630 applicability = "maybe-incorrect",
631 code = "=",
632 style = "verbose"
633 )]
634 pub sugg_span: Span,
635}
636
637#[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)]
638#[diag("expected `{\"{\"}`, found {$first_tok}")]
639pub(crate) struct ExpectedElseBlock {
640 #[primary_span]
641 pub first_tok_span: Span,
642 pub first_tok: String,
643 #[label("expected an `if` or a block after this `else`")]
644 pub else_span: Span,
645 #[suggestion(
646 "add an `if` if this is the condition of a chained `else if` statement",
647 applicability = "maybe-incorrect",
648 code = "if ",
649 style = "verbose"
650 )]
651 pub condition_start: Span,
652}
653
654#[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)]
655#[diag("expected one of `,`, `:`, or `{\"}\"}`, found `{$token}`")]
656pub(crate) struct ExpectedStructField {
657 #[primary_span]
658 #[label("expected one of `,`, `:`, or `{\"}\"}`")]
659 pub span: Span,
660 pub token: Token,
661 #[label("while parsing this struct field")]
662 pub ident_span: Span,
663}
664
665#[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)]
666#[diag("outer attributes are not allowed on `if` and `else` branches")]
667pub(crate) struct OuterAttributeNotAllowedOnIfElse {
668 #[primary_span]
669 pub last: Span,
670
671 #[label("the attributes are attached to this branch")]
672 pub branch_span: Span,
673
674 #[label("the branch belongs to this `{$ctx}`")]
675 pub ctx_span: Span,
676 pub ctx: String,
677
678 #[suggestion(
679 "remove the attributes",
680 applicability = "machine-applicable",
681 code = "",
682 style = "verbose"
683 )]
684 pub attributes: Span,
685}
686
687#[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)]
688#[diag("missing `in` in `for` loop")]
689pub(crate) struct MissingInInForLoop {
690 #[primary_span]
691 pub span: Span,
692 #[subdiagnostic]
693 pub sub: MissingInInForLoopSub,
694}
695
696#[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)]
697pub(crate) enum MissingInInForLoopSub {
698 #[suggestion(
701 "try using `in` here instead",
702 style = "verbose",
703 applicability = "maybe-incorrect",
704 code = "in"
705 )]
706 InNotOf(#[primary_span] Span),
707 #[suggestion(
709 "try using `in` here instead",
710 style = "verbose",
711 applicability = "maybe-incorrect",
712 code = "in"
713 )]
714 InNotEq(#[primary_span] Span),
715 #[suggestion(
716 "try adding `in` here",
717 style = "verbose",
718 applicability = "maybe-incorrect",
719 code = " in "
720 )]
721 AddIn(#[primary_span] Span),
722}
723
724#[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)]
725#[diag("missing expression to iterate on in `for` loop")]
726pub(crate) struct MissingExpressionInForLoop {
727 #[primary_span]
728 #[suggestion(
729 "try adding an expression to the `for` loop",
730 code = "/* expression */ ",
731 applicability = "has-placeholders",
732 style = "verbose"
733 )]
734 pub span: Span,
735}
736
737#[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)]
738#[diag("`{$loop_kind}...else` loops are not supported")]
739#[note(
740 "consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run"
741)]
742pub(crate) struct LoopElseNotSupported {
743 #[primary_span]
744 pub span: Span,
745 pub loop_kind: &'static str,
746 #[label("`else` is attached to this loop")]
747 pub loop_kw: Span,
748}
749
750#[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)]
751#[diag("expected `,` following `match` arm")]
752pub(crate) struct MissingCommaAfterMatchArm {
753 #[primary_span]
754 #[suggestion(
755 "missing a comma here to end this `match` arm",
756 applicability = "machine-applicable",
757 code = ",",
758 style = "verbose"
759 )]
760 pub span: Span,
761}
762
763#[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)]
764#[diag("keyword `catch` cannot follow a `try` block")]
765#[help("try using `match` on the result of the `try` block instead")]
766pub(crate) struct CatchAfterTry {
767 #[primary_span]
768 pub span: Span,
769}
770
771#[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)]
772#[diag("cannot use a comma after the base struct")]
773#[note("the base struct must always be the last field")]
774pub(crate) struct CommaAfterBaseStruct {
775 #[primary_span]
776 pub span: Span,
777 #[suggestion(
778 "remove this comma",
779 style = "verbose",
780 applicability = "machine-applicable",
781 code = ""
782 )]
783 pub comma: Span,
784}
785
786#[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)]
787#[diag("expected `:`, found `=`")]
788pub(crate) struct EqFieldInit {
789 #[primary_span]
790 pub span: Span,
791 #[suggestion(
792 "replace equals symbol with a colon",
793 applicability = "machine-applicable",
794 code = ":",
795 style = "verbose"
796 )]
797 pub eq: Span,
798}
799
800#[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)]
801#[diag("unexpected token: `...`")]
802pub(crate) struct DotDotDot {
803 #[primary_span]
804 #[suggestion(
805 "use `..` for an exclusive range",
806 applicability = "maybe-incorrect",
807 code = "..",
808 style = "verbose"
809 )]
810 #[suggestion(
811 "or `..=` for an inclusive range",
812 applicability = "maybe-incorrect",
813 code = "..=",
814 style = "verbose"
815 )]
816 pub span: Span,
817}
818
819#[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)]
820#[diag("unexpected token: `<-`")]
821pub(crate) struct LeftArrowOperator {
822 #[primary_span]
823 #[suggestion(
824 "if you meant to write a comparison against a negative value, add a space in between `<` and `-`",
825 applicability = "maybe-incorrect",
826 code = "< -",
827 style = "verbose"
828 )]
829 pub span: Span,
830}
831
832#[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)]
833#[diag("expected pattern, found `let`")]
834pub(crate) struct RemoveLet {
835 #[primary_span]
836 pub span: Span,
837 #[suggestion(
838 "remove the unnecessary `let` keyword",
839 applicability = "machine-applicable",
840 code = "",
841 style = "verbose"
842 )]
843 pub suggestion: Span,
844}
845
846#[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)]
847#[diag("unexpected `==`")]
848pub(crate) struct UseEqInstead {
849 #[primary_span]
850 #[suggestion(
851 "try using `=` instead",
852 style = "verbose",
853 applicability = "machine-applicable",
854 code = "="
855 )]
856 pub span: Span,
857}
858
859#[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)]
860#[diag("expected { \"`{}`\" }, found `;`")]
861pub(crate) struct UseEmptyBlockNotSemi {
862 #[primary_span]
863 #[suggestion(
864 r#"try using { "`{}`" } instead"#,
865 style = "hidden",
866 applicability = "machine-applicable",
867 code = "{{}}"
868 )]
869 pub span: Span,
870}
871
872#[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)]
873#[diag("`<` is interpreted as a start of generic arguments for `{$type}`, not a comparison")]
874pub(crate) struct ComparisonInterpretedAsGeneric {
875 #[primary_span]
876 #[label("not interpreted as comparison")]
877 pub comparison: Span,
878 pub r#type: Path,
879 #[label("interpreted as generic arguments")]
880 pub args: Span,
881 #[subdiagnostic]
882 pub suggestion: ComparisonInterpretedAsGenericSugg,
883}
884
885#[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)]
886#[multipart_suggestion("try comparing the cast value", applicability = "machine-applicable")]
887pub(crate) struct ComparisonInterpretedAsGenericSugg {
888 #[suggestion_part(code = "(")]
889 pub left: Span,
890 #[suggestion_part(code = ")")]
891 pub right: Span,
892}
893
894#[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)]
895#[diag("`<<` is interpreted as a start of generic arguments for `{$type}`, not a shift")]
896pub(crate) struct ShiftInterpretedAsGeneric {
897 #[primary_span]
898 #[label("not interpreted as shift")]
899 pub shift: Span,
900 pub r#type: Path,
901 #[label("interpreted as generic arguments")]
902 pub args: Span,
903 #[subdiagnostic]
904 pub suggestion: ShiftInterpretedAsGenericSugg,
905}
906
907#[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)]
908#[multipart_suggestion("try shifting the cast value", applicability = "machine-applicable")]
909pub(crate) struct ShiftInterpretedAsGenericSugg {
910 #[suggestion_part(code = "(")]
911 pub left: Span,
912 #[suggestion_part(code = ")")]
913 pub right: Span,
914}
915
916#[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)]
917#[diag("expected expression, found `{$token}`")]
918pub(crate) struct FoundExprWouldBeStmt {
919 #[primary_span]
920 #[label("expected expression")]
921 pub span: Span,
922 pub token: Token,
923 #[subdiagnostic]
924 pub suggestion: ExprParenthesesNeeded,
925}
926
927#[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)]
928#[diag("extra characters after frontmatter close are not allowed")]
929pub(crate) struct FrontmatterExtraCharactersAfterClose {
930 #[primary_span]
931 pub span: Span,
932}
933
934#[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)]
935#[diag("invalid infostring for frontmatter")]
936#[note("frontmatter infostrings must be a single identifier immediately following the opening")]
937pub(crate) struct FrontmatterInvalidInfostring {
938 #[primary_span]
939 pub span: Span,
940}
941
942#[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)]
943#[diag("invalid preceding whitespace for frontmatter opening")]
944pub(crate) struct FrontmatterInvalidOpeningPrecedingWhitespace {
945 #[primary_span]
946 pub span: Span,
947 #[note("frontmatter opening should not be preceded by whitespace")]
948 pub note_span: Span,
949}
950
951#[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)]
952#[diag("unclosed frontmatter")]
953pub(crate) struct FrontmatterUnclosed {
954 #[primary_span]
955 pub span: Span,
956 #[note("frontmatter opening here was not closed")]
957 pub note_span: Span,
958}
959
960#[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)]
961#[diag("invalid preceding whitespace for frontmatter close")]
962pub(crate) struct FrontmatterInvalidClosingPrecedingWhitespace {
963 #[primary_span]
964 pub span: Span,
965 #[note("frontmatter close should not be preceded by whitespace")]
966 pub note_span: Span,
967}
968
969#[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)]
970#[diag("frontmatter close does not match the opening")]
971pub(crate) struct FrontmatterLengthMismatch {
972 #[primary_span]
973 pub span: Span,
974 #[label("the opening here has {$len_opening} dashes...")]
975 pub opening: Span,
976 #[label("...while the close has {$len_close} dashes")]
977 pub close: Span,
978 pub len_opening: usize,
979 pub len_close: usize,
980}
981
982#[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)]
983#[diag(
984 "too many `-` symbols: frontmatter openings may be delimited by up to 255 `-` symbols, but found {$len_opening}"
985)]
986pub(crate) struct FrontmatterTooManyDashes {
987 pub len_opening: usize,
988}
989
990#[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)]
991#[diag("bare CR not allowed in frontmatter")]
992pub(crate) struct BareCrFrontmatter {
993 #[primary_span]
994 pub span: Span,
995}
996
997#[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)]
998#[diag("leading `+` is not supported")]
999pub(crate) struct LeadingPlusNotSupported {
1000 #[primary_span]
1001 #[label("unexpected `+`")]
1002 pub span: Span,
1003 #[suggestion(
1004 "try removing the `+`",
1005 style = "verbose",
1006 code = "",
1007 applicability = "machine-applicable"
1008 )]
1009 pub remove_plus: Option<Span>,
1010 #[subdiagnostic]
1011 pub add_parentheses: Option<ExprParenthesesNeeded>,
1012}
1013
1014#[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)]
1015#[diag("invalid `struct` delimiters or `fn` call arguments")]
1016pub(crate) struct ParenthesesWithStructFields {
1017 #[primary_span]
1018 pub span: Span,
1019 #[subdiagnostic]
1020 pub braces_for_struct: BracesForStructLiteral,
1021 #[subdiagnostic]
1022 pub no_fields_for_fn: NoFieldsForFnCall,
1023}
1024
1025#[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)]
1026#[multipart_suggestion(
1027 "if `{$type}` is a struct, use braces as delimiters",
1028 applicability = "maybe-incorrect"
1029)]
1030pub(crate) struct BracesForStructLiteral {
1031 pub r#type: Path,
1032 #[suggestion_part(code = " {{ ")]
1033 pub first: Span,
1034 #[suggestion_part(code = " }}")]
1035 pub second: Span,
1036}
1037
1038#[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)]
1039#[multipart_suggestion(
1040 "if `{$type}` is a function, use the arguments directly",
1041 applicability = "maybe-incorrect"
1042)]
1043pub(crate) struct NoFieldsForFnCall {
1044 pub r#type: Path,
1045 #[suggestion_part(code = "")]
1046 pub fields: Vec<Span>,
1047}
1048
1049#[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)]
1050#[diag(
1051 "parentheses are required around this expression to avoid confusion with a labeled break expression"
1052)]
1053pub(crate) struct LabeledLoopInBreak {
1054 #[primary_span]
1055 pub span: Span,
1056 #[subdiagnostic]
1057 pub sub: WrapInParentheses,
1058}
1059
1060#[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)]
1061pub(crate) enum WrapInParentheses {
1062 #[multipart_suggestion(
1063 "wrap the expression in parentheses",
1064 applicability = "machine-applicable"
1065 )]
1066 Expression {
1067 #[suggestion_part(code = "(")]
1068 left: Span,
1069 #[suggestion_part(code = ")")]
1070 right: Span,
1071 },
1072 #[multipart_suggestion(
1073 "use parentheses instead of braces for this macro",
1074 applicability = "machine-applicable"
1075 )]
1076 MacroArgs {
1077 #[suggestion_part(code = "(")]
1078 left: Span,
1079 #[suggestion_part(code = ")")]
1080 right: Span,
1081 },
1082}
1083
1084#[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)]
1085#[diag("this is a block expression, not an array")]
1086pub(crate) struct ArrayBracketsInsteadOfBraces {
1087 #[primary_span]
1088 pub span: Span,
1089 #[subdiagnostic]
1090 pub sub: ArrayBracketsInsteadOfBracesSugg,
1091}
1092
1093#[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)]
1094#[multipart_suggestion(
1095 "to make an array, use square brackets instead of curly braces",
1096 applicability = "maybe-incorrect"
1097)]
1098pub(crate) struct ArrayBracketsInsteadOfBracesSugg {
1099 #[suggestion_part(code = "[")]
1100 pub left: Span,
1101 #[suggestion_part(code = "]")]
1102 pub right: Span,
1103}
1104
1105#[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)]
1106#[diag("`match` arm body without braces")]
1107pub(crate) struct MatchArmBodyWithoutBraces {
1108 #[primary_span]
1109 #[label(
1110 "{$num_statements ->
1111 [one] this statement is not surrounded by a body
1112 *[other] these statements are not surrounded by a body
1113 }"
1114 )]
1115 pub statements: Span,
1116 #[label("while parsing the `match` arm starting here")]
1117 pub arrow: Span,
1118 pub num_statements: usize,
1119 #[subdiagnostic]
1120 pub sub: MatchArmBodyWithoutBracesSugg,
1121}
1122
1123#[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)]
1124#[diag("unexpected `=` after inclusive range")]
1125#[note("inclusive ranges end with a single equals sign (`..=`)")]
1126pub(crate) struct InclusiveRangeExtraEquals {
1127 #[primary_span]
1128 #[suggestion(
1129 "use `..=` instead",
1130 style = "verbose",
1131 code = "..=",
1132 applicability = "maybe-incorrect"
1133 )]
1134 pub span: Span,
1135}
1136
1137#[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,
after_pat: __binding_2 } => {
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_2,
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)]
1138#[diag("unexpected `>` after inclusive range")]
1139pub(crate) struct InclusiveRangeMatchArrow {
1140 #[primary_span]
1141 pub arrow: Span,
1142 #[label("this is parsed as an inclusive range `..=`")]
1143 pub span: Span,
1144 #[suggestion(
1145 "add a space between the pattern and `=>`",
1146 style = "verbose",
1147 code = " ",
1148 applicability = "machine-applicable"
1149 )]
1150 pub after_pat: Span,
1151}
1152
1153#[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, suggestion: __binding_1 } => {
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_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..` instead")),
__code_74, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1154#[diag("inclusive range with no end", code = E0586)]
1155#[note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")]
1156pub(crate) struct InclusiveRangeNoEnd {
1157 #[primary_span]
1158 pub span: Span,
1159 #[suggestion(
1160 "use `..` instead",
1161 code = "",
1162 applicability = "machine-applicable",
1163 style = "verbose"
1164 )]
1165 pub suggestion: Span,
1166}
1167
1168#[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)]
1169pub(crate) enum MatchArmBodyWithoutBracesSugg {
1170 #[multipart_suggestion(
1171 "surround the {$num_statements ->
1172 [one] statement
1173 *[other] statements
1174 } with a body",
1175 applicability = "machine-applicable"
1176 )]
1177 AddBraces {
1178 #[suggestion_part(code = "{{ ")]
1179 left: Span,
1180 #[suggestion_part(code = " }}")]
1181 right: Span,
1182 num_statements: usize,
1183 },
1184 #[suggestion(
1185 "replace `;` with `,` to end a `match` arm expression",
1186 code = ",",
1187 applicability = "machine-applicable",
1188 style = "verbose"
1189 )]
1190 UseComma {
1191 #[primary_span]
1192 semicolon: Span,
1193 },
1194}
1195
1196#[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)]
1197#[diag("struct literals are not allowed here")]
1198pub(crate) struct StructLiteralNotAllowedHere {
1199 #[primary_span]
1200 pub span: Span,
1201 #[subdiagnostic]
1202 pub sub: StructLiteralNotAllowedHereSugg,
1203}
1204
1205#[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)]
1206#[multipart_suggestion(
1207 "surround the struct literal with parentheses",
1208 applicability = "machine-applicable"
1209)]
1210pub(crate) struct StructLiteralNotAllowedHereSugg {
1211 #[suggestion_part(code = "(")]
1212 pub left: Span,
1213 #[suggestion_part(code = ")")]
1214 pub right: Span,
1215}
1216
1217#[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)]
1218#[diag("suffixes on a tuple index are invalid")]
1219pub(crate) struct InvalidLiteralSuffixOnTupleIndex {
1220 #[primary_span]
1221 #[label("invalid suffix `{$suffix}`")]
1222 pub span: Span,
1223 pub suffix: Symbol,
1224}
1225
1226#[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)]
1227#[diag("non-string ABI literal")]
1228pub(crate) struct NonStringAbiLiteral {
1229 #[primary_span]
1230 #[suggestion(
1231 "specify the ABI with a string literal",
1232 code = "\"C\"",
1233 applicability = "maybe-incorrect",
1234 style = "verbose"
1235 )]
1236 pub span: Span,
1237}
1238
1239#[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)]
1240#[diag("mismatched closing delimiter: `{$delimiter}`")]
1241pub(crate) struct MismatchedClosingDelimiter {
1242 #[primary_span]
1243 pub spans: Vec<Span>,
1244 pub delimiter: String,
1245 #[label("mismatched closing delimiter")]
1246 pub unmatched: Span,
1247 #[label("closing delimiter possibly meant for this")]
1248 pub opening_candidate: Option<Span>,
1249 #[label("unclosed delimiter")]
1250 pub unclosed: Option<Span>,
1251}
1252
1253#[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)]
1254#[diag("incorrect visibility restriction", code = E0704)]
1255#[help(
1256 "some possible visibility restrictions are:
1257 `pub(crate)`: visible only on the current crate
1258 `pub(super)`: visible only in the current module's parent
1259 `pub(in path::to::module)`: visible only on the specified path"
1260)]
1261pub(crate) struct IncorrectVisibilityRestriction {
1262 #[primary_span]
1263 #[suggestion(
1264 "make this visible only to module `{$inner_str}` with `in`",
1265 code = "in {inner_str}",
1266 applicability = "machine-applicable",
1267 style = "verbose"
1268 )]
1269 pub span: Span,
1270 pub inner_str: String,
1271}
1272
1273#[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)]
1274#[diag("incorrect `impl` restriction")]
1275#[help(
1276 "some possible `impl` restrictions are:
1277 `impl(crate)`: can only be implemented in the current crate
1278 `impl(super)`: can only be implemented in the parent module
1279 `impl(self)`: can only be implemented in current module
1280 `impl(in path::to::module)`: can only be implemented in the specified path"
1281)]
1282pub(crate) struct IncorrectImplRestriction {
1283 #[primary_span]
1284 #[suggestion(
1285 "help: use `in` to restrict implementations to the path `{$inner_str}`",
1286 code = "in {inner_str}",
1287 applicability = "machine-applicable"
1288 )]
1289 pub span: Span,
1290 pub inner_str: String,
1291}
1292
1293#[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)]
1294#[diag("<assignment> ... else {\"{\"} ... {\"}\"} is not allowed")]
1295pub(crate) struct AssignmentElseNotAllowed {
1296 #[primary_span]
1297 pub span: Span,
1298}
1299
1300#[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)]
1301#[diag("expected statement after outer attribute")]
1302pub(crate) struct ExpectedStatementAfterOuterAttr {
1303 #[primary_span]
1304 pub span: Span,
1305}
1306
1307#[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)]
1308#[diag("attribute without where predicates")]
1309pub(crate) struct AttrWithoutWherePredicates {
1310 #[primary_span]
1311 #[label("attributes are only permitted when preceding predicates")]
1312 pub span: Span,
1313}
1314
1315#[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_83 =
[::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_83, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1316#[diag("found a documentation comment that doesn't document anything", code = E0585)]
1317#[help("doc comments must come before what they document, if a comment was intended use `//`")]
1318pub(crate) struct DocCommentDoesNotDocumentAnything {
1319 #[primary_span]
1320 pub span: Span,
1321 #[suggestion(
1322 "missing comma here",
1323 code = ",",
1324 applicability = "machine-applicable",
1325 style = "verbose"
1326 )]
1327 pub missing_comma: Option<Span>,
1328}
1329
1330#[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_84 =
[::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_84, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1331#[diag("`const` and `let` are mutually exclusive")]
1332pub(crate) struct ConstLetMutuallyExclusive {
1333 #[primary_span]
1334 #[suggestion(
1335 "remove `let`",
1336 code = "const",
1337 applicability = "maybe-incorrect",
1338 style = "verbose"
1339 )]
1340 pub span: Span,
1341}
1342
1343#[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)]
1344#[diag("a `{$operator}` expression cannot be directly assigned in `let...else`")]
1345pub(crate) struct InvalidExpressionInLetElse {
1346 #[primary_span]
1347 pub span: Span,
1348 pub operator: &'static str,
1349 #[subdiagnostic]
1350 pub sugg: WrapInParentheses,
1351}
1352
1353#[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)]
1354#[diag("right curly brace `{\"}\"}` before `else` in a `let...else` statement not allowed")]
1355pub(crate) struct InvalidCurlyInLetElse {
1356 #[primary_span]
1357 pub span: Span,
1358 #[subdiagnostic]
1359 pub sugg: WrapInParentheses,
1360}
1361
1362#[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_85 =
[::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_85, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1363#[diag("can't reassign to an uninitialized variable")]
1364#[help("if you meant to overwrite, remove the `let` binding")]
1365pub(crate) struct CompoundAssignmentExpressionInLet {
1366 #[primary_span]
1367 pub span: Span,
1368 #[suggestion(
1369 "initialize the variable",
1370 style = "verbose",
1371 code = "",
1372 applicability = "maybe-incorrect"
1373 )]
1374 pub suggestion: Span,
1375}
1376
1377#[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)]
1378#[diag("suffixed literals are not allowed in attributes")]
1379#[help(
1380 "instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)"
1381)]
1382pub(crate) struct SuffixedLiteralInAttribute {
1383 #[primary_span]
1384 pub span: Span,
1385}
1386
1387#[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)]
1388#[diag("expected unsuffixed literal, found {$descr}")]
1389pub(crate) struct InvalidMetaItem {
1390 #[primary_span]
1391 pub span: Span,
1392 pub descr: String,
1393 #[subdiagnostic]
1394 pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
1395}
1396
1397#[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_86 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_87 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_86));
suggestions.push((__binding_1, __code_87));
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)]
1398#[multipart_suggestion(
1399 "surround the identifier with quotation marks to make it into a string literal",
1400 applicability = "machine-applicable"
1401)]
1402pub(crate) struct InvalidMetaItemQuoteIdentSugg {
1403 #[suggestion_part(code = "\"")]
1404 pub before: Span,
1405 #[suggestion_part(code = "\"")]
1406 pub after: Span,
1407}
1408
1409#[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_88 =
[::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_88, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1410#[suggestion(
1411 "escape `{$ident_name}` to use it as an identifier",
1412 style = "verbose",
1413 applicability = "maybe-incorrect",
1414 code = "r#"
1415)]
1416pub(crate) struct SuggEscapeIdentifier {
1417 #[primary_span]
1418 pub span: Span,
1419 pub ident_name: String,
1420}
1421
1422#[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_89 =
[::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_89, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1423#[suggestion(
1424 "remove this comma",
1425 applicability = "machine-applicable",
1426 code = "",
1427 style = "verbose"
1428)]
1429pub(crate) struct SuggRemoveComma {
1430 #[primary_span]
1431 pub span: Span,
1432}
1433
1434#[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_90 =
[::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_90, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1435#[suggestion(
1436 "you might have meant to introduce a new binding",
1437 style = "verbose",
1438 applicability = "maybe-incorrect",
1439 code = "let "
1440)]
1441pub(crate) struct SuggAddMissingLetStmt {
1442 #[primary_span]
1443 pub span: Span,
1444}
1445
1446#[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)]
1447pub(crate) enum ExpectedIdentifierFound {
1448 #[label("expected identifier, found reserved identifier")]
1449 ReservedIdentifier(#[primary_span] Span),
1450 #[label("expected identifier, found keyword")]
1451 Keyword(#[primary_span] Span),
1452 #[label("expected identifier, found reserved keyword")]
1453 ReservedKeyword(#[primary_span] Span),
1454 #[label("expected identifier, found doc comment")]
1455 DocComment(#[primary_span] Span),
1456 #[label("expected identifier, found metavariable")]
1457 MetaVar(#[primary_span] Span),
1458 #[label("expected identifier")]
1459 Other(#[primary_span] Span),
1460}
1461
1462impl ExpectedIdentifierFound {
1463 pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
1464 (match token_descr {
1465 Some(TokenDescription::ReservedIdentifier) => {
1466 ExpectedIdentifierFound::ReservedIdentifier
1467 }
1468 Some(TokenDescription::Keyword) => ExpectedIdentifierFound::Keyword,
1469 Some(TokenDescription::ReservedKeyword) => ExpectedIdentifierFound::ReservedKeyword,
1470 Some(TokenDescription::DocComment) => ExpectedIdentifierFound::DocComment,
1471 Some(TokenDescription::MetaVar(_)) => ExpectedIdentifierFound::MetaVar,
1472 None => ExpectedIdentifierFound::Other,
1473 })(span)
1474 }
1475}
1476
1477pub(crate) struct ExpectedIdentifier {
1478 pub span: Span,
1479 pub token: Token,
1480 pub suggest_raw: Option<SuggEscapeIdentifier>,
1481 pub suggest_remove_comma: Option<SuggRemoveComma>,
1482 pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
1483}
1484
1485impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
1486 #[track_caller]
1487 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1488 let token_descr = TokenDescription::from_token(&self.token);
1489
1490 let mut add_token = true;
1491 let mut diag = Diag::new(
1492 dcx,
1493 level,
1494 match token_descr {
1495 Some(TokenDescription::ReservedIdentifier) => {
1496 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved identifier `{$token}`"))msg!("expected identifier, found reserved identifier `{$token}`")
1497 }
1498 Some(TokenDescription::Keyword) => {
1499 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword `{$token}`"))msg!("expected identifier, found keyword `{$token}`")
1500 }
1501 Some(TokenDescription::ReservedKeyword) => {
1502 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved keyword `{$token}`"))msg!("expected identifier, found reserved keyword `{$token}`")
1503 }
1504 Some(TokenDescription::DocComment) => {
1505 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found doc comment `{$token}`"))msg!("expected identifier, found doc comment `{$token}`")
1506 }
1507 Some(TokenDescription::MetaVar(_)) => {
1508 add_token = false;
1509 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found metavariable"))msg!("expected identifier, found metavariable")
1510 }
1511 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found `{$token}`"))msg!("expected identifier, found `{$token}`"),
1512 },
1513 );
1514 diag.span(self.span);
1515 if add_token {
1516 diag.arg("token", self.token);
1517 }
1518
1519 if let Some(sugg) = self.suggest_raw {
1520 sugg.add_to_diag(&mut diag);
1521 }
1522
1523 ExpectedIdentifierFound::new(token_descr, self.span).add_to_diag(&mut diag);
1524
1525 if let Some(sugg) = self.suggest_remove_comma {
1526 sugg.add_to_diag(&mut diag);
1527 }
1528
1529 if let Some(help) = self.help_cannot_start_number {
1530 help.add_to_diag(&mut diag);
1531 }
1532
1533 diag
1534 }
1535}
1536
1537#[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)]
1538#[help("identifiers cannot start with a number")]
1539pub(crate) struct HelpIdentifierStartsWithNumber {
1540 #[primary_span]
1541 pub num_span: Span,
1542}
1543
1544pub(crate) struct ExpectedSemi {
1545 pub span: Span,
1546 pub token: Token,
1547 pub unexpected_token_label: Option<Span>,
1548 pub sugg: ExpectedSemiSugg,
1549}
1550
1551impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
1552 #[track_caller]
1553 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1554 let token_descr = TokenDescription::from_token(&self.token);
1555
1556 let mut add_token = true;
1557 let mut diag = Diag::new(
1558 dcx,
1559 level,
1560 match token_descr {
1561 Some(TokenDescription::ReservedIdentifier) => {
1562 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved identifier `{$token}`"))msg!("expected `;`, found reserved identifier `{$token}`")
1563 }
1564 Some(TokenDescription::Keyword) => {
1565 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found keyword `{$token}`"))msg!("expected `;`, found keyword `{$token}`")
1566 }
1567 Some(TokenDescription::ReservedKeyword) => {
1568 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved keyword `{$token}`"))msg!("expected `;`, found reserved keyword `{$token}`")
1569 }
1570 Some(TokenDescription::DocComment) => {
1571 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found doc comment `{$token}`"))msg!("expected `;`, found doc comment `{$token}`")
1572 }
1573 Some(TokenDescription::MetaVar(_)) => {
1574 add_token = false;
1575 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found metavariable"))msg!("expected `;`, found metavariable")
1576 }
1577 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found `{$token}`"))msg!("expected `;`, found `{$token}`"),
1578 },
1579 );
1580 diag.span(self.span);
1581 if add_token {
1582 diag.arg("token", self.token);
1583 }
1584
1585 if let Some(unexpected_token_label) = self.unexpected_token_label {
1586 diag.span_label(unexpected_token_label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token"))msg!("unexpected token"));
1587 }
1588
1589 self.sugg.add_to_diag(&mut diag);
1590
1591 diag
1592 }
1593}
1594
1595#[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_91 =
[::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_91, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
}
ExpectedSemiSugg::AddSemi(__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("add `;` here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_92, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
}
}
}
}
};Subdiagnostic)]
1596pub(crate) enum ExpectedSemiSugg {
1597 #[suggestion(
1598 "change this to `;`",
1599 code = ";",
1600 applicability = "machine-applicable",
1601 style = "short"
1602 )]
1603 ChangeToSemi(#[primary_span] Span),
1604 #[suggestion("add `;` here", code = ";", applicability = "machine-applicable", style = "short")]
1605 AddSemi(#[primary_span] Span),
1606}
1607
1608#[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)]
1609#[diag("struct literal body without path")]
1610pub(crate) struct StructLiteralBodyWithoutPath {
1611 #[primary_span]
1612 pub span: Span,
1613 #[subdiagnostic]
1614 pub sugg: StructLiteralBodyWithoutPathSugg,
1615}
1616
1617#[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_93 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ SomeStruct "))
});
let __code_94 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_93));
suggestions.push((__binding_1, __code_94));
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)]
1618#[multipart_suggestion(
1619 "you might have forgotten to add the struct literal inside the block",
1620 applicability = "has-placeholders"
1621)]
1622pub(crate) struct StructLiteralBodyWithoutPathSugg {
1623 #[suggestion_part(code = "{{ SomeStruct ")]
1624 pub before: Span,
1625 #[suggestion_part(code = " }}")]
1626 pub after: Span,
1627}
1628
1629#[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_95 =
[::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_95, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1630#[diag(
1631 "{$num_extra_brackets ->
1632 [one] unmatched angle bracket
1633 *[other] unmatched angle brackets
1634 }"
1635)]
1636pub(crate) struct UnmatchedAngleBrackets {
1637 #[primary_span]
1638 #[suggestion(
1639 "{$num_extra_brackets ->
1640 [one] remove extra angle bracket
1641 *[other] remove extra angle brackets
1642 }",
1643 code = "",
1644 applicability = "machine-applicable",
1645 style = "verbose"
1646 )]
1647 pub span: Span,
1648 pub num_extra_brackets: usize,
1649}
1650
1651#[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)]
1652#[diag("generic parameters without surrounding angle brackets")]
1653pub(crate) struct GenericParamsWithoutAngleBrackets {
1654 #[primary_span]
1655 pub span: Span,
1656 #[subdiagnostic]
1657 pub sugg: GenericParamsWithoutAngleBracketsSugg,
1658}
1659
1660#[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_96 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_97 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_96));
suggestions.push((__binding_1, __code_97));
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)]
1661#[multipart_suggestion(
1662 "surround the type parameters with angle brackets",
1663 applicability = "machine-applicable"
1664)]
1665pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
1666 #[suggestion_part(code = "<")]
1667 pub left: Span,
1668 #[suggestion_part(code = ">")]
1669 pub right: Span,
1670}
1671
1672#[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_98 =
[::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_98, 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)]
1673#[diag("comparison operators cannot be chained")]
1674pub(crate) struct ComparisonOperatorsCannotBeChained {
1675 #[primary_span]
1676 pub span: Vec<Span>,
1677 #[suggestion(
1678 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
1679 style = "verbose",
1680 code = "::",
1681 applicability = "maybe-incorrect"
1682 )]
1683 pub suggest_turbofish: Option<Span>,
1684 #[help("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")]
1685 #[help("or use `(...)` if you meant to specify fn arguments")]
1686 pub help_turbofish: bool,
1687 #[subdiagnostic]
1688 pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
1689}
1690
1691#[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_99 =
[::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("middle_term".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("split the comparison into two")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_99, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
ComparisonOperatorsCannotBeChainedSugg::Parenthesize {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_100 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_101 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_100));
suggestions.push((__binding_1, __code_101));
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)]
1692pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
1693 #[suggestion(
1694 "split the comparison into two",
1695 style = "verbose",
1696 code = " && {middle_term}",
1697 applicability = "maybe-incorrect"
1698 )]
1699 SplitComparison {
1700 #[primary_span]
1701 span: Span,
1702 middle_term: String,
1703 },
1704 #[multipart_suggestion("parenthesize the comparison", applicability = "maybe-incorrect")]
1705 Parenthesize {
1706 #[suggestion_part(code = "(")]
1707 left: Span,
1708 #[suggestion_part(code = ")")]
1709 right: Span,
1710 },
1711}
1712
1713#[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)]
1714#[diag("invalid `?` in type")]
1715pub(crate) struct QuestionMarkInType {
1716 #[primary_span]
1717 #[label("`?` is only allowed on expressions, not types")]
1718 pub span: Span,
1719 #[subdiagnostic]
1720 pub sugg: QuestionMarkInTypeSugg,
1721}
1722
1723#[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_102 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Option<"))
});
let __code_103 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_102));
suggestions.push((__binding_1, __code_103));
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)]
1724#[multipart_suggestion(
1725 "if you meant to express that the type might not contain a value, use the `Option` wrapper type",
1726 applicability = "machine-applicable"
1727)]
1728pub(crate) struct QuestionMarkInTypeSugg {
1729 #[suggestion_part(code = "Option<")]
1730 pub left: Span,
1731 #[suggestion_part(code = ">")]
1732 pub right: Span,
1733}
1734
1735#[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)]
1736#[diag("unexpected parentheses surrounding `for` loop head")]
1737pub(crate) struct ParenthesesInForHead {
1738 #[primary_span]
1739 pub span: Vec<Span>,
1740 #[subdiagnostic]
1741 pub sugg: ParenthesesInForHeadSugg,
1742}
1743
1744#[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_104 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_105 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
suggestions.push((__binding_0, __code_104));
suggestions.push((__binding_1, __code_105));
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)]
1745#[multipart_suggestion("remove parentheses in `for` loop", applicability = "machine-applicable")]
1746pub(crate) struct ParenthesesInForHeadSugg {
1747 #[suggestion_part(code = " ")]
1748 pub left: Span,
1749 #[suggestion_part(code = " ")]
1750 pub right: Span,
1751}
1752
1753#[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)]
1754#[diag("unexpected parentheses surrounding `match` arm pattern")]
1755pub(crate) struct ParenthesesInMatchPat {
1756 #[primary_span]
1757 pub span: Vec<Span>,
1758 #[subdiagnostic]
1759 pub sugg: ParenthesesInMatchPatSugg,
1760}
1761
1762#[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_106 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_107 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_106));
suggestions.push((__binding_1, __code_107));
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)]
1763#[multipart_suggestion(
1764 "remove parentheses surrounding the pattern",
1765 applicability = "machine-applicable"
1766)]
1767pub(crate) struct ParenthesesInMatchPatSugg {
1768 #[suggestion_part(code = "")]
1769 pub left: Span,
1770 #[suggestion_part(code = "")]
1771 pub right: Span,
1772}
1773
1774#[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)]
1775#[diag("documentation comments cannot be applied to a function parameter's type")]
1776pub(crate) struct DocCommentOnParamType {
1777 #[primary_span]
1778 #[label("doc comments are not allowed here")]
1779 pub span: Span,
1780}
1781
1782#[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)]
1783#[diag("attributes cannot be applied to a function parameter's type")]
1784pub(crate) struct AttributeOnParamType {
1785 #[primary_span]
1786 #[label("attributes are not allowed here")]
1787 pub span: Span,
1788}
1789
1790#[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_108 =
[::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_108, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
1791#[diag("attributes cannot be applied to types")]
1792pub(crate) struct AttributeOnType {
1793 #[primary_span]
1794 #[label("attributes are not allowed here")]
1795 pub span: Span,
1796 #[suggestion(
1797 "remove attribute from here",
1798 code = "",
1799 applicability = "machine-applicable",
1800 style = "tool-only"
1801 )]
1802 pub fix_span: Span,
1803}
1804
1805#[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_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)]
1806#[diag("attributes cannot be applied to generic arguments")]
1807pub(crate) struct AttributeOnGenericArg {
1808 #[primary_span]
1809 #[label("attributes are not allowed here")]
1810 pub span: Span,
1811 #[suggestion(
1812 "remove attribute from here",
1813 code = "",
1814 applicability = "machine-applicable",
1815 style = "tool-only"
1816 )]
1817 pub fix_span: Span,
1818}
1819
1820#[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)]
1821#[diag("attributes cannot be applied here")]
1822pub(crate) struct AttributeOnEmptyType {
1823 #[primary_span]
1824 #[label("attributes are not allowed here")]
1825 pub span: Span,
1826}
1827
1828#[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_110 =
[::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_110, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1829#[diag("patterns aren't allowed in methods without bodies", code = E0642)]
1830pub(crate) struct PatternMethodParamWithoutBody {
1831 #[primary_span]
1832 #[suggestion(
1833 "give this argument a name or use an underscore to ignore it",
1834 code = "_",
1835 applicability = "machine-applicable",
1836 style = "verbose"
1837 )]
1838 pub span: Span,
1839}
1840
1841#[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)]
1842#[diag("unexpected `self` parameter in function")]
1843pub(crate) struct SelfParamNotFirst {
1844 #[primary_span]
1845 #[label("must be the first parameter of an associated function")]
1846 pub span: Span,
1847}
1848
1849#[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)]
1850#[diag("expressions must be enclosed in braces to be used as const generic arguments")]
1851pub(crate) struct ConstGenericWithoutBraces {
1852 #[primary_span]
1853 pub span: Span,
1854 #[subdiagnostic]
1855 pub sugg: ConstGenericWithoutBracesSugg,
1856}
1857
1858#[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_111 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_112 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_111));
suggestions.push((__binding_1, __code_112));
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)]
1859#[multipart_suggestion(
1860 "enclose the `const` expression in braces",
1861 applicability = "machine-applicable"
1862)]
1863pub(crate) struct ConstGenericWithoutBracesSugg {
1864 #[suggestion_part(code = "{{ ")]
1865 pub left: Span,
1866 #[suggestion_part(code = " }}")]
1867 pub right: Span,
1868}
1869
1870#[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)]
1871#[diag("unexpected `const` parameter declaration")]
1872pub(crate) struct UnexpectedConstParamDeclaration {
1873 #[primary_span]
1874 #[label("expected a `const` expression, not a parameter declaration")]
1875 pub span: Span,
1876 #[subdiagnostic]
1877 pub sugg: Option<UnexpectedConstParamDeclarationSugg>,
1878}
1879
1880#[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_113 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", __binding_2))
});
let __code_114 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_113));
suggestions.push((__binding_1, __code_114));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("ident".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("`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_115 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_116 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_115));
suggestions.push((__binding_1, __code_116));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("ident".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("`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)]
1881pub(crate) enum UnexpectedConstParamDeclarationSugg {
1882 #[multipart_suggestion(
1883 "`const` parameters must be declared for the `impl`",
1884 applicability = "machine-applicable"
1885 )]
1886 AddParam {
1887 #[suggestion_part(code = "<{snippet}>")]
1888 impl_generics: Span,
1889 #[suggestion_part(code = "{ident}")]
1890 incorrect_decl: Span,
1891 snippet: String,
1892 ident: String,
1893 },
1894 #[multipart_suggestion(
1895 "`const` parameters must be declared for the `impl`",
1896 applicability = "machine-applicable"
1897 )]
1898 AppendParam {
1899 #[suggestion_part(code = ", {snippet}")]
1900 impl_generics_end: Span,
1901 #[suggestion_part(code = "{ident}")]
1902 incorrect_decl: Span,
1903 snippet: String,
1904 ident: String,
1905 },
1906}
1907
1908#[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_117 =
[::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_117, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1909#[diag("expected lifetime, type, or constant, found keyword `const`")]
1910pub(crate) struct UnexpectedConstInGenericParam {
1911 #[primary_span]
1912 pub span: Span,
1913 #[suggestion(
1914 "the `const` keyword is only needed in the definition of the type",
1915 style = "verbose",
1916 code = "",
1917 applicability = "maybe-incorrect"
1918 )]
1919 pub to_remove: Option<Span>,
1920}
1921
1922#[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_118 =
[::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_118, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1923#[diag("the order of `move` and `async` is incorrect")]
1924pub(crate) struct AsyncMoveOrderIncorrect {
1925 #[primary_span]
1926 #[suggestion(
1927 "try switching the order",
1928 style = "verbose",
1929 code = "async move",
1930 applicability = "maybe-incorrect"
1931 )]
1932 pub span: Span,
1933}
1934
1935#[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_119 =
[::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_119, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1936#[diag("the order of `use` and `async` is incorrect")]
1937pub(crate) struct AsyncUseOrderIncorrect {
1938 #[primary_span]
1939 #[suggestion(
1940 "try switching the order",
1941 style = "verbose",
1942 code = "async use",
1943 applicability = "maybe-incorrect"
1944 )]
1945 pub span: Span,
1946}
1947
1948#[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_120 =
[::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_120, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1949#[diag("expected `:` followed by trait or lifetime")]
1950pub(crate) struct DoubleColonInBound {
1951 #[primary_span]
1952 pub span: Span,
1953 #[suggestion(
1954 "use single colon",
1955 code = ": ",
1956 applicability = "machine-applicable",
1957 style = "verbose"
1958 )]
1959 pub between: Span,
1960}
1961
1962#[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)]
1963#[diag("function pointer types may not have generic parameters")]
1964pub(crate) struct FnPtrWithGenerics {
1965 #[primary_span]
1966 pub span: Span,
1967 #[subdiagnostic]
1968 pub sugg: Option<FnPtrWithGenericsSugg>,
1969}
1970
1971#[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_121 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {0}", __binding_1))
});
let __code_122 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_121));
suggestions.push((__binding_2, __code_122));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".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("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)]
1972#[multipart_suggestion(
1973 "place the return type after the function parameters",
1974 style = "verbose",
1975 applicability = "maybe-incorrect"
1976)]
1977pub(crate) struct MisplacedReturnType {
1978 #[suggestion_part(code = " {snippet}")]
1979 pub fn_params_end: Span,
1980 pub snippet: String,
1981 #[suggestion_part(code = "")]
1982 pub ret_ty_span: Span,
1983}
1984
1985#[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_123 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_124 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_123));
suggestions.push((__binding_2, __code_124));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
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)]
1986#[multipart_suggestion(
1987 "consider moving the lifetime {$arity ->
1988 [one] parameter
1989 *[other] parameters
1990 } to {$for_param_list_exists ->
1991 [true] the
1992 *[false] a
1993 } `for` parameter list",
1994 applicability = "maybe-incorrect"
1995)]
1996pub(crate) struct FnPtrWithGenericsSugg {
1997 #[suggestion_part(code = "{snippet}")]
1998 pub left: Span,
1999 pub snippet: String,
2000 #[suggestion_part(code = "")]
2001 pub right: Span,
2002 pub arity: usize,
2003 pub for_param_list_exists: bool,
2004}
2005
2006pub(crate) struct FnTraitMissingParen {
2007 pub span: Span,
2008}
2009
2010impl Subdiagnostic for FnTraitMissingParen {
2011 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
2012 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"));
2013 diag.span_suggestion_short(
2014 self.span.shrink_to_hi(),
2015 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses"))msg!("try adding parentheses"),
2016 "()",
2017 Applicability::MachineApplicable,
2018 );
2019 }
2020}
2021
2022#[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_125 =
[::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_125, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2023#[diag("unexpected `if` in the condition expression")]
2024pub(crate) struct UnexpectedIfWithIf(
2025 #[primary_span]
2026 #[suggestion(
2027 "remove the `if`",
2028 applicability = "machine-applicable",
2029 code = " ",
2030 style = "verbose"
2031 )]
2032 pub Span,
2033);
2034
2035#[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_126 =
[::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_126, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2036#[diag("you might have meant to write `impl` instead of `fn`")]
2037pub(crate) struct FnTypoWithImpl {
2038 #[primary_span]
2039 #[suggestion(
2040 "replace `fn` with `impl` here",
2041 applicability = "maybe-incorrect",
2042 code = "impl",
2043 style = "verbose"
2044 )]
2045 pub fn_span: Span,
2046}
2047
2048#[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_127 =
[::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_127, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2049#[diag("expected identifier, found keyword `fn`")]
2050pub(crate) struct ExpectedFnPathFoundFnKeyword {
2051 #[primary_span]
2052 #[suggestion(
2053 "use `Fn` to refer to the trait",
2054 applicability = "machine-applicable",
2055 code = "Fn",
2056 style = "verbose"
2057 )]
2058 pub fn_token_span: Span,
2059}
2060
2061#[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_128 =
[::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_128, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2062#[diag("`Trait(...)` syntax does not support named parameters")]
2063pub(crate) struct FnPathFoundNamedParams {
2064 #[primary_span]
2065 #[suggestion("remove the parameter name", applicability = "machine-applicable", code = "")]
2066 pub named_param_span: Span,
2067}
2068
2069#[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_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 `...`")),
__code_129, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2070#[diag("`Trait(...)` syntax does not support c_variadic parameters")]
2071pub(crate) struct PathFoundCVariadicParams {
2072 #[primary_span]
2073 #[suggestion("remove the `...`", applicability = "machine-applicable", code = "")]
2074 pub span: Span,
2075}
2076
2077#[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_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 attributes")),
__code_130, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2078#[diag("`Trait(...)` syntax does not support attributes in parameters")]
2079pub(crate) struct PathFoundAttributeInParams {
2080 #[primary_span]
2081 #[suggestion("remove the attributes", applicability = "machine-applicable", code = "")]
2082 pub span: Span,
2083}
2084
2085#[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_131 =
[::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_131, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2086#[diag("path separator must be a double colon")]
2087pub(crate) struct PathSingleColon {
2088 #[primary_span]
2089 pub span: Span,
2090
2091 #[suggestion(
2092 "use a double colon instead",
2093 applicability = "machine-applicable",
2094 code = ":",
2095 style = "verbose"
2096 )]
2097 pub suggestion: Span,
2098}
2099
2100#[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_132 =
[::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_132, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2101#[diag("path separator must be a double colon")]
2102pub(crate) struct PathTripleColon {
2103 #[primary_span]
2104 #[suggestion(
2105 "use a double colon instead",
2106 applicability = "maybe-incorrect",
2107 code = "",
2108 style = "verbose"
2109 )]
2110 pub span: Span,
2111}
2112
2113#[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_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 semicolon instead")),
__code_133, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2114#[diag("statements are terminated with a semicolon")]
2115pub(crate) struct ColonAsSemi {
2116 #[primary_span]
2117 #[suggestion(
2118 "use a semicolon instead",
2119 applicability = "machine-applicable",
2120 code = ";",
2121 style = "verbose"
2122 )]
2123 pub span: Span,
2124}
2125
2126#[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)]
2127#[diag("where clauses are not allowed before tuple struct bodies")]
2128pub(crate) struct WhereClauseBeforeTupleStructBody {
2129 #[primary_span]
2130 #[label("unexpected where clause")]
2131 pub span: Span,
2132 #[label("while parsing this tuple struct")]
2133 pub name: Span,
2134 #[label("the struct body")]
2135 pub body: Span,
2136 #[subdiagnostic]
2137 pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
2138}
2139
2140#[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_134 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_135 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_134));
suggestions.push((__binding_2, __code_135));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".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("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)]
2141#[multipart_suggestion(
2142 "move the body before the where clause",
2143 applicability = "machine-applicable"
2144)]
2145pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
2146 #[suggestion_part(code = "{snippet}")]
2147 pub left: Span,
2148 pub snippet: String,
2149 #[suggestion_part(code = "")]
2150 pub right: Span,
2151}
2152
2153#[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)]
2154#[diag("`async fn` is not permitted in Rust 2015", code = E0670)]
2155pub(crate) struct AsyncFnIn2015 {
2156 #[primary_span]
2157 #[label("to use `async fn`, switch to Rust 2018 or later")]
2158 pub span: Span,
2159 #[subdiagnostic]
2160 pub help: HelpUseLatestEdition,
2161}
2162
2163#[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)]
2164#[label("`async` blocks are only allowed in Rust 2018 or later")]
2165pub(crate) struct AsyncBlockIn2015 {
2166 #[primary_span]
2167 pub span: Span,
2168}
2169
2170#[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)]
2171#[diag("`async move` blocks are only allowed in Rust 2018 or later")]
2172pub(crate) struct AsyncMoveBlockIn2015 {
2173 #[primary_span]
2174 pub span: Span,
2175}
2176
2177#[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)]
2178#[diag("`async use` blocks are only allowed in Rust 2018 or later")]
2179pub(crate) struct AsyncUseBlockIn2015 {
2180 #[primary_span]
2181 pub span: Span,
2182}
2183
2184#[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)]
2185#[diag("`async` trait bounds are only allowed in Rust 2018 or later")]
2186pub(crate) struct AsyncBoundModifierIn2015 {
2187 #[primary_span]
2188 pub span: Span,
2189 #[subdiagnostic]
2190 pub help: HelpUseLatestEdition,
2191}
2192
2193#[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)]
2194#[diag("let chains are only allowed in Rust 2024 or later")]
2195pub(crate) struct LetChainPre2024 {
2196 #[primary_span]
2197 pub span: Span,
2198}
2199
2200#[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)]
2201#[diag("cannot pass `self` by raw pointer")]
2202pub(crate) struct SelfArgumentPointer {
2203 #[primary_span]
2204 #[label("cannot pass `self` by raw pointer")]
2205 pub span: Span,
2206}
2207
2208#[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)]
2209#[diag("unexpected token: {$actual}")]
2210pub(crate) struct UnexpectedTokenAfterDot {
2211 #[primary_span]
2212 pub span: Span,
2213 pub actual: String,
2214}
2215
2216#[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)]
2217#[diag("visibility `{$vis}` is not followed by an item")]
2218#[help("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")]
2219pub(crate) struct VisibilityNotFollowedByItem {
2220 #[primary_span]
2221 #[label("the visibility")]
2222 pub span: Span,
2223 pub vis: Visibility,
2224}
2225
2226#[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)]
2227#[diag("`default` is not followed by an item")]
2228#[note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")]
2229pub(crate) struct DefaultNotFollowedByItem {
2230 #[primary_span]
2231 #[label("the `default` qualifier")]
2232 pub span: Span,
2233}
2234
2235#[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)]
2236#[diag("`final` is not followed by an item")]
2237#[note("only associated functions in traits may be prefixed by `final`")]
2238pub(crate) struct FinalNotFollowedByItem {
2239 #[primary_span]
2240 #[label("the `final` qualifier")]
2241 pub span: Span,
2242}
2243
2244#[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_136 =
[::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_136, 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_137 =
[::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_137, 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_138 =
[::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_138, 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_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 method")),
__code_139, 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)]
2245pub(crate) enum MissingKeywordForItemDefinition {
2246 #[diag("missing `enum` for enum definition")]
2247 Enum {
2248 #[primary_span]
2249 span: Span,
2250 #[suggestion(
2251 "add `enum` here to parse `{$ident}` as an enum",
2252 style = "verbose",
2253 applicability = "maybe-incorrect",
2254 code = "enum "
2255 )]
2256 insert_span: Span,
2257 ident: Ident,
2258 },
2259 #[diag("missing `enum` or `struct` for enum or struct definition")]
2260 EnumOrStruct {
2261 #[primary_span]
2262 span: Span,
2263 },
2264 #[diag("missing `struct` for struct definition")]
2265 Struct {
2266 #[primary_span]
2267 span: Span,
2268 #[suggestion(
2269 "add `struct` here to parse `{$ident}` as a struct",
2270 style = "verbose",
2271 applicability = "maybe-incorrect",
2272 code = "struct "
2273 )]
2274 insert_span: Span,
2275 ident: Ident,
2276 },
2277 #[diag("missing `fn` for function definition")]
2278 Function {
2279 #[primary_span]
2280 span: Span,
2281 #[suggestion(
2282 "add `fn` here to parse `{$ident}` as a function",
2283 style = "verbose",
2284 applicability = "maybe-incorrect",
2285 code = "fn "
2286 )]
2287 insert_span: Span,
2288 ident: Ident,
2289 },
2290 #[diag("missing `fn` for method definition")]
2291 Method {
2292 #[primary_span]
2293 span: Span,
2294 #[suggestion(
2295 "add `fn` here to parse `{$ident}` as a method",
2296 style = "verbose",
2297 applicability = "maybe-incorrect",
2298 code = "fn "
2299 )]
2300 insert_span: Span,
2301 ident: Ident,
2302 },
2303 #[diag("missing `fn` or `struct` for function or struct definition")]
2304 Ambiguous {
2305 #[primary_span]
2306 span: Span,
2307 #[subdiagnostic]
2308 subdiag: Option<AmbiguousMissingKwForItemSub>,
2309 },
2310}
2311
2312#[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_140 =
[::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("snippet".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 call a macro, try")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_140, 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)]
2313pub(crate) enum AmbiguousMissingKwForItemSub {
2314 #[suggestion(
2315 "if you meant to call a macro, try",
2316 applicability = "maybe-incorrect",
2317 code = "{snippet}!",
2318 style = "verbose"
2319 )]
2320 SuggestMacro {
2321 #[primary_span]
2322 span: Span,
2323 snippet: String,
2324 },
2325 #[help(
2326 "if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier"
2327 )]
2328 HelpMacro,
2329}
2330
2331#[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_141 =
[::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_141, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2332#[diag("missing parameters for function definition")]
2333pub(crate) struct MissingFnParams {
2334 #[primary_span]
2335 #[suggestion(
2336 "add a parameter list",
2337 code = "()",
2338 applicability = "machine-applicable",
2339 style = "verbose"
2340 )]
2341 pub span: Span,
2342}
2343
2344#[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_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("remove invalid path separator")),
__code_142, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2345#[diag("invalid path separator in function definition")]
2346pub(crate) struct InvalidPathSepInFnDefinition {
2347 #[primary_span]
2348 #[suggestion(
2349 "remove invalid path separator",
2350 code = "",
2351 applicability = "machine-applicable",
2352 style = "verbose"
2353 )]
2354 pub span: Span,
2355}
2356
2357#[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_143 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" Trait "))
})].into_iter();
let __code_144 =
[::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_143, 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_144, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2358#[diag("missing trait in a trait impl")]
2359pub(crate) struct MissingTraitInTraitImpl {
2360 #[primary_span]
2361 #[suggestion(
2362 "add a trait here",
2363 code = " Trait ",
2364 applicability = "has-placeholders",
2365 style = "verbose"
2366 )]
2367 pub span: Span,
2368 #[suggestion(
2369 "for an inherent impl, drop this `for`",
2370 code = "",
2371 applicability = "maybe-incorrect",
2372 style = "verbose"
2373 )]
2374 pub for_span: Span,
2375}
2376
2377#[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_145 =
[::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_145, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2378#[diag("missing `for` in a trait impl")]
2379pub(crate) struct MissingForInTraitImpl {
2380 #[primary_span]
2381 #[suggestion(
2382 "add `for` here",
2383 style = "verbose",
2384 code = " for ",
2385 applicability = "machine-applicable"
2386 )]
2387 pub span: Span,
2388}
2389
2390#[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)]
2391#[diag("expected a trait, found type")]
2392pub(crate) struct ExpectedTraitInTraitImplFoundType {
2393 #[primary_span]
2394 pub span: Span,
2395}
2396
2397#[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_146 =
[::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_146, 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)]
2398#[diag("unexpected `impl` keyword")]
2399pub(crate) struct ExtraImplKeywordInTraitImpl {
2400 #[primary_span]
2401 #[suggestion(
2402 "remove the extra `impl`",
2403 code = "",
2404 applicability = "maybe-incorrect",
2405 style = "short"
2406 )]
2407 pub extra_impl_kw: Span,
2408 #[note("this is parsed as an `impl Trait` type, but a trait is expected at this position")]
2409 pub impl_trait_span: Span,
2410}
2411
2412#[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)]
2413#[diag("bounds are not allowed on trait aliases")]
2414pub(crate) struct BoundsNotAllowedOnTraitAliases {
2415 #[primary_span]
2416 pub span: Span,
2417}
2418
2419#[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)]
2420#[diag("trait aliases cannot be `auto`")]
2421pub(crate) struct TraitAliasCannotBeAuto {
2422 #[primary_span]
2423 #[label("trait aliases cannot be `auto`")]
2424 pub span: Span,
2425}
2426
2427#[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)]
2428#[diag("trait aliases cannot be `unsafe`")]
2429pub(crate) struct TraitAliasCannotBeUnsafe {
2430 #[primary_span]
2431 #[label("trait aliases cannot be `unsafe`")]
2432 pub span: Span,
2433}
2434
2435#[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)]
2436#[diag("trait aliases cannot be `impl`-restricted")]
2437pub(crate) struct TraitAliasCannotBeImplRestricted {
2438 #[primary_span]
2439 #[label("trait aliases cannot be `impl`-restricted")]
2440 pub span: Span,
2441}
2442
2443#[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)]
2444#[diag("associated `static` items are not allowed")]
2445pub(crate) struct AssociatedStaticItemNotAllowed {
2446 #[primary_span]
2447 pub span: Span,
2448}
2449
2450#[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)]
2451#[diag("crate name using dashes are not valid in `extern crate` statements")]
2452pub(crate) struct ExternCrateNameWithDashes {
2453 #[primary_span]
2454 #[label("dash-separated idents are not valid")]
2455 pub span: Span,
2456 #[subdiagnostic]
2457 pub sugg: ExternCrateNameWithDashesSugg,
2458}
2459
2460#[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_147 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_147.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)]
2461#[multipart_suggestion(
2462 "if the original crate name uses dashes you need to use underscores in the code",
2463 applicability = "machine-applicable"
2464)]
2465pub(crate) struct ExternCrateNameWithDashesSugg {
2466 #[suggestion_part(code = "_")]
2467 pub dashes: Vec<Span>,
2468}
2469
2470#[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_148 =
[::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_148, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
2471#[diag("extern items cannot be `const`")]
2472#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
2473pub(crate) struct ExternItemCannotBeConst {
2474 #[primary_span]
2475 pub ident_span: Span,
2476 #[suggestion(
2477 "try using a static value",
2478 code = "static ",
2479 applicability = "machine-applicable",
2480 style = "verbose"
2481 )]
2482 pub const_span: Option<Span>,
2483}
2484
2485#[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_149 =
[::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_149, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2486#[diag("const globals cannot be mutable")]
2487pub(crate) struct ConstGlobalCannotBeMutable {
2488 #[primary_span]
2489 #[label("cannot be mutable")]
2490 pub ident_span: Span,
2491 #[suggestion(
2492 "you might want to declare a static instead",
2493 code = "static",
2494 style = "verbose",
2495 applicability = "maybe-incorrect"
2496 )]
2497 pub const_span: Span,
2498}
2499
2500#[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_150 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} <type>",
__binding_2))
})].into_iter();
;
diag.arg("kind", __binding_1);
diag.arg("colon", __binding_2);
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_150, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2501#[diag("missing type for `{$kind}` item")]
2502pub(crate) struct MissingConstType {
2503 #[primary_span]
2504 #[suggestion(
2505 "provide a type for the item",
2506 code = "{colon} <type>",
2507 style = "verbose",
2508 applicability = "has-placeholders"
2509 )]
2510 pub span: Span,
2511
2512 pub kind: &'static str,
2513 pub colon: &'static str,
2514}
2515
2516#[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_151 =
[::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_151, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2517#[diag("`enum` and `struct` are mutually exclusive")]
2518pub(crate) struct EnumStructMutuallyExclusive {
2519 #[primary_span]
2520 #[suggestion(
2521 "replace `enum struct` with",
2522 code = "enum",
2523 style = "verbose",
2524 applicability = "machine-applicable"
2525 )]
2526 pub span: Span,
2527}
2528
2529#[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)]
2530pub(crate) enum UnexpectedTokenAfterStructName {
2531 #[diag(
2532 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`"
2533 )]
2534 ReservedIdentifier {
2535 #[primary_span]
2536 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2537 span: Span,
2538 token: Token,
2539 },
2540 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")]
2541 Keyword {
2542 #[primary_span]
2543 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2544 span: Span,
2545 token: Token,
2546 },
2547 #[diag(
2548 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`"
2549 )]
2550 ReservedKeyword {
2551 #[primary_span]
2552 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2553 span: Span,
2554 token: Token,
2555 },
2556 #[diag(
2557 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`"
2558 )]
2559 DocComment {
2560 #[primary_span]
2561 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2562 span: Span,
2563 token: Token,
2564 },
2565 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")]
2566 MetaVar {
2567 #[primary_span]
2568 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2569 span: Span,
2570 },
2571 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")]
2572 Other {
2573 #[primary_span]
2574 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2575 span: Span,
2576 token: Token,
2577 },
2578}
2579
2580impl UnexpectedTokenAfterStructName {
2581 pub(crate) fn new(span: Span, token: Token) -> Self {
2582 match TokenDescription::from_token(&token) {
2583 Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
2584 Some(TokenDescription::Keyword) => Self::Keyword { span, token },
2585 Some(TokenDescription::ReservedKeyword) => Self::ReservedKeyword { span, token },
2586 Some(TokenDescription::DocComment) => Self::DocComment { span, token },
2587 Some(TokenDescription::MetaVar(_)) => Self::MetaVar { span },
2588 None => Self::Other { span, token },
2589 }
2590 }
2591}
2592
2593#[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)]
2594#[diag("unexpected keyword `Self` in generic parameters")]
2595#[note("you cannot use `Self` as a generic parameter because it is reserved for associated items")]
2596pub(crate) struct UnexpectedSelfInGenericParameters {
2597 #[primary_span]
2598 pub span: Span,
2599}
2600
2601#[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)]
2602#[diag("unexpected default lifetime parameter")]
2603pub(crate) struct UnexpectedDefaultValueForLifetimeInGenericParameters {
2604 #[primary_span]
2605 #[label("lifetime parameters cannot have default values")]
2606 pub span: Span,
2607}
2608
2609#[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_152 =
[::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_152, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2610#[diag("cannot define duplicate `where` clauses on an item")]
2611pub(crate) struct MultipleWhereClauses {
2612 #[primary_span]
2613 pub span: Span,
2614 #[label("previous `where` clause starts here")]
2615 pub previous: Span,
2616 #[suggestion(
2617 "consider joining the two `where` clauses into one",
2618 style = "verbose",
2619 code = ",",
2620 applicability = "maybe-incorrect"
2621 )]
2622 pub between: Span,
2623}
2624
2625#[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)]
2626pub(crate) enum UnexpectedNonterminal {
2627 #[diag("expected an item keyword")]
2628 Item(#[primary_span] Span),
2629 #[diag("expected a statement")]
2630 Statement(#[primary_span] Span),
2631 #[diag("expected ident, found `{$token}`")]
2632 Ident {
2633 #[primary_span]
2634 span: Span,
2635 token: Token,
2636 },
2637 #[diag("expected a lifetime, found `{$token}`")]
2638 Lifetime {
2639 #[primary_span]
2640 span: Span,
2641 token: Token,
2642 },
2643}
2644
2645#[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)]
2646pub(crate) enum TopLevelOrPatternNotAllowed {
2647 #[diag("`let` bindings require top-level or-patterns in parentheses")]
2648 LetBinding {
2649 #[primary_span]
2650 span: Span,
2651 #[subdiagnostic]
2652 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2653 },
2654 #[diag("function parameters require top-level or-patterns in parentheses")]
2655 FunctionParameter {
2656 #[primary_span]
2657 span: Span,
2658 #[subdiagnostic]
2659 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2660 },
2661}
2662
2663#[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)]
2664#[diag("`{$ident}` cannot be a raw identifier")]
2665pub(crate) struct CannotBeRawIdent {
2666 #[primary_span]
2667 pub span: Span,
2668 pub ident: Symbol,
2669}
2670
2671#[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)]
2672#[diag("`{$ident}` cannot be a raw lifetime")]
2673pub(crate) struct CannotBeRawLifetime {
2674 #[primary_span]
2675 pub span: Span,
2676 pub ident: Symbol,
2677}
2678
2679#[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)]
2680#[diag("lifetimes cannot use keyword names")]
2681pub(crate) struct KeywordLifetime {
2682 #[primary_span]
2683 pub span: Span,
2684}
2685
2686#[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)]
2687#[diag("labels cannot use keyword names")]
2688pub(crate) struct KeywordLabel {
2689 #[primary_span]
2690 pub span: Span,
2691}
2692
2693#[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)]
2694#[diag(
2695 "bare CR not allowed in {$block ->
2696 [true] block doc-comment
2697 *[false] doc-comment
2698 }"
2699)]
2700pub(crate) struct CrDocComment {
2701 #[primary_span]
2702 pub span: Span,
2703 pub block: bool,
2704}
2705
2706#[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)]
2707#[diag("no valid digits found for number", code = E0768)]
2708pub(crate) struct NoDigitsLiteral {
2709 #[primary_span]
2710 pub span: Span,
2711}
2712
2713#[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)]
2714#[diag("invalid digit for a base {$base} literal")]
2715pub(crate) struct InvalidDigitLiteral {
2716 #[primary_span]
2717 pub span: Span,
2718 pub base: u32,
2719}
2720
2721#[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)]
2722#[diag("expected at least one digit in exponent")]
2723pub(crate) struct EmptyExponentFloat {
2724 #[primary_span]
2725 pub span: Span,
2726}
2727
2728#[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)]
2729#[diag("{$base} float literal is not supported")]
2730pub(crate) struct FloatLiteralUnsupportedBase {
2731 #[primary_span]
2732 pub span: Span,
2733 pub base: &'static str,
2734}
2735
2736#[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)]
2737#[diag("prefix `{$prefix}` is unknown")]
2738#[note("prefixed identifiers and literals are reserved since Rust 2021")]
2739pub(crate) struct UnknownPrefix<'a> {
2740 #[primary_span]
2741 #[label("unknown prefix")]
2742 pub span: Span,
2743 pub prefix: &'a str,
2744 #[subdiagnostic]
2745 pub sugg: Option<UnknownPrefixSugg>,
2746}
2747
2748#[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)]
2749#[note("macros cannot expand to {$adt_ty} fields")]
2750pub(crate) struct MacroExpandsToAdtField<'a> {
2751 pub adt_ty: &'a str,
2752}
2753
2754#[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_153 =
[::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_153, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::UseCr(__binding_0) => {
let __code_154 =
[::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_154, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::Whitespace(__binding_0) => {
let __code_155 =
[::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_155, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::MeantStr {
start: __binding_0, end: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_156 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_157 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_156));
suggestions.push((__binding_1, __code_157));
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)]
2755pub(crate) enum UnknownPrefixSugg {
2756 #[suggestion(
2757 "use `br` for a raw byte string",
2758 code = "br",
2759 applicability = "maybe-incorrect",
2760 style = "verbose"
2761 )]
2762 UseBr(#[primary_span] Span),
2763 #[suggestion(
2764 "use `cr` for a raw C-string",
2765 code = "cr",
2766 applicability = "maybe-incorrect",
2767 style = "verbose"
2768 )]
2769 UseCr(#[primary_span] Span),
2770 #[suggestion(
2771 "consider inserting whitespace here",
2772 code = " ",
2773 applicability = "maybe-incorrect",
2774 style = "verbose"
2775 )]
2776 Whitespace(#[primary_span] Span),
2777 #[multipart_suggestion(
2778 "if you meant to write a string literal, use double quotes",
2779 applicability = "maybe-incorrect",
2780 style = "verbose"
2781 )]
2782 MeantStr {
2783 #[suggestion_part(code = "\"")]
2784 start: Span,
2785 #[suggestion_part(code = "\"")]
2786 end: Span,
2787 },
2788}
2789
2790#[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)]
2791#[diag("reserved multi-hash token is forbidden")]
2792#[note("sequences of two or more # are reserved for future use since Rust 2024")]
2793pub(crate) struct ReservedMultihash {
2794 #[primary_span]
2795 pub span: Span,
2796 #[subdiagnostic]
2797 pub sugg: Option<GuardedStringSugg>,
2798}
2799#[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)]
2800#[diag("invalid string literal")]
2801#[note("unprefixed guarded string literals are reserved for future use since Rust 2024")]
2802pub(crate) struct ReservedString {
2803 #[primary_span]
2804 pub span: Span,
2805 #[subdiagnostic]
2806 pub sugg: Option<GuardedStringSugg>,
2807}
2808#[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_158 =
[::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_158, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2809#[suggestion(
2810 "consider inserting whitespace here",
2811 code = " ",
2812 applicability = "maybe-incorrect",
2813 style = "verbose"
2814)]
2815pub(crate) struct GuardedStringSugg(#[primary_span] pub Span);
2816
2817#[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)]
2818#[diag(
2819 "too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}"
2820)]
2821pub(crate) struct TooManyHashes {
2822 #[primary_span]
2823 pub span: Span,
2824 pub num: u32,
2825}
2826
2827#[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)]
2828#[diag("unknown start of token: {$escaped}")]
2829pub(crate) struct UnknownTokenStart {
2830 #[primary_span]
2831 pub span: Span,
2832 pub escaped: String,
2833 #[subdiagnostic]
2834 pub sugg: Option<TokenSubstitution>,
2835 #[help(
2836 "source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
2837 )]
2838 pub null: bool,
2839 #[subdiagnostic]
2840 pub repeat: Option<UnknownTokenRepeat>,
2841 #[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
2842 pub invisible: bool,
2843}
2844
2845#[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_159 =
[::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("suggestion".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
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_159, 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_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("suggestion".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
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_160, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2846pub(crate) enum TokenSubstitution {
2847 #[suggestion(
2848 "Unicode characters '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '{$ascii_str}' ({$ascii_name}), but are not",
2849 code = "{suggestion}",
2850 applicability = "maybe-incorrect",
2851 style = "verbose"
2852 )]
2853 DirectedQuotes {
2854 #[primary_span]
2855 span: Span,
2856 suggestion: String,
2857 ascii_str: &'static str,
2858 ascii_name: &'static str,
2859 },
2860 #[suggestion(
2861 "Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not",
2862 code = "{suggestion}",
2863 applicability = "maybe-incorrect",
2864 style = "verbose"
2865 )]
2866 Other {
2867 #[primary_span]
2868 span: Span,
2869 suggestion: String,
2870 ch: String,
2871 u_name: &'static str,
2872 ascii_str: &'static str,
2873 ascii_name: &'static str,
2874 },
2875}
2876
2877#[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)]
2878#[note(
2879 "character appears {$repeats ->
2880 [one] once more
2881 *[other] {$repeats} more times
2882 }"
2883)]
2884pub(crate) struct UnknownTokenRepeat {
2885 pub repeats: usize,
2886}
2887
2888#[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_161 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
;
diag.arg("escaped_sugg", __binding_2);
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_161, 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_162 =
[::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_162, 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.arg("ch", __binding_1);
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_163 =
[::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_163, 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)]
2889pub(crate) enum UnescapeError {
2890 #[diag("invalid unicode character escape")]
2891 #[help(
2892 "unicode escape must {$surrogate ->
2893 [true] not be a surrogate
2894 *[false] be at most 10FFFF
2895 }"
2896 )]
2897 InvalidUnicodeEscape {
2898 #[primary_span]
2899 #[label("invalid escape")]
2900 span: Span,
2901 surrogate: bool,
2902 },
2903 #[diag(
2904 "{$byte ->
2905 [true] byte
2906 *[false] character
2907 } constant must be escaped: `{$escaped_msg}`"
2908 )]
2909 EscapeOnlyChar {
2910 #[primary_span]
2911 span: Span,
2912 #[suggestion(
2913 "escape the character",
2914 applicability = "machine-applicable",
2915 code = "{escaped_sugg}",
2916 style = "verbose"
2917 )]
2918 char_span: Span,
2919 escaped_sugg: String,
2920 escaped_msg: String,
2921 byte: bool,
2922 },
2923 #[diag(
2924 r#"{$double_quotes ->
2925 [true] bare CR not allowed in string, use `\r` instead
2926 *[false] character constant must be escaped: `\r`
2927 }"#
2928 )]
2929 BareCr {
2930 #[primary_span]
2931 #[suggestion(
2932 "escape the character",
2933 applicability = "machine-applicable",
2934 code = "\\r",
2935 style = "verbose"
2936 )]
2937 span: Span,
2938 double_quotes: bool,
2939 },
2940 #[diag("bare CR not allowed in raw string")]
2941 BareCrRawString(#[primary_span] Span),
2942 #[diag("numeric character escape is too short")]
2943 TooShortHexEscape(#[primary_span] Span),
2944 #[diag(
2945 "invalid character in {$is_hex ->
2946 [true] numeric character
2947 *[false] unicode
2948 } escape: `{$ch}`"
2949 )]
2950 InvalidCharInEscape {
2951 #[primary_span]
2952 #[label(
2953 "invalid character in {$is_hex ->
2954 [true] numeric character
2955 *[false] unicode
2956 } escape"
2957 )]
2958 span: Span,
2959 is_hex: bool,
2960 ch: String,
2961 },
2962 #[diag("invalid start of unicode escape: `_`")]
2963 LeadingUnderscoreUnicodeEscape {
2964 #[primary_span]
2965 #[label("invalid start of unicode escape")]
2966 span: Span,
2967 ch: String,
2968 },
2969 #[diag("overlong unicode escape")]
2970 OverlongUnicodeEscape(
2971 #[primary_span]
2972 #[label("must have at most 6 hex digits")]
2973 Span,
2974 ),
2975 #[diag("unterminated unicode escape")]
2976 UnclosedUnicodeEscape(
2977 #[primary_span]
2978 #[label(r#"missing a closing `{"}"}`"#)]
2979 Span,
2980 #[suggestion(
2981 "terminate the unicode escape",
2982 code = "}}",
2983 applicability = "maybe-incorrect",
2984 style = "verbose"
2985 )]
2986 Span,
2987 ),
2988 #[diag("incorrect unicode escape sequence")]
2989 NoBraceInUnicodeEscape {
2990 #[primary_span]
2991 span: Span,
2992 #[label("incorrect unicode escape sequence")]
2993 label: Option<Span>,
2994 #[subdiagnostic]
2995 sub: NoBraceUnicodeSub,
2996 },
2997 #[diag("unicode escape in byte string")]
2998 #[help("unicode escape sequences cannot be used as a byte or in a byte string")]
2999 UnicodeEscapeInByte(
3000 #[primary_span]
3001 #[label("unicode escape in byte string")]
3002 Span,
3003 ),
3004 #[diag("empty unicode escape")]
3005 EmptyUnicodeEscape(
3006 #[primary_span]
3007 #[label("this escape must have at least 1 hex digit")]
3008 Span,
3009 ),
3010 #[diag("empty character literal")]
3011 ZeroChars(
3012 #[primary_span]
3013 #[label("empty character literal")]
3014 Span,
3015 ),
3016 #[diag("invalid trailing slash in literal")]
3017 LoneSlash(
3018 #[primary_span]
3019 #[label("invalid trailing slash in literal")]
3020 Span,
3021 ),
3022 #[diag("whitespace symbol '{$ch}' is not skipped")]
3023 UnskippedWhitespace {
3024 #[primary_span]
3025 span: Span,
3026 #[label("whitespace symbol '{$ch}' is not skipped")]
3027 char_span: Span,
3028 ch: String,
3029 },
3030 #[diag("multiple lines skipped by escaped newline")]
3031 MultipleSkippedLinesWarning(
3032 #[primary_span]
3033 #[label("skipping everything up to and including this point")]
3034 Span,
3035 ),
3036 #[diag("character literal may only contain one codepoint")]
3037 MoreThanOneChar {
3038 #[primary_span]
3039 span: Span,
3040 #[subdiagnostic]
3041 note: Option<MoreThanOneCharNote>,
3042 #[subdiagnostic]
3043 suggestion: MoreThanOneCharSugg,
3044 },
3045 #[diag("null characters in C string literals are not supported")]
3046 NulInCStr {
3047 #[primary_span]
3048 span: Span,
3049 },
3050}
3051
3052#[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_164 =
[::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));
sub_args.insert("normalized".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("consider using the normalized form `{$ch}` of this character")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_164, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::RemoveNonPrinting {
span: __binding_0, ch: __binding_1 } => {
let __code_165 =
[::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_165, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::QuotesFull {
span: __binding_0, is_byte: __binding_1, sugg: __binding_2 }
=> {
let __code_166 =
[::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));
sub_args.insert("sugg".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.span_suggestions_with_style(__binding_0, __message,
__code_166, 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_167 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}\"", __binding_3))
});
let __code_168 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_167));
suggestions.push((__binding_1, __code_168));
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));
sub_args.insert("prefix".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("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)]
3053pub(crate) enum MoreThanOneCharSugg {
3054 #[suggestion(
3055 "consider using the normalized form `{$ch}` of this character",
3056 code = "{normalized}",
3057 applicability = "machine-applicable",
3058 style = "verbose"
3059 )]
3060 NormalizedForm {
3061 #[primary_span]
3062 span: Span,
3063 ch: String,
3064 normalized: String,
3065 },
3066 #[suggestion(
3067 "consider removing the non-printing characters",
3068 code = "{ch}",
3069 applicability = "maybe-incorrect",
3070 style = "verbose"
3071 )]
3072 RemoveNonPrinting {
3073 #[primary_span]
3074 span: Span,
3075 ch: String,
3076 },
3077 #[suggestion(
3078 "if you meant to write a {$is_byte ->
3079 [true] byte string
3080 *[false] string
3081 } literal, use double quotes",
3082 code = "{sugg}",
3083 applicability = "machine-applicable",
3084 style = "verbose"
3085 )]
3086 QuotesFull {
3087 #[primary_span]
3088 span: Span,
3089 is_byte: bool,
3090 sugg: String,
3091 },
3092 #[multipart_suggestion(
3093 "if you meant to write a {$is_byte ->
3094 [true] byte string
3095 *[false] string
3096 } literal, use double quotes",
3097 applicability = "machine-applicable"
3098 )]
3099 Quotes {
3100 #[suggestion_part(code = "{prefix}\"")]
3101 start: Span,
3102 #[suggestion_part(code = "\"")]
3103 end: Span,
3104 is_byte: bool,
3105 prefix: &'static str,
3106 },
3107}
3108
3109#[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)]
3110pub(crate) enum MoreThanOneCharNote {
3111 #[note(
3112 "this `{$chr}` is followed by the combining {$len ->
3113 [one] mark
3114 *[other] marks
3115 } `{$escaped_marks}`"
3116 )]
3117 AllCombining {
3118 #[primary_span]
3119 span: Span,
3120 chr: String,
3121 len: usize,
3122 escaped_marks: String,
3123 },
3124 #[note("there are non-printing characters, the full sequence is `{$escaped}`")]
3125 NonPrinting {
3126 #[primary_span]
3127 span: Span,
3128 escaped: String,
3129 },
3130}
3131
3132#[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_169 =
[::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("suggestion".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("format of unicode escape sequences uses braces")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_169, 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)]
3133pub(crate) enum NoBraceUnicodeSub {
3134 #[suggestion(
3135 "format of unicode escape sequences uses braces",
3136 code = "{suggestion}",
3137 applicability = "maybe-incorrect",
3138 style = "verbose"
3139 )]
3140 Suggestion {
3141 #[primary_span]
3142 span: Span,
3143 suggestion: String,
3144 },
3145 #[help(r#"format of unicode escape sequences is `\u{"{...}"}`"#)]
3146 Help,
3147}
3148
3149#[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_170 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_171 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_170));
suggestions.push((__binding_1, __code_171));
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)]
3150#[multipart_suggestion("wrap the pattern in parentheses", applicability = "machine-applicable")]
3151pub(crate) struct WrapInParens {
3152 #[suggestion_part(code = "(")]
3153 pub(crate) lo: Span,
3154 #[suggestion_part(code = ")")]
3155 pub(crate) hi: Span,
3156}
3157
3158#[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_172 =
[::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_172, 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)]
3159pub(crate) enum TopLevelOrPatternNotAllowedSugg {
3160 #[suggestion(
3161 "remove the `|`",
3162 code = "",
3163 applicability = "machine-applicable",
3164 style = "tool-only"
3165 )]
3166 RemoveLeadingVert {
3167 #[primary_span]
3168 span: Span,
3169 },
3170 WrapInParens {
3171 #[primary_span]
3172 span: Span,
3173 #[subdiagnostic]
3174 suggestion: WrapInParens,
3175 },
3176}
3177
3178#[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_173 =
[::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_173, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3179#[diag("unexpected `||` before function parameter")]
3180#[note("alternatives in or-patterns are separated with `|`, not `||`")]
3181pub(crate) struct UnexpectedVertVertBeforeFunctionParam {
3182 #[primary_span]
3183 #[suggestion(
3184 "remove the `||`",
3185 code = "",
3186 applicability = "machine-applicable",
3187 style = "verbose"
3188 )]
3189 pub span: Span,
3190}
3191
3192#[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_174 =
[::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_174, 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)]
3193#[diag("unexpected token `||` in pattern")]
3194pub(crate) struct UnexpectedVertVertInPattern {
3195 #[primary_span]
3196 #[suggestion(
3197 "use a single `|` to separate multiple alternative patterns",
3198 code = "|",
3199 applicability = "machine-applicable",
3200 style = "verbose"
3201 )]
3202 pub span: Span,
3203 #[label("while parsing this or-pattern starting here")]
3204 pub start: Option<Span>,
3205}
3206
3207#[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_175 =
[::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_175, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
3208#[suggestion(
3209 "a trailing `{$token}` is not allowed in an or-pattern",
3210 code = "",
3211 applicability = "machine-applicable",
3212 style = "tool-only"
3213)]
3214pub(crate) struct TrailingVertSuggestion {
3215 #[primary_span]
3216 pub span: Span,
3217 pub token: Token,
3218}
3219
3220#[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)]
3221#[diag("a trailing `{$token}` is not allowed in an or-pattern")]
3222pub(crate) struct TrailingVertNotAllowed {
3223 #[primary_span]
3224 pub span: Span,
3225 #[subdiagnostic]
3226 pub suggestion: TrailingVertSuggestion,
3227 #[label("while parsing this or-pattern starting here")]
3228 pub start: Option<Span>,
3229 pub token: Token,
3230 #[note("alternatives in or-patterns are separated with `|`, not `||`")]
3231 pub note_double_vert: bool,
3232}
3233
3234#[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_176 =
[::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_176, 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)]
3235#[diag("unexpected `...`")]
3236pub(crate) struct DotDotDotRestPattern {
3237 #[primary_span]
3238 #[label("not a valid pattern")]
3239 pub span: Span,
3240 #[suggestion(
3241 "for a rest pattern, use `..` instead of `...`",
3242 style = "verbose",
3243 code = "",
3244 applicability = "machine-applicable"
3245 )]
3246 pub suggestion: Option<Span>,
3247 #[note(
3248 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3249 )]
3250 pub var_args: Option<()>,
3251}
3252
3253#[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_177 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("whole_pat", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order")),
__code_177, 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)]
3254#[diag("pattern on wrong side of `@`")]
3255pub(crate) struct PatternOnWrongSideOfAt {
3256 #[primary_span]
3257 #[suggestion(
3258 "switch the order",
3259 code = "{whole_pat}",
3260 applicability = "machine-applicable",
3261 style = "verbose"
3262 )]
3263 pub whole_span: Span,
3264 pub whole_pat: String,
3265 #[label("pattern on the left, should be on the right")]
3266 pub pattern: Span,
3267 #[label("binding on the right, should be on the left")]
3268 pub binding: Span,
3269}
3270
3271#[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)]
3272#[diag("left-hand side of `@` must be a binding")]
3273#[note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")]
3274pub(crate) struct ExpectedBindingLeftOfAt {
3275 #[primary_span]
3276 pub whole_span: Span,
3277 #[label("interpreted as a pattern, not a binding")]
3278 pub lhs: Span,
3279 #[label("also a pattern")]
3280 pub rhs: Span,
3281}
3282
3283#[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_178 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_179 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_178));
suggestions.push((__binding_1, __code_179));
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)]
3284#[multipart_suggestion(
3285 "add parentheses to clarify the precedence",
3286 applicability = "machine-applicable"
3287)]
3288pub(crate) struct ParenRangeSuggestion {
3289 #[suggestion_part(code = "(")]
3290 pub lo: Span,
3291 #[suggestion_part(code = ")")]
3292 pub hi: Span,
3293}
3294
3295#[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)]
3296#[diag("the range pattern here has ambiguous interpretation")]
3297pub(crate) struct AmbiguousRangePattern {
3298 #[primary_span]
3299 pub span: Span,
3300 #[subdiagnostic]
3301 pub suggestion: ParenRangeSuggestion,
3302}
3303
3304#[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_180 =
[::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_180, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3305#[diag("unexpected lifetime `{$symbol}` in pattern")]
3306pub(crate) struct UnexpectedLifetimeInPattern {
3307 #[primary_span]
3308 pub span: Span,
3309 pub symbol: Symbol,
3310 #[suggestion(
3311 "remove the lifetime",
3312 code = "",
3313 applicability = "machine-applicable",
3314 style = "verbose"
3315 )]
3316 pub suggestion: Span,
3317}
3318
3319#[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_181 =
[::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.arg("pat", __binding_1);
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_181, 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_182 =
[::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_182, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3320pub(crate) enum InvalidMutInPattern {
3321 #[diag("`mut` must be attached to each individual binding")]
3322 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3323 NestedIdent {
3324 #[primary_span]
3325 #[suggestion(
3326 "add `mut` to each binding",
3327 code = "{pat}",
3328 applicability = "machine-applicable",
3329 style = "verbose"
3330 )]
3331 span: Span,
3332 pat: String,
3333 },
3334 #[diag("`mut` must be followed by a named binding")]
3335 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3336 NonIdent {
3337 #[primary_span]
3338 #[suggestion(
3339 "remove the `mut` prefix",
3340 code = "",
3341 applicability = "machine-applicable",
3342 style = "verbose"
3343 )]
3344 span: Span,
3345 },
3346}
3347
3348#[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_183 =
[::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_183, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3349#[diag("`mut` on a binding may not be repeated")]
3350pub(crate) struct RepeatedMutInPattern {
3351 #[primary_span]
3352 pub span: Span,
3353 #[suggestion(
3354 "remove the additional `mut`s",
3355 code = "",
3356 applicability = "machine-applicable",
3357 style = "verbose"
3358 )]
3359 pub suggestion: Span,
3360}
3361
3362#[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_184 =
[::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_184, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3363#[diag("range-to patterns with `...` are not allowed")]
3364pub(crate) struct DotDotDotRangeToPatternNotAllowed {
3365 #[primary_span]
3366 #[suggestion(
3367 "use `..=` instead",
3368 style = "verbose",
3369 code = "..=",
3370 applicability = "machine-applicable"
3371 )]
3372 pub span: Span,
3373}
3374
3375#[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)]
3376#[diag("expected identifier, found enum pattern")]
3377pub(crate) struct EnumPatternInsteadOfIdentifier {
3378 #[primary_span]
3379 pub span: Span,
3380}
3381
3382#[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_185 =
[::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_185, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3383#[diag("`@ ..` is not supported in struct patterns")]
3384pub(crate) struct AtDotDotInStructPattern {
3385 #[primary_span]
3386 pub span: Span,
3387 #[suggestion(
3388 "bind to each field separately or, if you don't need them, just remove `{$ident} @`",
3389 code = "",
3390 style = "verbose",
3391 applicability = "machine-applicable"
3392 )]
3393 pub remove: Span,
3394 pub ident: Ident,
3395}
3396
3397#[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)]
3398#[diag("unexpected `@` in struct pattern")]
3399#[note("struct patterns use `field: pattern` syntax to bind to fields")]
3400#[help(
3401 "consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended"
3402)]
3403pub(crate) struct AtInStructPattern {
3404 #[primary_span]
3405 pub span: Span,
3406}
3407
3408#[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_186 =
[::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_186, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3409#[diag("expected field pattern, found `{$token_str}`")]
3410pub(crate) struct DotDotDotForRemainingFields {
3411 #[primary_span]
3412 #[suggestion(
3413 "to omit remaining fields, use `..`",
3414 code = "..",
3415 style = "verbose",
3416 applicability = "machine-applicable"
3417 )]
3418 pub span: Span,
3419 pub token_str: Cow<'static, str>,
3420}
3421
3422#[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)]
3423#[diag("expected `,`")]
3424pub(crate) struct ExpectedCommaAfterPatternField {
3425 #[primary_span]
3426 pub span: Span,
3427}
3428
3429#[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,
expr_precedence: __binding_2 } => {
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.arg("expr_precedence", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a pattern")));
diag
}
}
}
}
};Diagnostic)]
3430#[diag(
3431 "expected {$is_bound ->
3432 [true] a pattern range bound
3433 *[false] a pattern
3434 }, found an expression"
3435)]
3436#[note(
3437 "arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>"
3438)]
3439pub(crate) struct UnexpectedExpressionInPattern {
3440 #[primary_span]
3442 #[label("not a pattern")]
3443 pub span: Span,
3444 pub is_bound: bool,
3446 pub expr_precedence: ExprPrecedence,
3448}
3449
3450#[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_187 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
let __code_188 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if {1} == {0}",
__binding_3, __binding_2))
});
suggestions.push((__binding_0, __code_187));
suggestions.push((__binding_1, __code_188));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("expr".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("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_189 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
let __code_190 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_191 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1} && {2} == {0}",
__binding_5, __binding_3, __binding_4))
});
suggestions.push((__binding_0, __code_189));
if let Some(__binding_1) = __binding_1 {
suggestions.push((__binding_1, __code_190));
}
suggestions.push((__binding_2, __code_191));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("guard_hi_paren".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
sub_args.insert("expr".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("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_192 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{2}const {1}: /* Type */ = {0};\n",
__binding_3, __binding_2, __binding_4))
});
let __code_193 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_192));
suggestions.push((__binding_1, __code_193));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("expr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("indentation".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 extracting the expression into a `const`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3451pub(crate) enum UnexpectedExpressionInPatternSugg {
3452 #[multipart_suggestion(
3453 "consider moving the expression to a match arm guard",
3454 applicability = "maybe-incorrect"
3455 )]
3456 CreateGuard {
3457 #[suggestion_part(code = "{ident}")]
3459 ident_span: Span,
3460 #[suggestion_part(code = " if {ident} == {expr}")]
3462 pat_hi: Span,
3463 ident: String,
3465 expr: String,
3467 },
3468
3469 #[multipart_suggestion(
3470 "consider moving the expression to the match arm guard",
3471 applicability = "maybe-incorrect"
3472 )]
3473 UpdateGuard {
3474 #[suggestion_part(code = "{ident}")]
3476 ident_span: Span,
3477 #[suggestion_part(code = "(")]
3479 guard_lo: Option<Span>,
3480 #[suggestion_part(code = "{guard_hi_paren} && {ident} == {expr}")]
3482 guard_hi: Span,
3483 guard_hi_paren: &'static str,
3485 ident: String,
3487 expr: String,
3489 },
3490
3491 #[multipart_suggestion(
3492 "consider extracting the expression into a `const`",
3493 applicability = "has-placeholders"
3494 )]
3495 Const {
3496 #[suggestion_part(code = "{indentation}const {ident}: /* Type */ = {expr};\n")]
3498 stmt_lo: Span,
3499 #[suggestion_part(code = "{ident}")]
3501 ident_span: Span,
3502 ident: String,
3504 expr: String,
3506 indentation: String,
3508 },
3509}
3510
3511#[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)]
3512#[diag("range pattern bounds cannot have parentheses")]
3513pub(crate) struct UnexpectedParenInRangePat {
3514 #[primary_span]
3515 pub span: Vec<Span>,
3516 #[subdiagnostic]
3517 pub sugg: UnexpectedParenInRangePatSugg,
3518}
3519
3520#[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_194 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_195 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_194));
suggestions.push((__binding_1, __code_195));
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)]
3521#[multipart_suggestion("remove these parentheses", applicability = "machine-applicable")]
3522pub(crate) struct UnexpectedParenInRangePatSugg {
3523 #[suggestion_part(code = "")]
3524 pub start_span: Span,
3525 #[suggestion_part(code = "")]
3526 pub end_span: Span,
3527}
3528
3529#[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_196 =
[::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_196, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3530#[diag("return types are denoted using `->`")]
3531pub(crate) struct ReturnTypesUseThinArrow {
3532 #[primary_span]
3533 pub span: Span,
3534 #[suggestion(
3535 "use `->` instead",
3536 style = "verbose",
3537 code = " -> ",
3538 applicability = "machine-applicable"
3539 )]
3540 pub suggestion: Span,
3541}
3542
3543#[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_197 =
[::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_197, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3544#[diag("lifetimes must be followed by `+` to form a trait object type")]
3545pub(crate) struct NeedPlusAfterTraitObjectLifetime {
3546 #[primary_span]
3547 pub span: Span,
3548 #[suggestion(
3549 "consider adding a trait bound after the potential lifetime bound",
3550 code = " + /* Trait */",
3551 applicability = "has-placeholders"
3552 )]
3553 pub suggestion: Span,
3554}
3555
3556#[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_198 =
[::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_198, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3557#[diag("expected `mut` or `const` keyword in raw pointer type")]
3558pub(crate) struct ExpectedMutOrConstInRawPointerType {
3559 #[primary_span]
3560 pub span: Span,
3561 #[suggestion(
3562 "add `mut` or `const` here",
3563 code("mut ", "const "),
3564 applicability = "has-placeholders",
3565 style = "verbose"
3566 )]
3567 pub after_asterisk: Span,
3568}
3569
3570#[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_199 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&{0} mut", __binding_2))
})].into_iter();
;
diag.arg("snippet", __binding_2);
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_199, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
3571#[diag("lifetime must precede `mut`")]
3572pub(crate) struct LifetimeAfterMut {
3573 #[primary_span]
3574 pub span: Span,
3575 #[suggestion(
3576 "place the lifetime before `mut`",
3577 code = "&{snippet} mut",
3578 applicability = "maybe-incorrect",
3579 style = "verbose"
3580 )]
3581 pub suggest_lifetime: Option<Span>,
3582 pub snippet: String,
3583}
3584
3585#[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_200 =
[::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_200, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3586#[diag("`mut` must precede `dyn`")]
3587pub(crate) struct DynAfterMut {
3588 #[primary_span]
3589 #[suggestion(
3590 "place `mut` before `dyn`",
3591 code = "&mut dyn",
3592 applicability = "machine-applicable",
3593 style = "verbose"
3594 )]
3595 pub span: Span,
3596}
3597
3598#[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_201 =
[::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_201, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3599#[diag("an `fn` pointer type cannot be `const`")]
3600#[note("allowed qualifiers are: `unsafe` and `extern`")]
3601pub(crate) struct FnPointerCannotBeConst {
3602 #[primary_span]
3603 #[label("`const` because of this")]
3604 pub span: Span,
3605 #[suggestion(
3606 "remove the `const` qualifier",
3607 code = "",
3608 applicability = "maybe-incorrect",
3609 style = "verbose"
3610 )]
3611 pub suggestion: Span,
3612}
3613
3614#[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_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("`async` because of this")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `async` qualifier")),
__code_202, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3615#[diag("an `fn` pointer type cannot be `async`")]
3616#[note("allowed qualifiers are: `unsafe` and `extern`")]
3617pub(crate) struct FnPointerCannotBeAsync {
3618 #[primary_span]
3619 #[label("`async` because of this")]
3620 pub span: Span,
3621 #[suggestion(
3622 "remove the `async` 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
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)]
3631#[diag("C-variadic type `...` may not be nested inside another type", code = E0743)]
3632pub(crate) struct NestedCVariadicType {
3633 #[primary_span]
3634 pub span: Span,
3635}
3636
3637#[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)]
3638#[diag("unexpected `...`")]
3639#[note(
3640 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3641)]
3642pub(crate) struct InvalidCVariadicType {
3643 #[primary_span]
3644 pub span: Span,
3645}
3646
3647#[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_203 =
[::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_203, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3648#[diag("invalid `dyn` keyword")]
3649#[help("`dyn` is only needed at the start of a trait `+`-separated list")]
3650pub(crate) struct InvalidDynKeyword {
3651 #[primary_span]
3652 pub span: Span,
3653 #[suggestion(
3654 "remove this keyword",
3655 code = "",
3656 applicability = "machine-applicable",
3657 style = "verbose"
3658 )]
3659 pub suggestion: Span,
3660}
3661
3662#[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)]
3663pub(crate) enum HelpUseLatestEdition {
3664 #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
3665 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3666 Cargo { edition: Edition },
3667 #[help("pass `--edition {$edition}` to `rustc`")]
3668 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3669 Standalone { edition: Edition },
3670}
3671
3672impl HelpUseLatestEdition {
3673 pub(crate) fn new() -> Self {
3674 let edition = LATEST_STABLE_EDITION;
3675 if rustc_session::utils::was_invoked_from_cargo() {
3676 Self::Cargo { edition }
3677 } else {
3678 Self::Standalone { edition }
3679 }
3680 }
3681}
3682
3683#[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)]
3684#[diag("`box_syntax` has been removed")]
3685pub(crate) struct BoxSyntaxRemoved {
3686 #[primary_span]
3687 pub span: Span,
3688 #[subdiagnostic]
3689 pub sugg: AddBoxNew,
3690}
3691
3692#[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_204 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new("))
});
let __code_205 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_204));
suggestions.push((__binding_1, __code_205));
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)]
3693#[multipart_suggestion(
3694 "use `Box::new()` instead",
3695 applicability = "machine-applicable",
3696 style = "verbose"
3697)]
3698pub(crate) struct AddBoxNew {
3699 #[suggestion_part(code = "Box::new(")]
3700 pub box_kw_and_lo: Span,
3701 #[suggestion_part(code = ")")]
3702 pub hi: Span,
3703}
3704
3705#[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_206 =
[::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_206, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3706#[diag("return type not allowed with return type notation")]
3707pub(crate) struct BadReturnTypeNotationOutput {
3708 #[primary_span]
3709 pub span: Span,
3710 #[suggestion(
3711 "remove the return type",
3712 code = "",
3713 applicability = "maybe-incorrect",
3714 style = "verbose"
3715 )]
3716 pub suggestion: Span,
3717}
3718
3719#[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)]
3720#[diag("bounds on associated types do not belong here")]
3721pub(crate) struct BadAssocTypeBounds {
3722 #[primary_span]
3723 #[label("belongs in `where` clause")]
3724 pub span: Span,
3725}
3726
3727#[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)]
3728#[diag("trailing attribute after generic parameter")]
3729pub(crate) struct AttrAfterGeneric {
3730 #[primary_span]
3731 #[label("attributes must go before parameters")]
3732 pub span: Span,
3733}
3734
3735#[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)]
3736#[diag("attribute without generic parameters")]
3737pub(crate) struct AttrWithoutGenerics {
3738 #[primary_span]
3739 #[label("attributes are only permitted when preceding parameters")]
3740 pub span: Span,
3741}
3742
3743#[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)]
3744#[diag("generic parameters on `where` clauses are reserved for future use")]
3745pub(crate) struct WhereOnGenerics {
3746 #[primary_span]
3747 #[label("currently unsupported")]
3748 pub span: Span,
3749}
3750
3751#[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)]
3752#[diag("unexpected generic arguments in path")]
3753pub(crate) struct GenericsInPath {
3754 #[primary_span]
3755 pub span: Vec<Span>,
3756}
3757
3758#[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_207 =
[::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_207, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3759#[diag("lifetimes are not permitted in this context")]
3760#[help("if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}`")]
3761pub(crate) struct LifetimeInEqConstraint {
3762 #[primary_span]
3763 #[label("lifetime is not allowed here")]
3764 pub span: Span,
3765 pub lifetime: Ident,
3766 #[label("this introduces an associated item binding")]
3767 pub binding_label: Span,
3768 #[suggestion(
3769 "you might have meant to write a bound here",
3770 style = "verbose",
3771 applicability = "maybe-incorrect",
3772 code = ": "
3773 )]
3774 pub colon_sugg: Span,
3775}
3776
3777#[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_208 =
[::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_208, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
3778#[diag("`{$modifier}` may only modify trait bounds, not lifetime bounds")]
3779pub(crate) struct ModifierLifetime {
3780 #[primary_span]
3781 #[suggestion(
3782 "remove the `{$modifier}`",
3783 style = "tool-only",
3784 applicability = "maybe-incorrect",
3785 code = ""
3786 )]
3787 pub span: Span,
3788 pub modifier: &'static str,
3789}
3790
3791#[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)]
3792#[diag("underscore literal suffix is not allowed")]
3793pub(crate) struct UnderscoreLiteralSuffix {
3794 #[primary_span]
3795 pub span: Span,
3796}
3797
3798#[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_209 =
[::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_209, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3799#[diag("expected a label, found an identifier")]
3800pub(crate) struct ExpectedLabelFoundIdent {
3801 #[primary_span]
3802 pub span: Span,
3803 #[suggestion(
3804 "labels start with a tick",
3805 code = "'",
3806 applicability = "machine-applicable",
3807 style = "verbose"
3808 )]
3809 pub start: Span,
3810}
3811
3812#[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)]
3813#[diag("{$article} {$descr} cannot be `default`")]
3814#[note("only associated `fn`, `const`, and `type` items can be `default`")]
3815pub(crate) struct InappropriateDefault {
3816 #[primary_span]
3817 #[label("`default` because of this")]
3818 pub span: Span,
3819 pub article: &'static str,
3820 pub descr: &'static str,
3821}
3822
3823#[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_210 =
[::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_210, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3824#[diag("expected item, found {$token_name}")]
3825pub(crate) struct RecoverImportAsUse {
3826 #[primary_span]
3827 #[suggestion(
3828 "items are imported using the `use` keyword",
3829 code = "use",
3830 applicability = "machine-applicable",
3831 style = "verbose"
3832 )]
3833 pub span: Span,
3834 pub token_name: String,
3835}
3836
3837#[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)]
3838#[diag("{$article} {$descr} cannot be `final`")]
3839#[note("only associated functions in traits can be `final`")]
3840pub(crate) struct InappropriateFinal {
3841 #[primary_span]
3842 #[label("`final` because of this")]
3843 pub span: Span,
3844 pub article: &'static str,
3845 pub descr: &'static str,
3846}
3847
3848#[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_211 =
[::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_211, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3849#[diag("expected `::`, found `:`")]
3850#[note("import paths are delimited using `::`")]
3851pub(crate) struct SingleColonImportPath {
3852 #[primary_span]
3853 #[suggestion(
3854 "use double colon",
3855 code = "::",
3856 applicability = "machine-applicable",
3857 style = "verbose"
3858 )]
3859 pub span: Span,
3860}
3861
3862#[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)]
3863#[diag("{$descr} is not supported in {$ctx}")]
3864pub(crate) struct BadItemKind {
3865 #[primary_span]
3866 pub span: Span,
3867 pub descr: &'static str,
3868 pub ctx: &'static str,
3869 #[help("consider moving the {$descr} out to a nearby module scope")]
3870 pub help: bool,
3871}
3872
3873#[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_212 =
[::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_212, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3874#[diag("expected `!` after `macro_rules`")]
3875pub(crate) struct MacroRulesMissingBang {
3876 #[primary_span]
3877 pub span: Span,
3878 #[suggestion("add a `!`", code = "!", applicability = "machine-applicable", style = "verbose")]
3879 pub hi: Span,
3880}
3881
3882#[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_213 =
[::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_213, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
3883#[diag("macro names aren't followed by a `!`")]
3884pub(crate) struct MacroNameRemoveBang {
3885 #[primary_span]
3886 #[suggestion(
3887 "remove the `!`",
3888 code = "",
3889 applicability = "machine-applicable",
3890 style = "short"
3891 )]
3892 pub span: Span,
3893}
3894
3895#[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_214 =
[::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_214, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3896#[diag("can't qualify macro_rules invocation with `{$vis}`")]
3897pub(crate) struct MacroRulesVisibility<'a> {
3898 #[primary_span]
3899 #[suggestion(
3900 "try exporting the macro",
3901 code = "#[macro_export]",
3902 applicability = "maybe-incorrect",
3903 style = "verbose"
3904 )]
3905 pub span: Span,
3906 pub vis: &'a str,
3907}
3908
3909#[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_215 =
[::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_215, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3910#[diag("can't qualify macro invocation with `pub`")]
3911#[help("try adjusting the macro to put `{$vis}` inside the invocation")]
3912pub(crate) struct MacroInvocationVisibility<'a> {
3913 #[primary_span]
3914 #[suggestion(
3915 "remove the visibility",
3916 code = "",
3917 applicability = "machine-applicable",
3918 style = "verbose"
3919 )]
3920 pub span: Span,
3921 pub vis: &'a str,
3922}
3923
3924#[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_216 =
[::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_216, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3925#[diag("`{$kw_str}` definition cannot be nested inside `{$keyword}`")]
3926pub(crate) struct NestedAdt<'a> {
3927 #[primary_span]
3928 pub span: Span,
3929 #[suggestion(
3930 "consider creating a new `{$kw_str}` definition instead of nesting",
3931 code = "",
3932 applicability = "maybe-incorrect",
3933 style = "verbose"
3934 )]
3935 pub item: Span,
3936 pub keyword: &'a str,
3937 pub kw_str: Cow<'a, str>,
3938}
3939
3940#[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)]
3941#[diag("function body cannot be `= expression;`")]
3942pub(crate) struct FunctionBodyEqualsExpr {
3943 #[primary_span]
3944 pub span: Span,
3945 #[subdiagnostic]
3946 pub sugg: FunctionBodyEqualsExprSugg,
3947}
3948
3949#[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_217 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_218 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_217));
suggestions.push((__binding_1, __code_218));
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)]
3950#[multipart_suggestion(
3951 r#"surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`"#,
3952 applicability = "machine-applicable"
3953)]
3954pub(crate) struct FunctionBodyEqualsExprSugg {
3955 #[suggestion_part(code = "{{")]
3956 pub eq: Span,
3957 #[suggestion_part(code = " }}")]
3958 pub semi: Span,
3959}
3960
3961#[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_219 =
[::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_219, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3962#[diag("expected pattern, found {$descr}")]
3963pub(crate) struct BoxNotPat {
3964 #[primary_span]
3965 pub span: Span,
3966 #[note("`box` is a reserved keyword")]
3967 pub kw: Span,
3968 #[suggestion(
3969 "escape `box` to use it as an identifier",
3970 code = "r#",
3971 applicability = "maybe-incorrect",
3972 style = "verbose"
3973 )]
3974 pub lo: Span,
3975 pub descr: String,
3976}
3977
3978#[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_220 =
[::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_220, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3979#[diag(
3980 "unmatched angle {$plural ->
3981 [true] brackets
3982 *[false] bracket
3983 }"
3984)]
3985pub(crate) struct UnmatchedAngle {
3986 #[primary_span]
3987 #[suggestion(
3988 "remove extra angle {$plural ->
3989 [true] brackets
3990 *[false] bracket
3991 }",
3992 code = "",
3993 applicability = "machine-applicable",
3994 style = "verbose"
3995 )]
3996 pub span: Span,
3997 pub plural: bool,
3998}
3999
4000#[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_221 =
[::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_221, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4001#[diag("expected `+` between lifetime and {$sym}")]
4002pub(crate) struct MissingPlusBounds {
4003 #[primary_span]
4004 pub span: Span,
4005 #[suggestion("add `+`", code = " +", applicability = "maybe-incorrect", style = "verbose")]
4006 pub hi: Span,
4007 pub sym: Symbol,
4008}
4009
4010#[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)]
4011#[diag("incorrect parentheses around trait bounds")]
4012pub(crate) struct IncorrectParensTraitBounds {
4013 #[primary_span]
4014 pub span: Vec<Span>,
4015 #[subdiagnostic]
4016 pub sugg: IncorrectParensTraitBoundsSugg,
4017}
4018
4019#[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_222 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_223 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
suggestions.push((__binding_0, __code_222));
suggestions.push((__binding_1, __code_223));
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)]
4020#[multipart_suggestion("fix the parentheses", applicability = "machine-applicable")]
4021pub(crate) struct IncorrectParensTraitBoundsSugg {
4022 #[suggestion_part(code = " ")]
4023 pub wrong_span: Span,
4024 #[suggestion_part(code = "(")]
4025 pub new_span: Span,
4026}
4027
4028#[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_224 =
[::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_224, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4029#[diag("keyword `{$kw}` is written in the wrong case")]
4030pub(crate) struct KwBadCase<'a> {
4031 #[primary_span]
4032 #[suggestion(
4033 "write it in {$case}",
4034 code = "{kw}",
4035 style = "verbose",
4036 applicability = "machine-applicable"
4037 )]
4038 pub span: Span,
4039 pub kw: &'a str,
4040 pub case: Case,
4041}
4042
4043pub(crate) enum Case {
4044 Upper,
4045 Lower,
4046 Mixed,
4047}
4048
4049impl IntoDiagArg for Case {
4050 fn into_diag_arg(self, path: &mut Option<PathBuf>) -> DiagArgValue {
4051 match self {
4052 Case::Upper => "uppercase",
4053 Case::Lower => "lowercase",
4054 Case::Mixed => "the correct case",
4055 }
4056 .into_diag_arg(path)
4057 }
4058}
4059
4060#[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)]
4061#[diag("unknown `builtin #` construct `{$name}`")]
4062pub(crate) struct UnknownBuiltinConstruct {
4063 #[primary_span]
4064 pub span: Span,
4065 pub name: Ident,
4066}
4067
4068#[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)]
4069#[diag("expected identifier after `builtin #`")]
4070pub(crate) struct ExpectedBuiltinIdent {
4071 #[primary_span]
4072 pub span: Span,
4073}
4074
4075#[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)]
4076#[diag("static items may not have generic parameters")]
4077pub(crate) struct StaticWithGenerics {
4078 #[primary_span]
4079 pub span: Span,
4080}
4081
4082#[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)]
4083#[diag("where clauses are not allowed before const item bodies")]
4084pub(crate) struct WhereClauseBeforeConstBody {
4085 #[primary_span]
4086 #[label("unexpected where clause")]
4087 pub span: Span,
4088 #[label("while parsing this const item")]
4089 pub name: Span,
4090 #[label("the item body")]
4091 pub body: Span,
4092 #[subdiagnostic]
4093 pub sugg: Option<WhereClauseBeforeConstBodySugg>,
4094}
4095
4096#[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_225 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("= {0} ", __binding_1))
});
let __code_226 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_225));
suggestions.push((__binding_2, __code_226));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".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("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)]
4097#[multipart_suggestion(
4098 "move the body before the where clause",
4099 applicability = "machine-applicable"
4100)]
4101pub(crate) struct WhereClauseBeforeConstBodySugg {
4102 #[suggestion_part(code = "= {snippet} ")]
4103 pub left: Span,
4104 pub snippet: String,
4105 #[suggestion_part(code = "")]
4106 pub right: Span,
4107}
4108
4109#[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_227 =
[::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_227, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4110#[diag("generic args in patterns require the turbofish syntax")]
4111pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
4112 #[primary_span]
4113 pub span: Span,
4114 #[suggestion(
4115 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
4116 style = "verbose",
4117 code = "::",
4118 applicability = "maybe-incorrect"
4119 )]
4120 pub suggest_turbofish: Span,
4121}
4122
4123#[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)]
4124#[diag("`for<...>` expected after `{$kw}`, not before")]
4125pub(crate) struct TransposeDynOrImpl<'a> {
4126 #[primary_span]
4127 pub span: Span,
4128 pub kw: &'a str,
4129 #[subdiagnostic]
4130 pub sugg: TransposeDynOrImplSugg<'a>,
4131}
4132
4133#[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_228 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_229 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_2))
});
suggestions.push((__binding_0, __code_228));
suggestions.push((__binding_1, __code_229));
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)]
4134#[multipart_suggestion("move `{$kw}` before the `for<...>`", applicability = "machine-applicable")]
4135pub(crate) struct TransposeDynOrImplSugg<'a> {
4136 #[suggestion_part(code = "")]
4137 pub removal_span: Span,
4138 #[suggestion_part(code = "{kw} ")]
4139 pub insertion_span: Span,
4140 pub kw: &'a str,
4141}
4142
4143#[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)]
4144#[diag("array indexing not supported in offset_of")]
4145pub(crate) struct ArrayIndexInOffsetOf(#[primary_span] pub Span);
4146
4147#[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)]
4148#[diag("offset_of expects dot-separated field and variant names")]
4149pub(crate) struct InvalidOffsetOf(#[primary_span] pub Span);
4150
4151#[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)]
4152#[diag("`async` trait implementations are unsupported")]
4153pub(crate) struct AsyncImpl {
4154 #[primary_span]
4155 pub span: Span,
4156}
4157
4158#[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_230 =
[::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_230, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4159#[diag("`->` is not valid syntax for field accesses and method calls")]
4160#[help(
4161 "the `.` operator will automatically dereference the value, except if the value is a raw pointer"
4162)]
4163pub(crate) struct ExprRArrowCall {
4164 #[primary_span]
4165 #[suggestion(
4166 "try using `.` instead",
4167 style = "verbose",
4168 applicability = "machine-applicable",
4169 code = "."
4170 )]
4171 pub span: Span,
4172}
4173
4174#[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)]
4175#[diag("attributes are not allowed on range expressions starting with `..`")]
4176pub(crate) struct DotDotRangeAttribute {
4177 #[primary_span]
4178 pub span: Span,
4179}
4180
4181#[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)]
4182#[diag("`for<...>` binder should be placed before trait bound modifiers")]
4183pub(crate) struct BinderBeforeModifiers {
4184 #[primary_span]
4185 pub binder_span: Span,
4186 #[label("place the `for<...>` binder before any modifiers")]
4187 pub modifiers_span: Span,
4188}
4189
4190#[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)]
4191#[diag("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")]
4192pub(crate) struct BinderAndPolarity {
4193 #[primary_span]
4194 pub polarity_span: Span,
4195 #[label("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")]
4196 pub binder_span: Span,
4197 pub polarity: &'static str,
4198}
4199
4200#[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)]
4201#[diag("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")]
4202pub(crate) struct PolarityAndModifiers {
4203 #[primary_span]
4204 pub polarity_span: Span,
4205 #[label(
4206 "there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait"
4207 )]
4208 pub modifiers_span: Span,
4209 pub polarity: &'static str,
4210 pub modifiers_concatenated: String,
4211}
4212
4213#[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)]
4214#[diag("type not allowed for shorthand `self` parameter")]
4215pub(crate) struct IncorrectTypeOnSelf {
4216 #[primary_span]
4217 pub span: Span,
4218 #[subdiagnostic]
4219 pub move_self_modifier: MoveSelfModifier,
4220}
4221
4222#[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_231 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_232 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_231));
suggestions.push((__binding_1, __code_232));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("modifier".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 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)]
4223#[multipart_suggestion(
4224 "move the modifiers on `self` to the type",
4225 applicability = "machine-applicable"
4226)]
4227pub(crate) struct MoveSelfModifier {
4228 #[suggestion_part(code = "")]
4229 pub removal_span: Span,
4230 #[suggestion_part(code = "{modifier}")]
4231 pub insertion_span: Span,
4232 pub modifier: String,
4233}
4234
4235#[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)]
4236#[diag("the `{$symbol}` operand cannot be used with `{$macro_name}!`")]
4237pub(crate) struct AsmUnsupportedOperand<'a> {
4238 #[primary_span]
4239 #[label(
4240 "the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it"
4241 )]
4242 pub(crate) span: Span,
4243 pub(crate) symbol: &'a str,
4244 pub(crate) macro_name: &'static str,
4245}
4246
4247#[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)]
4248#[diag("_ cannot be used for input operands")]
4249pub(crate) struct AsmUnderscoreInput {
4250 #[primary_span]
4251 pub(crate) span: Span,
4252}
4253
4254#[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)]
4255#[diag("expected a path for argument to `sym`")]
4256pub(crate) struct AsmSymNoPath {
4257 #[primary_span]
4258 pub(crate) span: Span,
4259}
4260
4261#[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)]
4262#[diag("requires at least a template string argument")]
4263pub(crate) struct AsmRequiresTemplate {
4264 #[primary_span]
4265 pub(crate) span: Span,
4266}
4267
4268#[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)]
4269#[diag("expected token: `,`")]
4270pub(crate) struct AsmExpectedComma {
4271 #[primary_span]
4272 #[label("expected `,`")]
4273 pub(crate) span: Span,
4274}
4275
4276#[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)]
4277#[diag(
4278 "expected operand, {$is_inline_asm ->
4279 [false] options
4280 *[true] clobber_abi, options
4281 }, or additional template string"
4282)]
4283pub(crate) struct AsmExpectedOther {
4284 #[primary_span]
4285 #[label(
4286 "expected operand, {$is_inline_asm ->
4287 [false] options
4288 *[true] clobber_abi, options
4289 }, or additional template string"
4290 )]
4291 pub(crate) span: Span,
4292 pub(crate) is_inline_asm: bool,
4293}
4294
4295#[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)]
4296#[diag("at least one abi must be provided as an argument to `clobber_abi`")]
4297pub(crate) struct NonABI {
4298 #[primary_span]
4299 pub(crate) span: Span,
4300}
4301
4302#[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)]
4303#[diag("expected string literal")]
4304pub(crate) struct AsmExpectedStringLiteral {
4305 #[primary_span]
4306 #[label("not a string literal")]
4307 pub(crate) span: Span,
4308}
4309
4310#[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)]
4311#[diag("expected register class or explicit register")]
4312pub(crate) struct ExpectedRegisterClassOrExplicitRegister {
4313 #[primary_span]
4314 pub(crate) span: Span,
4315}
4316
4317#[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)]
4318#[diag("unicode codepoint changing visible direction of text present in {$label}")]
4319#[note(
4320 "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"
4321)]
4322pub(crate) struct HiddenUnicodeCodepointsDiag {
4323 pub label: String,
4324 pub count: usize,
4325 #[label(
4326 "this {$label} contains {$count ->
4327 [one] an invisible
4328 *[other] invisible
4329 } unicode text flow control {$count ->
4330 [one] codepoint
4331 *[other] codepoints
4332 }"
4333 )]
4334 pub span_label: Span,
4335 #[subdiagnostic]
4336 pub labels: Option<HiddenUnicodeCodepointsDiagLabels>,
4337 #[subdiagnostic]
4338 pub sub: HiddenUnicodeCodepointsDiagSub,
4339}
4340
4341pub(crate) struct HiddenUnicodeCodepointsDiagLabels {
4342 pub spans: Vec<(char, Span)>,
4343}
4344
4345impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
4346 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4347 for (c, span) in self.spans {
4348 diag.span_label(span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"));
4349 }
4350 }
4351}
4352
4353pub(crate) enum HiddenUnicodeCodepointsDiagSub {
4354 Escape { spans: Vec<(char, Span)> },
4355 NoEscape { spans: Vec<(char, Span)>, is_doc_comment: bool },
4356}
4357
4358impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
4360 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4361 match self {
4362 HiddenUnicodeCodepointsDiagSub::Escape { spans } => {
4363 diag.multipart_suggestion_with_style(
4364 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"),
4365 spans.iter().map(|(_, span)| (*span, "".to_string())).collect(),
4366 Applicability::MachineApplicable,
4367 SuggestionStyle::HideCodeAlways,
4368 );
4369 diag.multipart_suggestion(
4370 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"),
4371 spans
4372 .into_iter()
4373 .map(|(c, span)| {
4374 let c = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}");
4375 (span, c[1..c.len() - 1].to_string())
4376 })
4377 .collect(),
4378 Applicability::MachineApplicable,
4379 );
4380 }
4381 HiddenUnicodeCodepointsDiagSub::NoEscape { spans, is_doc_comment } => {
4382 diag.arg(
4386 "escaped",
4387 spans
4388 .into_iter()
4389 .map(|(c, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"))
4390 .collect::<Vec<String>>()
4391 .join(", "),
4392 );
4393 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"));
4394 if is_doc_comment {
4395 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}"#));
4396 } else {
4397 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}"));
4398 }
4399 }
4400 }
4401 }
4402}
4403
4404#[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_233 =
[::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_233, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4405#[diag("missing pattern for `...` argument")]
4406pub(crate) struct VarargsWithoutPattern {
4407 #[suggestion(
4408 "name the argument, or use `_` to continue ignoring it",
4409 code = "_: ...",
4410 applicability = "machine-applicable"
4411 )]
4412 pub span: Span,
4413}
4414
4415#[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)]
4416#[diag("only trait impls can be reused")]
4417pub(crate) struct ImplReuseInherentImpl {
4418 #[primary_span]
4419 pub span: Span,
4420}
4421
4422#[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_234 =
[::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_234, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4423#[diag("placeholder `_` is not allowed for the path in struct literals")]
4424pub(crate) struct StructLiteralPlaceholderPath {
4425 #[primary_span]
4426 #[label("not allowed in struct literals")]
4427 #[suggestion(
4428 "replace it with the correct type",
4429 applicability = "has-placeholders",
4430 code = "/* Type */",
4431 style = "verbose"
4432 )]
4433 pub span: Span,
4434}
4435
4436#[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_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("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_235, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4437#[diag("struct literal body without path")]
4438pub(crate) struct StructLiteralWithoutPathLate {
4439 #[primary_span]
4440 #[label("struct name missing for struct literal")]
4441 pub span: Span,
4442 #[suggestion(
4443 "add the correct type",
4444 applicability = "has-placeholders",
4445 code = "/* Type */ ",
4446 style = "verbose"
4447 )]
4448 pub suggestion_span: Span,
4449}
4450
4451#[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)]
4453pub(crate) enum ForbiddenLetReason {
4454 OtherForbidden,
4456 #[note("`||` operators are not supported in let chain expressions")]
4458 NotSupportedOr(#[primary_span] Span),
4459 #[note("`let`s wrapped in parentheses are not supported in a context with let chains")]
4464 NotSupportedParentheses(#[primary_span] Span),
4465}
4466
4467#[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_236 =
[::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_236, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};rustc_macros::Subdiagnostic)]
4468#[suggestion(
4469 "{$is_incorrect_case ->
4470 [true] write keyword `{$similar_kw}` in lowercase
4471 *[false] there is a keyword `{$similar_kw}` with a similar name
4472 }",
4473 applicability = "machine-applicable",
4474 code = "{similar_kw}",
4475 style = "verbose"
4476)]
4477pub(crate) struct MisspelledKw {
4478 pub similar_kw: String,
4481 #[primary_span]
4482 pub span: Span,
4483 pub is_incorrect_case: bool,
4484}
4485
4486#[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)]
4487pub(super) enum TokenDescription {
4488 ReservedIdentifier,
4489 Keyword,
4490 ReservedKeyword,
4491 DocComment,
4492
4493 MetaVar(MetaVarKind),
4498}
4499
4500impl TokenDescription {
4501 pub(super) fn from_token(token: &Token) -> Option<Self> {
4502 match token.kind {
4503 _ if token.is_special_ident() => Some(TokenDescription::ReservedIdentifier),
4504 _ if token.is_used_keyword() => Some(TokenDescription::Keyword),
4505 _ if token.is_unused_keyword() => Some(TokenDescription::ReservedKeyword),
4506 token::DocComment(..) => Some(TokenDescription::DocComment),
4507 token::OpenInvisible(InvisibleOrigin::MetaVar(kind)) => {
4508 Some(TokenDescription::MetaVar(kind))
4509 }
4510 _ => None,
4511 }
4512 }
4513}
4514
4515#[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)]
4516#[diag(
4517 "this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression"
4518)]
4519pub(crate) struct BreakWithLabelAndLoop {
4520 #[subdiagnostic]
4521 pub sub: BreakWithLabelAndLoopSub,
4522}
4523
4524#[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_237 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_238 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_237));
suggestions.push((__binding_1, __code_238));
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)]
4525#[multipart_suggestion("wrap this expression in parentheses", applicability = "machine-applicable")]
4526pub(crate) struct BreakWithLabelAndLoopSub {
4527 #[suggestion_part(code = "(")]
4528 pub left: Span,
4529 #[suggestion_part(code = ")")]
4530 pub right: Span,
4531}
4532
4533#[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_239 =
[::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_239, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4534#[diag("prefix `'r` is reserved")]
4535pub(crate) struct RawPrefix {
4536 #[label("reserved prefix")]
4537 pub label: Span,
4538 #[suggestion(
4539 "insert whitespace here to avoid this being parsed as a prefix in Rust 2021",
4540 code = " ",
4541 applicability = "machine-applicable"
4542 )]
4543 pub suggestion: Span,
4544}
4545
4546#[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)]
4547#[diag("unicode codepoint changing visible direction of text present in comment")]
4548#[note(
4549 "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"
4550)]
4551pub(crate) struct UnicodeTextFlow {
4552 #[label(
4553 "{$num_codepoints ->
4554 [1] this comment contains an invisible unicode text flow control codepoint
4555 *[other] this comment contains invisible unicode text flow control codepoints
4556 }"
4557 )]
4558 pub comment_span: Span,
4559 #[subdiagnostic]
4560 pub characters: Vec<UnicodeCharNoteSub>,
4561 #[subdiagnostic]
4562 pub suggestions: Option<UnicodeTextFlowSuggestion>,
4563
4564 pub num_codepoints: usize,
4565}
4566
4567#[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)]
4568#[label("{$c_debug}")]
4569pub(crate) struct UnicodeCharNoteSub {
4570 #[primary_span]
4571 pub span: Span,
4572 pub c_debug: String,
4573}
4574
4575#[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_240 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_240.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)]
4576#[multipart_suggestion(
4577 "if their presence wasn't intentional, you can remove them",
4578 applicability = "machine-applicable",
4579 style = "hidden"
4580)]
4581pub(crate) struct UnicodeTextFlowSuggestion {
4582 #[suggestion_part(code = "")]
4583 pub spans: Vec<Span>,
4584}
4585
4586#[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_241 =
[::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_241, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4587#[diag("prefix `{$prefix}` is unknown")]
4588pub(crate) struct ReservedPrefix {
4589 #[label("unknown prefix")]
4590 pub label: Span,
4591 #[suggestion(
4592 "insert whitespace here to avoid this being parsed as a prefix in Rust 2021",
4593 code = " ",
4594 applicability = "machine-applicable"
4595 )]
4596 pub suggestion: Span,
4597
4598 pub prefix: String,
4599}
4600
4601#[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_242 =
[::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_242, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4602#[diag("will be parsed as a guarded string in Rust 2024")]
4603pub(crate) struct ReservedStringLint {
4604 #[suggestion(
4605 "insert whitespace here to avoid this being parsed as a guarded string in Rust 2024",
4606 code = " ",
4607 applicability = "machine-applicable"
4608 )]
4609 pub suggestion: Span,
4610}
4611
4612#[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_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 forbidden token in Rust 2024")),
__code_243, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4613#[diag("reserved token in Rust 2024")]
4614pub(crate) struct ReservedMultihashLint {
4615 #[suggestion(
4616 "insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024",
4617 code = " ",
4618 applicability = "machine-applicable"
4619 )]
4620 pub suggestion: Span,
4621}