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 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_102 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_103 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_102));
suggestions.push((__binding_1, __code_103));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("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)]
1716#[multipart_suggestion(
1717 "surround the type parameters with angle brackets",
1718 applicability = "machine-applicable"
1719)]
1720pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
1721 #[suggestion_part(code = "<")]
1722 pub left: Span,
1723 #[suggestion_part(code = ">")]
1724 pub right: Span,
1725}
1726
1727#[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_104 =
[::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_104, 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)]
1728#[diag("comparison operators cannot be chained")]
1729pub(crate) struct ComparisonOperatorsCannotBeChained {
1730 #[primary_span]
1731 pub span: Vec<Span>,
1732 #[suggestion(
1733 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
1734 style = "verbose",
1735 code = "::",
1736 applicability = "maybe-incorrect"
1737 )]
1738 pub suggest_turbofish: Option<Span>,
1739 #[help("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")]
1740 #[help("or use `(...)` if you meant to specify fn arguments")]
1741 pub help_turbofish: bool,
1742 #[subdiagnostic]
1743 pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
1744}
1745
1746#[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_105 =
[::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_105, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
ComparisonOperatorsCannotBeChainedSugg::Parenthesize {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_106 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_107 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_106));
suggestions.push((__binding_1, __code_107));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthesize the comparison")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1747pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
1748 #[suggestion(
1749 "split the comparison into two",
1750 style = "verbose",
1751 code = " && {middle_term}",
1752 applicability = "maybe-incorrect"
1753 )]
1754 SplitComparison {
1755 #[primary_span]
1756 span: Span,
1757 middle_term: String,
1758 },
1759 #[multipart_suggestion("parenthesize the comparison", applicability = "maybe-incorrect")]
1760 Parenthesize {
1761 #[suggestion_part(code = "(")]
1762 left: Span,
1763 #[suggestion_part(code = ")")]
1764 right: Span,
1765 },
1766}
1767
1768#[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)]
1769#[diag("invalid `?` in type")]
1770pub(crate) struct QuestionMarkInType {
1771 #[primary_span]
1772 #[label("`?` is only allowed on expressions, not types")]
1773 pub span: Span,
1774 #[subdiagnostic]
1775 pub sugg: QuestionMarkInTypeSugg,
1776}
1777
1778#[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_108 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Option<"))
});
let __code_109 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_108));
suggestions.push((__binding_1, __code_109));
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)]
1779#[multipart_suggestion(
1780 "if you meant to express that the type might not contain a value, use the `Option` wrapper type",
1781 applicability = "machine-applicable"
1782)]
1783pub(crate) struct QuestionMarkInTypeSugg {
1784 #[suggestion_part(code = "Option<")]
1785 pub left: Span,
1786 #[suggestion_part(code = ">")]
1787 pub right: Span,
1788}
1789
1790#[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)]
1791#[diag("unexpected parentheses surrounding `for` loop head")]
1792pub(crate) struct ParenthesesInForHead {
1793 #[primary_span]
1794 pub span: Vec<Span>,
1795 #[subdiagnostic]
1796 pub sugg: ParenthesesInForHeadSugg,
1797}
1798
1799#[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_110 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_111 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
suggestions.push((__binding_0, __code_110));
suggestions.push((__binding_1, __code_111));
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)]
1800#[multipart_suggestion("remove parentheses in `for` loop", applicability = "machine-applicable")]
1801pub(crate) struct ParenthesesInForHeadSugg {
1802 #[suggestion_part(code = " ")]
1803 pub left: Span,
1804 #[suggestion_part(code = " ")]
1805 pub right: Span,
1806}
1807
1808#[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)]
1809#[diag("unexpected parentheses surrounding `match` arm pattern")]
1810pub(crate) struct ParenthesesInMatchPat {
1811 #[primary_span]
1812 pub span: Vec<Span>,
1813 #[subdiagnostic]
1814 pub sugg: ParenthesesInMatchPatSugg,
1815}
1816
1817#[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_112 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_113 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_112));
suggestions.push((__binding_1, __code_113));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove parentheses surrounding the pattern")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1818#[multipart_suggestion(
1819 "remove parentheses surrounding the pattern",
1820 applicability = "machine-applicable"
1821)]
1822pub(crate) struct ParenthesesInMatchPatSugg {
1823 #[suggestion_part(code = "")]
1824 pub left: Span,
1825 #[suggestion_part(code = "")]
1826 pub right: Span,
1827}
1828
1829#[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_114 =
[::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_114, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1830#[diag("patterns aren't allowed in {$target}", code = E0642)]
1831pub(crate) struct PatternMethodParamWithoutBody {
1832 #[primary_span]
1833 #[suggestion(
1834 "give this argument a name or use an underscore to ignore it",
1835 code = "_",
1836 applicability = "machine-applicable",
1837 style = "verbose"
1838 )]
1839 pub span: Span,
1840 pub target: &'static str,
1841}
1842
1843#[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)]
1844#[diag("unexpected `self` parameter in function")]
1845pub(crate) struct SelfParamNotFirst {
1846 #[primary_span]
1847 #[label("must be the first parameter of an associated function")]
1848 pub span: Span,
1849}
1850
1851#[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)]
1852#[diag("expressions must be enclosed in braces to be used as const generic arguments")]
1853pub(crate) struct ConstGenericWithoutBraces {
1854 #[primary_span]
1855 pub span: Span,
1856 #[subdiagnostic]
1857 pub sugg: ConstGenericWithoutBracesSugg,
1858}
1859
1860#[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_115 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_116 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_115));
suggestions.push((__binding_1, __code_116));
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)]
1861#[multipart_suggestion(
1862 "enclose the `const` expression in braces",
1863 applicability = "machine-applicable"
1864)]
1865pub(crate) struct ConstGenericWithoutBracesSugg {
1866 #[suggestion_part(code = "{{ ")]
1867 pub left: Span,
1868 #[suggestion_part(code = " }}")]
1869 pub right: Span,
1870}
1871
1872#[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)]
1873#[diag("unexpected `const` parameter declaration")]
1874pub(crate) struct UnexpectedConstParamDeclaration {
1875 #[primary_span]
1876 #[label("expected a `const` expression, not a parameter declaration")]
1877 pub span: Span,
1878 #[subdiagnostic]
1879 pub sugg: Option<UnexpectedConstParamDeclarationSugg>,
1880}
1881
1882#[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_117 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", __binding_2))
});
let __code_118 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_117));
suggestions.push((__binding_1, __code_118));
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_119 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_120 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_119));
suggestions.push((__binding_1, __code_120));
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)]
1883pub(crate) enum UnexpectedConstParamDeclarationSugg {
1884 #[multipart_suggestion(
1885 "`const` parameters must be declared for the `impl`",
1886 applicability = "machine-applicable"
1887 )]
1888 AddParam {
1889 #[suggestion_part(code = "<{snippet}>")]
1890 impl_generics: Span,
1891 #[suggestion_part(code = "{ident}")]
1892 incorrect_decl: Span,
1893 snippet: String,
1894 ident: String,
1895 },
1896 #[multipart_suggestion(
1897 "`const` parameters must be declared for the `impl`",
1898 applicability = "machine-applicable"
1899 )]
1900 AppendParam {
1901 #[suggestion_part(code = ", {snippet}")]
1902 impl_generics_end: Span,
1903 #[suggestion_part(code = "{ident}")]
1904 incorrect_decl: Span,
1905 snippet: String,
1906 ident: String,
1907 },
1908}
1909
1910#[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_121 =
[::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_121, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1911#[diag("expected lifetime, type, or constant, found keyword `const`")]
1912pub(crate) struct UnexpectedConstInGenericParam {
1913 #[primary_span]
1914 pub span: Span,
1915 #[suggestion(
1916 "the `const` keyword is only needed in the definition of the type",
1917 style = "verbose",
1918 code = "",
1919 applicability = "maybe-incorrect"
1920 )]
1921 pub to_remove: Option<Span>,
1922}
1923
1924#[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_122 =
[::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_122, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1925#[diag("the order of `move` and `async` is incorrect")]
1926pub(crate) struct AsyncMoveOrderIncorrect {
1927 #[primary_span]
1928 #[suggestion(
1929 "try switching the order",
1930 style = "verbose",
1931 code = "async move",
1932 applicability = "maybe-incorrect"
1933 )]
1934 pub span: Span,
1935}
1936
1937#[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_123 =
[::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_123, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1938#[diag("the order of `use` and `async` is incorrect")]
1939pub(crate) struct AsyncUseOrderIncorrect {
1940 #[primary_span]
1941 #[suggestion(
1942 "try switching the order",
1943 style = "verbose",
1944 code = "async use",
1945 applicability = "maybe-incorrect"
1946 )]
1947 pub span: Span,
1948}
1949
1950#[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_124 =
[::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_124, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1951#[diag("expected `:` followed by trait or lifetime")]
1952pub(crate) struct DoubleColonInBound {
1953 #[primary_span]
1954 pub span: Span,
1955 #[suggestion(
1956 "use single colon",
1957 code = ": ",
1958 applicability = "machine-applicable",
1959 style = "verbose"
1960 )]
1961 pub between: Span,
1962}
1963
1964#[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)]
1965#[diag("function pointer types may not have generic parameters")]
1966pub(crate) struct FnPtrWithGenerics {
1967 #[primary_span]
1968 pub span: Span,
1969 #[subdiagnostic]
1970 pub sugg: Option<FnPtrWithGenericsSugg>,
1971}
1972
1973#[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_125 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {0}", __binding_1))
});
let __code_126 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_125));
suggestions.push((__binding_2, __code_126));
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)]
1974#[multipart_suggestion(
1975 "place the return type after the function parameters",
1976 style = "verbose",
1977 applicability = "maybe-incorrect"
1978)]
1979pub(crate) struct MisplacedReturnType {
1980 #[suggestion_part(code = " {snippet}")]
1981 pub fn_params_end: Span,
1982 pub snippet: String,
1983 #[suggestion_part(code = "")]
1984 pub ret_ty_span: Span,
1985}
1986
1987#[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_127 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_128 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_127));
suggestions.push((__binding_2, __code_128));
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)]
1988#[multipart_suggestion(
1989 "consider moving the lifetime {$arity ->
1990 [one] parameter
1991 *[other] parameters
1992 } to {$for_param_list_exists ->
1993 [true] the
1994 *[false] a
1995 } `for` parameter list",
1996 applicability = "maybe-incorrect"
1997)]
1998pub(crate) struct FnPtrWithGenericsSugg {
1999 #[suggestion_part(code = "{snippet}")]
2000 pub left: Span,
2001 pub snippet: String,
2002 #[suggestion_part(code = "")]
2003 pub right: Span,
2004 pub arity: usize,
2005 pub for_param_list_exists: bool,
2006}
2007
2008pub(crate) struct FnTraitMissingParen {
2009 pub span: Span,
2010}
2011
2012impl Subdiagnostic for FnTraitMissingParen {
2013 fn add_to_diag(self, diag: &mut Diag<'_>) {
2014 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"));
2015 diag.span_suggestion_short(
2016 self.span.shrink_to_hi(),
2017 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses"))msg!("try adding parentheses"),
2018 "()",
2019 Applicability::MachineApplicable,
2020 );
2021 }
2022}
2023
2024#[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_129 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `if`")),
__code_129, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2025#[diag("unexpected `if` in the condition expression")]
2026pub(crate) struct UnexpectedIfWithIf(
2027 #[primary_span]
2028 #[suggestion(
2029 "remove the `if`",
2030 applicability = "machine-applicable",
2031 code = " ",
2032 style = "verbose"
2033 )]
2034 pub Span,
2035);
2036
2037#[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_130 =
[::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_130, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2038#[diag("you might have meant to write `impl` instead of `fn`")]
2039pub(crate) struct FnTypoWithImpl {
2040 #[primary_span]
2041 #[suggestion(
2042 "replace `fn` with `impl` here",
2043 applicability = "maybe-incorrect",
2044 code = "impl",
2045 style = "verbose"
2046 )]
2047 pub fn_span: Span,
2048}
2049
2050#[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_131 =
[::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_131, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2051#[diag("expected identifier, found keyword `fn`")]
2052pub(crate) struct ExpectedFnPathFoundFnKeyword {
2053 #[primary_span]
2054 #[suggestion(
2055 "use `Fn` to refer to the trait",
2056 applicability = "machine-applicable",
2057 code = "Fn",
2058 style = "verbose"
2059 )]
2060 pub fn_token_span: Span,
2061}
2062
2063#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PathFoundCVariadicParams {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PathFoundCVariadicParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support c_variadic parameters")));
let __code_132 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `...`")),
__code_132, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2064#[diag("`Trait(...)` syntax does not support c_variadic parameters")]
2065pub(crate) struct PathFoundCVariadicParams {
2066 #[primary_span]
2067 #[suggestion("remove the `...`", applicability = "machine-applicable", code = "")]
2068 pub span: Span,
2069}
2070
2071#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PathFoundAttributeInParams {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PathFoundAttributeInParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support attributes in parameters")));
let __code_133 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attributes")),
__code_133, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2072#[diag("`Trait(...)` syntax does not support attributes in parameters")]
2073pub(crate) struct PathFoundAttributeInParams {
2074 #[primary_span]
2075 #[suggestion("remove the attributes", applicability = "machine-applicable", code = "")]
2076 pub span: Span,
2077}
2078
2079#[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_134 =
[::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_134, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2080#[diag("path separator must be a double colon")]
2081pub(crate) struct PathSingleColon {
2082 #[primary_span]
2083 pub span: Span,
2084
2085 #[suggestion(
2086 "use a double colon instead",
2087 applicability = "machine-applicable",
2088 code = ":",
2089 style = "verbose"
2090 )]
2091 pub suggestion: Span,
2092}
2093
2094#[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_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 double colon instead")),
__code_135, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2095#[diag("path separator must be a double colon")]
2096pub(crate) struct PathTripleColon {
2097 #[primary_span]
2098 #[suggestion(
2099 "use a double colon instead",
2100 applicability = "maybe-incorrect",
2101 code = "",
2102 style = "verbose"
2103 )]
2104 pub span: Span,
2105}
2106
2107#[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_136 =
[::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_136, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2108#[diag("statements are terminated with a semicolon")]
2109pub(crate) struct ColonAsSemi {
2110 #[primary_span]
2111 #[suggestion(
2112 "use a semicolon instead",
2113 applicability = "machine-applicable",
2114 code = ";",
2115 style = "verbose"
2116 )]
2117 pub span: Span,
2118}
2119
2120#[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)]
2121#[diag("where clauses are not allowed before tuple struct bodies")]
2122pub(crate) struct WhereClauseBeforeTupleStructBody {
2123 #[primary_span]
2124 #[label("unexpected where clause")]
2125 pub span: Span,
2126 #[label("while parsing this tuple struct")]
2127 pub name: Span,
2128 #[label("the struct body")]
2129 pub body: Span,
2130 #[subdiagnostic]
2131 pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
2132}
2133
2134#[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_137 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_138 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_137));
suggestions.push((__binding_2, __code_138));
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)]
2135#[multipart_suggestion(
2136 "move the body before the where clause",
2137 applicability = "machine-applicable"
2138)]
2139pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
2140 #[suggestion_part(code = "{snippet}")]
2141 pub left: Span,
2142 pub snippet: String,
2143 #[suggestion_part(code = "")]
2144 pub right: Span,
2145}
2146
2147#[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)]
2148#[diag("`async fn` is not permitted in Rust 2015", code = E0670)]
2149pub(crate) struct AsyncFnIn2015 {
2150 #[primary_span]
2151 #[label("to use `async fn`, switch to Rust 2018 or later")]
2152 pub span: Span,
2153 #[subdiagnostic]
2154 pub help: HelpUseLatestEdition,
2155}
2156
2157#[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)]
2158#[label("`async` blocks are only allowed in Rust 2018 or later")]
2159pub(crate) struct AsyncBlockIn2015 {
2160 #[primary_span]
2161 pub span: Span,
2162}
2163
2164#[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)]
2165#[diag("`async move` blocks are only allowed in Rust 2018 or later")]
2166pub(crate) struct AsyncMoveBlockIn2015 {
2167 #[primary_span]
2168 pub span: Span,
2169}
2170
2171#[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)]
2172#[diag("`async use` blocks are only allowed in Rust 2018 or later")]
2173pub(crate) struct AsyncUseBlockIn2015 {
2174 #[primary_span]
2175 pub span: Span,
2176}
2177
2178#[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)]
2179#[diag("`async` trait bounds are only allowed in Rust 2018 or later")]
2180pub(crate) struct AsyncBoundModifierIn2015 {
2181 #[primary_span]
2182 pub span: Span,
2183 #[subdiagnostic]
2184 pub help: HelpUseLatestEdition,
2185}
2186
2187#[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)]
2188#[diag("let chains are only allowed in Rust 2024 or later")]
2189pub(crate) struct LetChainPre2024 {
2190 #[primary_span]
2191 pub span: Span,
2192}
2193
2194#[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)]
2195#[diag("cannot pass `self` by raw pointer")]
2196pub(crate) struct SelfArgumentPointer {
2197 #[primary_span]
2198 #[label("cannot pass `self` by raw pointer")]
2199 pub span: Span,
2200}
2201
2202#[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)]
2203#[diag("unexpected token: {$actual}")]
2204pub(crate) struct UnexpectedTokenAfterDot {
2205 #[primary_span]
2206 pub span: Span,
2207 pub actual: String,
2208}
2209
2210#[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)]
2211#[diag("visibility `{$vis}` is not followed by an item")]
2212#[help("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")]
2213pub(crate) struct VisibilityNotFollowedByItem {
2214 #[primary_span]
2215 #[label("the visibility")]
2216 pub span: Span,
2217 pub vis: String,
2218}
2219
2220#[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)]
2221#[diag("`default` is not followed by an item")]
2222#[note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")]
2223pub(crate) struct DefaultNotFollowedByItem {
2224 #[primary_span]
2225 #[label("the `default` qualifier")]
2226 pub span: Span,
2227}
2228
2229#[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)]
2230#[diag("`final` is not followed by an item")]
2231#[note("only associated functions in traits may be prefixed by `final`")]
2232pub(crate) struct FinalNotFollowedByItem {
2233 #[primary_span]
2234 #[label("the `final` qualifier")]
2235 pub span: Span,
2236}
2237
2238#[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_139 =
[::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_139, 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_140 =
[::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_140, 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_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 function")),
__code_141, 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_142 =
[::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_142, 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)]
2239pub(crate) enum MissingKeywordForItemDefinition {
2240 #[diag("missing `enum` for enum definition")]
2241 Enum {
2242 #[primary_span]
2243 span: Span,
2244 #[suggestion(
2245 "add `enum` here to parse `{$ident}` as an enum",
2246 style = "verbose",
2247 applicability = "maybe-incorrect",
2248 code = "enum "
2249 )]
2250 insert_span: Span,
2251 ident: Ident,
2252 },
2253 #[diag("missing `enum` or `struct` for enum or struct definition")]
2254 EnumOrStruct {
2255 #[primary_span]
2256 span: Span,
2257 },
2258 #[diag("missing `struct` for struct definition")]
2259 Struct {
2260 #[primary_span]
2261 span: Span,
2262 #[suggestion(
2263 "add `struct` here to parse `{$ident}` as a struct",
2264 style = "verbose",
2265 applicability = "maybe-incorrect",
2266 code = "struct "
2267 )]
2268 insert_span: Span,
2269 ident: Ident,
2270 },
2271 #[diag("missing `fn` for function definition")]
2272 Function {
2273 #[primary_span]
2274 span: Span,
2275 #[suggestion(
2276 "add `fn` here to parse `{$ident}` as a function",
2277 style = "verbose",
2278 applicability = "maybe-incorrect",
2279 code = "fn "
2280 )]
2281 insert_span: Span,
2282 ident: Ident,
2283 },
2284 #[diag("missing `fn` for method definition")]
2285 Method {
2286 #[primary_span]
2287 span: Span,
2288 #[suggestion(
2289 "add `fn` here to parse `{$ident}` as a method",
2290 style = "verbose",
2291 applicability = "maybe-incorrect",
2292 code = "fn "
2293 )]
2294 insert_span: Span,
2295 ident: Ident,
2296 },
2297 #[diag("missing `fn` or `struct` for function or struct definition")]
2298 Ambiguous {
2299 #[primary_span]
2300 span: Span,
2301 #[subdiagnostic]
2302 subdiag: Option<AmbiguousMissingKwForItemSub>,
2303 },
2304}
2305
2306#[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_143 =
[::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_143, 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)]
2307pub(crate) enum AmbiguousMissingKwForItemSub {
2308 #[suggestion(
2309 "if you meant to call a macro, try",
2310 applicability = "maybe-incorrect",
2311 code = "{snippet}!",
2312 style = "verbose"
2313 )]
2314 SuggestMacro {
2315 #[primary_span]
2316 span: Span,
2317 snippet: String,
2318 },
2319 #[help(
2320 "if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier"
2321 )]
2322 HelpMacro,
2323}
2324
2325#[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_144 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("()"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a parameter list")),
__code_144, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2326#[diag("missing parameters for function definition")]
2327pub(crate) struct MissingFnParams {
2328 #[primary_span]
2329 #[suggestion(
2330 "add a parameter list",
2331 code = "()",
2332 applicability = "machine-applicable",
2333 style = "verbose"
2334 )]
2335 pub span: Span,
2336}
2337
2338#[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_145 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove invalid path separator")),
__code_145, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2339#[diag("invalid path separator in function definition")]
2340pub(crate) struct InvalidPathSepInFnDefinition {
2341 #[primary_span]
2342 #[suggestion(
2343 "remove invalid path separator",
2344 code = "",
2345 applicability = "machine-applicable",
2346 style = "verbose"
2347 )]
2348 pub span: Span,
2349}
2350
2351#[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_146 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" Trait "))
})].into_iter();
let __code_147 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a trait here")),
__code_146, 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_147, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2352#[diag("missing trait in a trait impl")]
2353pub(crate) struct MissingTraitInTraitImpl {
2354 #[primary_span]
2355 #[suggestion(
2356 "add a trait here",
2357 code = " Trait ",
2358 applicability = "has-placeholders",
2359 style = "verbose"
2360 )]
2361 pub span: Span,
2362 #[suggestion(
2363 "for an inherent impl, drop this `for`",
2364 code = "",
2365 applicability = "maybe-incorrect",
2366 style = "verbose"
2367 )]
2368 pub for_span: Span,
2369}
2370
2371#[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_148 =
[::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_148, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2372#[diag("missing `for` in a trait impl")]
2373pub(crate) struct MissingForInTraitImpl {
2374 #[primary_span]
2375 #[suggestion(
2376 "add `for` here",
2377 style = "verbose",
2378 code = " for ",
2379 applicability = "machine-applicable"
2380 )]
2381 pub span: Span,
2382}
2383
2384#[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)]
2385#[diag("expected a trait, found type")]
2386pub(crate) struct ExpectedTraitInTraitImplFoundType {
2387 #[primary_span]
2388 pub span: Span,
2389}
2390
2391#[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_149 =
[::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_149, 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)]
2392#[diag("unexpected `impl` keyword")]
2393pub(crate) struct ExtraImplKeywordInTraitImpl {
2394 #[primary_span]
2395 #[suggestion(
2396 "remove the extra `impl`",
2397 code = "",
2398 applicability = "maybe-incorrect",
2399 style = "short"
2400 )]
2401 pub extra_impl_kw: Span,
2402 #[note("this is parsed as an `impl Trait` type, but a trait is expected at this position")]
2403 pub impl_trait_span: Span,
2404}
2405
2406#[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)]
2407#[diag("bounds are not allowed on trait aliases")]
2408pub(crate) struct BoundsNotAllowedOnTraitAliases {
2409 #[primary_span]
2410 pub span: Span,
2411}
2412
2413#[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)]
2414#[diag("trait aliases cannot be `auto`")]
2415pub(crate) struct TraitAliasCannotBeAuto {
2416 #[primary_span]
2417 #[label("trait aliases cannot be `auto`")]
2418 pub span: Span,
2419}
2420
2421#[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)]
2422#[diag("trait aliases cannot be `unsafe`")]
2423pub(crate) struct TraitAliasCannotBeUnsafe {
2424 #[primary_span]
2425 #[label("trait aliases cannot be `unsafe`")]
2426 pub span: Span,
2427}
2428
2429#[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)]
2430#[diag("trait aliases cannot be `impl`-restricted")]
2431pub(crate) struct TraitAliasCannotBeImplRestricted {
2432 #[primary_span]
2433 #[label("trait aliases cannot be `impl`-restricted")]
2434 pub span: Span,
2435}
2436
2437#[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)]
2438#[diag("associated `static` items are not allowed")]
2439pub(crate) struct AssociatedStaticItemNotAllowed {
2440 #[primary_span]
2441 pub span: Span,
2442}
2443
2444#[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)]
2445pub(crate) enum FieldNotAllowedInTraitSugg {
2446 #[help("consider using a method instead: `fn {$ident}(&self) -> {$ty};`")]
2447 Method { ident: String, ty: String },
2448 #[note("`self` can only appear as a method receiver; consider `fn method(self: {$ty})`")]
2449 SelfReceiver { ty: String },
2450}
2451
2452#[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)]
2453#[diag("fields are not allowed in trait definitions")]
2454pub(crate) struct FieldNotAllowedInTrait {
2455 #[primary_span]
2456 pub span: Span,
2457 #[subdiagnostic]
2458 pub sugg: FieldNotAllowedInTraitSugg,
2459}
2460
2461#[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)]
2462#[diag("crate name using dashes are not valid in `extern crate` statements")]
2463pub(crate) struct ExternCrateNameWithDashes {
2464 #[primary_span]
2465 #[label("dash-separated idents are not valid")]
2466 pub span: Span,
2467 #[subdiagnostic]
2468 pub sugg: ExternCrateNameWithDashesSugg,
2469}
2470
2471#[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_150 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_150.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)]
2472#[multipart_suggestion(
2473 "if the original crate name uses dashes you need to use underscores in the code",
2474 applicability = "machine-applicable"
2475)]
2476pub(crate) struct ExternCrateNameWithDashesSugg {
2477 #[suggestion_part(code = "_")]
2478 pub dashes: Vec<Span>,
2479}
2480
2481#[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_151 =
[::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_151, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
2482#[diag("extern items cannot be `const`")]
2483#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
2484pub(crate) struct ExternItemCannotBeConst {
2485 #[primary_span]
2486 pub ident_span: Span,
2487 #[suggestion(
2488 "try using a static value",
2489 code = "static ",
2490 applicability = "machine-applicable",
2491 style = "verbose"
2492 )]
2493 pub const_span: Option<Span>,
2494}
2495
2496#[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_152 =
[::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_152, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2497#[diag("const globals cannot be mutable")]
2498pub(crate) struct ConstGlobalCannotBeMutable {
2499 #[primary_span]
2500 #[label("cannot be mutable")]
2501 pub ident_span: Span,
2502 #[suggestion(
2503 "you might want to declare a static instead",
2504 code = "static",
2505 style = "verbose",
2506 applicability = "maybe-incorrect"
2507 )]
2508 pub const_span: Span,
2509}
2510
2511#[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_153 =
[::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_153, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2512#[diag("missing type for `{$kind}` item")]
2513pub(crate) struct MissingConstType {
2514 #[primary_span]
2515 #[suggestion(
2516 "provide a type for the item",
2517 code = "{colon} <type>",
2518 style = "verbose",
2519 applicability = "has-placeholders"
2520 )]
2521 pub span: Span,
2522
2523 pub kind: &'static str,
2524 pub colon: &'static str,
2525}
2526
2527#[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_154 =
[::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_154, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2528#[diag("`enum` and `struct` are mutually exclusive")]
2529pub(crate) struct EnumStructMutuallyExclusive {
2530 #[primary_span]
2531 #[suggestion(
2532 "replace `enum struct` with",
2533 code = "enum",
2534 style = "verbose",
2535 applicability = "machine-applicable"
2536 )]
2537 pub span: Span,
2538}
2539
2540#[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)]
2541pub(crate) enum UnexpectedTokenAfterStructName {
2542 #[diag(
2543 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`"
2544 )]
2545 ReservedIdentifier {
2546 #[primary_span]
2547 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2548 span: Span,
2549 token: Cow<'static, str>,
2550 },
2551 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")]
2552 Keyword {
2553 #[primary_span]
2554 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2555 span: Span,
2556 token: Cow<'static, str>,
2557 },
2558 #[diag(
2559 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`"
2560 )]
2561 ReservedKeyword {
2562 #[primary_span]
2563 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2564 span: Span,
2565 token: Cow<'static, str>,
2566 },
2567 #[diag(
2568 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`"
2569 )]
2570 DocComment {
2571 #[primary_span]
2572 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2573 span: Span,
2574 token: Cow<'static, str>,
2575 },
2576 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")]
2577 MetaVar {
2578 #[primary_span]
2579 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2580 span: Span,
2581 },
2582 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")]
2583 Other {
2584 #[primary_span]
2585 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2586 span: Span,
2587 token: Cow<'static, str>,
2588 },
2589}
2590
2591impl UnexpectedTokenAfterStructName {
2592 pub(crate) fn new(span: Span, orig_token: Token) -> Self {
2593 let token = pprust::token_to_string(&orig_token);
2594 match TokenDescription::from_token(&orig_token) {
2595 Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
2596 Some(TokenDescription::Keyword) => Self::Keyword { span, token },
2597 Some(TokenDescription::ReservedKeyword) => Self::ReservedKeyword { span, token },
2598 Some(TokenDescription::DocComment) => Self::DocComment { span, token },
2599 Some(TokenDescription::MetaVar(_)) => Self::MetaVar { span },
2600 None => Self::Other { span, token },
2601 }
2602 }
2603}
2604
2605#[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)]
2606#[diag("unexpected keyword `Self` in generic parameters")]
2607#[note("you cannot use `Self` as a generic parameter because it is reserved for associated items")]
2608pub(crate) struct UnexpectedSelfInGenericParameters {
2609 #[primary_span]
2610 pub span: Span,
2611}
2612
2613#[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)]
2614#[diag("unexpected default lifetime parameter")]
2615pub(crate) struct UnexpectedDefaultValueForLifetimeInGenericParameters {
2616 #[primary_span]
2617 #[label("lifetime parameters cannot have default values")]
2618 pub span: Span,
2619}
2620
2621#[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_155 =
[::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_155, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2622#[diag("cannot define duplicate `where` clauses on an item")]
2623pub(crate) struct MultipleWhereClauses {
2624 #[primary_span]
2625 pub span: Span,
2626 #[label("previous `where` clause starts here")]
2627 pub previous: Span,
2628 #[suggestion(
2629 "consider joining the two `where` clauses into one",
2630 style = "verbose",
2631 code = ",",
2632 applicability = "maybe-incorrect"
2633 )]
2634 pub between: Span,
2635}
2636
2637#[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)]
2638pub(crate) enum UnexpectedNonterminal {
2639 #[diag("expected an item keyword")]
2640 Item(#[primary_span] Span),
2641 #[diag("expected a statement")]
2642 Statement(#[primary_span] Span),
2643 #[diag("expected ident, found `{$token}`")]
2644 Ident {
2645 #[primary_span]
2646 span: Span,
2647 token: Cow<'static, str>,
2648 },
2649 #[diag("expected a lifetime, found `{$token}`")]
2650 Lifetime {
2651 #[primary_span]
2652 span: Span,
2653 token: Cow<'static, str>,
2654 },
2655}
2656
2657#[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)]
2658pub(crate) enum TopLevelOrPatternNotAllowed {
2659 #[diag("`let` bindings require top-level or-patterns in parentheses")]
2660 LetBinding {
2661 #[primary_span]
2662 span: Span,
2663 #[subdiagnostic]
2664 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2665 },
2666 #[diag("function parameters require top-level or-patterns in parentheses")]
2667 FunctionParameter {
2668 #[primary_span]
2669 span: Span,
2670 #[subdiagnostic]
2671 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2672 },
2673}
2674
2675#[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)]
2676#[diag("`{$ident}` cannot be a raw identifier")]
2677pub(crate) struct CannotBeRawIdent {
2678 #[primary_span]
2679 pub span: Span,
2680 pub ident: Symbol,
2681}
2682
2683#[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)]
2684#[diag("`{$ident}` cannot be a raw lifetime")]
2685pub(crate) struct CannotBeRawLifetime {
2686 #[primary_span]
2687 pub span: Span,
2688 pub ident: Symbol,
2689}
2690
2691#[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)]
2692#[diag("lifetimes cannot use keyword names")]
2693pub(crate) struct KeywordLifetime {
2694 #[primary_span]
2695 pub span: Span,
2696}
2697
2698#[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)]
2699#[diag("labels cannot use keyword names")]
2700pub(crate) struct KeywordLabel {
2701 #[primary_span]
2702 pub span: Span,
2703}
2704
2705#[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)]
2706#[diag(
2707 "bare CR not allowed in {$block ->
2708 [true] block doc-comment
2709 *[false] doc-comment
2710 }"
2711)]
2712pub(crate) struct CrDocComment {
2713 #[primary_span]
2714 pub span: Span,
2715 pub block: bool,
2716}
2717
2718#[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)]
2719#[diag("no valid digits found for number", code = E0768)]
2720pub(crate) struct NoDigitsLiteral {
2721 #[primary_span]
2722 pub span: Span,
2723}
2724
2725#[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)]
2726#[diag("invalid digit for a base {$base} literal")]
2727pub(crate) struct InvalidDigitLiteral {
2728 #[primary_span]
2729 pub span: Span,
2730 pub base: u32,
2731}
2732
2733#[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)]
2734#[diag("expected at least one digit in exponent")]
2735pub(crate) struct EmptyExponentFloat {
2736 #[primary_span]
2737 pub span: Span,
2738}
2739
2740#[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)]
2741#[diag("{$base} float literal is not supported")]
2742pub(crate) struct FloatLiteralUnsupportedBase {
2743 #[primary_span]
2744 pub span: Span,
2745 pub base: &'static str,
2746}
2747
2748#[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)]
2749#[diag("prefix `{$prefix}` is unknown")]
2750#[note("prefixed identifiers and literals are reserved since Rust 2021")]
2751pub(crate) struct UnknownPrefix<'a> {
2752 #[primary_span]
2753 #[label("unknown prefix")]
2754 pub span: Span,
2755 pub prefix: &'a str,
2756 #[subdiagnostic]
2757 pub sugg: Option<UnknownPrefixSugg>,
2758}
2759
2760#[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)]
2761#[note("macros cannot expand to {$adt_ty} fields")]
2762pub(crate) struct MacroExpandsToAdtField<'a> {
2763 pub adt_ty: &'a str,
2764}
2765
2766#[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_156 =
[::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_156, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::UseCr(__binding_0) => {
let __code_157 =
[::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_157, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::Whitespace(__binding_0) => {
let __code_158 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider inserting whitespace here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_158, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnknownPrefixSugg::MeantStr {
start: __binding_0, end: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_159 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_160 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_159));
suggestions.push((__binding_1, __code_160));
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)]
2767pub(crate) enum UnknownPrefixSugg {
2768 #[suggestion(
2769 "use `br` for a raw byte string",
2770 code = "br",
2771 applicability = "maybe-incorrect",
2772 style = "verbose"
2773 )]
2774 UseBr(#[primary_span] Span),
2775 #[suggestion(
2776 "use `cr` for a raw C-string",
2777 code = "cr",
2778 applicability = "maybe-incorrect",
2779 style = "verbose"
2780 )]
2781 UseCr(#[primary_span] Span),
2782 #[suggestion(
2783 "consider inserting whitespace here",
2784 code = " ",
2785 applicability = "maybe-incorrect",
2786 style = "verbose"
2787 )]
2788 Whitespace(#[primary_span] Span),
2789 #[multipart_suggestion(
2790 "if you meant to write a string literal, use double quotes",
2791 applicability = "maybe-incorrect",
2792 style = "verbose"
2793 )]
2794 MeantStr {
2795 #[suggestion_part(code = "\"")]
2796 start: Span,
2797 #[suggestion_part(code = "\"")]
2798 end: Span,
2799 },
2800}
2801
2802#[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)]
2803#[diag("reserved multi-hash token is forbidden")]
2804#[note("sequences of two or more # are reserved for future use since Rust 2024")]
2805pub(crate) struct ReservedMultihash {
2806 #[primary_span]
2807 pub span: Span,
2808 #[subdiagnostic]
2809 pub sugg: Option<GuardedStringSugg>,
2810}
2811#[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)]
2812#[diag("invalid string literal")]
2813#[note("unprefixed guarded string literals are reserved for future use since Rust 2024")]
2814pub(crate) struct ReservedString {
2815 #[primary_span]
2816 pub span: Span,
2817 #[subdiagnostic]
2818 pub sugg: Option<GuardedStringSugg>,
2819}
2820#[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_161 =
[::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_161, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2821#[suggestion(
2822 "consider inserting whitespace here",
2823 code = " ",
2824 applicability = "maybe-incorrect",
2825 style = "verbose"
2826)]
2827pub(crate) struct GuardedStringSugg(#[primary_span] pub Span);
2828
2829#[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)]
2830#[diag(
2831 "too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}"
2832)]
2833pub(crate) struct TooManyHashes {
2834 #[primary_span]
2835 pub span: Span,
2836 pub num: u32,
2837}
2838
2839#[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)]
2840#[diag("unknown start of token: {$escaped}")]
2841pub(crate) struct UnknownTokenStart {
2842 #[primary_span]
2843 pub span: Span,
2844 pub escaped: String,
2845 #[subdiagnostic]
2846 pub sugg: Option<TokenSubstitution>,
2847 #[help(
2848 "source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
2849 )]
2850 pub null: bool,
2851 #[subdiagnostic]
2852 pub repeat: Option<UnknownTokenRepeat>,
2853 #[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
2854 pub invisible: bool,
2855}
2856
2857#[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_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("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_162, 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_163 =
[::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_163, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2858pub(crate) enum TokenSubstitution {
2859 #[suggestion(
2860 "Unicode characters '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '{$ascii_str}' ({$ascii_name}), but are not",
2861 code = "{suggestion}",
2862 applicability = "maybe-incorrect",
2863 style = "verbose"
2864 )]
2865 DirectedQuotes {
2866 #[primary_span]
2867 span: Span,
2868 suggestion: String,
2869 ascii_str: &'static str,
2870 ascii_name: &'static str,
2871 },
2872 #[suggestion(
2873 "Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not",
2874 code = "{suggestion}",
2875 applicability = "maybe-incorrect",
2876 style = "verbose"
2877 )]
2878 Other {
2879 #[primary_span]
2880 span: Span,
2881 suggestion: String,
2882 ch: String,
2883 u_name: &'static str,
2884 ascii_str: &'static str,
2885 ascii_name: &'static str,
2886 },
2887}
2888
2889#[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)]
2890#[note(
2891 "character appears {$repeats ->
2892 [one] once more
2893 *[other] {$repeats} more times
2894 }"
2895)]
2896pub(crate) struct UnknownTokenRepeat {
2897 pub repeats: usize,
2898}
2899
2900#[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_164 =
[::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_164, 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_165 =
[::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_165, 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_166 =
[::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_166, 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)]
2901pub(crate) enum UnescapeError {
2902 #[diag("invalid unicode character escape")]
2903 #[help(
2904 "unicode escape must {$surrogate ->
2905 [true] not be a surrogate
2906 *[false] be at most 10FFFF
2907 }"
2908 )]
2909 InvalidUnicodeEscape {
2910 #[primary_span]
2911 #[label("invalid escape")]
2912 span: Span,
2913 surrogate: bool,
2914 },
2915 #[diag(
2916 "{$byte ->
2917 [true] byte
2918 *[false] character
2919 } constant must be escaped: `{$escaped_msg}`"
2920 )]
2921 EscapeOnlyChar {
2922 #[primary_span]
2923 span: Span,
2924 #[suggestion(
2925 "escape the character",
2926 applicability = "machine-applicable",
2927 code = "{escaped_sugg}",
2928 style = "verbose"
2929 )]
2930 char_span: Span,
2931 escaped_sugg: String,
2932 escaped_msg: String,
2933 byte: bool,
2934 },
2935 #[diag(
2936 r#"{$double_quotes ->
2937 [true] bare CR not allowed in string, use `\r` instead
2938 *[false] character constant must be escaped: `\r`
2939 }"#
2940 )]
2941 BareCr {
2942 #[primary_span]
2943 #[suggestion(
2944 "escape the character",
2945 applicability = "machine-applicable",
2946 code = "\\r",
2947 style = "verbose"
2948 )]
2949 span: Span,
2950 double_quotes: bool,
2951 },
2952 #[diag("bare CR not allowed in raw string")]
2953 BareCrRawString(#[primary_span] Span),
2954 #[diag("numeric character escape is too short")]
2955 TooShortHexEscape(#[primary_span] Span),
2956 #[diag(
2957 "invalid character in {$is_hex ->
2958 [true] numeric character
2959 *[false] unicode
2960 } escape: `{$ch}`"
2961 )]
2962 InvalidCharInEscape {
2963 #[primary_span]
2964 #[label(
2965 "invalid character in {$is_hex ->
2966 [true] numeric character
2967 *[false] unicode
2968 } escape"
2969 )]
2970 span: Span,
2971 is_hex: bool,
2972 ch: String,
2973 },
2974 #[diag("invalid start of unicode escape: `_`")]
2975 LeadingUnderscoreUnicodeEscape {
2976 #[primary_span]
2977 #[label("invalid start of unicode escape")]
2978 span: Span,
2979 ch: String,
2980 },
2981 #[diag("overlong unicode escape")]
2982 OverlongUnicodeEscape(
2983 #[primary_span]
2984 #[label("must have at most 6 hex digits")]
2985 Span,
2986 ),
2987 #[diag("unterminated unicode escape")]
2988 UnclosedUnicodeEscape(
2989 #[primary_span]
2990 #[label(r#"missing a closing `{"}"}`"#)]
2991 Span,
2992 #[suggestion(
2993 "terminate the unicode escape",
2994 code = "}}",
2995 applicability = "maybe-incorrect",
2996 style = "verbose"
2997 )]
2998 Span,
2999 ),
3000 #[diag("incorrect unicode escape sequence")]
3001 NoBraceInUnicodeEscape {
3002 #[primary_span]
3003 span: Span,
3004 #[label("incorrect unicode escape sequence")]
3005 label: Option<Span>,
3006 #[subdiagnostic]
3007 sub: NoBraceUnicodeSub,
3008 },
3009 #[diag("unicode escape in byte string")]
3010 #[help("unicode escape sequences cannot be used as a byte or in a byte string")]
3011 UnicodeEscapeInByte(
3012 #[primary_span]
3013 #[label("unicode escape in byte string")]
3014 Span,
3015 ),
3016 #[diag("empty unicode escape")]
3017 EmptyUnicodeEscape(
3018 #[primary_span]
3019 #[label("this escape must have at least 1 hex digit")]
3020 Span,
3021 ),
3022 #[diag("empty character literal")]
3023 ZeroChars(
3024 #[primary_span]
3025 #[label("empty character literal")]
3026 Span,
3027 ),
3028 #[diag("invalid trailing slash in literal")]
3029 LoneSlash(
3030 #[primary_span]
3031 #[label("invalid trailing slash in literal")]
3032 Span,
3033 ),
3034 #[diag("whitespace symbol '{$ch}' is not skipped")]
3035 UnskippedWhitespace {
3036 #[primary_span]
3037 span: Span,
3038 #[label("whitespace symbol '{$ch}' is not skipped")]
3039 char_span: Span,
3040 ch: String,
3041 },
3042 #[diag("multiple lines skipped by escaped newline")]
3043 MultipleSkippedLinesWarning(
3044 #[primary_span]
3045 #[label("skipping everything up to and including this point")]
3046 Span,
3047 ),
3048 #[diag("character literal may only contain one codepoint")]
3049 MoreThanOneChar {
3050 #[primary_span]
3051 span: Span,
3052 #[subdiagnostic]
3053 note: Option<MoreThanOneCharNote>,
3054 #[subdiagnostic]
3055 suggestion: MoreThanOneCharSugg,
3056 },
3057 #[diag("null characters in C string literals are not supported")]
3058 NulInCStr {
3059 #[primary_span]
3060 span: Span,
3061 },
3062}
3063
3064#[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_167 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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_167, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::RemoveNonPrinting {
span: __binding_0, ch: __binding_1 } => {
let __code_168 =
[::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_168, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MoreThanOneCharSugg::QuotesFull {
span: __binding_0, is_byte: __binding_1, sugg: __binding_2 }
=> {
let __code_169 =
[::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_169, 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_170 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}\"", __binding_3))
});
let __code_171 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_170));
suggestions.push((__binding_1, __code_171));
let mut sub_args = rustc_errors::DiagArgMap::default();
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)]
3065pub(crate) enum MoreThanOneCharSugg {
3066 #[suggestion(
3067 "consider using the normalized form `{$ch}` of this character",
3068 code = "{normalized}",
3069 applicability = "machine-applicable",
3070 style = "verbose"
3071 )]
3072 NormalizedForm {
3073 #[primary_span]
3074 span: Span,
3075 ch: String,
3076 normalized: String,
3077 },
3078 #[suggestion(
3079 "consider removing the non-printing characters",
3080 code = "{ch}",
3081 applicability = "maybe-incorrect",
3082 style = "verbose"
3083 )]
3084 RemoveNonPrinting {
3085 #[primary_span]
3086 span: Span,
3087 ch: String,
3088 },
3089 #[suggestion(
3090 "if you meant to write a {$is_byte ->
3091 [true] byte string
3092 *[false] string
3093 } literal, use double quotes",
3094 code = "{sugg}",
3095 applicability = "machine-applicable",
3096 style = "verbose"
3097 )]
3098 QuotesFull {
3099 #[primary_span]
3100 span: Span,
3101 is_byte: bool,
3102 sugg: String,
3103 },
3104 #[multipart_suggestion(
3105 "if you meant to write a {$is_byte ->
3106 [true] byte string
3107 *[false] string
3108 } literal, use double quotes",
3109 applicability = "machine-applicable"
3110 )]
3111 Quotes {
3112 #[suggestion_part(code = "{prefix}\"")]
3113 start: Span,
3114 #[suggestion_part(code = "\"")]
3115 end: Span,
3116 is_byte: bool,
3117 prefix: &'static str,
3118 },
3119}
3120
3121#[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)]
3122pub(crate) enum MoreThanOneCharNote {
3123 #[note(
3124 "this `{$chr}` is followed by the combining {$len ->
3125 [one] mark
3126 *[other] marks
3127 } `{$escaped_marks}`"
3128 )]
3129 AllCombining {
3130 #[primary_span]
3131 span: Span,
3132 chr: String,
3133 len: usize,
3134 escaped_marks: String,
3135 },
3136 #[note("there are non-printing characters, the full sequence is `{$escaped}`")]
3137 NonPrinting {
3138 #[primary_span]
3139 span: Span,
3140 escaped: String,
3141 },
3142}
3143
3144#[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_172 =
[::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_172, 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)]
3145pub(crate) enum NoBraceUnicodeSub {
3146 #[suggestion(
3147 "format of unicode escape sequences uses braces",
3148 code = "{suggestion}",
3149 applicability = "maybe-incorrect",
3150 style = "verbose"
3151 )]
3152 Suggestion {
3153 #[primary_span]
3154 span: Span,
3155 suggestion: String,
3156 },
3157 #[help(r#"format of unicode escape sequences is `\u{"{...}"}`"#)]
3158 Help,
3159}
3160
3161#[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_173 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_174 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_173));
suggestions.push((__binding_1, __code_174));
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)]
3162#[multipart_suggestion("wrap the pattern in parentheses", applicability = "machine-applicable")]
3163pub(crate) struct WrapInParens {
3164 #[suggestion_part(code = "(")]
3165 pub(crate) lo: Span,
3166 #[suggestion_part(code = ")")]
3167 pub(crate) hi: Span,
3168}
3169
3170#[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_175 =
[::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_175, 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)]
3171pub(crate) enum TopLevelOrPatternNotAllowedSugg {
3172 #[suggestion(
3173 "remove the `|`",
3174 code = "",
3175 applicability = "machine-applicable",
3176 style = "tool-only"
3177 )]
3178 RemoveLeadingVert {
3179 #[primary_span]
3180 span: Span,
3181 },
3182 WrapInParens {
3183 #[primary_span]
3184 span: Span,
3185 #[subdiagnostic]
3186 suggestion: WrapInParens,
3187 },
3188}
3189
3190#[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_176 =
[::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_176, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3191#[diag("unexpected `||` before function parameter")]
3192#[note("alternatives in or-patterns are separated with `|`, not `||`")]
3193pub(crate) struct UnexpectedVertVertBeforeFunctionParam {
3194 #[primary_span]
3195 #[suggestion(
3196 "remove the `||`",
3197 code = "",
3198 applicability = "machine-applicable",
3199 style = "verbose"
3200 )]
3201 pub span: Span,
3202}
3203
3204#[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_177 =
[::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_177, 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)]
3205#[diag("unexpected token `||` in pattern")]
3206pub(crate) struct UnexpectedVertVertInPattern {
3207 #[primary_span]
3208 #[suggestion(
3209 "use a single `|` to separate multiple alternative patterns",
3210 code = "|",
3211 applicability = "machine-applicable",
3212 style = "verbose"
3213 )]
3214 pub span: Span,
3215 #[label("while parsing this or-pattern starting here")]
3216 pub start: Option<Span>,
3217}
3218
3219#[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_178 =
[::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_178, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
3220#[suggestion(
3221 "a trailing `{$token}` is not allowed in an or-pattern",
3222 code = "",
3223 applicability = "machine-applicable",
3224 style = "tool-only"
3225)]
3226pub(crate) struct TrailingVertSuggestion {
3227 #[primary_span]
3228 pub span: Span,
3229 pub token: Cow<'static, str>,
3230}
3231
3232#[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)]
3233#[diag("a trailing `{$token}` is not allowed in an or-pattern")]
3234pub(crate) struct TrailingVertNotAllowed {
3235 #[primary_span]
3236 pub span: Span,
3237 #[subdiagnostic]
3238 pub suggestion: TrailingVertSuggestion,
3239 #[label("while parsing this or-pattern starting here")]
3240 pub start: Option<Span>,
3241 pub token: Cow<'static, str>,
3242 #[note("alternatives in or-patterns are separated with `|`, not `||`")]
3243 pub note_double_vert: bool,
3244}
3245
3246#[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_179 =
[::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_179, 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)]
3247#[diag("unexpected `...`")]
3248pub(crate) struct DotDotDotRestPattern {
3249 #[primary_span]
3250 #[label("not a valid pattern")]
3251 pub span: Span,
3252 #[suggestion(
3253 "for a rest pattern, use `..` instead of `...`",
3254 style = "verbose",
3255 code = "..",
3256 applicability = "machine-applicable"
3257 )]
3258 pub suggestion: Option<Span>,
3259 #[note(
3260 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3261 )]
3262 pub var_args: Option<()>,
3263}
3264
3265#[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_180 =
[::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_180, 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)]
3266#[diag("pattern on wrong side of `@`")]
3267pub(crate) struct PatternOnWrongSideOfAt {
3268 #[primary_span]
3269 #[suggestion(
3270 "switch the order",
3271 code = "{whole_pat}",
3272 applicability = "machine-applicable",
3273 style = "verbose"
3274 )]
3275 pub whole_span: Span,
3276 pub whole_pat: String,
3277 #[label("pattern on the left, should be on the right")]
3278 pub pattern: Span,
3279 #[label("binding on the right, should be on the left")]
3280 pub binding: Span,
3281}
3282
3283#[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)]
3284#[diag("left-hand side of `@` must be a binding")]
3285#[note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")]
3286pub(crate) struct ExpectedBindingLeftOfAt {
3287 #[primary_span]
3288 pub whole_span: Span,
3289 #[label("interpreted as a pattern, not a binding")]
3290 pub lhs: Span,
3291 #[label("also a pattern")]
3292 pub rhs: Span,
3293}
3294
3295#[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_181 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_182 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_181));
suggestions.push((__binding_1, __code_182));
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)]
3296#[multipart_suggestion(
3297 "add parentheses to clarify the precedence",
3298 applicability = "machine-applicable"
3299)]
3300pub(crate) struct ParenRangeSuggestion {
3301 #[suggestion_part(code = "(")]
3302 pub lo: Span,
3303 #[suggestion_part(code = ")")]
3304 pub hi: Span,
3305}
3306
3307#[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)]
3308#[diag("the range pattern here has ambiguous interpretation")]
3309pub(crate) struct AmbiguousRangePattern {
3310 #[primary_span]
3311 pub span: Span,
3312 #[subdiagnostic]
3313 pub suggestion: ParenRangeSuggestion,
3314}
3315
3316#[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_183 =
[::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_183, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3317#[diag("unexpected lifetime `{$symbol}` in pattern")]
3318pub(crate) struct UnexpectedLifetimeInPattern {
3319 #[primary_span]
3320 pub span: Span,
3321 pub symbol: Symbol,
3322 #[suggestion(
3323 "remove the lifetime",
3324 code = "",
3325 applicability = "machine-applicable",
3326 style = "verbose"
3327 )]
3328 pub suggestion: Span,
3329}
3330
3331#[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_184 =
[::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_184, 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_185 =
[::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_185, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3332pub(crate) enum InvalidMutInPattern {
3333 #[diag("`mut` must be attached to each individual binding")]
3334 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3335 NestedIdent {
3336 #[primary_span]
3337 #[suggestion(
3338 "add `mut` to each binding",
3339 code = "{pat}",
3340 applicability = "machine-applicable",
3341 style = "verbose"
3342 )]
3343 span: Span,
3344 pat: String,
3345 },
3346 #[diag("`mut` must be followed by a named binding")]
3347 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3348 NonIdent {
3349 #[primary_span]
3350 #[suggestion(
3351 "remove the `mut` prefix",
3352 code = "",
3353 applicability = "machine-applicable",
3354 style = "verbose"
3355 )]
3356 span: Span,
3357 },
3358}
3359
3360#[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_186 =
[::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_186, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3361#[diag("`mut` on a binding may not be repeated")]
3362pub(crate) struct RepeatedMutInPattern {
3363 #[primary_span]
3364 pub span: Span,
3365 #[suggestion(
3366 "remove the additional `mut`s",
3367 code = "",
3368 applicability = "machine-applicable",
3369 style = "verbose"
3370 )]
3371 pub suggestion: Span,
3372}
3373
3374#[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_187 =
[::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_187, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3375#[diag("range-to patterns with `...` are not allowed")]
3376pub(crate) struct DotDotDotRangeToPatternNotAllowed {
3377 #[primary_span]
3378 #[suggestion(
3379 "use `..=` instead",
3380 style = "verbose",
3381 code = "..=",
3382 applicability = "machine-applicable"
3383 )]
3384 pub span: Span,
3385}
3386
3387#[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)]
3388#[diag("expected identifier, found enum pattern")]
3389pub(crate) struct EnumPatternInsteadOfIdentifier {
3390 #[primary_span]
3391 pub span: Span,
3392}
3393
3394#[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_188 =
[::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_188, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3395#[diag("`@ ..` is not supported in struct patterns")]
3396pub(crate) struct AtDotDotInStructPattern {
3397 #[primary_span]
3398 pub span: Span,
3399 #[suggestion(
3400 "bind to each field separately or, if you don't need them, just remove `{$ident} @`",
3401 code = "",
3402 style = "verbose",
3403 applicability = "machine-applicable"
3404 )]
3405 pub remove: Span,
3406 pub ident: Ident,
3407}
3408
3409#[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)]
3410#[diag("unexpected `@` in struct pattern")]
3411#[note("struct patterns use `field: pattern` syntax to bind to fields")]
3412#[help(
3413 "consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended"
3414)]
3415pub(crate) struct AtInStructPattern {
3416 #[primary_span]
3417 pub span: Span,
3418}
3419
3420#[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_189 =
[::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_189, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3421#[diag("expected field pattern, found `{$token_str}`")]
3422pub(crate) struct DotDotDotForRemainingFields {
3423 #[primary_span]
3424 #[suggestion(
3425 "to omit remaining fields, use `..`",
3426 code = "..",
3427 style = "verbose",
3428 applicability = "machine-applicable"
3429 )]
3430 pub span: Span,
3431 pub token_str: Cow<'static, str>,
3432}
3433
3434#[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)]
3435#[diag("expected `,`")]
3436pub(crate) struct ExpectedCommaAfterPatternField {
3437 #[primary_span]
3438 pub span: Span,
3439}
3440
3441#[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)]
3442#[diag(
3443 "expected {$is_bound ->
3444 [true] a pattern range bound
3445 *[false] a pattern
3446 }, found an expression"
3447)]
3448#[note(
3449 "arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>"
3450)]
3451pub(crate) struct UnexpectedExpressionInPattern {
3452 #[primary_span]
3454 #[label("not a pattern")]
3455 pub span: Span,
3456 pub is_bound: bool,
3458}
3459
3460#[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_190 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
let __code_191 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if {1} == {0}",
__binding_3, __binding_2))
});
suggestions.push((__binding_0, __code_190));
suggestions.push((__binding_1, __code_191));
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_192 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
let __code_193 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_194 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1} && {2} == {0}",
__binding_5, __binding_3, __binding_4))
});
suggestions.push((__binding_0, __code_192));
if let Some(__binding_1) = __binding_1 {
suggestions.push((__binding_1, __code_193));
}
suggestions.push((__binding_2, __code_194));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider 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_195 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{2}const {1}: /* Type */ = {0};\n",
__binding_3, __binding_2, __binding_4))
});
let __code_196 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_195));
suggestions.push((__binding_1, __code_196));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("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)]
3461pub(crate) enum UnexpectedExpressionInPatternSugg {
3462 #[multipart_suggestion(
3463 "consider moving the expression to a match arm guard",
3464 applicability = "maybe-incorrect"
3465 )]
3466 CreateGuard {
3467 #[suggestion_part(code = "{ident}")]
3469 ident_span: Span,
3470 #[suggestion_part(code = " if {ident} == {expr}")]
3472 pat_hi: Span,
3473 ident: String,
3475 expr: String,
3477 },
3478
3479 #[multipart_suggestion(
3480 "consider moving the expression to the match arm guard",
3481 applicability = "maybe-incorrect"
3482 )]
3483 UpdateGuard {
3484 #[suggestion_part(code = "{ident}")]
3486 ident_span: Span,
3487 #[suggestion_part(code = "(")]
3489 guard_lo: Option<Span>,
3490 #[suggestion_part(code = "{guard_hi_paren} && {ident} == {expr}")]
3492 guard_hi: Span,
3493 guard_hi_paren: &'static str,
3495 ident: String,
3497 expr: String,
3499 },
3500
3501 #[multipart_suggestion(
3502 "consider extracting the expression into a `const`",
3503 applicability = "has-placeholders"
3504 )]
3505 Const {
3506 #[suggestion_part(code = "{indentation}const {ident}: /* Type */ = {expr};\n")]
3508 stmt_lo: Span,
3509 #[suggestion_part(code = "{ident}")]
3511 ident_span: Span,
3512 ident: String,
3514 expr: String,
3516 indentation: String,
3518 },
3519}
3520
3521#[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)]
3522#[diag("range pattern bounds cannot have parentheses")]
3523pub(crate) struct UnexpectedParenInRangePat {
3524 #[primary_span]
3525 pub span: Vec<Span>,
3526 #[subdiagnostic]
3527 pub sugg: UnexpectedParenInRangePatSugg,
3528}
3529
3530#[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_197 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_198 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_197));
suggestions.push((__binding_1, __code_198));
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)]
3531#[multipart_suggestion("remove these parentheses", applicability = "machine-applicable")]
3532pub(crate) struct UnexpectedParenInRangePatSugg {
3533 #[suggestion_part(code = "")]
3534 pub start_span: Span,
3535 #[suggestion_part(code = "")]
3536 pub end_span: Span,
3537}
3538
3539#[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_199 =
[::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_199, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3540#[diag("return types are denoted using `->`")]
3541pub(crate) struct ReturnTypesUseThinArrow {
3542 #[primary_span]
3543 pub span: Span,
3544 #[suggestion(
3545 "use `->` instead",
3546 style = "verbose",
3547 code = " -> ",
3548 applicability = "machine-applicable"
3549 )]
3550 pub suggestion: Span,
3551}
3552
3553#[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_200 =
[::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_200, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3554#[diag("lifetimes must be followed by `+` to form a trait object type")]
3555pub(crate) struct NeedPlusAfterTraitObjectLifetime {
3556 #[primary_span]
3557 pub span: Span,
3558 #[suggestion(
3559 "consider adding a trait bound after the potential lifetime bound",
3560 code = " + /* Trait */",
3561 applicability = "has-placeholders"
3562 )]
3563 pub suggestion: Span,
3564}
3565
3566#[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_201 =
[::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_201, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3567#[diag("expected `mut` or `const` keyword in raw pointer type")]
3568pub(crate) struct ExpectedMutOrConstInRawPointerType {
3569 #[primary_span]
3570 pub span: Span,
3571 #[suggestion(
3572 "add `mut` or `const` here",
3573 code("mut ", "const "),
3574 applicability = "has-placeholders",
3575 style = "verbose"
3576 )]
3577 pub after_asterisk: Span,
3578}
3579
3580#[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_202 =
[::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_202, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
3581#[diag("lifetime must precede `mut`")]
3582pub(crate) struct LifetimeAfterMut {
3583 #[primary_span]
3584 pub span: Span,
3585 #[suggestion(
3586 "place the lifetime before `mut`",
3587 code = "&{snippet} mut",
3588 applicability = "maybe-incorrect",
3589 style = "verbose"
3590 )]
3591 pub suggest_lifetime: Option<Span>,
3592 pub snippet: String,
3593}
3594
3595#[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_203 =
[::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_203, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3596#[diag("`mut` must precede `dyn`")]
3597pub(crate) struct DynAfterMut {
3598 #[primary_span]
3599 #[suggestion(
3600 "place `mut` before `dyn`",
3601 code = "&mut dyn",
3602 applicability = "machine-applicable",
3603 style = "verbose"
3604 )]
3605 pub span: Span,
3606}
3607
3608#[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_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("`const` because of this")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `const` qualifier")),
__code_204, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3609#[diag("an `fn` pointer type cannot be `const`")]
3610#[note("allowed qualifiers are: `unsafe` and `extern`")]
3611pub(crate) struct FnPointerCannotBeConst {
3612 #[primary_span]
3613 #[label("`const` because of this")]
3614 pub span: Span,
3615 #[suggestion(
3616 "remove the `const` qualifier",
3617 code = "",
3618 applicability = "maybe-incorrect",
3619 style = "verbose"
3620 )]
3621 pub suggestion: Span,
3622}
3623
3624#[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_205 =
[::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_205, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3625#[diag("an `fn` pointer type cannot be `async`")]
3626#[note("allowed qualifiers are: `unsafe` and `extern`")]
3627pub(crate) struct FnPointerCannotBeAsync {
3628 #[primary_span]
3629 #[label("`async` because of this")]
3630 pub span: Span,
3631 #[suggestion(
3632 "remove the `async` qualifier",
3633 code = "",
3634 applicability = "maybe-incorrect",
3635 style = "verbose"
3636 )]
3637 pub suggestion: Span,
3638}
3639
3640#[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)]
3641#[diag("C-variadic type `...` may not be nested inside another type", code = E0743)]
3642pub(crate) struct NestedCVariadicType {
3643 #[primary_span]
3644 pub span: Span,
3645}
3646
3647#[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)]
3648#[diag("unexpected `...`")]
3649#[note(
3650 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3651)]
3652pub(crate) struct InvalidCVariadicType {
3653 #[primary_span]
3654 pub span: Span,
3655}
3656
3657#[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_206 =
[::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_206, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3658#[diag("invalid `dyn` keyword")]
3659#[help("`dyn` is only needed at the start of a trait `+`-separated list")]
3660pub(crate) struct InvalidDynKeyword {
3661 #[primary_span]
3662 pub span: Span,
3663 #[suggestion(
3664 "remove this keyword",
3665 code = "",
3666 applicability = "machine-applicable",
3667 style = "verbose"
3668 )]
3669 pub suggestion: Span,
3670}
3671
3672#[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)]
3673pub(crate) enum HelpUseLatestEdition {
3674 #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
3675 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3676 Cargo { edition: Edition },
3677 #[help("pass `--edition {$edition}` to `rustc`")]
3678 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3679 Standalone { edition: Edition },
3680}
3681
3682impl HelpUseLatestEdition {
3683 pub(crate) fn new() -> Self {
3684 let edition = LATEST_STABLE_EDITION;
3685 if rustc_session::utils::was_invoked_from_cargo() {
3686 Self::Cargo { edition }
3687 } else {
3688 Self::Standalone { edition }
3689 }
3690 }
3691}
3692
3693#[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_207 =
[::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_207, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
3694#[diag("`box` patterns have been removed (feature `box_patterns`)")]
3695#[help("enable feature `deref_patterns` instead and...")]
3696pub(crate) struct BoxPatsRemoved {
3697 #[primary_span]
3698 pub span: Span,
3699 #[suggestion(
3700 "...if possible just remove keyword `box`...",
3701 code = "",
3702 applicability = "maybe-incorrect",
3703 style = "verbose"
3704 )]
3705 pub sugg_removal: Span,
3706 #[subdiagnostic]
3707 pub sugg_deref_macro_call: UseDerefMacro,
3708}
3709
3710pub(crate) struct UseDerefMacro {
3711 pub field: Option<(Span, Ident)>,
3712 pub before: Span,
3713 pub after: Span,
3714}
3715
3716impl Subdiagnostic for UseDerefMacro {
3717 fn add_to_diag(self, diag: &mut Diag<'_>) {
3718 let Self { field, before, after } = self;
3719
3720 let mut parts = Vec::new();
3721 if let Some((span, field)) = field {
3722 parts.push((span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}: ", field))
})format!("{field}: ")));
3723 }
3724 parts.push((before, "deref!(".into()));
3725 parts.push((after, ")".into()));
3726 diag.multipart_suggestion(
3727 "...otherwise replace it with an invocation of macro `deref`",
3728 parts,
3729 Applicability::MaybeIncorrect,
3730 );
3731 }
3732}
3733
3734#[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_208 =
[::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_208, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3735#[diag("return type not allowed with return type notation")]
3736pub(crate) struct BadReturnTypeNotationOutput {
3737 #[primary_span]
3738 pub span: Span,
3739 #[suggestion(
3740 "remove the return type",
3741 code = "",
3742 applicability = "maybe-incorrect",
3743 style = "verbose"
3744 )]
3745 pub suggestion: Span,
3746}
3747
3748#[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)]
3749#[diag("bounds on associated types do not belong here")]
3750pub(crate) struct BadAssocTypeBounds {
3751 #[primary_span]
3752 #[label("belongs in `where` clause")]
3753 pub span: Span,
3754}
3755
3756#[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)]
3757#[diag("trailing attribute after generic parameter")]
3758pub(crate) struct AttrAfterGeneric {
3759 #[primary_span]
3760 #[label("attributes must go before parameters")]
3761 pub span: Span,
3762}
3763
3764#[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)]
3765#[diag("attribute without generic parameters")]
3766pub(crate) struct AttrWithoutGenerics {
3767 #[primary_span]
3768 #[label("attributes are only permitted when preceding parameters")]
3769 pub span: Span,
3770}
3771
3772#[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)]
3773#[diag("generic parameters on `where` clauses are reserved for future use")]
3774pub(crate) struct WhereOnGenerics {
3775 #[primary_span]
3776 #[label("currently unsupported")]
3777 pub span: Span,
3778}
3779
3780#[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)]
3781#[diag("unexpected generic arguments in path")]
3782pub(crate) struct GenericsInPath {
3783 #[primary_span]
3784 pub span: Vec<Span>,
3785}
3786
3787#[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_209 =
[::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_209, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3788#[diag("lifetimes are not permitted in this context")]
3789#[help("if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}`")]
3790pub(crate) struct LifetimeInEqConstraint {
3791 #[primary_span]
3792 #[label("lifetime is not allowed here")]
3793 pub span: Span,
3794 pub lifetime: Ident,
3795 #[label("this introduces an associated item binding")]
3796 pub binding_label: Span,
3797 #[suggestion(
3798 "you might have meant to write a bound here",
3799 style = "verbose",
3800 applicability = "maybe-incorrect",
3801 code = ": "
3802 )]
3803 pub colon_sugg: Span,
3804}
3805
3806#[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_210 =
[::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_210, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
3807#[diag("`{$modifier}` may only modify trait bounds, not lifetime bounds")]
3808pub(crate) struct ModifierLifetime {
3809 #[primary_span]
3810 #[suggestion(
3811 "remove the `{$modifier}`",
3812 style = "tool-only",
3813 applicability = "maybe-incorrect",
3814 code = ""
3815 )]
3816 pub span: Span,
3817 pub modifier: &'static str,
3818}
3819
3820#[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)]
3821#[diag("underscore literal suffix is not allowed")]
3822pub(crate) struct UnderscoreLiteralSuffix {
3823 #[primary_span]
3824 pub span: Span,
3825}
3826
3827#[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_211 =
[::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_211, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3828#[diag("expected a label, found an identifier")]
3829pub(crate) struct ExpectedLabelFoundIdent {
3830 #[primary_span]
3831 pub span: Span,
3832 #[suggestion(
3833 "labels start with a tick",
3834 code = "'",
3835 applicability = "machine-applicable",
3836 style = "verbose"
3837 )]
3838 pub start: Span,
3839}
3840
3841#[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)]
3842#[diag("{$article} {$descr} cannot be `default`")]
3843#[note("only associated `fn`, `const`, and `type` items can be `default`")]
3844pub(crate) struct InappropriateDefault {
3845 #[primary_span]
3846 #[label("`default` because of this")]
3847 pub span: Span,
3848 pub article: &'static str,
3849 pub descr: &'static str,
3850}
3851
3852#[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_212 =
[::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_212, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3853#[diag("expected item, found {$token_name}")]
3854pub(crate) struct RecoverImportAsUse {
3855 #[primary_span]
3856 #[suggestion(
3857 "items are imported using the `use` keyword",
3858 code = "use",
3859 applicability = "machine-applicable",
3860 style = "verbose"
3861 )]
3862 pub span: Span,
3863 pub token_name: String,
3864}
3865
3866#[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)]
3867#[diag("{$article} {$descr} cannot be `final`")]
3868#[note("only associated functions in traits can be `final`")]
3869pub(crate) struct InappropriateFinal {
3870 #[primary_span]
3871 #[label("`final` because of this")]
3872 pub span: Span,
3873 pub article: &'static str,
3874 pub descr: &'static str,
3875}
3876
3877#[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_213 =
[::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_213, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3878#[diag("expected `::`, found `:`")]
3879#[note("import paths are delimited using `::`")]
3880pub(crate) struct SingleColonImportPath {
3881 #[primary_span]
3882 #[suggestion(
3883 "use double colon",
3884 code = "::",
3885 applicability = "machine-applicable",
3886 style = "verbose"
3887 )]
3888 pub span: Span,
3889}
3890
3891#[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)]
3892#[diag("{$descr} is not supported in {$ctx}")]
3893pub(crate) struct BadItemKind {
3894 #[primary_span]
3895 pub span: Span,
3896 pub descr: &'static str,
3897 pub ctx: &'static str,
3898 #[help("consider moving the {$descr} out to a nearby module scope")]
3899 pub help: bool,
3900}
3901
3902#[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_214 =
[::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_214, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3903#[diag("expected `!` after `macro_rules`")]
3904pub(crate) struct MacroRulesMissingBang {
3905 #[primary_span]
3906 pub span: Span,
3907 #[suggestion("add a `!`", code = "!", applicability = "machine-applicable", style = "verbose")]
3908 pub hi: Span,
3909}
3910
3911#[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_215 =
[::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_215, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
3912#[diag("macro names aren't followed by a `!`")]
3913pub(crate) struct MacroNameRemoveBang {
3914 #[primary_span]
3915 #[suggestion(
3916 "remove the `!`",
3917 code = "",
3918 applicability = "machine-applicable",
3919 style = "short"
3920 )]
3921 pub span: Span,
3922}
3923
3924#[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_216 =
[::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_216, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3925#[diag("can't qualify macro_rules invocation with `{$vis}`")]
3926pub(crate) struct MacroRulesVisibility<'a> {
3927 #[primary_span]
3928 #[suggestion(
3929 "try exporting the macro",
3930 code = "#[macro_export]",
3931 applicability = "maybe-incorrect",
3932 style = "verbose"
3933 )]
3934 pub span: Span,
3935 pub vis: &'a str,
3936}
3937
3938#[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_217 =
[::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_217, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3939#[diag("can't qualify macro invocation with `pub`")]
3940#[help("try adjusting the macro to put `{$vis}` inside the invocation")]
3941pub(crate) struct MacroInvocationVisibility<'a> {
3942 #[primary_span]
3943 #[suggestion(
3944 "remove the visibility",
3945 code = "",
3946 applicability = "machine-applicable",
3947 style = "verbose"
3948 )]
3949 pub span: Span,
3950 pub vis: &'a str,
3951}
3952
3953#[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_218 =
[::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_218, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3954#[diag("`{$kw_str}` definition cannot be nested inside `{$keyword}`")]
3955pub(crate) struct NestedAdt<'a> {
3956 #[primary_span]
3957 pub span: Span,
3958 #[suggestion(
3959 "consider creating a new `{$kw_str}` definition instead of nesting",
3960 code = "",
3961 applicability = "maybe-incorrect",
3962 style = "verbose"
3963 )]
3964 pub item: Span,
3965 pub keyword: &'a str,
3966 pub kw_str: Cow<'a, str>,
3967}
3968
3969#[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)]
3970#[diag("function body cannot be `= expression;`")]
3971pub(crate) struct FunctionBodyEqualsExpr {
3972 #[primary_span]
3973 pub span: Span,
3974 #[subdiagnostic]
3975 pub sugg: FunctionBodyEqualsExprSugg,
3976}
3977
3978#[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_219 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_220 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_219));
suggestions.push((__binding_1, __code_220));
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)]
3979#[multipart_suggestion(
3980 r#"surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`"#,
3981 applicability = "machine-applicable"
3982)]
3983pub(crate) struct FunctionBodyEqualsExprSugg {
3984 #[suggestion_part(code = "{{")]
3985 pub eq: Span,
3986 #[suggestion_part(code = " }}")]
3987 pub semi: Span,
3988}
3989
3990#[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_221 =
[::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_221, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3991#[diag("expected pattern, found {$descr}")]
3992pub(crate) struct BoxNotPat {
3993 #[primary_span]
3994 pub span: Span,
3995 #[note("`box` is a reserved keyword")]
3996 pub kw: Span,
3997 #[suggestion(
3998 "escape `box` to use it as an identifier",
3999 code = "r#",
4000 applicability = "maybe-incorrect",
4001 style = "verbose"
4002 )]
4003 pub lo: Span,
4004 pub descr: String,
4005}
4006
4007#[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_222 =
[::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_222, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4008#[diag(
4009 "unmatched angle {$plural ->
4010 [true] brackets
4011 *[false] bracket
4012 }"
4013)]
4014pub(crate) struct UnmatchedAngle {
4015 #[primary_span]
4016 #[suggestion(
4017 "remove extra angle {$plural ->
4018 [true] brackets
4019 *[false] bracket
4020 }",
4021 code = "",
4022 applicability = "machine-applicable",
4023 style = "verbose"
4024 )]
4025 pub span: Span,
4026 pub plural: bool,
4027}
4028
4029#[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_223 =
[::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_223, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4030#[diag("expected `+` between lifetime and {$sym}")]
4031pub(crate) struct MissingPlusBounds {
4032 #[primary_span]
4033 pub span: Span,
4034 #[suggestion("add `+`", code = " +", applicability = "maybe-incorrect", style = "verbose")]
4035 pub hi: Span,
4036 pub sym: Symbol,
4037}
4038
4039#[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)]
4040#[diag("incorrect parentheses around trait bounds")]
4041pub(crate) struct IncorrectParensTraitBounds {
4042 #[primary_span]
4043 pub span: Vec<Span>,
4044 #[subdiagnostic]
4045 pub sugg: IncorrectParensTraitBoundsSugg,
4046}
4047
4048#[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_224 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_225 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
suggestions.push((__binding_0, __code_224));
suggestions.push((__binding_1, __code_225));
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)]
4049#[multipart_suggestion("fix the parentheses", applicability = "machine-applicable")]
4050pub(crate) struct IncorrectParensTraitBoundsSugg {
4051 #[suggestion_part(code = " ")]
4052 pub wrong_span: Span,
4053 #[suggestion_part(code = "(")]
4054 pub new_span: Span,
4055}
4056
4057#[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_226 =
[::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_226, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4058#[diag("keyword `{$kw}` is written in the wrong case")]
4059pub(crate) struct KwBadCase<'a> {
4060 #[primary_span]
4061 #[suggestion(
4062 "write it in {$case}",
4063 code = "{kw}",
4064 style = "verbose",
4065 applicability = "machine-applicable"
4066 )]
4067 pub span: Span,
4068 pub kw: &'a str,
4069 pub case: Case,
4070}
4071
4072pub(crate) enum Case {
4073 Upper,
4074 Lower,
4075 Mixed,
4076}
4077
4078impl IntoDiagArg for Case {
4079 fn into_diag_arg(self, path: &mut Option<PathBuf>) -> DiagArgValue {
4080 match self {
4081 Case::Upper => "uppercase",
4082 Case::Lower => "lowercase",
4083 Case::Mixed => "the correct case",
4084 }
4085 .into_diag_arg(path)
4086 }
4087}
4088
4089#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnknownBuiltinConstruct {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnknownBuiltinConstruct {
span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `builtin #` construct `{$name}`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4090#[diag("unknown `builtin #` construct `{$name}`")]
4091pub(crate) struct UnknownBuiltinConstruct {
4092 #[primary_span]
4093 pub span: Span,
4094 pub name: Ident,
4095}
4096
4097#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ExpectedBuiltinIdent
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExpectedBuiltinIdent { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier after `builtin #`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4098#[diag("expected identifier after `builtin #`")]
4099pub(crate) struct ExpectedBuiltinIdent {
4100 #[primary_span]
4101 pub span: Span,
4102}
4103
4104#[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)]
4105#[diag("static items may not have generic parameters")]
4106pub(crate) struct StaticWithGenerics {
4107 #[primary_span]
4108 pub span: Span,
4109}
4110
4111#[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)]
4112#[diag("where clauses are not allowed before const item bodies")]
4113pub(crate) struct WhereClauseBeforeConstBody {
4114 #[primary_span]
4115 #[label("unexpected where clause")]
4116 pub span: Span,
4117 #[label("while parsing this const item")]
4118 pub name: Span,
4119 #[label("the item body")]
4120 pub body: Span,
4121 #[subdiagnostic]
4122 pub sugg: Option<WhereClauseBeforeConstBodySugg>,
4123}
4124
4125#[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_227 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("= {0} ", __binding_1))
});
let __code_228 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_227));
suggestions.push((__binding_2, __code_228));
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)]
4126#[multipart_suggestion(
4127 "move the body before the where clause",
4128 applicability = "machine-applicable"
4129)]
4130pub(crate) struct WhereClauseBeforeConstBodySugg {
4131 #[suggestion_part(code = "= {snippet} ")]
4132 pub left: Span,
4133 pub snippet: String,
4134 #[suggestion_part(code = "")]
4135 pub right: Span,
4136}
4137
4138#[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_229 =
[::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_229, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4139#[diag("generic args in patterns require the turbofish syntax")]
4140pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
4141 #[primary_span]
4142 pub span: Span,
4143 #[suggestion(
4144 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
4145 style = "verbose",
4146 code = "::",
4147 applicability = "maybe-incorrect"
4148 )]
4149 pub suggest_turbofish: Span,
4150}
4151
4152#[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)]
4153#[diag("`for<...>` expected after `{$kw}`, not before")]
4154pub(crate) struct TransposeDynOrImpl<'a> {
4155 #[primary_span]
4156 pub span: Span,
4157 pub kw: &'a str,
4158 #[subdiagnostic]
4159 pub sugg: TransposeDynOrImplSugg<'a>,
4160}
4161
4162#[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_230 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_231 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_2))
});
suggestions.push((__binding_0, __code_230));
suggestions.push((__binding_1, __code_231));
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)]
4163#[multipart_suggestion("move `{$kw}` before the `for<...>`", applicability = "machine-applicable")]
4164pub(crate) struct TransposeDynOrImplSugg<'a> {
4165 #[suggestion_part(code = "")]
4166 pub removal_span: Span,
4167 #[suggestion_part(code = "{kw} ")]
4168 pub insertion_span: Span,
4169 pub kw: &'a str,
4170}
4171
4172#[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)]
4173#[diag("array indexing not supported in offset_of")]
4174pub(crate) struct ArrayIndexInOffsetOf(#[primary_span] pub Span);
4175
4176#[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)]
4177#[diag("offset_of expects dot-separated field and variant names")]
4178pub(crate) struct InvalidOffsetOf(#[primary_span] pub Span);
4179
4180#[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)]
4181#[diag("`async` trait implementations are unsupported")]
4182pub(crate) struct AsyncImpl {
4183 #[primary_span]
4184 pub span: Span,
4185}
4186
4187#[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_232 =
[::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_232, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4188#[diag("`->` is not valid syntax for field accesses and method calls")]
4189#[help(
4190 "the `.` operator will automatically dereference the value, except if the value is a raw pointer"
4191)]
4192pub(crate) struct ExprRArrowCall {
4193 #[primary_span]
4194 #[suggestion(
4195 "try using `.` instead",
4196 style = "verbose",
4197 applicability = "machine-applicable",
4198 code = "."
4199 )]
4200 pub span: Span,
4201}
4202
4203#[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)]
4204#[diag("attributes are not allowed on range expressions starting with `..`")]
4205pub(crate) struct DotDotRangeAttribute {
4206 #[primary_span]
4207 pub span: Span,
4208}
4209
4210#[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)]
4211#[diag("`for<...>` binder should be placed before trait bound modifiers")]
4212pub(crate) struct BinderBeforeModifiers {
4213 #[primary_span]
4214 pub binder_span: Span,
4215 #[label("place the `for<...>` binder before any modifiers")]
4216 pub modifiers_span: Span,
4217}
4218
4219#[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)]
4220#[diag("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")]
4221pub(crate) struct BinderAndPolarity {
4222 #[primary_span]
4223 pub polarity_span: Span,
4224 #[label("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")]
4225 pub binder_span: Span,
4226 pub polarity: &'static str,
4227}
4228
4229#[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)]
4230#[diag("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")]
4231pub(crate) struct PolarityAndModifiers {
4232 #[primary_span]
4233 pub polarity_span: Span,
4234 #[label(
4235 "there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait"
4236 )]
4237 pub modifiers_span: Span,
4238 pub polarity: &'static str,
4239 pub modifiers_concatenated: String,
4240}
4241
4242#[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)]
4243#[diag("type not allowed for shorthand `self` parameter")]
4244pub(crate) struct IncorrectTypeOnSelf {
4245 #[primary_span]
4246 pub span: Span,
4247 #[subdiagnostic]
4248 pub move_self_modifier: MoveSelfModifier,
4249}
4250
4251#[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_233 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_234 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_233));
suggestions.push((__binding_1, __code_234));
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)]
4252#[multipart_suggestion(
4253 "move the modifiers on `self` to the type",
4254 applicability = "machine-applicable"
4255)]
4256pub(crate) struct MoveSelfModifier {
4257 #[suggestion_part(code = "")]
4258 pub removal_span: Span,
4259 #[suggestion_part(code = "{modifier}")]
4260 pub insertion_span: Span,
4261 pub modifier: String,
4262}
4263
4264#[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)]
4265#[diag("the `{$symbol}` operand cannot be used with `{$macro_name}!`")]
4266pub(crate) struct AsmUnsupportedOperand<'a> {
4267 #[primary_span]
4268 #[label(
4269 "the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it"
4270 )]
4271 pub(crate) span: Span,
4272 pub(crate) symbol: &'a str,
4273 pub(crate) macro_name: &'static str,
4274}
4275
4276#[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)]
4277#[diag("_ cannot be used for input operands")]
4278pub(crate) struct AsmUnderscoreInput {
4279 #[primary_span]
4280 pub(crate) span: Span,
4281}
4282
4283#[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)]
4284#[diag("expected a path for argument to `sym`")]
4285pub(crate) struct AsmSymNoPath {
4286 #[primary_span]
4287 pub(crate) span: Span,
4288}
4289
4290#[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)]
4291#[diag("requires at least a template string argument")]
4292pub(crate) struct AsmRequiresTemplate {
4293 #[primary_span]
4294 pub(crate) span: Span,
4295}
4296
4297#[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)]
4298#[diag("expected token: `,`")]
4299pub(crate) struct AsmExpectedComma {
4300 #[primary_span]
4301 #[label("expected `,`")]
4302 pub(crate) span: Span,
4303}
4304
4305#[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)]
4306#[diag(
4307 "expected operand, {$is_inline_asm ->
4308 [false] options
4309 *[true] clobber_abi, options
4310 }, or additional template string"
4311)]
4312pub(crate) struct AsmExpectedOther {
4313 #[primary_span]
4314 #[label(
4315 "expected operand, {$is_inline_asm ->
4316 [false] options
4317 *[true] clobber_abi, options
4318 }, or additional template string"
4319 )]
4320 pub(crate) span: Span,
4321 pub(crate) is_inline_asm: bool,
4322}
4323
4324#[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)]
4325#[diag("at least one abi must be provided as an argument to `clobber_abi`")]
4326pub(crate) struct NonABI {
4327 #[primary_span]
4328 pub(crate) span: Span,
4329}
4330
4331#[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)]
4332#[diag("expected string literal")]
4333pub(crate) struct AsmExpectedStringLiteral {
4334 #[primary_span]
4335 #[label("not a string literal")]
4336 pub(crate) span: Span,
4337}
4338
4339#[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)]
4340#[diag("expected register class or explicit register")]
4341pub(crate) struct ExpectedRegisterClassOrExplicitRegister {
4342 #[primary_span]
4343 pub(crate) span: Span,
4344}
4345
4346#[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)]
4347#[diag("unicode codepoint changing visible direction of text present in {$label}")]
4348#[note(
4349 "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"
4350)]
4351pub(crate) struct HiddenUnicodeCodepointsDiag {
4352 pub label: String,
4353 pub count: usize,
4354 #[label(
4355 "this {$label} contains {$count ->
4356 [one] an invisible
4357 *[other] invisible
4358 } unicode text flow control {$count ->
4359 [one] codepoint
4360 *[other] codepoints
4361 }"
4362 )]
4363 pub span_label: Span,
4364 #[subdiagnostic]
4365 pub labels: Option<HiddenUnicodeCodepointsDiagLabels>,
4366 #[subdiagnostic]
4367 pub sub: HiddenUnicodeCodepointsDiagSub,
4368}
4369
4370pub(crate) struct HiddenUnicodeCodepointsDiagLabels {
4371 pub spans: Vec<(char, Span)>,
4372}
4373
4374impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
4375 fn add_to_diag(self, diag: &mut Diag<'_>) {
4376 for (c, span) in self.spans {
4377 diag.span_label(span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"));
4378 }
4379 }
4380}
4381
4382pub(crate) enum HiddenUnicodeCodepointsDiagSub {
4383 Escape { spans: Vec<(char, Span)> },
4384 NoEscape { spans: Vec<(char, Span)>, is_doc_comment: bool },
4385}
4386
4387impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
4389 fn add_to_diag(self, diag: &mut Diag<'_>) {
4390 match self {
4391 HiddenUnicodeCodepointsDiagSub::Escape { spans } => {
4392 diag.multipart_suggestion_with_style(
4393 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them"))msg!("if their presence wasn't intentional, you can remove them"),
4394 spans.iter().map(|(_, span)| (*span, "".to_string())).collect(),
4395 Applicability::MachineApplicable,
4396 SuggestionStyle::HideCodeAlways,
4397 );
4398 diag.multipart_suggestion(
4399 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"),
4400 spans
4401 .into_iter()
4402 .map(|(c, span)| {
4403 let c = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}");
4404 (span, c[1..c.len() - 1].to_string())
4405 })
4406 .collect(),
4407 Applicability::MachineApplicable,
4408 );
4409 }
4410 HiddenUnicodeCodepointsDiagSub::NoEscape { spans, is_doc_comment } => {
4411 diag.arg(
4415 "escaped",
4416 spans
4417 .into_iter()
4418 .map(|(c, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"))
4419 .collect::<Vec<String>>()
4420 .join(", "),
4421 );
4422 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"));
4423 if is_doc_comment {
4424 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}"#));
4425 } else {
4426 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}"));
4427 }
4428 }
4429 }
4430 }
4431}
4432
4433#[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_235 =
[::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_235, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
4434#[diag("missing pattern for `...` argument")]
4435pub(crate) struct VarargsWithoutPattern {
4436 #[suggestion(
4437 "name the argument, or use `_` to continue ignoring it",
4438 code = "_: ...",
4439 applicability = "machine-applicable"
4440 )]
4441 pub span: Span,
4442}
4443
4444#[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)]
4445#[diag("only trait impls can be reused")]
4446pub(crate) struct ImplReuseInherentImpl {
4447 #[primary_span]
4448 pub span: Span,
4449}
4450
4451#[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_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("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_236, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4452#[diag("placeholder `_` is not allowed for the path in struct literals")]
4453pub(crate) struct StructLiteralPlaceholderPath {
4454 #[primary_span]
4455 #[label("not allowed in struct literals")]
4456 #[suggestion(
4457 "replace it with the correct type",
4458 applicability = "has-placeholders",
4459 code = "/* Type */",
4460 style = "verbose"
4461 )]
4462 pub span: Span,
4463}
4464
4465#[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_237 =
[::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_237, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4466#[diag("struct literal body without path")]
4467pub(crate) struct StructLiteralWithoutPathLate {
4468 #[primary_span]
4469 #[label("struct name missing for struct literal")]
4470 pub span: Span,
4471 #[suggestion(
4472 "add the correct type",
4473 applicability = "has-placeholders",
4474 code = "/* Type */ ",
4475 style = "verbose"
4476 )]
4477 pub suggestion_span: Span,
4478}
4479
4480#[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)]
4482pub(crate) enum ForbiddenLetReason {
4483 OtherForbidden,
4485 #[note("`||` operators are not supported in let chain expressions")]
4487 NotSupportedOr(#[primary_span] Span),
4488 #[note("`let`s wrapped in parentheses are not supported in a context with let chains")]
4493 NotSupportedParentheses(#[primary_span] Span),
4494}
4495
4496#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MisspelledKw {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "MisspelledKw",
"similar_kw", &self.similar_kw, "span", &self.span,
"is_incorrect_case", &&self.is_incorrect_case)
}
}Debug, const _: () =
{
impl rustc_errors::Subdiagnostic for MisspelledKw {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MisspelledKw {
similar_kw: __binding_0,
span: __binding_1,
is_incorrect_case: __binding_2 } => {
let __code_238 =
[::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_238, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};rustc_macros::Subdiagnostic)]
4497#[suggestion(
4498 "{$is_incorrect_case ->
4499 [true] write keyword `{$similar_kw}` in lowercase
4500 *[false] there is a keyword `{$similar_kw}` with a similar name
4501 }",
4502 applicability = "machine-applicable",
4503 code = "{similar_kw}",
4504 style = "verbose"
4505)]
4506pub(crate) struct MisspelledKw {
4507 pub similar_kw: String,
4510 #[primary_span]
4511 pub span: Span,
4512 pub is_incorrect_case: bool,
4513}
4514
4515#[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_tuple_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)]
4516pub(super) enum TokenDescription {
4517 ReservedIdentifier,
4518 Keyword,
4519 ReservedKeyword,
4520 DocComment,
4521
4522 MetaVar(MetaVarKind),
4527}
4528
4529impl TokenDescription {
4530 pub(super) fn from_token(token: &Token) -> Option<Self> {
4531 match token.kind {
4532 _ if token.is_special_ident() => Some(TokenDescription::ReservedIdentifier),
4533 _ if token.is_used_keyword() => Some(TokenDescription::Keyword),
4534 _ if token.is_unused_keyword() => Some(TokenDescription::ReservedKeyword),
4535 token::DocComment(..) => Some(TokenDescription::DocComment),
4536 token::OpenInvisible(InvisibleOrigin::MetaVar(kind)) => {
4537 Some(TokenDescription::MetaVar(kind))
4538 }
4539 _ => None,
4540 }
4541 }
4542}
4543
4544#[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)]
4545#[diag(
4546 "this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression"
4547)]
4548pub(crate) struct BreakWithLabelAndLoop {
4549 #[subdiagnostic]
4550 pub sub: BreakWithLabelAndLoopSub,
4551}
4552
4553#[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_239 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_240 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_239));
suggestions.push((__binding_1, __code_240));
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)]
4554#[multipart_suggestion("wrap this expression in parentheses", applicability = "machine-applicable")]
4555pub(crate) struct BreakWithLabelAndLoopSub {
4556 #[suggestion_part(code = "(")]
4557 pub left: Span,
4558 #[suggestion_part(code = ")")]
4559 pub right: Span,
4560}
4561
4562#[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)]
4563#[diag("unicode codepoint changing visible direction of text present in comment")]
4564#[note(
4565 "these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen"
4566)]
4567pub(crate) struct UnicodeTextFlow {
4568 #[label(
4569 "{$num_codepoints ->
4570 [1] this comment contains an invisible unicode text flow control codepoint
4571 *[other] this comment contains invisible unicode text flow control codepoints
4572 }"
4573 )]
4574 pub comment_span: Span,
4575 #[subdiagnostic]
4576 pub characters: Vec<UnicodeCharNoteSub>,
4577 #[subdiagnostic]
4578 pub suggestions: Option<UnicodeTextFlowSuggestion>,
4579
4580 pub num_codepoints: usize,
4581}
4582
4583#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnicodeCharNoteSub {
fn add_to_diag(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)]
4584#[label("{$c_debug}")]
4585pub(crate) struct UnicodeCharNoteSub {
4586 #[primary_span]
4587 pub span: Span,
4588 pub c_debug: String,
4589}
4590
4591#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnicodeTextFlowSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnicodeTextFlowSuggestion { spans: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_241 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_241.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeAlways);
}
}
}
}
};Subdiagnostic)]
4592#[multipart_suggestion(
4593 "if their presence wasn't intentional, you can remove them",
4594 applicability = "machine-applicable",
4595 style = "hidden"
4596)]
4597pub(crate) struct UnicodeTextFlowSuggestion {
4598 #[suggestion_part(code = "")]
4599 pub spans: Vec<Span>,
4600}
4601
4602#[derive(const _: () =
{
impl<'_sess> 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_242 =
[::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_242, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4603#[diag("{$subject} is parsed as a {$kind} in Rust {$edition} and onward")]
4604pub(crate) struct ReservedPrefixLint {
4605 pub subject: String,
4606 pub kind: &'static str,
4607 pub edition: Edition,
4608 #[suggestion(
4609 "consider inserting whitespace here to avoid this",
4610 code = " ",
4611 applicability = "machine-applicable",
4612 style = "verbose"
4613 )]
4614 pub sugg: Span,
4615}
4616
4617#[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_243 =
[::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_243, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4618#[suggestion(
4619 "if you meant to write a path, use a double colon",
4620 code = "::",
4621 applicability = "maybe-incorrect"
4622)]
4623pub(crate) struct UseDoubleColonSuggestion {
4624 #[primary_span]
4625 pub colon: Span,
4626}
4627
4628#[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_244 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ "))
});
let __code_245 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
let __code_246 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_244));
suggestions.push((__binding_1, __code_245));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_246));
}
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)]
4629#[multipart_suggestion(
4630 "if you meant to create a regular struct, use curly braces",
4631 applicability = "maybe-incorrect"
4632)]
4633pub(crate) struct UseRegularStructSuggestion {
4634 #[suggestion_part(code = " {{ ")]
4635 pub open: Span,
4636 #[suggestion_part(code = " }}")]
4637 pub close: Span,
4638 #[suggestion_part(code = "")]
4639 pub semicolon: Option<Span>,
4640}
4641#[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)]
4642#[diag("expected type parameter, found path `{$path}`")]
4643pub(crate) struct FoundPathInGenerics {
4644 #[primary_span]
4645 pub span: Span,
4646 pub path: String,
4647}
4648#[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_247 =
[::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_247, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4649#[suggestion(
4650 "you might have meant to bind a type parameter to a trait",
4651 applicability = "maybe-incorrect",
4652 code = "T: "
4653)]
4654
4655pub(crate) struct SuggestBindTypeParameter {
4656 #[primary_span]
4657 pub span: Span,
4658}
4659
4660#[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_248 =
[::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_248, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4661#[suggestion(
4662 "alternatively, you might have meant to introduce type parameter",
4663 applicability = "maybe-incorrect",
4664 code = "{parameters}"
4665)]
4666pub(crate) struct SuggestIntroduceTypeParameter {
4667 #[primary_span]
4668 pub span: Span,
4669 pub parameters: String,
4670}
4671
4672#[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_249 =
[::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_249, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
4673#[suggestion(
4674 "you might have meant to write a diverging block on a refutable `let` statement by using `let-else`
4675 for more information, visit <https://doc.rust-lang.org/beta/rust-by-example/flow_control/let_else.html>",
4676 code = " else ",
4677 applicability = "maybe-incorrect"
4678)]
4679pub(crate) struct MissingElseInLet {
4680 #[primary_span]
4681 pub span: Span,
4682}