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