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