1use std::borrow::Cow;
4use std::path::PathBuf;
5
6use rustc_ast::token::{self, InvisibleOrigin, MetaVarKind, Token};
7use rustc_ast::util::parser::ExprPrecedence;
8use rustc_ast::{Path, Visibility};
9use rustc_errors::codes::*;
10use rustc_errors::{
11 Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg,
12 Level, Subdiagnostic, SuggestionStyle, inline_fluent,
13};
14use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
15use rustc_session::errors::ExprParenthesesNeeded;
16use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
17use rustc_span::{Ident, Span, Symbol};
18
19#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AmbiguousPlus
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousPlus { span: __binding_0, suggestion: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous `+` in a type")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
20#[diag("ambiguous `+` in a type")]
21pub(crate) struct AmbiguousPlus {
22 #[primary_span]
23 pub span: Span,
24 #[subdiagnostic]
25 pub suggestion: AddParen,
26}
27
28#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadTypePlus
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadTypePlus { span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a path on the left-hand side of `+`")));
diag.code(E0178);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
29#[diag("expected a path on the left-hand side of `+`", code = E0178)]
30pub(crate) struct BadTypePlus {
31 #[primary_span]
32 pub span: Span,
33 #[subdiagnostic]
34 pub sub: BadTypePlusSub,
35}
36
37#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddParen {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddParen { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_0 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_0));
suggestions.push((__binding_1, __code_1));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
38#[multipart_suggestion("try adding parentheses", applicability = "machine-applicable")]
39pub(crate) struct AddParen {
40 #[suggestion_part(code = "(")]
41 pub lo: Span,
42 #[suggestion_part(code = ")")]
43 pub hi: Span,
44}
45
46#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BadTypePlusSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BadTypePlusSub::AddParen { suggestion: __binding_0 } => {
__binding_0.add_to_diag(diag);
diag.store_args();
diag.restore_args();
}
BadTypePlusSub::ForgotParen { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("perhaps you forgot parentheses?")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
BadTypePlusSub::ExpectPath { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a path")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
47pub(crate) enum BadTypePlusSub {
48 AddParen {
49 #[subdiagnostic]
50 suggestion: AddParen,
51 },
52 #[label("perhaps you forgot parentheses?")]
53 ForgotParen {
54 #[primary_span]
55 span: Span,
56 },
57 #[label("expected a path")]
58 ExpectPath {
59 #[primary_span]
60 span: Span,
61 },
62}
63
64#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadQPathStage2
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadQPathStage2 { span: __binding_0, wrap: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing angle brackets in associated item path")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
65#[diag("missing angle brackets in associated item path")]
66pub(crate) struct BadQPathStage2 {
67 #[primary_span]
68 pub span: Span,
69 #[subdiagnostic]
70 pub wrap: WrapType,
71}
72
73#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplModifierInInherentImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitImplModifierInInherentImpl {
span: __binding_0,
modifier: __binding_1,
modifier_name: __binding_2,
modifier_span: __binding_3,
self_ty: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent impls cannot be {$modifier_name}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only trait implementations may be annotated with `{$modifier}`")));
;
diag.arg("modifier", __binding_1);
diag.arg("modifier_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$modifier_name} because of this")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inherent impl for this type")));
diag
}
}
}
}
};Diagnostic)]
74#[diag("inherent impls cannot be {$modifier_name}")]
75#[note("only trait implementations may be annotated with `{$modifier}`")]
76pub(crate) struct TraitImplModifierInInherentImpl {
77 #[primary_span]
78 pub span: Span,
79 pub modifier: &'static str,
80 pub modifier_name: &'static str,
81 #[label("{$modifier_name} because of this")]
82 pub modifier_span: Span,
83 #[label("inherent impl for this type")]
84 pub self_ty: Span,
85}
86
87#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapType {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapType { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_2 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_3 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_2));
suggestions.push((__binding_1, __code_3));
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
88#[multipart_suggestion(
89 "types that don't start with an identifier need to be surrounded with angle brackets in qualified paths",
90 applicability = "machine-applicable"
91)]
92pub(crate) struct WrapType {
93 #[suggestion_part(code = "<")]
94 pub lo: Span,
95 #[suggestion_part(code = ">")]
96 pub hi: Span,
97}
98
99#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectSemicolon<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectSemicolon {
span: __binding_0, show_help: __binding_1, name: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected item, found `;`")));
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this semicolon")),
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name} declarations are not followed by a semicolon")));
}
diag
}
}
}
}
};Diagnostic)]
100#[diag("expected item, found `;`")]
101pub(crate) struct IncorrectSemicolon<'a> {
102 #[primary_span]
103 #[suggestion(
104 "remove this semicolon",
105 style = "verbose",
106 code = "",
107 applicability = "machine-applicable"
108 )]
109 pub span: Span,
110 #[help("{$name} declarations are not followed by a semicolon")]
111 pub show_help: bool,
112 pub name: &'a str,
113}
114
115#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectUseOfAwait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectUseOfAwait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `await`")));
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`await` is not a method call, remove the parentheses")),
__code_5, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
116#[diag("incorrect use of `await`")]
117pub(crate) struct IncorrectUseOfAwait {
118 #[primary_span]
119 #[suggestion(
120 "`await` is not a method call, remove the parentheses",
121 style = "verbose",
122 code = "",
123 applicability = "machine-applicable"
124 )]
125 pub span: Span,
126}
127
128#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectUseOfUse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectUseOfUse { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `use`")));
let __code_6 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`use` is not a method call, try removing the parentheses")),
__code_6, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
129#[diag("incorrect use of `use`")]
130pub(crate) struct IncorrectUseOfUse {
131 #[primary_span]
132 #[suggestion(
133 "`use` is not a method call, try removing the parentheses",
134 style = "verbose",
135 code = "",
136 applicability = "machine-applicable"
137 )]
138 pub span: Span,
139}
140
141#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AwaitSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AwaitSuggestion {
removal: __binding_0,
dot_await: __binding_1,
question_mark: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".await{0}", __binding_2))
});
suggestions.push((__binding_0, __code_7));
suggestions.push((__binding_1, __code_8));
diag.store_args();
diag.arg("question_mark", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`await` is a postfix operation")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
142#[multipart_suggestion("`await` is a postfix operation", applicability = "machine-applicable")]
143pub(crate) struct AwaitSuggestion {
144 #[suggestion_part(code = "")]
145 pub removal: Span,
146 #[suggestion_part(code = ".await{question_mark}")]
147 pub dot_await: Span,
148 pub question_mark: &'static str,
149}
150
151#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for IncorrectAwait
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectAwait { span: __binding_0, suggestion: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect use of `await`")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
152#[diag("incorrect use of `await`")]
153pub(crate) struct IncorrectAwait {
154 #[primary_span]
155 pub span: Span,
156 #[subdiagnostic]
157 pub suggestion: AwaitSuggestion,
158}
159
160#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InInTypo where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InInTypo { span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected iterable, found keyword `in`")));
let __code_9 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the duplicated `in`")),
__code_9, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
161#[diag("expected iterable, found keyword `in`")]
162pub(crate) struct InInTypo {
163 #[primary_span]
164 pub span: Span,
165 #[suggestion(
166 "remove the duplicated `in`",
167 code = "",
168 style = "verbose",
169 applicability = "machine-applicable"
170 )]
171 pub sugg_span: Span,
172}
173
174#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidVariableDeclaration where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidVariableDeclaration {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid variable declaration")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
175#[diag("invalid variable declaration")]
176pub(crate) struct InvalidVariableDeclaration {
177 #[primary_span]
178 pub span: Span,
179 #[subdiagnostic]
180 pub sub: InvalidVariableDeclarationSub,
181}
182
183#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidVariableDeclarationSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidVariableDeclarationSub::SwitchMutLetOrder(__binding_0)
=> {
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let mut"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order of `mut` and `let`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_10, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
InvalidVariableDeclarationSub::MissingLet(__binding_0) => {
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let mut"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing keyword")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
InvalidVariableDeclarationSub::UseLetNotAuto(__binding_0) =>
{
let __code_12 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("write `let` instead of `auto` to introduce a new variable")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_12, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
InvalidVariableDeclarationSub::UseLetNotVar(__binding_0) =>
{
let __code_13 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("write `let` instead of `var` to introduce a new variable")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_13, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
184pub(crate) enum InvalidVariableDeclarationSub {
185 #[suggestion(
186 "switch the order of `mut` and `let`",
187 style = "verbose",
188 applicability = "maybe-incorrect",
189 code = "let mut"
190 )]
191 SwitchMutLetOrder(#[primary_span] Span),
192 #[suggestion(
193 "missing keyword",
194 applicability = "machine-applicable",
195 style = "verbose",
196 code = "let mut"
197 )]
198 MissingLet(#[primary_span] Span),
199 #[suggestion(
200 "write `let` instead of `auto` to introduce a new variable",
201 style = "verbose",
202 applicability = "machine-applicable",
203 code = "let"
204 )]
205 UseLetNotAuto(#[primary_span] Span),
206 #[suggestion(
207 "write `let` instead of `var` to introduce a new variable",
208 style = "verbose",
209 applicability = "machine-applicable",
210 code = "let"
211 )]
212 UseLetNotVar(#[primary_span] Span),
213}
214
215#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SwitchRefBoxOrder where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SwitchRefBoxOrder { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order of `ref` and `box`")));
let __code_14 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("box ref"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("swap them")),
__code_14, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
216#[diag("switch the order of `ref` and `box`")]
217pub(crate) struct SwitchRefBoxOrder {
218 #[primary_span]
219 #[suggestion(
220 "swap them",
221 applicability = "machine-applicable",
222 style = "verbose",
223 code = "box ref"
224 )]
225 pub span: Span,
226}
227
228#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidComparisonOperator where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidComparisonOperator {
span: __binding_0, invalid: __binding_1, sub: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid comparison operator `{$invalid}`")));
;
diag.arg("invalid", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
229#[diag("invalid comparison operator `{$invalid}`")]
230pub(crate) struct InvalidComparisonOperator {
231 #[primary_span]
232 pub span: Span,
233 pub invalid: String,
234 #[subdiagnostic]
235 pub sub: InvalidComparisonOperatorSub,
236}
237
238#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidComparisonOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidComparisonOperatorSub::Correctable {
span: __binding_0,
invalid: __binding_1,
correct: __binding_2 } => {
let __code_15 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("invalid", __binding_1);
diag.arg("correct", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$invalid}` is not a valid comparison operator, use `{$correct}`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_15, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
InvalidComparisonOperatorSub::Spaceship(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`<=>` is not a valid comparison operator, use `std::cmp::Ordering`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
239pub(crate) enum InvalidComparisonOperatorSub {
240 #[suggestion(
241 "`{$invalid}` is not a valid comparison operator, use `{$correct}`",
242 style = "verbose",
243 applicability = "machine-applicable",
244 code = "{correct}"
245 )]
246 Correctable {
247 #[primary_span]
248 span: Span,
249 invalid: String,
250 correct: String,
251 },
252 #[label("`<=>` is not a valid comparison operator, use `std::cmp::Ordering`")]
253 Spaceship(#[primary_span] Span),
254}
255
256#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidLogicalOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidLogicalOperator {
span: __binding_0, incorrect: __binding_1, sub: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$incorrect}` is not a logical operator")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators")));
;
diag.arg("incorrect", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
257#[diag("`{$incorrect}` is not a logical operator")]
258#[note("unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators")]
259pub(crate) struct InvalidLogicalOperator {
260 #[primary_span]
261 pub span: Span,
262 pub incorrect: String,
263 #[subdiagnostic]
264 pub sub: InvalidLogicalOperatorSub,
265}
266
267#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidLogicalOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidLogicalOperatorSub::Conjunction(__binding_0) => {
let __code_16 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&&"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `&&` to perform logical conjunction")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
InvalidLogicalOperatorSub::Disjunction(__binding_0) => {
let __code_17 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("||"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `||` to perform logical disjunction")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
268pub(crate) enum InvalidLogicalOperatorSub {
269 #[suggestion(
270 "use `&&` to perform logical conjunction",
271 style = "verbose",
272 applicability = "machine-applicable",
273 code = "&&"
274 )]
275 Conjunction(#[primary_span] Span),
276 #[suggestion(
277 "use `||` to perform logical disjunction",
278 style = "verbose",
279 applicability = "machine-applicable",
280 code = "||"
281 )]
282 Disjunction(#[primary_span] Span),
283}
284
285#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TildeAsUnaryOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TildeAsUnaryOperator(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`~` cannot be used as a unary operator")));
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `!` to perform bitwise not")),
__code_18, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
286#[diag("`~` cannot be used as a unary operator")]
287pub(crate) struct TildeAsUnaryOperator(
288 #[primary_span]
289 #[suggestion(
290 "use `!` to perform bitwise not",
291 style = "verbose",
292 applicability = "machine-applicable",
293 code = "!"
294 )]
295 pub Span,
296);
297
298#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NotAsNegationOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NotAsNegationOperator {
negated: __binding_0,
negated_desc: __binding_1,
sub: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected {$negated_desc} after identifier")));
;
diag.arg("negated_desc", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
299#[diag("unexpected {$negated_desc} after identifier")]
300pub(crate) struct NotAsNegationOperator {
301 #[primary_span]
302 pub negated: Span,
303 pub negated_desc: String,
304 #[subdiagnostic]
305 pub sub: NotAsNegationOperatorSub,
306}
307
308#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NotAsNegationOperatorSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NotAsNegationOperatorSub::SuggestNotDefault(__binding_0) =>
{
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `!` to perform logical negation or bitwise not")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_19, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
NotAsNegationOperatorSub::SuggestNotBitwise(__binding_0) =>
{
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `!` to perform bitwise not")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_20, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
NotAsNegationOperatorSub::SuggestNotLogical(__binding_0) =>
{
let __code_21 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `!` to perform logical negation")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_21, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
309pub(crate) enum NotAsNegationOperatorSub {
310 #[suggestion(
311 "use `!` to perform logical negation or bitwise not",
312 style = "verbose",
313 applicability = "machine-applicable",
314 code = "!"
315 )]
316 SuggestNotDefault(#[primary_span] Span),
317
318 #[suggestion(
319 "use `!` to perform bitwise not",
320 style = "verbose",
321 applicability = "machine-applicable",
322 code = "!"
323 )]
324 SuggestNotBitwise(#[primary_span] Span),
325
326 #[suggestion(
327 "use `!` to perform logical negation",
328 style = "verbose",
329 applicability = "machine-applicable",
330 code = "!"
331 )]
332 SuggestNotLogical(#[primary_span] Span),
333}
334
335#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedLoopLabel where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedLoopLabel {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed loop label")));
let __code_22 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\'"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use the correct loop label format")),
__code_22, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
336#[diag("malformed loop label")]
337pub(crate) struct MalformedLoopLabel {
338 #[primary_span]
339 pub span: Span,
340 #[suggestion(
341 "use the correct loop label format",
342 applicability = "machine-applicable",
343 code = "'",
344 style = "verbose"
345 )]
346 pub suggestion: Span,
347}
348
349#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeInBorrowExpression where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeInBorrowExpression {
span: __binding_0, lifetime_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow expressions cannot be annotated with lifetimes")));
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime annotation")),
__code_23, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("annotated with lifetime here")));
diag
}
}
}
}
};Diagnostic)]
350#[diag("borrow expressions cannot be annotated with lifetimes")]
351pub(crate) struct LifetimeInBorrowExpression {
352 #[primary_span]
353 pub span: Span,
354 #[suggestion(
355 "remove the lifetime annotation",
356 applicability = "machine-applicable",
357 code = "",
358 style = "verbose"
359 )]
360 #[label("annotated with lifetime here")]
361 pub lifetime_span: Span,
362}
363
364#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FieldExpressionWithGeneric where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FieldExpressionWithGeneric(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field expressions cannot have generic arguments")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
365#[diag("field expressions cannot have generic arguments")]
366pub(crate) struct FieldExpressionWithGeneric(#[primary_span] pub Span);
367
368#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroInvocationWithQualifiedPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroInvocationWithQualifiedPath(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot use qualified paths")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
369#[diag("macros cannot use qualified paths")]
370pub(crate) struct MacroInvocationWithQualifiedPath(#[primary_span] pub Span);
371
372#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterLabel where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterLabel {
span: __binding_0,
remove_label: __binding_1,
enclose_in_block: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `while`, `for`, `loop` or `{\"{\"}` after a label")));
let __code_24 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `while`, `for`, `loop` or `{\"{\"}` after a label")));
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the label")),
__code_24, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
373#[diag("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
374pub(crate) struct UnexpectedTokenAfterLabel {
375 #[primary_span]
376 #[label("expected `while`, `for`, `loop` or `{\"{\"}` after a label")]
377 pub span: Span,
378 #[suggestion("consider removing the label", style = "verbose", code = "")]
379 pub remove_label: Option<Span>,
380 #[subdiagnostic]
381 pub enclose_in_block: Option<UnexpectedTokenAfterLabelSugg>,
382}
383
384#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedTokenAfterLabelSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedTokenAfterLabelSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_25 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_26 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_25));
suggestions.push((__binding_1, __code_26));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider enclosing expression in a block")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
385#[multipart_suggestion(
386 "consider enclosing expression in a block",
387 applicability = "machine-applicable"
388)]
389pub(crate) struct UnexpectedTokenAfterLabelSugg {
390 #[suggestion_part(code = "{{ ")]
391 pub left: Span,
392 #[suggestion_part(code = " }}")]
393 pub right: Span,
394}
395
396#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RequireColonAfterLabeledExpression where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RequireColonAfterLabeledExpression {
span: __binding_0,
label: __binding_1,
label_end: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled expression must be followed by `:`")));
let __code_27 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": "))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labels are used before loops and blocks, allowing e.g., `break 'label` to them")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label")));
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `:` after the label")),
__code_27, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
397#[diag("labeled expression must be followed by `:`")]
398#[note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")]
399pub(crate) struct RequireColonAfterLabeledExpression {
400 #[primary_span]
401 pub span: Span,
402 #[label("the label")]
403 pub label: Span,
404 #[suggestion(
405 "add `:` after the label",
406 style = "verbose",
407 applicability = "machine-applicable",
408 code = ": "
409 )]
410 pub label_end: Span,
411}
412
413#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DoCatchSyntaxRemoved where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DoCatchSyntaxRemoved { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found removed `do catch` syntax")));
let __code_28 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("try"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("following RFC #2388, the new non-placeholder syntax is `try`")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace with the new syntax")),
__code_28, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
414#[diag("found removed `do catch` syntax")]
415#[note("following RFC #2388, the new non-placeholder syntax is `try`")]
416pub(crate) struct DoCatchSyntaxRemoved {
417 #[primary_span]
418 #[suggestion(
419 "replace with the new syntax",
420 applicability = "machine-applicable",
421 code = "try",
422 style = "verbose"
423 )]
424 pub span: Span,
425}
426
427#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FloatLiteralRequiresIntegerPart where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FloatLiteralRequiresIntegerPart {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("float literals must have an integer part")));
let __code_29 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("0"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must have an integer part")),
__code_29, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
428#[diag("float literals must have an integer part")]
429pub(crate) struct FloatLiteralRequiresIntegerPart {
430 #[primary_span]
431 pub span: Span,
432 #[suggestion(
433 "must have an integer part",
434 applicability = "machine-applicable",
435 code = "0",
436 style = "verbose"
437 )]
438 pub suggestion: Span,
439}
440
441#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingSemicolonBeforeArray where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingSemicolonBeforeArray {
open_delim: __binding_0, semicolon: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found `[`")));
let __code_30 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding `;` here")),
__code_30, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
442#[diag("expected `;`, found `[`")]
443pub(crate) struct MissingSemicolonBeforeArray {
444 #[primary_span]
445 pub open_delim: Span,
446 #[suggestion(
447 "consider adding `;` here",
448 style = "verbose",
449 applicability = "maybe-incorrect",
450 code = ";"
451 )]
452 pub semicolon: Span,
453}
454
455#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MissingDotDot
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingDotDot {
token_span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `..`, found `...`")));
let __code_31 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..` to fill in the rest of the fields")),
__code_31, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
456#[diag("expected `..`, found `...`")]
457pub(crate) struct MissingDotDot {
458 #[primary_span]
459 pub token_span: Span,
460 #[suggestion(
461 "use `..` to fill in the rest of the fields",
462 applicability = "maybe-incorrect",
463 code = "..",
464 style = "verbose"
465 )]
466 pub sugg_span: Span,
467}
468
469#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidBlockMacroSegment where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidBlockMacroSegment {
span: __binding_0, context: __binding_1, wrap: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use a `block` macro fragment here")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `block` fragment is within this context")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
470#[diag("cannot use a `block` macro fragment here")]
471pub(crate) struct InvalidBlockMacroSegment {
472 #[primary_span]
473 pub span: Span,
474 #[label("the `block` fragment is within this context")]
475 pub context: Span,
476 #[subdiagnostic]
477 pub wrap: WrapInExplicitBlock,
478}
479
480#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInExplicitBlock {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInExplicitBlock { lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_32 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_33 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_32));
suggestions.push((__binding_1, __code_33));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap this in another block")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
481#[multipart_suggestion("wrap this in another block", applicability = "machine-applicable")]
482pub(crate) struct WrapInExplicitBlock {
483 #[suggestion_part(code = "{{ ")]
484 pub lo: Span,
485 #[suggestion_part(code = " }}")]
486 pub hi: Span,
487}
488
489#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IfExpressionMissingThenBlock where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IfExpressionMissingThenBlock {
if_span: __binding_0,
missing_then_block_sub: __binding_1,
let_else_sub: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `if` expression is missing a block after the condition")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
490#[diag("this `if` expression is missing a block after the condition")]
491pub(crate) struct IfExpressionMissingThenBlock {
492 #[primary_span]
493 pub if_span: Span,
494 #[subdiagnostic]
495 pub missing_then_block_sub: IfExpressionMissingThenBlockSub,
496 #[subdiagnostic]
497 pub let_else_sub: Option<IfExpressionLetSomeSub>,
498}
499
500#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IfExpressionMissingThenBlockSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IfExpressionMissingThenBlockSub::UnfinishedCondition(__binding_0)
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this binary operation is possibly unfinished")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
IfExpressionMissingThenBlockSub::AddThenBlock(__binding_0)
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a block here")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
501pub(crate) enum IfExpressionMissingThenBlockSub {
502 #[help("this binary operation is possibly unfinished")]
503 UnfinishedCondition(#[primary_span] Span),
504 #[help("add a block here")]
505 AddThenBlock(#[primary_span] Span),
506}
507
508#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TernaryOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TernaryOperator {
span: __binding_0, sugg: __binding_1, no_sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("Rust has no ternary operator")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an `if-else` expression instead")));
}
diag
}
}
}
}
};Diagnostic)]
509#[diag("Rust has no ternary operator")]
510pub(crate) struct TernaryOperator {
511 #[primary_span]
512 pub span: Span,
513 #[subdiagnostic]
515 pub sugg: Option<TernaryOperatorSuggestion>,
516 #[help("use an `if-else` expression instead")]
518 pub no_sugg: bool,
519}
520
521#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TernaryOperatorSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TernaryOperatorSuggestion {
before_cond: __binding_0,
question: __binding_1,
colon: __binding_2,
end: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_34 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_35 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_36 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("}} else {{"))
});
let __code_37 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_34));
suggestions.push((__binding_1, __code_35));
suggestions.push((__binding_2, __code_36));
suggestions.push((__binding_3, __code_37));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an `if-else` expression instead")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::marker::Copy for TernaryOperatorSuggestion { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TernaryOperatorSuggestion {
#[inline]
fn clone(&self) -> TernaryOperatorSuggestion {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone)]
522#[multipart_suggestion(
523 "use an `if-else` expression instead",
524 applicability = "maybe-incorrect",
525 style = "verbose"
526)]
527pub(crate) struct TernaryOperatorSuggestion {
528 #[suggestion_part(code = "if ")]
529 pub before_cond: Span,
530 #[suggestion_part(code = "{{")]
531 pub question: Span,
532 #[suggestion_part(code = "}} else {{")]
533 pub colon: Span,
534 #[suggestion_part(code = " }}")]
535 pub end: Span,
536}
537
538#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IfExpressionLetSomeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IfExpressionLetSomeSub { if_span: __binding_0 } => {
let __code_38 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `if` if you meant to write a `let...else` statement")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_38, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
539#[suggestion(
540 "remove the `if` if you meant to write a `let...else` statement",
541 applicability = "maybe-incorrect",
542 code = "",
543 style = "verbose"
544)]
545pub(crate) struct IfExpressionLetSomeSub {
546 #[primary_span]
547 pub if_span: Span,
548}
549
550#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IfExpressionMissingCondition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IfExpressionMissingCondition {
if_span: __binding_0, block_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing condition for `if` expression")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected condition here")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if this block is the condition of the `if` expression, then it must be followed by another block")));
diag
}
}
}
}
};Diagnostic)]
551#[diag("missing condition for `if` expression")]
552pub(crate) struct IfExpressionMissingCondition {
553 #[primary_span]
554 #[label("expected condition here")]
555 pub if_span: Span,
556 #[label(
557 "if this block is the condition of the `if` expression, then it must be followed by another block"
558 )]
559 pub block_span: Span,
560}
561
562#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedExpressionFoundLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedExpressionFoundLet {
span: __binding_0,
reason: __binding_1,
missing_let: __binding_2,
comparison: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression, found `let` statement")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only supported directly in conditions of `if` and `while` expressions")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
563#[diag("expected expression, found `let` statement")]
564#[note("only supported directly in conditions of `if` and `while` expressions")]
565pub(crate) struct ExpectedExpressionFoundLet {
566 #[primary_span]
567 pub span: Span,
568 #[subdiagnostic]
569 pub reason: ForbiddenLetReason,
570 #[subdiagnostic]
571 pub missing_let: Option<MaybeMissingLet>,
572 #[subdiagnostic]
573 pub comparison: Option<MaybeComparison>,
574}
575
576#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LetChainMissingLet where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LetChainMissingLet {
span: __binding_0,
label_span: __binding_1,
rhs_span: __binding_2,
sug_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let-chain with missing `let`")));
let __code_39 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `let` expression, found assignment")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let expression later in the condition")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `let` before the expression")),
__code_39, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
577#[diag("let-chain with missing `let`")]
578pub(crate) struct LetChainMissingLet {
579 #[primary_span]
580 pub span: Span,
581 #[label("expected `let` expression, found assignment")]
582 pub label_span: Span,
583 #[label("let expression later in the condition")]
584 pub rhs_span: Span,
585 #[suggestion(
586 "add `let` before the expression",
587 applicability = "maybe-incorrect",
588 code = "let ",
589 style = "verbose"
590 )]
591 pub sug_span: Span,
592}
593
594#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for OrInLetChain
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OrInLetChain { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`||` operators are not supported in let chain conditions")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
595#[diag("`||` operators are not supported in let chain conditions")]
596pub(crate) struct OrInLetChain {
597 #[primary_span]
598 pub span: Span,
599}
600
601#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeMissingLet {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MaybeMissingLet { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_40 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
});
suggestions.push((__binding_0, __code_40));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to continue the let-chain")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::clone::Clone for MaybeMissingLet {
#[inline]
fn clone(&self) -> MaybeMissingLet {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeMissingLet { }Copy)]
602#[multipart_suggestion(
603 "you might have meant to continue the let-chain",
604 applicability = "maybe-incorrect",
605 style = "verbose"
606)]
607pub(crate) struct MaybeMissingLet {
608 #[suggestion_part(code = "let ")]
609 pub span: Span,
610}
611
612#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeComparison {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MaybeComparison { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_41 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
});
suggestions.push((__binding_0, __code_41));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to compare for equality")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::clone::Clone for MaybeComparison {
#[inline]
fn clone(&self) -> MaybeComparison {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MaybeComparison { }Copy)]
613#[multipart_suggestion(
614 "you might have meant to compare for equality",
615 applicability = "maybe-incorrect",
616 style = "verbose"
617)]
618pub(crate) struct MaybeComparison {
619 #[suggestion_part(code = "=")]
620 pub span: Span,
621}
622
623#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedEqForLetExpr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedEqForLetExpr {
span: __binding_0, sugg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `=`, found `==`")));
let __code_42 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `=` here")),
__code_42, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
624#[diag("expected `=`, found `==`")]
625pub(crate) struct ExpectedEqForLetExpr {
626 #[primary_span]
627 pub span: Span,
628 #[suggestion(
629 "consider using `=` here",
630 applicability = "maybe-incorrect",
631 code = "=",
632 style = "verbose"
633 )]
634 pub sugg_span: Span,
635}
636
637#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedElseBlock where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedElseBlock {
first_tok_span: __binding_0,
first_tok: __binding_1,
else_span: __binding_2,
condition_start: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{\"{\"}`, found {$first_tok}")));
let __code_43 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
})].into_iter();
;
diag.arg("first_tok", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an `if` or a block after this `else`")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add an `if` if this is the condition of a chained `else if` statement")),
__code_43, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
638#[diag("expected `{\"{\"}`, found {$first_tok}")]
639pub(crate) struct ExpectedElseBlock {
640 #[primary_span]
641 pub first_tok_span: Span,
642 pub first_tok: String,
643 #[label("expected an `if` or a block after this `else`")]
644 pub else_span: Span,
645 #[suggestion(
646 "add an `if` if this is the condition of a chained `else if` statement",
647 applicability = "maybe-incorrect",
648 code = "if ",
649 style = "verbose"
650 )]
651 pub condition_start: Span,
652}
653
654#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedStructField where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedStructField {
span: __binding_0,
token: __binding_1,
ident_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected one of `,`, `:`, or `{\"}\"}`, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected one of `,`, `:`, or `{\"}\"}`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this struct field")));
diag
}
}
}
}
};Diagnostic)]
655#[diag("expected one of `,`, `:`, or `{\"}\"}`, found `{$token}`")]
656pub(crate) struct ExpectedStructField {
657 #[primary_span]
658 #[label("expected one of `,`, `:`, or `{\"}\"}`")]
659 pub span: Span,
660 pub token: Token,
661 #[label("while parsing this struct field")]
662 pub ident_span: Span,
663}
664
665#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OuterAttributeNotAllowedOnIfElse where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OuterAttributeNotAllowedOnIfElse {
last: __binding_0,
branch_span: __binding_1,
ctx_span: __binding_2,
ctx: __binding_3,
attributes: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("outer attributes are not allowed on `if` and `else` branches")));
let __code_44 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("ctx", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the attributes are attached to this branch")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the branch belongs to this `{$ctx}`")));
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attributes")),
__code_44, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
666#[diag("outer attributes are not allowed on `if` and `else` branches")]
667pub(crate) struct OuterAttributeNotAllowedOnIfElse {
668 #[primary_span]
669 pub last: Span,
670
671 #[label("the attributes are attached to this branch")]
672 pub branch_span: Span,
673
674 #[label("the branch belongs to this `{$ctx}`")]
675 pub ctx_span: Span,
676 pub ctx: String,
677
678 #[suggestion(
679 "remove the attributes",
680 applicability = "machine-applicable",
681 code = "",
682 style = "verbose"
683 )]
684 pub attributes: Span,
685}
686
687#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingInInForLoop where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingInInForLoop { span: __binding_0, sub: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `in` in `for` loop")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
688#[diag("missing `in` in `for` loop")]
689pub(crate) struct MissingInInForLoop {
690 #[primary_span]
691 pub span: Span,
692 #[subdiagnostic]
693 pub sub: MissingInInForLoopSub,
694}
695
696#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingInInForLoopSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MissingInInForLoopSub::InNotOf(__binding_0) => {
let __code_45 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `in` here instead")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_45, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
MissingInInForLoopSub::InNotEq(__binding_0) => {
let __code_46 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `in` here instead")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_46, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
MissingInInForLoopSub::AddIn(__binding_0) => {
let __code_47 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" in "))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding `in` here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_47, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
697pub(crate) enum MissingInInForLoopSub {
698 #[suggestion(
701 "try using `in` here instead",
702 style = "verbose",
703 applicability = "maybe-incorrect",
704 code = "in"
705 )]
706 InNotOf(#[primary_span] Span),
707 #[suggestion(
709 "try using `in` here instead",
710 style = "verbose",
711 applicability = "maybe-incorrect",
712 code = "in"
713 )]
714 InNotEq(#[primary_span] Span),
715 #[suggestion(
716 "try adding `in` here",
717 style = "verbose",
718 applicability = "maybe-incorrect",
719 code = " in "
720 )]
721 AddIn(#[primary_span] Span),
722}
723
724#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingExpressionInForLoop where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingExpressionInForLoop { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing expression to iterate on in `for` loop")));
let __code_48 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* expression */ "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding an expression to the `for` loop")),
__code_48, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
725#[diag("missing expression to iterate on in `for` loop")]
726pub(crate) struct MissingExpressionInForLoop {
727 #[primary_span]
728 #[suggestion(
729 "try adding an expression to the `for` loop",
730 code = "/* expression */ ",
731 applicability = "has-placeholders",
732 style = "verbose"
733 )]
734 pub span: Span,
735}
736
737#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopElseNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopElseNotSupported {
span: __binding_0,
loop_kind: __binding_1,
loop_kw: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$loop_kind}...else` loops are not supported")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run")));
;
diag.arg("loop_kind", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`else` is attached to this loop")));
diag
}
}
}
}
};Diagnostic)]
738#[diag("`{$loop_kind}...else` loops are not supported")]
739#[note(
740 "consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run"
741)]
742pub(crate) struct LoopElseNotSupported {
743 #[primary_span]
744 pub span: Span,
745 pub loop_kind: &'static str,
746 #[label("`else` is attached to this loop")]
747 pub loop_kw: Span,
748}
749
750#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingCommaAfterMatchArm where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingCommaAfterMatchArm { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,` following `match` arm")));
let __code_49 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(","))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing a comma here to end this `match` arm")),
__code_49, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
751#[diag("expected `,` following `match` arm")]
752pub(crate) struct MissingCommaAfterMatchArm {
753 #[primary_span]
754 #[suggestion(
755 "missing a comma here to end this `match` arm",
756 applicability = "machine-applicable",
757 code = ",",
758 style = "verbose"
759 )]
760 pub span: Span,
761}
762
763#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CatchAfterTry
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CatchAfterTry { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("keyword `catch` cannot follow a `try` block")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `match` on the result of the `try` block instead")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
764#[diag("keyword `catch` cannot follow a `try` block")]
765#[help("try using `match` on the result of the `try` block instead")]
766pub(crate) struct CatchAfterTry {
767 #[primary_span]
768 pub span: Span,
769}
770
771#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CommaAfterBaseStruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CommaAfterBaseStruct { span: __binding_0, comma: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use a comma after the base struct")));
let __code_50 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the base struct must always be the last field")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this comma")),
__code_50, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
772#[diag("cannot use a comma after the base struct")]
773#[note("the base struct must always be the last field")]
774pub(crate) struct CommaAfterBaseStruct {
775 #[primary_span]
776 pub span: Span,
777 #[suggestion(
778 "remove this comma",
779 style = "verbose",
780 applicability = "machine-applicable",
781 code = ""
782 )]
783 pub comma: Span,
784}
785
786#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for EqFieldInit
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EqFieldInit { span: __binding_0, eq: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `:`, found `=`")));
let __code_51 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(":"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace equals symbol with a colon")),
__code_51, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
787#[diag("expected `:`, found `=`")]
788pub(crate) struct EqFieldInit {
789 #[primary_span]
790 pub span: Span,
791 #[suggestion(
792 "replace equals symbol with a colon",
793 applicability = "machine-applicable",
794 code = ":",
795 style = "verbose"
796 )]
797 pub eq: Span,
798}
799
800#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DotDotDot
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDot { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: `...`")));
let __code_52 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".."))
})].into_iter();
let __code_53 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("..="))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..` for an exclusive range")),
__code_52, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or `..=` for an inclusive range")),
__code_53, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
801#[diag("unexpected token: `...`")]
802pub(crate) struct DotDotDot {
803 #[primary_span]
804 #[suggestion(
805 "use `..` for an exclusive range",
806 applicability = "maybe-incorrect",
807 code = "..",
808 style = "verbose"
809 )]
810 #[suggestion(
811 "or `..=` for an inclusive range",
812 applicability = "maybe-incorrect",
813 code = "..=",
814 style = "verbose"
815 )]
816 pub span: Span,
817}
818
819#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LeftArrowOperator where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LeftArrowOperator { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: `<-`")));
let __code_54 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("< -"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a comparison against a negative value, add a space in between `<` and `-`")),
__code_54, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
820#[diag("unexpected token: `<-`")]
821pub(crate) struct LeftArrowOperator {
822 #[primary_span]
823 #[suggestion(
824 "if you meant to write a comparison against a negative value, add a space in between `<` and `-`",
825 applicability = "maybe-incorrect",
826 code = "< -",
827 style = "verbose"
828 )]
829 pub span: Span,
830}
831
832#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for RemoveLet
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RemoveLet { span: __binding_0, suggestion: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected pattern, found `let`")));
let __code_55 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the unnecessary `let` keyword")),
__code_55, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
833#[diag("expected pattern, found `let`")]
834pub(crate) struct RemoveLet {
835 #[primary_span]
836 pub span: Span,
837 #[suggestion(
838 "remove the unnecessary `let` keyword",
839 applicability = "machine-applicable",
840 code = "",
841 style = "verbose"
842 )]
843 pub suggestion: Span,
844}
845
846#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UseEqInstead
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseEqInstead { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `==`")));
let __code_56 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `=` instead")),
__code_56, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
847#[diag("unexpected `==`")]
848pub(crate) struct UseEqInstead {
849 #[primary_span]
850 #[suggestion(
851 "try using `=` instead",
852 style = "verbose",
853 applicability = "machine-applicable",
854 code = "="
855 )]
856 pub span: Span,
857}
858
859#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseEmptyBlockNotSemi where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseEmptyBlockNotSemi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected { \"`{}`\" }, found `;`")));
let __code_57 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{}}"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using { \"`{}`\" } instead")),
__code_57, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeAlways);
diag
}
}
}
}
};Diagnostic)]
860#[diag("expected { \"`{}`\" }, found `;`")]
861pub(crate) struct UseEmptyBlockNotSemi {
862 #[primary_span]
863 #[suggestion(
864 r#"try using { "`{}`" } instead"#,
865 style = "hidden",
866 applicability = "machine-applicable",
867 code = "{{}}"
868 )]
869 pub span: Span,
870}
871
872#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ComparisonInterpretedAsGeneric where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ComparisonInterpretedAsGeneric {
comparison: __binding_0,
r#type: __binding_1,
args: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`<` is interpreted as a start of generic arguments for `{$type}`, not a comparison")));
;
diag.arg("type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not interpreted as comparison")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as generic arguments")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
873#[diag("`<` is interpreted as a start of generic arguments for `{$type}`, not a comparison")]
874pub(crate) struct ComparisonInterpretedAsGeneric {
875 #[primary_span]
876 #[label("not interpreted as comparison")]
877 pub comparison: Span,
878 pub r#type: Path,
879 #[label("interpreted as generic arguments")]
880 pub args: Span,
881 #[subdiagnostic]
882 pub suggestion: ComparisonInterpretedAsGenericSugg,
883}
884
885#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ComparisonInterpretedAsGenericSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ComparisonInterpretedAsGenericSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_58 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_59 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_58));
suggestions.push((__binding_1, __code_59));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try comparing the cast value")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
886#[multipart_suggestion("try comparing the cast value", applicability = "machine-applicable")]
887pub(crate) struct ComparisonInterpretedAsGenericSugg {
888 #[suggestion_part(code = "(")]
889 pub left: Span,
890 #[suggestion_part(code = ")")]
891 pub right: Span,
892}
893
894#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ShiftInterpretedAsGeneric where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ShiftInterpretedAsGeneric {
shift: __binding_0,
r#type: __binding_1,
args: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`<<` is interpreted as a start of generic arguments for `{$type}`, not a shift")));
;
diag.arg("type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not interpreted as shift")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as generic arguments")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
895#[diag("`<<` is interpreted as a start of generic arguments for `{$type}`, not a shift")]
896pub(crate) struct ShiftInterpretedAsGeneric {
897 #[primary_span]
898 #[label("not interpreted as shift")]
899 pub shift: Span,
900 pub r#type: Path,
901 #[label("interpreted as generic arguments")]
902 pub args: Span,
903 #[subdiagnostic]
904 pub suggestion: ShiftInterpretedAsGenericSugg,
905}
906
907#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ShiftInterpretedAsGenericSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ShiftInterpretedAsGenericSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_60 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_61 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_60));
suggestions.push((__binding_1, __code_61));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try shifting the cast value")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
908#[multipart_suggestion("try shifting the cast value", applicability = "machine-applicable")]
909pub(crate) struct ShiftInterpretedAsGenericSugg {
910 #[suggestion_part(code = "(")]
911 pub left: Span,
912 #[suggestion_part(code = ")")]
913 pub right: Span,
914}
915
916#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FoundExprWouldBeStmt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FoundExprWouldBeStmt {
span: __binding_0,
token: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected expression")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
917#[diag("expected expression, found `{$token}`")]
918pub(crate) struct FoundExprWouldBeStmt {
919 #[primary_span]
920 #[label("expected expression")]
921 pub span: Span,
922 pub token: Token,
923 #[subdiagnostic]
924 pub suggestion: ExprParenthesesNeeded,
925}
926
927#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterExtraCharactersAfterClose where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterExtraCharactersAfterClose { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extra characters after frontmatter close are not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
928#[diag("extra characters after frontmatter close are not allowed")]
929pub(crate) struct FrontmatterExtraCharactersAfterClose {
930 #[primary_span]
931 pub span: Span,
932}
933
934#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidInfostring where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidInfostring { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid infostring for frontmatter")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter infostrings must be a single identifier immediately following the opening")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
935#[diag("invalid infostring for frontmatter")]
936#[note("frontmatter infostrings must be a single identifier immediately following the opening")]
937pub(crate) struct FrontmatterInvalidInfostring {
938 #[primary_span]
939 pub span: Span,
940}
941
942#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidOpeningPrecedingWhitespace where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidOpeningPrecedingWhitespace {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid preceding whitespace for frontmatter opening")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter opening should not be preceded by whitespace")));
diag
}
}
}
}
};Diagnostic)]
943#[diag("invalid preceding whitespace for frontmatter opening")]
944pub(crate) struct FrontmatterInvalidOpeningPrecedingWhitespace {
945 #[primary_span]
946 pub span: Span,
947 #[note("frontmatter opening should not be preceded by whitespace")]
948 pub note_span: Span,
949}
950
951#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterUnclosed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterUnclosed {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unclosed frontmatter")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter opening here was not closed")));
diag
}
}
}
}
};Diagnostic)]
952#[diag("unclosed frontmatter")]
953pub(crate) struct FrontmatterUnclosed {
954 #[primary_span]
955 pub span: Span,
956 #[note("frontmatter opening here was not closed")]
957 pub note_span: Span,
958}
959
960#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterInvalidClosingPrecedingWhitespace where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterInvalidClosingPrecedingWhitespace {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid preceding whitespace for frontmatter close")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter close should not be preceded by whitespace")));
diag
}
}
}
}
};Diagnostic)]
961#[diag("invalid preceding whitespace for frontmatter close")]
962pub(crate) struct FrontmatterInvalidClosingPrecedingWhitespace {
963 #[primary_span]
964 pub span: Span,
965 #[note("frontmatter close should not be preceded by whitespace")]
966 pub note_span: Span,
967}
968
969#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterLengthMismatch where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterLengthMismatch {
span: __binding_0,
opening: __binding_1,
close: __binding_2,
len_opening: __binding_3,
len_close: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("frontmatter close does not match the opening")));
;
diag.arg("len_opening", __binding_3);
diag.arg("len_close", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the opening here has {$len_opening} dashes...")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...while the close has {$len_close} dashes")));
diag
}
}
}
}
};Diagnostic)]
970#[diag("frontmatter close does not match the opening")]
971pub(crate) struct FrontmatterLengthMismatch {
972 #[primary_span]
973 pub span: Span,
974 #[label("the opening here has {$len_opening} dashes...")]
975 pub opening: Span,
976 #[label("...while the close has {$len_close} dashes")]
977 pub close: Span,
978 pub len_opening: usize,
979 pub len_close: usize,
980}
981
982#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FrontmatterTooManyDashes where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FrontmatterTooManyDashes { len_opening: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("too many `-` symbols: frontmatter openings may be delimited by up to 255 `-` symbols, but found {$len_opening}")));
;
diag.arg("len_opening", __binding_0);
diag
}
}
}
}
};Diagnostic)]
983#[diag(
984 "too many `-` symbols: frontmatter openings may be delimited by up to 255 `-` symbols, but found {$len_opening}"
985)]
986pub(crate) struct FrontmatterTooManyDashes {
987 pub len_opening: usize,
988}
989
990#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BareCrFrontmatter where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BareCrFrontmatter { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in frontmatter")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
991#[diag("bare CR not allowed in frontmatter")]
992pub(crate) struct BareCrFrontmatter {
993 #[primary_span]
994 pub span: Span,
995}
996
997#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LeadingPlusNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LeadingPlusNotSupported {
span: __binding_0,
remove_plus: __binding_1,
add_parentheses: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("leading `+` is not supported")));
let __code_62 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `+`")));
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try removing the `+`")),
__code_62, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
998#[diag("leading `+` is not supported")]
999pub(crate) struct LeadingPlusNotSupported {
1000 #[primary_span]
1001 #[label("unexpected `+`")]
1002 pub span: Span,
1003 #[suggestion(
1004 "try removing the `+`",
1005 style = "verbose",
1006 code = "",
1007 applicability = "machine-applicable"
1008 )]
1009 pub remove_plus: Option<Span>,
1010 #[subdiagnostic]
1011 pub add_parentheses: Option<ExprParenthesesNeeded>,
1012}
1013
1014#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesWithStructFields where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesWithStructFields {
span: __binding_0,
r#type: __binding_1,
braces_for_struct: __binding_2,
no_fields_for_fn: __binding_3 } => {
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.arg("type", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1015#[diag("invalid `struct` delimiters or `fn` call arguments")]
1016pub(crate) struct ParenthesesWithStructFields {
1017 #[primary_span]
1018 pub span: Span,
1019 pub r#type: Path,
1020 #[subdiagnostic]
1021 pub braces_for_struct: BracesForStructLiteral,
1022 #[subdiagnostic]
1023 pub no_fields_for_fn: NoFieldsForFnCall,
1024}
1025
1026#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BracesForStructLiteral {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BracesForStructLiteral {
first: __binding_0, second: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_63 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ "))
});
let __code_64 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_63));
suggestions.push((__binding_1, __code_64));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$type}` is a struct, use braces as delimiters")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1027#[multipart_suggestion(
1028 "if `{$type}` is a struct, use braces as delimiters",
1029 applicability = "maybe-incorrect"
1030)]
1031pub(crate) struct BracesForStructLiteral {
1032 #[suggestion_part(code = " {{ ")]
1033 pub first: Span,
1034 #[suggestion_part(code = " }}")]
1035 pub second: Span,
1036}
1037
1038#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NoFieldsForFnCall {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoFieldsForFnCall { fields: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_65 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_65.clone()));
}
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if `{$type}` is a function, use the arguments directly")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1039#[multipart_suggestion(
1040 "if `{$type}` is a function, use the arguments directly",
1041 applicability = "maybe-incorrect"
1042)]
1043pub(crate) struct NoFieldsForFnCall {
1044 #[suggestion_part(code = "")]
1045 pub fields: Vec<Span>,
1046}
1047
1048#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LabeledLoopInBreak where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LabeledLoopInBreak { span: __binding_0, sub: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parentheses are required around this expression to avoid confusion with a labeled break expression")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1049#[diag(
1050 "parentheses are required around this expression to avoid confusion with a labeled break expression"
1051)]
1052pub(crate) struct LabeledLoopInBreak {
1053 #[primary_span]
1054 pub span: Span,
1055 #[subdiagnostic]
1056 pub sub: WrapInParentheses,
1057}
1058
1059#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInParentheses {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInParentheses::Expression {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_66 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_67 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_66));
suggestions.push((__binding_1, __code_67));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the expression in parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
WrapInParentheses::MacroArgs {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_68 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_69 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_68));
suggestions.push((__binding_1, __code_69));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use parentheses instead of braces for this macro")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1060pub(crate) enum WrapInParentheses {
1061 #[multipart_suggestion(
1062 "wrap the expression in parentheses",
1063 applicability = "machine-applicable"
1064 )]
1065 Expression {
1066 #[suggestion_part(code = "(")]
1067 left: Span,
1068 #[suggestion_part(code = ")")]
1069 right: Span,
1070 },
1071 #[multipart_suggestion(
1072 "use parentheses instead of braces for this macro",
1073 applicability = "machine-applicable"
1074 )]
1075 MacroArgs {
1076 #[suggestion_part(code = "(")]
1077 left: Span,
1078 #[suggestion_part(code = ")")]
1079 right: Span,
1080 },
1081}
1082
1083#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArrayBracketsInsteadOfBraces where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ArrayBracketsInsteadOfBraces {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a block expression, not an array")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1084#[diag("this is a block expression, not an array")]
1085pub(crate) struct ArrayBracketsInsteadOfBraces {
1086 #[primary_span]
1087 pub span: Span,
1088 #[subdiagnostic]
1089 pub sub: ArrayBracketsInsteadOfBracesSugg,
1090}
1091
1092#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ArrayBracketsInsteadOfBracesSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ArrayBracketsInsteadOfBracesSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_70 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("["))
});
let __code_71 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("]"))
});
suggestions.push((__binding_0, __code_70));
suggestions.push((__binding_1, __code_71));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to make an array, use square brackets instead of curly braces")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1093#[multipart_suggestion(
1094 "to make an array, use square brackets instead of curly braces",
1095 applicability = "maybe-incorrect"
1096)]
1097pub(crate) struct ArrayBracketsInsteadOfBracesSugg {
1098 #[suggestion_part(code = "[")]
1099 pub left: Span,
1100 #[suggestion_part(code = "]")]
1101 pub right: Span,
1102}
1103
1104#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MatchArmBodyWithoutBraces where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MatchArmBodyWithoutBraces {
statements: __binding_0,
arrow: __binding_1,
num_statements: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`match` arm body without braces")));
;
diag.arg("num_statements", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_statements ->\n [one] this statement is not surrounded by a body\n *[other] these statements are not surrounded by a body\n }")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing the `match` arm starting here")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1105#[diag("`match` arm body without braces")]
1106pub(crate) struct MatchArmBodyWithoutBraces {
1107 #[primary_span]
1108 #[label(
1109 "{$num_statements ->
1110 [one] this statement is not surrounded by a body
1111 *[other] these statements are not surrounded by a body
1112 }"
1113 )]
1114 pub statements: Span,
1115 #[label("while parsing the `match` arm starting here")]
1116 pub arrow: Span,
1117 pub num_statements: usize,
1118 #[subdiagnostic]
1119 pub sub: MatchArmBodyWithoutBracesSugg,
1120}
1121
1122#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeExtraEquals where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeExtraEquals { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `=` after inclusive range")));
let __code_72 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("..="))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive ranges end with a single equals sign (`..=`)")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` instead")),
__code_72, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1123#[diag("unexpected `=` after inclusive range")]
1124#[note("inclusive ranges end with a single equals sign (`..=`)")]
1125pub(crate) struct InclusiveRangeExtraEquals {
1126 #[primary_span]
1127 #[suggestion(
1128 "use `..=` instead",
1129 style = "verbose",
1130 code = "..=",
1131 applicability = "maybe-incorrect"
1132 )]
1133 pub span: Span,
1134}
1135
1136#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeMatchArrow where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeMatchArrow {
arrow: __binding_0,
span: __binding_1,
after_pat: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `>` after inclusive range")));
let __code_73 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is parsed as an inclusive range `..=`")));
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a space between the pattern and `=>`")),
__code_73, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1137#[diag("unexpected `>` after inclusive range")]
1138pub(crate) struct InclusiveRangeMatchArrow {
1139 #[primary_span]
1140 pub arrow: Span,
1141 #[label("this is parsed as an inclusive range `..=`")]
1142 pub span: Span,
1143 #[suggestion(
1144 "add a space between the pattern and `=>`",
1145 style = "verbose",
1146 code = " ",
1147 applicability = "machine-applicable"
1148 )]
1149 pub after_pat: Span,
1150}
1151
1152#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InclusiveRangeNoEnd where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InclusiveRangeNoEnd {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive range with no end")));
let __code_74 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.code(E0586);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..` instead")),
__code_74, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1153#[diag("inclusive range with no end", code = E0586)]
1154#[note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")]
1155pub(crate) struct InclusiveRangeNoEnd {
1156 #[primary_span]
1157 pub span: Span,
1158 #[suggestion(
1159 "use `..` instead",
1160 code = "",
1161 applicability = "machine-applicable",
1162 style = "verbose"
1163 )]
1164 pub suggestion: Span,
1165}
1166
1167#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MatchArmBodyWithoutBracesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MatchArmBodyWithoutBracesSugg::AddBraces {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_75 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_76 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_75));
suggestions.push((__binding_1, __code_76));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the {$num_statements ->\n [one] statement\n *[other] statements\n } with a body")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
MatchArmBodyWithoutBracesSugg::UseComma {
semicolon: __binding_0 } => {
let __code_77 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(","))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `;` with `,` to end a `match` arm expression")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_77, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1168pub(crate) enum MatchArmBodyWithoutBracesSugg {
1169 #[multipart_suggestion(
1170 "surround the {$num_statements ->
1171 [one] statement
1172 *[other] statements
1173 } with a body",
1174 applicability = "machine-applicable"
1175 )]
1176 AddBraces {
1177 #[suggestion_part(code = "{{ ")]
1178 left: Span,
1179 #[suggestion_part(code = " }}")]
1180 right: Span,
1181 },
1182 #[suggestion(
1183 "replace `;` with `,` to end a `match` arm expression",
1184 code = ",",
1185 applicability = "machine-applicable",
1186 style = "verbose"
1187 )]
1188 UseComma {
1189 #[primary_span]
1190 semicolon: Span,
1191 },
1192}
1193
1194#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralNotAllowedHere where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralNotAllowedHere {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literals are not allowed here")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1195#[diag("struct literals are not allowed here")]
1196pub(crate) struct StructLiteralNotAllowedHere {
1197 #[primary_span]
1198 pub span: Span,
1199 #[subdiagnostic]
1200 pub sub: StructLiteralNotAllowedHereSugg,
1201}
1202
1203#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for StructLiteralNotAllowedHereSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
StructLiteralNotAllowedHereSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_78 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_79 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_78));
suggestions.push((__binding_1, __code_79));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the struct literal with parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1204#[multipart_suggestion(
1205 "surround the struct literal with parentheses",
1206 applicability = "machine-applicable"
1207)]
1208pub(crate) struct StructLiteralNotAllowedHereSugg {
1209 #[suggestion_part(code = "(")]
1210 pub left: Span,
1211 #[suggestion_part(code = ")")]
1212 pub right: Span,
1213}
1214
1215#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidLiteralSuffixOnTupleIndex where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidLiteralSuffixOnTupleIndex {
span: __binding_0, suffix: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixes on a tuple index are invalid")));
;
diag.arg("suffix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
diag
}
}
}
}
};Diagnostic)]
1216#[diag("suffixes on a tuple index are invalid")]
1217pub(crate) struct InvalidLiteralSuffixOnTupleIndex {
1218 #[primary_span]
1219 #[label("invalid suffix `{$suffix}`")]
1220 pub span: Span,
1221 pub suffix: Symbol,
1222}
1223
1224#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonStringAbiLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonStringAbiLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-string ABI literal")));
let __code_80 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\"C\""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the ABI with a string literal")),
__code_80, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1225#[diag("non-string ABI literal")]
1226pub(crate) struct NonStringAbiLiteral {
1227 #[primary_span]
1228 #[suggestion(
1229 "specify the ABI with a string literal",
1230 code = "\"C\"",
1231 applicability = "maybe-incorrect",
1232 style = "verbose"
1233 )]
1234 pub span: Span,
1235}
1236
1237#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MismatchedClosingDelimiter where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MismatchedClosingDelimiter {
spans: __binding_0,
delimiter: __binding_1,
unmatched: __binding_2,
opening_candidate: __binding_3,
unclosed: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched closing delimiter: `{$delimiter}`")));
;
diag.arg("delimiter", __binding_1);
diag.span(__binding_0.clone());
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched closing delimiter")));
if let Some(__binding_3) = __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closing delimiter possibly meant for this")));
}
if let Some(__binding_4) = __binding_4 {
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unclosed delimiter")));
}
diag
}
}
}
}
};Diagnostic)]
1238#[diag("mismatched closing delimiter: `{$delimiter}`")]
1239pub(crate) struct MismatchedClosingDelimiter {
1240 #[primary_span]
1241 pub spans: Vec<Span>,
1242 pub delimiter: String,
1243 #[label("mismatched closing delimiter")]
1244 pub unmatched: Span,
1245 #[label("closing delimiter possibly meant for this")]
1246 pub opening_candidate: Option<Span>,
1247 #[label("unclosed delimiter")]
1248 pub unclosed: Option<Span>,
1249}
1250
1251#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectVisibilityRestriction where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectVisibilityRestriction {
span: __binding_0, inner_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect visibility restriction")));
let __code_81 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("in {0}", __binding_1))
})].into_iter();
diag.code(E0704);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("some possible visibility restrictions are:\n `pub(crate)`: visible only on the current crate\n `pub(super)`: visible only in the current module's parent\n `pub(in path::to::module)`: visible only on the specified path")));
;
diag.arg("inner_str", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("make this visible only to module `{$inner_str}` with `in`")),
__code_81, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1252#[diag("incorrect visibility restriction", code = E0704)]
1253#[help(
1254 "some possible visibility restrictions are:
1255 `pub(crate)`: visible only on the current crate
1256 `pub(super)`: visible only in the current module's parent
1257 `pub(in path::to::module)`: visible only on the specified path"
1258)]
1259pub(crate) struct IncorrectVisibilityRestriction {
1260 #[primary_span]
1261 #[suggestion(
1262 "make this visible only to module `{$inner_str}` with `in`",
1263 code = "in {inner_str}",
1264 applicability = "machine-applicable",
1265 style = "verbose"
1266 )]
1267 pub span: Span,
1268 pub inner_str: String,
1269}
1270
1271#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssignmentElseNotAllowed where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssignmentElseNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("<assignment> ... else {\"{\"} ... {\"}\"} is not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1272#[diag("<assignment> ... else {\"{\"} ... {\"}\"} is not allowed")]
1273pub(crate) struct AssignmentElseNotAllowed {
1274 #[primary_span]
1275 pub span: Span,
1276}
1277
1278#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedStatementAfterOuterAttr where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedStatementAfterOuterAttr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected statement after outer attribute")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1279#[diag("expected statement after outer attribute")]
1280pub(crate) struct ExpectedStatementAfterOuterAttr {
1281 #[primary_span]
1282 pub span: Span,
1283}
1284
1285#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocCommentDoesNotDocumentAnything where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocCommentDoesNotDocumentAnything {
span: __binding_0, missing_comma: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found a documentation comment that doesn't document anything")));
let __code_82 =
[::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_82, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1286#[diag("found a documentation comment that doesn't document anything", code = E0585)]
1287#[help("doc comments must come before what they document, if a comment was intended use `//`")]
1288pub(crate) struct DocCommentDoesNotDocumentAnything {
1289 #[primary_span]
1290 pub span: Span,
1291 #[suggestion(
1292 "missing comma here",
1293 code = ",",
1294 applicability = "machine-applicable",
1295 style = "verbose"
1296 )]
1297 pub missing_comma: Option<Span>,
1298}
1299
1300#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstLetMutuallyExclusive where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstLetMutuallyExclusive { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` and `let` are mutually exclusive")));
let __code_83 =
[::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_83, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1301#[diag("`const` and `let` are mutually exclusive")]
1302pub(crate) struct ConstLetMutuallyExclusive {
1303 #[primary_span]
1304 #[suggestion(
1305 "remove `let`",
1306 code = "const",
1307 applicability = "maybe-incorrect",
1308 style = "verbose"
1309 )]
1310 pub span: Span,
1311}
1312
1313#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidExpressionInLetElse where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidExpressionInLetElse {
span: __binding_0, operator: __binding_1, sugg: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `{$operator}` expression cannot be directly assigned in `let...else`")));
;
diag.arg("operator", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1314#[diag("a `{$operator}` expression cannot be directly assigned in `let...else`")]
1315pub(crate) struct InvalidExpressionInLetElse {
1316 #[primary_span]
1317 pub span: Span,
1318 pub operator: &'static str,
1319 #[subdiagnostic]
1320 pub sugg: WrapInParentheses,
1321}
1322
1323#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidCurlyInLetElse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidCurlyInLetElse { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("right curly brace `{\"}\"}` before `else` in a `let...else` statement not allowed")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1324#[diag("right curly brace `{\"}\"}` before `else` in a `let...else` statement not allowed")]
1325pub(crate) struct InvalidCurlyInLetElse {
1326 #[primary_span]
1327 pub span: Span,
1328 #[subdiagnostic]
1329 pub sugg: WrapInParentheses,
1330}
1331
1332#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CompoundAssignmentExpressionInLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CompoundAssignmentExpressionInLet {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reassign to an uninitialized variable")));
let __code_84 =
[::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_84, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1333#[diag("can't reassign to an uninitialized variable")]
1334#[help("if you meant to overwrite, remove the `let` binding")]
1335pub(crate) struct CompoundAssignmentExpressionInLet {
1336 #[primary_span]
1337 pub span: Span,
1338 #[suggestion(
1339 "initialize the variable",
1340 style = "verbose",
1341 code = "",
1342 applicability = "maybe-incorrect"
1343 )]
1344 pub suggestion: Span,
1345}
1346
1347#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SuffixedLiteralInAttribute where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SuffixedLiteralInAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixed literals are not allowed in attributes")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1348#[diag("suffixed literals are not allowed in attributes")]
1349#[help(
1350 "instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)"
1351)]
1352pub(crate) struct SuffixedLiteralInAttribute {
1353 #[primary_span]
1354 pub span: Span,
1355}
1356
1357#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidMetaItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidMetaItem {
span: __binding_0,
descr: __binding_1,
quote_ident_sugg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected unsuffixed literal, found {$descr}")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1358#[diag("expected unsuffixed literal, found {$descr}")]
1359pub(crate) struct InvalidMetaItem {
1360 #[primary_span]
1361 pub span: Span,
1362 pub descr: String,
1363 #[subdiagnostic]
1364 pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
1365}
1366
1367#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidMetaItemQuoteIdentSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidMetaItemQuoteIdentSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_85 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_86 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_85));
suggestions.push((__binding_1, __code_86));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the identifier with quotation marks to make it into a string literal")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1368#[multipart_suggestion(
1369 "surround the identifier with quotation marks to make it into a string literal",
1370 applicability = "machine-applicable"
1371)]
1372pub(crate) struct InvalidMetaItemQuoteIdentSugg {
1373 #[suggestion_part(code = "\"")]
1374 pub before: Span,
1375 #[suggestion_part(code = "\"")]
1376 pub after: Span,
1377}
1378
1379#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggEscapeIdentifier {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggEscapeIdentifier {
span: __binding_0, ident_name: __binding_1 } => {
let __code_87 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("r#"))
})].into_iter();
diag.store_args();
diag.arg("ident_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("escape `{$ident_name}` to use it as an identifier")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_87, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1380#[suggestion(
1381 "escape `{$ident_name}` to use it as an identifier",
1382 style = "verbose",
1383 applicability = "maybe-incorrect",
1384 code = "r#"
1385)]
1386pub(crate) struct SuggEscapeIdentifier {
1387 #[primary_span]
1388 pub span: Span,
1389 pub ident_name: String,
1390}
1391
1392#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggRemoveComma {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggRemoveComma { span: __binding_0 } => {
let __code_88 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this comma")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_88, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1393#[suggestion(
1394 "remove this comma",
1395 applicability = "machine-applicable",
1396 code = "",
1397 style = "verbose"
1398)]
1399pub(crate) struct SuggRemoveComma {
1400 #[primary_span]
1401 pub span: Span,
1402}
1403
1404#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggAddMissingLetStmt {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggAddMissingLetStmt { span: __binding_0 } => {
let __code_89 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let "))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to introduce a new binding")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_89, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1405#[suggestion(
1406 "you might have meant to introduce a new binding",
1407 style = "verbose",
1408 applicability = "maybe-incorrect",
1409 code = "let "
1410)]
1411pub(crate) struct SuggAddMissingLetStmt {
1412 #[primary_span]
1413 pub span: Span,
1414}
1415
1416#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedIdentifierFound {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedIdentifierFound::ReservedIdentifier(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved identifier")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ExpectedIdentifierFound::Keyword(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ExpectedIdentifierFound::ReservedKeyword(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved keyword")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ExpectedIdentifierFound::DocComment(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found doc comment")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ExpectedIdentifierFound::MetaVar(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found metavariable")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ExpectedIdentifierFound::Other(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1417pub(crate) enum ExpectedIdentifierFound {
1418 #[label("expected identifier, found reserved identifier")]
1419 ReservedIdentifier(#[primary_span] Span),
1420 #[label("expected identifier, found keyword")]
1421 Keyword(#[primary_span] Span),
1422 #[label("expected identifier, found reserved keyword")]
1423 ReservedKeyword(#[primary_span] Span),
1424 #[label("expected identifier, found doc comment")]
1425 DocComment(#[primary_span] Span),
1426 #[label("expected identifier, found metavariable")]
1427 MetaVar(#[primary_span] Span),
1428 #[label("expected identifier")]
1429 Other(#[primary_span] Span),
1430}
1431
1432impl ExpectedIdentifierFound {
1433 pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
1434 (match token_descr {
1435 Some(TokenDescription::ReservedIdentifier) => {
1436 ExpectedIdentifierFound::ReservedIdentifier
1437 }
1438 Some(TokenDescription::Keyword) => ExpectedIdentifierFound::Keyword,
1439 Some(TokenDescription::ReservedKeyword) => ExpectedIdentifierFound::ReservedKeyword,
1440 Some(TokenDescription::DocComment) => ExpectedIdentifierFound::DocComment,
1441 Some(TokenDescription::MetaVar(_)) => ExpectedIdentifierFound::MetaVar,
1442 None => ExpectedIdentifierFound::Other,
1443 })(span)
1444 }
1445}
1446
1447pub(crate) struct ExpectedIdentifier {
1448 pub span: Span,
1449 pub token: Token,
1450 pub suggest_raw: Option<SuggEscapeIdentifier>,
1451 pub suggest_remove_comma: Option<SuggRemoveComma>,
1452 pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
1453}
1454
1455impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
1456 #[track_caller]
1457 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1458 let token_descr = TokenDescription::from_token(&self.token);
1459
1460 let mut add_token = true;
1461 let mut diag = Diag::new(
1462 dcx,
1463 level,
1464 match token_descr {
1465 Some(TokenDescription::ReservedIdentifier) => {
1466 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved identifier `{$token}`"))inline_fluent!("expected identifier, found reserved identifier `{$token}`")
1467 }
1468 Some(TokenDescription::Keyword) => {
1469 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword `{$token}`"))inline_fluent!("expected identifier, found keyword `{$token}`")
1470 }
1471 Some(TokenDescription::ReservedKeyword) => {
1472 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found reserved keyword `{$token}`"))inline_fluent!("expected identifier, found reserved keyword `{$token}`")
1473 }
1474 Some(TokenDescription::DocComment) => {
1475 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found doc comment `{$token}`"))inline_fluent!("expected identifier, found doc comment `{$token}`")
1476 }
1477 Some(TokenDescription::MetaVar(_)) => {
1478 add_token = false;
1479 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found metavariable"))inline_fluent!("expected identifier, found metavariable")
1480 }
1481 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found `{$token}`"))inline_fluent!("expected identifier, found `{$token}`"),
1482 },
1483 );
1484 diag.span(self.span);
1485 if add_token {
1486 diag.arg("token", self.token);
1487 }
1488
1489 if let Some(sugg) = self.suggest_raw {
1490 sugg.add_to_diag(&mut diag);
1491 }
1492
1493 ExpectedIdentifierFound::new(token_descr, self.span).add_to_diag(&mut diag);
1494
1495 if let Some(sugg) = self.suggest_remove_comma {
1496 sugg.add_to_diag(&mut diag);
1497 }
1498
1499 if let Some(help) = self.help_cannot_start_number {
1500 help.add_to_diag(&mut diag);
1501 }
1502
1503 diag
1504 }
1505}
1506
1507#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HelpIdentifierStartsWithNumber {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
HelpIdentifierStartsWithNumber { num_span: __binding_0 } =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifiers cannot start with a number")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1508#[help("identifiers cannot start with a number")]
1509pub(crate) struct HelpIdentifierStartsWithNumber {
1510 #[primary_span]
1511 pub num_span: Span,
1512}
1513
1514pub(crate) struct ExpectedSemi {
1515 pub span: Span,
1516 pub token: Token,
1517
1518 pub unexpected_token_label: Option<Span>,
1519 pub sugg: ExpectedSemiSugg,
1520}
1521
1522impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
1523 #[track_caller]
1524 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1525 let token_descr = TokenDescription::from_token(&self.token);
1526
1527 let mut add_token = true;
1528 let mut diag = Diag::new(
1529 dcx,
1530 level,
1531 match token_descr {
1532 Some(TokenDescription::ReservedIdentifier) => {
1533 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved identifier `{$token}`"))inline_fluent!("expected `;`, found reserved identifier `{$token}`")
1534 }
1535 Some(TokenDescription::Keyword) => {
1536 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found keyword `{$token}`"))inline_fluent!("expected `;`, found keyword `{$token}`")
1537 }
1538 Some(TokenDescription::ReservedKeyword) => {
1539 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found reserved keyword `{$token}`"))inline_fluent!("expected `;`, found reserved keyword `{$token}`")
1540 }
1541 Some(TokenDescription::DocComment) => {
1542 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found doc comment `{$token}`"))inline_fluent!("expected `;`, found doc comment `{$token}`")
1543 }
1544 Some(TokenDescription::MetaVar(_)) => {
1545 add_token = false;
1546 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found metavariable"))inline_fluent!("expected `;`, found metavariable")
1547 }
1548 None => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `;`, found `{$token}`"))inline_fluent!("expected `;`, found `{$token}`"),
1549 },
1550 );
1551 diag.span(self.span);
1552 if add_token {
1553 diag.arg("token", self.token);
1554 }
1555
1556 if let Some(unexpected_token_label) = self.unexpected_token_label {
1557 diag.span_label(unexpected_token_label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token"))inline_fluent!("unexpected token"));
1558 }
1559
1560 self.sugg.add_to_diag(&mut diag);
1561
1562 diag
1563 }
1564}
1565
1566#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedSemiSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedSemiSugg::ChangeToSemi(__binding_0) => {
let __code_90 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change this to `;`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_90, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag.restore_args();
}
ExpectedSemiSugg::AddSemi(__binding_0) => {
let __code_91 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `;` here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_91, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1567pub(crate) enum ExpectedSemiSugg {
1568 #[suggestion(
1569 "change this to `;`",
1570 code = ";",
1571 applicability = "machine-applicable",
1572 style = "short"
1573 )]
1574 ChangeToSemi(#[primary_span] Span),
1575 #[suggestion("add `;` here", code = ";", applicability = "machine-applicable", style = "short")]
1576 AddSemi(#[primary_span] Span),
1577}
1578
1579#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralBodyWithoutPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralBodyWithoutPath {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literal body without path")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1580#[diag("struct literal body without path")]
1581pub(crate) struct StructLiteralBodyWithoutPath {
1582 #[primary_span]
1583 pub span: Span,
1584 #[subdiagnostic]
1585 pub sugg: StructLiteralBodyWithoutPathSugg,
1586}
1587
1588#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for StructLiteralBodyWithoutPathSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
StructLiteralBodyWithoutPathSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_92 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ SomeStruct "))
});
let __code_93 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_92));
suggestions.push((__binding_1, __code_93));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have forgotten to add the struct literal inside the block")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1589#[multipart_suggestion(
1590 "you might have forgotten to add the struct literal inside the block",
1591 applicability = "has-placeholders"
1592)]
1593pub(crate) struct StructLiteralBodyWithoutPathSugg {
1594 #[suggestion_part(code = "{{ SomeStruct ")]
1595 pub before: Span,
1596 #[suggestion_part(code = " }}")]
1597 pub after: Span,
1598}
1599
1600#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnmatchedAngleBrackets where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnmatchedAngleBrackets {
span: __binding_0, num_extra_brackets: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_extra_brackets ->\n [one] unmatched angle bracket\n *[other] unmatched angle brackets\n }")));
let __code_94 =
[::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_94, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1601#[diag(
1602 "{$num_extra_brackets ->
1603 [one] unmatched angle bracket
1604 *[other] unmatched angle brackets
1605 }"
1606)]
1607pub(crate) struct UnmatchedAngleBrackets {
1608 #[primary_span]
1609 #[suggestion(
1610 "{$num_extra_brackets ->
1611 [one] remove extra angle bracket
1612 *[other] remove extra angle brackets
1613 }",
1614 code = "",
1615 applicability = "machine-applicable",
1616 style = "verbose"
1617 )]
1618 pub span: Span,
1619 pub num_extra_brackets: usize,
1620}
1621
1622#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericParamsWithoutAngleBrackets where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericParamsWithoutAngleBrackets {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters without surrounding angle brackets")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1623#[diag("generic parameters without surrounding angle brackets")]
1624pub(crate) struct GenericParamsWithoutAngleBrackets {
1625 #[primary_span]
1626 pub span: Span,
1627 #[subdiagnostic]
1628 pub sugg: GenericParamsWithoutAngleBracketsSugg,
1629}
1630
1631#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsWithoutAngleBracketsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GenericParamsWithoutAngleBracketsSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_95 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_96 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_95));
suggestions.push((__binding_1, __code_96));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the type parameters with angle brackets")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1632#[multipart_suggestion(
1633 "surround the type parameters with angle brackets",
1634 applicability = "machine-applicable"
1635)]
1636pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
1637 #[suggestion_part(code = "<")]
1638 pub left: Span,
1639 #[suggestion_part(code = ">")]
1640 pub right: Span,
1641}
1642
1643#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ComparisonOperatorsCannotBeChained where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ComparisonOperatorsCannotBeChained {
span: __binding_0,
suggest_turbofish: __binding_1,
help_turbofish: __binding_2,
chaining_sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("comparison operators cannot be chained")));
let __code_97 =
[::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_97, 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)]
1644#[diag("comparison operators cannot be chained")]
1645pub(crate) struct ComparisonOperatorsCannotBeChained {
1646 #[primary_span]
1647 pub span: Vec<Span>,
1648 #[suggestion(
1649 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
1650 style = "verbose",
1651 code = "::",
1652 applicability = "maybe-incorrect"
1653 )]
1654 pub suggest_turbofish: Option<Span>,
1655 #[help("use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments")]
1656 #[help("or use `(...)` if you meant to specify fn arguments")]
1657 pub help_turbofish: bool,
1658 #[subdiagnostic]
1659 pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
1660}
1661
1662#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ComparisonOperatorsCannotBeChainedSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ComparisonOperatorsCannotBeChainedSugg::SplitComparison {
span: __binding_0, middle_term: __binding_1 } => {
let __code_98 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" && {0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("middle_term", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("split the comparison into two")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_98, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
ComparisonOperatorsCannotBeChainedSugg::Parenthesize {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_99 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_100 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_99));
suggestions.push((__binding_1, __code_100));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthesize the comparison")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1663pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
1664 #[suggestion(
1665 "split the comparison into two",
1666 style = "verbose",
1667 code = " && {middle_term}",
1668 applicability = "maybe-incorrect"
1669 )]
1670 SplitComparison {
1671 #[primary_span]
1672 span: Span,
1673 middle_term: String,
1674 },
1675 #[multipart_suggestion("parenthesize the comparison", applicability = "maybe-incorrect")]
1676 Parenthesize {
1677 #[suggestion_part(code = "(")]
1678 left: Span,
1679 #[suggestion_part(code = ")")]
1680 right: Span,
1681 },
1682}
1683
1684#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
QuestionMarkInType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
QuestionMarkInType { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `?` in type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`?` is only allowed on expressions, not types")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1685#[diag("invalid `?` in type")]
1686pub(crate) struct QuestionMarkInType {
1687 #[primary_span]
1688 #[label("`?` is only allowed on expressions, not types")]
1689 pub span: Span,
1690 #[subdiagnostic]
1691 pub sugg: QuestionMarkInTypeSugg,
1692}
1693
1694#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for QuestionMarkInTypeSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
QuestionMarkInTypeSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_101 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Option<"))
});
let __code_102 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_101));
suggestions.push((__binding_1, __code_102));
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1695#[multipart_suggestion(
1696 "if you meant to express that the type might not contain a value, use the `Option` wrapper type",
1697 applicability = "machine-applicable"
1698)]
1699pub(crate) struct QuestionMarkInTypeSugg {
1700 #[suggestion_part(code = "Option<")]
1701 pub left: Span,
1702 #[suggestion_part(code = ">")]
1703 pub right: Span,
1704}
1705
1706#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesInForHead where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesInForHead { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected parentheses surrounding `for` loop head")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1707#[diag("unexpected parentheses surrounding `for` loop head")]
1708pub(crate) struct ParenthesesInForHead {
1709 #[primary_span]
1710 pub span: Vec<Span>,
1711 #[subdiagnostic]
1712 pub sugg: ParenthesesInForHeadSugg,
1713}
1714
1715#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesesInForHeadSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenthesesInForHeadSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_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));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove parentheses in `for` loop")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1716#[multipart_suggestion("remove parentheses in `for` loop", applicability = "machine-applicable")]
1717pub(crate) struct ParenthesesInForHeadSugg {
1718 #[suggestion_part(code = " ")]
1719 pub left: Span,
1720 #[suggestion_part(code = " ")]
1721 pub right: Span,
1722}
1723
1724#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenthesesInMatchPat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenthesesInMatchPat { span: __binding_0, sugg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected parentheses surrounding `match` arm pattern")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1725#[diag("unexpected parentheses surrounding `match` arm pattern")]
1726pub(crate) struct ParenthesesInMatchPat {
1727 #[primary_span]
1728 pub span: Vec<Span>,
1729 #[subdiagnostic]
1730 pub sugg: ParenthesesInMatchPatSugg,
1731}
1732
1733#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesesInMatchPatSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenthesesInMatchPatSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_105 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_106 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_105));
suggestions.push((__binding_1, __code_106));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove parentheses surrounding the pattern")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1734#[multipart_suggestion(
1735 "remove parentheses surrounding the pattern",
1736 applicability = "machine-applicable"
1737)]
1738pub(crate) struct ParenthesesInMatchPatSugg {
1739 #[suggestion_part(code = "")]
1740 pub left: Span,
1741 #[suggestion_part(code = "")]
1742 pub right: Span,
1743}
1744
1745#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocCommentOnParamType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocCommentOnParamType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("documentation comments cannot be applied to a function parameter's type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doc comments are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
1746#[diag("documentation comments cannot be applied to a function parameter's type")]
1747pub(crate) struct DocCommentOnParamType {
1748 #[primary_span]
1749 #[label("doc comments are not allowed here")]
1750 pub span: Span,
1751}
1752
1753#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnParamType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnParamType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to a function parameter's type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
1754#[diag("attributes cannot be applied to a function parameter's type")]
1755pub(crate) struct AttributeOnParamType {
1756 #[primary_span]
1757 #[label("attributes are not allowed here")]
1758 pub span: Span,
1759}
1760
1761#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnType { span: __binding_0, fix_span: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to types")));
let __code_107 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove attribute from here")),
__code_107, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
1762#[diag("attributes cannot be applied to types")]
1763pub(crate) struct AttributeOnType {
1764 #[primary_span]
1765 #[label("attributes are not allowed here")]
1766 pub span: Span,
1767 #[suggestion(
1768 "remove attribute from here",
1769 code = "",
1770 applicability = "machine-applicable",
1771 style = "tool-only"
1772 )]
1773 pub fix_span: Span,
1774}
1775
1776#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnGenericArg where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnGenericArg {
span: __binding_0, fix_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied to generic arguments")));
let __code_108 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove attribute from here")),
__code_108, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
1777#[diag("attributes cannot be applied to generic arguments")]
1778pub(crate) struct AttributeOnGenericArg {
1779 #[primary_span]
1780 #[label("attributes are not allowed here")]
1781 pub span: Span,
1782 #[suggestion(
1783 "remove attribute from here",
1784 code = "",
1785 applicability = "machine-applicable",
1786 style = "tool-only"
1787 )]
1788 pub fix_span: Span,
1789}
1790
1791#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeOnEmptyType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeOnEmptyType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes cannot be applied here")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed here")));
diag
}
}
}
}
};Diagnostic)]
1792#[diag("attributes cannot be applied here")]
1793pub(crate) struct AttributeOnEmptyType {
1794 #[primary_span]
1795 #[label("attributes are not allowed here")]
1796 pub span: Span,
1797}
1798
1799#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternMethodParamWithoutBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternMethodParamWithoutBody { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns aren't allowed in methods without bodies")));
let __code_109 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
})].into_iter();
diag.code(E0642);
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("give this argument a name or use an underscore to ignore it")),
__code_109, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1800#[diag("patterns aren't allowed in methods without bodies", code = E0642)]
1801pub(crate) struct PatternMethodParamWithoutBody {
1802 #[primary_span]
1803 #[suggestion(
1804 "give this argument a name or use an underscore to ignore it",
1805 code = "_",
1806 applicability = "machine-applicable",
1807 style = "verbose"
1808 )]
1809 pub span: Span,
1810}
1811
1812#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfParamNotFirst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfParamNotFirst { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `self` parameter in function")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must be the first parameter of an associated function")));
diag
}
}
}
}
};Diagnostic)]
1813#[diag("unexpected `self` parameter in function")]
1814pub(crate) struct SelfParamNotFirst {
1815 #[primary_span]
1816 #[label("must be the first parameter of an associated function")]
1817 pub span: Span,
1818}
1819
1820#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstGenericWithoutBraces where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstGenericWithoutBraces {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expressions must be enclosed in braces to be used as const generic arguments")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1821#[diag("expressions must be enclosed in braces to be used as const generic arguments")]
1822pub(crate) struct ConstGenericWithoutBraces {
1823 #[primary_span]
1824 pub span: Span,
1825 #[subdiagnostic]
1826 pub sugg: ConstGenericWithoutBracesSugg,
1827}
1828
1829#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConstGenericWithoutBracesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConstGenericWithoutBracesSugg {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_110 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_111 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_110));
suggestions.push((__binding_1, __code_111));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclose the `const` expression in braces")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1830#[multipart_suggestion(
1831 "enclose the `const` expression in braces",
1832 applicability = "machine-applicable"
1833)]
1834pub(crate) struct ConstGenericWithoutBracesSugg {
1835 #[suggestion_part(code = "{{ ")]
1836 pub left: Span,
1837 #[suggestion_part(code = " }}")]
1838 pub right: Span,
1839}
1840
1841#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedConstParamDeclaration where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedConstParamDeclaration {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `const` parameter declaration")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a `const` expression, not a parameter declaration")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1842#[diag("unexpected `const` parameter declaration")]
1843pub(crate) struct UnexpectedConstParamDeclaration {
1844 #[primary_span]
1845 #[label("expected a `const` expression, not a parameter declaration")]
1846 pub span: Span,
1847 #[subdiagnostic]
1848 pub sugg: Option<UnexpectedConstParamDeclarationSugg>,
1849}
1850
1851#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedConstParamDeclarationSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedConstParamDeclarationSugg::AddParam {
impl_generics: __binding_0,
incorrect_decl: __binding_1,
snippet: __binding_2,
ident: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_112 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", __binding_2))
});
let __code_113 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_112));
suggestions.push((__binding_1, __code_113));
diag.store_args();
diag.arg("snippet", __binding_2);
diag.arg("ident", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` parameters must be declared for the `impl`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
UnexpectedConstParamDeclarationSugg::AppendParam {
impl_generics_end: __binding_0,
incorrect_decl: __binding_1,
snippet: __binding_2,
ident: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_114 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_115 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_114));
suggestions.push((__binding_1, __code_115));
diag.store_args();
diag.arg("snippet", __binding_2);
diag.arg("ident", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` parameters must be declared for the `impl`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1852pub(crate) enum UnexpectedConstParamDeclarationSugg {
1853 #[multipart_suggestion(
1854 "`const` parameters must be declared for the `impl`",
1855 applicability = "machine-applicable"
1856 )]
1857 AddParam {
1858 #[suggestion_part(code = "<{snippet}>")]
1859 impl_generics: Span,
1860 #[suggestion_part(code = "{ident}")]
1861 incorrect_decl: Span,
1862 snippet: String,
1863 ident: String,
1864 },
1865 #[multipart_suggestion(
1866 "`const` parameters must be declared for the `impl`",
1867 applicability = "machine-applicable"
1868 )]
1869 AppendParam {
1870 #[suggestion_part(code = ", {snippet}")]
1871 impl_generics_end: Span,
1872 #[suggestion_part(code = "{ident}")]
1873 incorrect_decl: Span,
1874 snippet: String,
1875 ident: String,
1876 },
1877}
1878
1879#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedConstInGenericParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedConstInGenericParam {
span: __binding_0, to_remove: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected lifetime, type, or constant, found keyword `const`")));
let __code_116 =
[::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_116, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1880#[diag("expected lifetime, type, or constant, found keyword `const`")]
1881pub(crate) struct UnexpectedConstInGenericParam {
1882 #[primary_span]
1883 pub span: Span,
1884 #[suggestion(
1885 "the `const` keyword is only needed in the definition of the type",
1886 style = "verbose",
1887 code = "",
1888 applicability = "maybe-incorrect"
1889 )]
1890 pub to_remove: Option<Span>,
1891}
1892
1893#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncMoveOrderIncorrect where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncMoveOrderIncorrect { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the order of `move` and `async` is incorrect")));
let __code_117 =
[::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_117, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1894#[diag("the order of `move` and `async` is incorrect")]
1895pub(crate) struct AsyncMoveOrderIncorrect {
1896 #[primary_span]
1897 #[suggestion(
1898 "try switching the order",
1899 style = "verbose",
1900 code = "async move",
1901 applicability = "maybe-incorrect"
1902 )]
1903 pub span: Span,
1904}
1905
1906#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncUseOrderIncorrect where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncUseOrderIncorrect { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the order of `use` and `async` is incorrect")));
let __code_118 =
[::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_118, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1907#[diag("the order of `use` and `async` is incorrect")]
1908pub(crate) struct AsyncUseOrderIncorrect {
1909 #[primary_span]
1910 #[suggestion(
1911 "try switching the order",
1912 style = "verbose",
1913 code = "async use",
1914 applicability = "maybe-incorrect"
1915 )]
1916 pub span: Span,
1917}
1918
1919#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DoubleColonInBound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DoubleColonInBound { span: __binding_0, between: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `:` followed by trait or lifetime")));
let __code_119 =
[::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_119, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1920#[diag("expected `:` followed by trait or lifetime")]
1921pub(crate) struct DoubleColonInBound {
1922 #[primary_span]
1923 pub span: Span,
1924 #[suggestion(
1925 "use single colon",
1926 code = ": ",
1927 applicability = "machine-applicable",
1928 style = "verbose"
1929 )]
1930 pub between: Span,
1931}
1932
1933#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPtrWithGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPtrWithGenerics { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer types may not have generic parameters")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1934#[diag("function pointer types may not have generic parameters")]
1935pub(crate) struct FnPtrWithGenerics {
1936 #[primary_span]
1937 pub span: Span,
1938 #[subdiagnostic]
1939 pub sugg: Option<FnPtrWithGenericsSugg>,
1940}
1941
1942#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MisplacedReturnType {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MisplacedReturnType {
fn_params_end: __binding_0,
snippet: __binding_1,
ret_ty_span: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_120 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {0}", __binding_1))
});
let __code_121 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_120));
suggestions.push((__binding_2, __code_121));
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place the return type after the function parameters")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1943#[multipart_suggestion(
1944 "place the return type after the function parameters",
1945 style = "verbose",
1946 applicability = "maybe-incorrect"
1947)]
1948pub(crate) struct MisplacedReturnType {
1949 #[suggestion_part(code = " {snippet}")]
1950 pub fn_params_end: Span,
1951 pub snippet: String,
1952 #[suggestion_part(code = "")]
1953 pub ret_ty_span: Span,
1954}
1955
1956#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FnPtrWithGenericsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FnPtrWithGenericsSugg {
left: __binding_0,
snippet: __binding_1,
right: __binding_2,
arity: __binding_3,
for_param_list_exists: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_122 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_123 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_122));
suggestions.push((__binding_2, __code_123));
diag.store_args();
diag.arg("snippet", __binding_1);
diag.arg("arity", __binding_3);
diag.arg("for_param_list_exists", __binding_4);
let __message =
diag.eagerly_translate(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")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1957#[multipart_suggestion(
1958 "consider moving the lifetime {$arity ->
1959 [one] parameter
1960 *[other] parameters
1961 } to {$for_param_list_exists ->
1962 [true] the
1963 *[false] a
1964 } `for` parameter list",
1965 applicability = "maybe-incorrect"
1966)]
1967pub(crate) struct FnPtrWithGenericsSugg {
1968 #[suggestion_part(code = "{snippet}")]
1969 pub left: Span,
1970 pub snippet: String,
1971 #[suggestion_part(code = "")]
1972 pub right: Span,
1973 pub arity: usize,
1974 pub for_param_list_exists: bool,
1975}
1976
1977pub(crate) struct FnTraitMissingParen {
1978 pub span: Span,
1979}
1980
1981impl Subdiagnostic for FnTraitMissingParen {
1982 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1983 diag.span_label(self.span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Fn` bounds require arguments in parentheses"))inline_fluent!("`Fn` bounds require arguments in parentheses"));
1984 diag.span_suggestion_short(
1985 self.span.shrink_to_hi(),
1986 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses"))inline_fluent!("try adding parentheses"),
1987 "()",
1988 Applicability::MachineApplicable,
1989 );
1990 }
1991}
1992
1993#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedIfWithIf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedIfWithIf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `if` in the condition expression")));
let __code_124 =
[::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_124, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1994#[diag("unexpected `if` in the condition expression")]
1995pub(crate) struct UnexpectedIfWithIf(
1996 #[primary_span]
1997 #[suggestion(
1998 "remove the `if`",
1999 applicability = "machine-applicable",
2000 code = " ",
2001 style = "verbose"
2002 )]
2003 pub Span,
2004);
2005
2006#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnTypoWithImpl
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnTypoWithImpl { fn_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write `impl` instead of `fn`")));
let __code_125 =
[::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_125, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2007#[diag("you might have meant to write `impl` instead of `fn`")]
2008pub(crate) struct FnTypoWithImpl {
2009 #[primary_span]
2010 #[suggestion(
2011 "replace `fn` with `impl` here",
2012 applicability = "maybe-incorrect",
2013 code = "impl",
2014 style = "verbose"
2015 )]
2016 pub fn_span: Span,
2017}
2018
2019#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedFnPathFoundFnKeyword where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedFnPathFoundFnKeyword { fn_token_span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found keyword `fn`")));
let __code_126 =
[::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_126, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2020#[diag("expected identifier, found keyword `fn`")]
2021pub(crate) struct ExpectedFnPathFoundFnKeyword {
2022 #[primary_span]
2023 #[suggestion(
2024 "use `Fn` to refer to the trait",
2025 applicability = "machine-applicable",
2026 code = "Fn",
2027 style = "verbose"
2028 )]
2029 pub fn_token_span: Span,
2030}
2031
2032#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPathFoundNamedParams where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPathFoundNamedParams { named_param_span: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support named parameters")));
let __code_127 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the parameter name")),
__code_127, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2033#[diag("`Trait(...)` syntax does not support named parameters")]
2034pub(crate) struct FnPathFoundNamedParams {
2035 #[primary_span]
2036 #[suggestion("remove the parameter name", applicability = "machine-applicable", code = "")]
2037 pub named_param_span: Span,
2038}
2039
2040#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathFoundCVariadicParams where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathFoundCVariadicParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support c_variadic parameters")));
let __code_128 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `...`")),
__code_128, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2041#[diag("`Trait(...)` syntax does not support c_variadic parameters")]
2042pub(crate) struct PathFoundCVariadicParams {
2043 #[primary_span]
2044 #[suggestion("remove the `...`", applicability = "machine-applicable", code = "")]
2045 pub span: Span,
2046}
2047
2048#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathFoundAttributeInParams where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathFoundAttributeInParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Trait(...)` syntax does not support attributes in parameters")));
let __code_129 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attributes")),
__code_129, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2049#[diag("`Trait(...)` syntax does not support attributes in parameters")]
2050pub(crate) struct PathFoundAttributeInParams {
2051 #[primary_span]
2052 #[suggestion("remove the attributes", applicability = "machine-applicable", code = "")]
2053 pub span: Span,
2054}
2055
2056#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathSingleColon where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathSingleColon { span: __binding_0, suggestion: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path separator must be a double colon")));
let __code_130 =
[::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_130, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2057#[diag("path separator must be a double colon")]
2058pub(crate) struct PathSingleColon {
2059 #[primary_span]
2060 pub span: Span,
2061
2062 #[suggestion(
2063 "use a double colon instead",
2064 applicability = "machine-applicable",
2065 code = ":",
2066 style = "verbose"
2067 )]
2068 pub suggestion: Span,
2069}
2070
2071#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathTripleColon where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathTripleColon { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path separator must be a double colon")));
let __code_131 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a double colon instead")),
__code_131, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2072#[diag("path separator must be a double colon")]
2073pub(crate) struct PathTripleColon {
2074 #[primary_span]
2075 #[suggestion(
2076 "use a double colon instead",
2077 applicability = "maybe-incorrect",
2078 code = "",
2079 style = "verbose"
2080 )]
2081 pub span: Span,
2082}
2083
2084#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ColonAsSemi
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ColonAsSemi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("statements are terminated with a semicolon")));
let __code_132 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a semicolon instead")),
__code_132, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2085#[diag("statements are terminated with a semicolon")]
2086pub(crate) struct ColonAsSemi {
2087 #[primary_span]
2088 #[suggestion(
2089 "use a semicolon instead",
2090 applicability = "machine-applicable",
2091 code = ";",
2092 style = "verbose"
2093 )]
2094 pub span: Span,
2095}
2096
2097#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseBeforeTupleStructBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseBeforeTupleStructBody {
span: __binding_0,
name: __binding_1,
body: __binding_2,
sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed before tuple struct bodies")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected where clause")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this tuple struct")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the struct body")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
2098#[diag("where clauses are not allowed before tuple struct bodies")]
2099pub(crate) struct WhereClauseBeforeTupleStructBody {
2100 #[primary_span]
2101 #[label("unexpected where clause")]
2102 pub span: Span,
2103 #[label("while parsing this tuple struct")]
2104 pub name: Span,
2105 #[label("the struct body")]
2106 pub body: Span,
2107 #[subdiagnostic]
2108 pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
2109}
2110
2111#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
WhereClauseBeforeTupleStructBodySugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WhereClauseBeforeTupleStructBodySugg {
left: __binding_0, snippet: __binding_1, right: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_133 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_134 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_133));
suggestions.push((__binding_2, __code_134));
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the body before the where clause")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2112#[multipart_suggestion(
2113 "move the body before the where clause",
2114 applicability = "machine-applicable"
2115)]
2116pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
2117 #[suggestion_part(code = "{snippet}")]
2118 pub left: Span,
2119 pub snippet: String,
2120 #[suggestion_part(code = "")]
2121 pub right: Span,
2122}
2123
2124#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsyncFnIn2015
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncFnIn2015 { span: __binding_0, help: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async fn` is not permitted in Rust 2015")));
diag.code(E0670);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to use `async fn`, switch to Rust 2018 or later")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2125#[diag("`async fn` is not permitted in Rust 2015", code = E0670)]
2126pub(crate) struct AsyncFnIn2015 {
2127 #[primary_span]
2128 #[label("to use `async fn`, switch to Rust 2018 or later")]
2129 pub span: Span,
2130 #[subdiagnostic]
2131 pub help: HelpUseLatestEdition,
2132}
2133
2134#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AsyncBlockIn2015 {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AsyncBlockIn2015 { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` blocks are only allowed in Rust 2018 or later")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2135#[label("`async` blocks are only allowed in Rust 2018 or later")]
2136pub(crate) struct AsyncBlockIn2015 {
2137 #[primary_span]
2138 pub span: Span,
2139}
2140
2141#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncMoveBlockIn2015 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncMoveBlockIn2015 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async move` blocks are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2142#[diag("`async move` blocks are only allowed in Rust 2018 or later")]
2143pub(crate) struct AsyncMoveBlockIn2015 {
2144 #[primary_span]
2145 pub span: Span,
2146}
2147
2148#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncUseBlockIn2015 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncUseBlockIn2015 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async use` blocks are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2149#[diag("`async use` blocks are only allowed in Rust 2018 or later")]
2150pub(crate) struct AsyncUseBlockIn2015 {
2151 #[primary_span]
2152 pub span: Span,
2153}
2154
2155#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncBoundModifierIn2015 where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncBoundModifierIn2015 {
span: __binding_0, help: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` trait bounds are only allowed in Rust 2018 or later")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2156#[diag("`async` trait bounds are only allowed in Rust 2018 or later")]
2157pub(crate) struct AsyncBoundModifierIn2015 {
2158 #[primary_span]
2159 pub span: Span,
2160 #[subdiagnostic]
2161 pub help: HelpUseLatestEdition,
2162}
2163
2164#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LetChainPre2024 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LetChainPre2024 { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("let chains are only allowed in Rust 2024 or later")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2165#[diag("let chains are only allowed in Rust 2024 or later")]
2166pub(crate) struct LetChainPre2024 {
2167 #[primary_span]
2168 pub span: Span,
2169}
2170
2171#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfArgumentPointer where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfArgumentPointer { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot pass `self` by raw pointer")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot pass `self` by raw pointer")));
diag
}
}
}
}
};Diagnostic)]
2172#[diag("cannot pass `self` by raw pointer")]
2173pub(crate) struct SelfArgumentPointer {
2174 #[primary_span]
2175 #[label("cannot pass `self` by raw pointer")]
2176 pub span: Span,
2177}
2178
2179#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterDot where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterDot {
span: __binding_0, actual: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token: {$actual}")));
;
diag.arg("actual", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2180#[diag("unexpected token: {$actual}")]
2181pub(crate) struct UnexpectedTokenAfterDot {
2182 #[primary_span]
2183 pub span: Span,
2184 pub actual: String,
2185}
2186
2187#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VisibilityNotFollowedByItem where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VisibilityNotFollowedByItem {
span: __binding_0, vis: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("visibility `{$vis}` is not followed by an item")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")));
;
diag.arg("vis", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the visibility")));
diag
}
}
}
}
};Diagnostic)]
2188#[diag("visibility `{$vis}` is not followed by an item")]
2189#[help("you likely meant to define an item, e.g., `{$vis} fn foo() {\"{}\"}`")]
2190pub(crate) struct VisibilityNotFollowedByItem {
2191 #[primary_span]
2192 #[label("the visibility")]
2193 pub span: Span,
2194 pub vis: Visibility,
2195}
2196
2197#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DefaultNotFollowedByItem where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DefaultNotFollowedByItem { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` is not followed by an item")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `default` qualifier")));
diag
}
}
}
}
};Diagnostic)]
2198#[diag("`default` is not followed by an item")]
2199#[note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")]
2200pub(crate) struct DefaultNotFollowedByItem {
2201 #[primary_span]
2202 #[label("the `default` qualifier")]
2203 pub span: Span,
2204}
2205
2206#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingKeywordForItemDefinition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingKeywordForItemDefinition::Enum {
span: __binding_0,
insert_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `enum` for enum definition")));
let __code_135 =
[::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_135, 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_136 =
[::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_136, 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_137 =
[::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_137, 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_138 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("fn "))
})].into_iter();
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `fn` here to parse `{$ident}` as a method")),
__code_138, 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)]
2207pub(crate) enum MissingKeywordForItemDefinition {
2208 #[diag("missing `enum` for enum definition")]
2209 Enum {
2210 #[primary_span]
2211 span: Span,
2212 #[suggestion(
2213 "add `enum` here to parse `{$ident}` as an enum",
2214 style = "verbose",
2215 applicability = "maybe-incorrect",
2216 code = "enum "
2217 )]
2218 insert_span: Span,
2219 ident: Ident,
2220 },
2221 #[diag("missing `enum` or `struct` for enum or struct definition")]
2222 EnumOrStruct {
2223 #[primary_span]
2224 span: Span,
2225 },
2226 #[diag("missing `struct` for struct definition")]
2227 Struct {
2228 #[primary_span]
2229 span: Span,
2230 #[suggestion(
2231 "add `struct` here to parse `{$ident}` as a struct",
2232 style = "verbose",
2233 applicability = "maybe-incorrect",
2234 code = "struct "
2235 )]
2236 insert_span: Span,
2237 ident: Ident,
2238 },
2239 #[diag("missing `fn` for function definition")]
2240 Function {
2241 #[primary_span]
2242 span: Span,
2243 #[suggestion(
2244 "add `fn` here to parse `{$ident}` as a function",
2245 style = "verbose",
2246 applicability = "maybe-incorrect",
2247 code = "fn "
2248 )]
2249 insert_span: Span,
2250 ident: Ident,
2251 },
2252 #[diag("missing `fn` for method definition")]
2253 Method {
2254 #[primary_span]
2255 span: Span,
2256 #[suggestion(
2257 "add `fn` here to parse `{$ident}` as a method",
2258 style = "verbose",
2259 applicability = "maybe-incorrect",
2260 code = "fn "
2261 )]
2262 insert_span: Span,
2263 ident: Ident,
2264 },
2265 #[diag("missing `fn` or `struct` for function or struct definition")]
2266 Ambiguous {
2267 #[primary_span]
2268 span: Span,
2269 #[subdiagnostic]
2270 subdiag: Option<AmbiguousMissingKwForItemSub>,
2271 },
2272}
2273
2274#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AmbiguousMissingKwForItemSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousMissingKwForItemSub::SuggestMacro {
span: __binding_0, snippet: __binding_1 } => {
let __code_139 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}!", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to call a macro, try")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_139, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
AmbiguousMissingKwForItemSub::HelpMacro => {
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2275pub(crate) enum AmbiguousMissingKwForItemSub {
2276 #[suggestion(
2277 "if you meant to call a macro, try",
2278 applicability = "maybe-incorrect",
2279 code = "{snippet}!",
2280 style = "verbose"
2281 )]
2282 SuggestMacro {
2283 #[primary_span]
2284 span: Span,
2285 snippet: String,
2286 },
2287 #[help(
2288 "if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier"
2289 )]
2290 HelpMacro,
2291}
2292
2293#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingFnParams where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingFnParams { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing parameters for function definition")));
let __code_140 =
[::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_140, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2294#[diag("missing parameters for function definition")]
2295pub(crate) struct MissingFnParams {
2296 #[primary_span]
2297 #[suggestion(
2298 "add a parameter list",
2299 code = "()",
2300 applicability = "machine-applicable",
2301 style = "verbose"
2302 )]
2303 pub span: Span,
2304}
2305
2306#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidPathSepInFnDefinition where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidPathSepInFnDefinition { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid path separator in function definition")));
let __code_141 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove invalid path separator")),
__code_141, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2307#[diag("invalid path separator in function definition")]
2308pub(crate) struct InvalidPathSepInFnDefinition {
2309 #[primary_span]
2310 #[suggestion(
2311 "remove invalid path separator",
2312 code = "",
2313 applicability = "machine-applicable",
2314 style = "verbose"
2315 )]
2316 pub span: Span,
2317}
2318
2319#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingTraitInTraitImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingTraitInTraitImpl {
span: __binding_0, for_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing trait in a trait impl")));
let __code_142 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" Trait "))
})].into_iter();
let __code_143 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a trait here")),
__code_142, 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_143, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2320#[diag("missing trait in a trait impl")]
2321pub(crate) struct MissingTraitInTraitImpl {
2322 #[primary_span]
2323 #[suggestion(
2324 "add a trait here",
2325 code = " Trait ",
2326 applicability = "has-placeholders",
2327 style = "verbose"
2328 )]
2329 pub span: Span,
2330 #[suggestion(
2331 "for an inherent impl, drop this `for`",
2332 code = "",
2333 applicability = "maybe-incorrect",
2334 style = "verbose"
2335 )]
2336 pub for_span: Span,
2337}
2338
2339#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingForInTraitImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingForInTraitImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `for` in a trait impl")));
let __code_144 =
[::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_144, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2340#[diag("missing `for` in a trait impl")]
2341pub(crate) struct MissingForInTraitImpl {
2342 #[primary_span]
2343 #[suggestion(
2344 "add `for` here",
2345 style = "verbose",
2346 code = " for ",
2347 applicability = "machine-applicable"
2348 )]
2349 pub span: Span,
2350}
2351
2352#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedTraitInTraitImplFoundType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedTraitInTraitImplFoundType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a trait, found type")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2353#[diag("expected a trait, found type")]
2354pub(crate) struct ExpectedTraitInTraitImplFoundType {
2355 #[primary_span]
2356 pub span: Span,
2357}
2358
2359#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExtraImplKeywordInTraitImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExtraImplKeywordInTraitImpl {
extra_impl_kw: __binding_0, impl_trait_span: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `impl` keyword")));
let __code_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 the extra `impl`")),
__code_145, 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)]
2360#[diag("unexpected `impl` keyword")]
2361pub(crate) struct ExtraImplKeywordInTraitImpl {
2362 #[primary_span]
2363 #[suggestion(
2364 "remove the extra `impl`",
2365 code = "",
2366 applicability = "maybe-incorrect",
2367 style = "short"
2368 )]
2369 pub extra_impl_kw: Span,
2370 #[note("this is parsed as an `impl Trait` type, but a trait is expected at this position")]
2371 pub impl_trait_span: Span,
2372}
2373
2374#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BoundsNotAllowedOnTraitAliases where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoundsNotAllowedOnTraitAliases { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds are not allowed on trait aliases")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2375#[diag("bounds are not allowed on trait aliases")]
2376pub(crate) struct BoundsNotAllowedOnTraitAliases {
2377 #[primary_span]
2378 pub span: Span,
2379}
2380
2381#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitAliasCannotBeAuto where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitAliasCannotBeAuto { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `auto`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `auto`")));
diag
}
}
}
}
};Diagnostic)]
2382#[diag("trait aliases cannot be `auto`")]
2383pub(crate) struct TraitAliasCannotBeAuto {
2384 #[primary_span]
2385 #[label("trait aliases cannot be `auto`")]
2386 pub span: Span,
2387}
2388
2389#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitAliasCannotBeUnsafe where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitAliasCannotBeUnsafe { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `unsafe`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait aliases cannot be `unsafe`")));
diag
}
}
}
}
};Diagnostic)]
2390#[diag("trait aliases cannot be `unsafe`")]
2391pub(crate) struct TraitAliasCannotBeUnsafe {
2392 #[primary_span]
2393 #[label("trait aliases cannot be `unsafe`")]
2394 pub span: Span,
2395}
2396
2397#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssociatedStaticItemNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssociatedStaticItemNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated `static` items are not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2398#[diag("associated `static` items are not allowed")]
2399pub(crate) struct AssociatedStaticItemNotAllowed {
2400 #[primary_span]
2401 pub span: Span,
2402}
2403
2404#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternCrateNameWithDashes where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExternCrateNameWithDashes {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate name using dashes are not valid in `extern crate` statements")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dash-separated idents are not valid")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2405#[diag("crate name using dashes are not valid in `extern crate` statements")]
2406pub(crate) struct ExternCrateNameWithDashes {
2407 #[primary_span]
2408 #[label("dash-separated idents are not valid")]
2409 pub span: Span,
2410 #[subdiagnostic]
2411 pub sugg: ExternCrateNameWithDashesSugg,
2412}
2413
2414#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExternCrateNameWithDashesSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExternCrateNameWithDashesSugg { dashes: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_146 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_146.clone()));
}
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if the original crate name uses dashes you need to use underscores in the code")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2415#[multipart_suggestion(
2416 "if the original crate name uses dashes you need to use underscores in the code",
2417 applicability = "machine-applicable"
2418)]
2419pub(crate) struct ExternCrateNameWithDashesSugg {
2420 #[suggestion_part(code = "_")]
2421 pub dashes: Vec<Span>,
2422}
2423
2424#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternItemCannotBeConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExternItemCannotBeConst {
ident_span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern items cannot be `const`")));
let __code_147 =
[::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_147, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
2425#[diag("extern items cannot be `const`")]
2426#[note("for more information, visit https://doc.rust-lang.org/std/keyword.extern.html")]
2427pub(crate) struct ExternItemCannotBeConst {
2428 #[primary_span]
2429 pub ident_span: Span,
2430 #[suggestion(
2431 "try using a static value",
2432 code = "static ",
2433 applicability = "machine-applicable",
2434 style = "verbose"
2435 )]
2436 pub const_span: Option<Span>,
2437}
2438
2439#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstGlobalCannotBeMutable where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstGlobalCannotBeMutable {
ident_span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const globals cannot be mutable")));
let __code_148 =
[::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_148, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2440#[diag("const globals cannot be mutable")]
2441pub(crate) struct ConstGlobalCannotBeMutable {
2442 #[primary_span]
2443 #[label("cannot be mutable")]
2444 pub ident_span: Span,
2445 #[suggestion(
2446 "you might want to declare a static instead",
2447 code = "static",
2448 style = "verbose",
2449 applicability = "maybe-incorrect"
2450 )]
2451 pub const_span: Span,
2452}
2453
2454#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingConstType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingConstType {
span: __binding_0, kind: __binding_1, colon: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing type for `{$kind}` item")));
let __code_149 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} <type>",
__binding_2))
})].into_iter();
;
diag.arg("kind", __binding_1);
diag.arg("colon", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide a type for the item")),
__code_149, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2455#[diag("missing type for `{$kind}` item")]
2456pub(crate) struct MissingConstType {
2457 #[primary_span]
2458 #[suggestion(
2459 "provide a type for the item",
2460 code = "{colon} <type>",
2461 style = "verbose",
2462 applicability = "has-placeholders"
2463 )]
2464 pub span: Span,
2465
2466 pub kind: &'static str,
2467 pub colon: &'static str,
2468}
2469
2470#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EnumStructMutuallyExclusive where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EnumStructMutuallyExclusive { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`enum` and `struct` are mutually exclusive")));
let __code_150 =
[::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_150, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2471#[diag("`enum` and `struct` are mutually exclusive")]
2472pub(crate) struct EnumStructMutuallyExclusive {
2473 #[primary_span]
2474 #[suggestion(
2475 "replace `enum struct` with",
2476 code = "enum",
2477 style = "verbose",
2478 applicability = "machine-applicable"
2479 )]
2480 pub span: Span,
2481}
2482
2483#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedTokenAfterStructName where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedTokenAfterStructName::ReservedIdentifier {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::Keyword {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::ReservedKeyword {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::DocComment {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::MetaVar { span: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
UnexpectedTokenAfterStructName::Other {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")));
diag
}
}
}
}
};Diagnostic)]
2484pub(crate) enum UnexpectedTokenAfterStructName {
2485 #[diag(
2486 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`"
2487 )]
2488 ReservedIdentifier {
2489 #[primary_span]
2490 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2491 span: Span,
2492 token: Token,
2493 },
2494 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found keyword `{$token}`")]
2495 Keyword {
2496 #[primary_span]
2497 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2498 span: Span,
2499 token: Token,
2500 },
2501 #[diag(
2502 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`"
2503 )]
2504 ReservedKeyword {
2505 #[primary_span]
2506 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2507 span: Span,
2508 token: Token,
2509 },
2510 #[diag(
2511 "expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found doc comment `{$token}`"
2512 )]
2513 DocComment {
2514 #[primary_span]
2515 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2516 span: Span,
2517 token: Token,
2518 },
2519 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found metavar")]
2520 MetaVar {
2521 #[primary_span]
2522 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2523 span: Span,
2524 },
2525 #[diag("expected `where`, `{\"{\"}`, `(`, or `;` after struct name, found `{$token}`")]
2526 Other {
2527 #[primary_span]
2528 #[label("expected `where`, `{\"{\"}`, `(`, or `;` after struct name")]
2529 span: Span,
2530 token: Token,
2531 },
2532}
2533
2534impl UnexpectedTokenAfterStructName {
2535 pub(crate) fn new(span: Span, token: Token) -> Self {
2536 match TokenDescription::from_token(&token) {
2537 Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
2538 Some(TokenDescription::Keyword) => Self::Keyword { span, token },
2539 Some(TokenDescription::ReservedKeyword) => Self::ReservedKeyword { span, token },
2540 Some(TokenDescription::DocComment) => Self::DocComment { span, token },
2541 Some(TokenDescription::MetaVar(_)) => Self::MetaVar { span },
2542 None => Self::Other { span, token },
2543 }
2544 }
2545}
2546
2547#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedSelfInGenericParameters where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedSelfInGenericParameters { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected keyword `Self` in generic parameters")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you cannot use `Self` as a generic parameter because it is reserved for associated items")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2548#[diag("unexpected keyword `Self` in generic parameters")]
2549#[note("you cannot use `Self` as a generic parameter because it is reserved for associated items")]
2550pub(crate) struct UnexpectedSelfInGenericParameters {
2551 #[primary_span]
2552 pub span: Span,
2553}
2554
2555#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedDefaultValueForLifetimeInGenericParameters where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedDefaultValueForLifetimeInGenericParameters {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected default lifetime parameter")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters cannot have default values")));
diag
}
}
}
}
};Diagnostic)]
2556#[diag("unexpected default lifetime parameter")]
2557pub(crate) struct UnexpectedDefaultValueForLifetimeInGenericParameters {
2558 #[primary_span]
2559 #[label("lifetime parameters cannot have default values")]
2560 pub span: Span,
2561}
2562
2563#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MultipleWhereClauses where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MultipleWhereClauses {
span: __binding_0,
previous: __binding_1,
between: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define duplicate `where` clauses on an item")));
let __code_151 =
[::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_151, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
2564#[diag("cannot define duplicate `where` clauses on an item")]
2565pub(crate) struct MultipleWhereClauses {
2566 #[primary_span]
2567 pub span: Span,
2568 #[label("previous `where` clause starts here")]
2569 pub previous: Span,
2570 #[suggestion(
2571 "consider joining the two `where` clauses into one",
2572 style = "verbose",
2573 code = ",",
2574 applicability = "maybe-incorrect"
2575 )]
2576 pub between: Span,
2577}
2578
2579#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedNonterminal where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedNonterminal::Item(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an item keyword")));
;
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Statement(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a statement")));
;
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Ident {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected ident, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag
}
UnexpectedNonterminal::Lifetime {
span: __binding_0, token: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a lifetime, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2580pub(crate) enum UnexpectedNonterminal {
2581 #[diag("expected an item keyword")]
2582 Item(#[primary_span] Span),
2583 #[diag("expected a statement")]
2584 Statement(#[primary_span] Span),
2585 #[diag("expected ident, found `{$token}`")]
2586 Ident {
2587 #[primary_span]
2588 span: Span,
2589 token: Token,
2590 },
2591 #[diag("expected a lifetime, found `{$token}`")]
2592 Lifetime {
2593 #[primary_span]
2594 span: Span,
2595 token: Token,
2596 },
2597}
2598
2599#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TopLevelOrPatternNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TopLevelOrPatternNotAllowed::LetBinding {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`let` bindings require top-level or-patterns in parentheses")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
TopLevelOrPatternNotAllowed::FunctionParameter {
span: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function parameters require top-level or-patterns in parentheses")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2600pub(crate) enum TopLevelOrPatternNotAllowed {
2601 #[diag("`let` bindings require top-level or-patterns in parentheses")]
2602 LetBinding {
2603 #[primary_span]
2604 span: Span,
2605 #[subdiagnostic]
2606 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2607 },
2608 #[diag("function parameters require top-level or-patterns in parentheses")]
2609 FunctionParameter {
2610 #[primary_span]
2611 span: Span,
2612 #[subdiagnostic]
2613 sub: Option<TopLevelOrPatternNotAllowedSugg>,
2614 },
2615}
2616
2617#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeRawIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeRawIdent { span: __binding_0, ident: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` cannot be a raw identifier")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2618#[diag("`{$ident}` cannot be a raw identifier")]
2619pub(crate) struct CannotBeRawIdent {
2620 #[primary_span]
2621 pub span: Span,
2622 pub ident: Symbol,
2623}
2624
2625#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeRawLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeRawLifetime { span: __binding_0, ident: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` cannot be a raw lifetime")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2626#[diag("`{$ident}` cannot be a raw lifetime")]
2627pub(crate) struct CannotBeRawLifetime {
2628 #[primary_span]
2629 pub span: Span,
2630 pub ident: Symbol,
2631}
2632
2633#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
KeywordLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
KeywordLifetime { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes cannot use keyword names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2634#[diag("lifetimes cannot use keyword names")]
2635pub(crate) struct KeywordLifetime {
2636 #[primary_span]
2637 pub span: Span,
2638}
2639
2640#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for KeywordLabel
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
KeywordLabel { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labels cannot use keyword names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2641#[diag("labels cannot use keyword names")]
2642pub(crate) struct KeywordLabel {
2643 #[primary_span]
2644 pub span: Span,
2645}
2646
2647#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CrDocComment
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CrDocComment { span: __binding_0, block: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in {$block ->\n [true] block doc-comment\n *[false] doc-comment\n }")));
;
diag.arg("block", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2648#[diag(
2649 "bare CR not allowed in {$block ->
2650 [true] block doc-comment
2651 *[false] doc-comment
2652 }"
2653)]
2654pub(crate) struct CrDocComment {
2655 #[primary_span]
2656 pub span: Span,
2657 pub block: bool,
2658}
2659
2660#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NoDigitsLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NoDigitsLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no valid digits found for number")));
diag.code(E0768);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2661#[diag("no valid digits found for number", code = E0768)]
2662pub(crate) struct NoDigitsLiteral {
2663 #[primary_span]
2664 pub span: Span,
2665}
2666
2667#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidDigitLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidDigitLiteral { span: __binding_0, base: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid digit for a base {$base} literal")));
;
diag.arg("base", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2668#[diag("invalid digit for a base {$base} literal")]
2669pub(crate) struct InvalidDigitLiteral {
2670 #[primary_span]
2671 pub span: Span,
2672 pub base: u32,
2673}
2674
2675#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmptyExponentFloat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EmptyExponentFloat { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected at least one digit in exponent")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2676#[diag("expected at least one digit in exponent")]
2677pub(crate) struct EmptyExponentFloat {
2678 #[primary_span]
2679 pub span: Span,
2680}
2681
2682#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FloatLiteralUnsupportedBase where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FloatLiteralUnsupportedBase {
span: __binding_0, base: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$base} float literal is not supported")));
;
diag.arg("base", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2683#[diag("{$base} float literal is not supported")]
2684pub(crate) struct FloatLiteralUnsupportedBase {
2685 #[primary_span]
2686 pub span: Span,
2687 pub base: &'static str,
2688}
2689
2690#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownPrefix<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownPrefix {
span: __binding_0, prefix: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefix `{$prefix}` is unknown")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefixed identifiers and literals are reserved since Rust 2021")));
;
diag.arg("prefix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown prefix")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
2691#[diag("prefix `{$prefix}` is unknown")]
2692#[note("prefixed identifiers and literals are reserved since Rust 2021")]
2693pub(crate) struct UnknownPrefix<'a> {
2694 #[primary_span]
2695 #[label("unknown prefix")]
2696 pub span: Span,
2697 pub prefix: &'a str,
2698 #[subdiagnostic]
2699 pub sugg: Option<UnknownPrefixSugg>,
2700}
2701
2702#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for MacroExpandsToAdtField<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroExpandsToAdtField { adt_ty: __binding_0 } => {
diag.store_args();
diag.arg("adt_ty", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot expand to {$adt_ty} fields")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2703#[note("macros cannot expand to {$adt_ty} fields")]
2704pub(crate) struct MacroExpandsToAdtField<'a> {
2705 pub adt_ty: &'a str,
2706}
2707
2708#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownPrefixSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownPrefixSugg::UseBr(__binding_0) => {
let __code_152 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("br"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `br` for a raw byte string")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_152, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
UnknownPrefixSugg::UseCr(__binding_0) => {
let __code_153 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("cr"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `cr` for a raw C-string")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_153, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
UnknownPrefixSugg::Whitespace(__binding_0) => {
let __code_154 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider inserting whitespace here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_154, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
UnknownPrefixSugg::MeantStr {
start: __binding_0, end: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_155 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
let __code_156 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_155));
suggestions.push((__binding_1, __code_156));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a string literal, use double quotes")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2709pub(crate) enum UnknownPrefixSugg {
2710 #[suggestion(
2711 "use `br` for a raw byte string",
2712 code = "br",
2713 applicability = "maybe-incorrect",
2714 style = "verbose"
2715 )]
2716 UseBr(#[primary_span] Span),
2717 #[suggestion(
2718 "use `cr` for a raw C-string",
2719 code = "cr",
2720 applicability = "maybe-incorrect",
2721 style = "verbose"
2722 )]
2723 UseCr(#[primary_span] Span),
2724 #[suggestion(
2725 "consider inserting whitespace here",
2726 code = " ",
2727 applicability = "maybe-incorrect",
2728 style = "verbose"
2729 )]
2730 Whitespace(#[primary_span] Span),
2731 #[multipart_suggestion(
2732 "if you meant to write a string literal, use double quotes",
2733 applicability = "maybe-incorrect",
2734 style = "verbose"
2735 )]
2736 MeantStr {
2737 #[suggestion_part(code = "\"")]
2738 start: Span,
2739 #[suggestion_part(code = "\"")]
2740 end: Span,
2741 },
2742}
2743
2744#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReservedMultihash where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedMultihash { span: __binding_0, sugg: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reserved multi-hash token is forbidden")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sequences of two or more # are reserved for future use since Rust 2024")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2745#[diag("reserved multi-hash token is forbidden")]
2746#[note("sequences of two or more # are reserved for future use since Rust 2024")]
2747pub(crate) struct ReservedMultihash {
2748 #[primary_span]
2749 pub span: Span,
2750 #[subdiagnostic]
2751 pub sugg: Option<GuardedStringSugg>,
2752}
2753#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ReservedString
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReservedString { span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid string literal")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unprefixed guarded string literals are reserved for future use since Rust 2024")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
2754#[diag("invalid string literal")]
2755#[note("unprefixed guarded string literals are reserved for future use since Rust 2024")]
2756pub(crate) struct ReservedString {
2757 #[primary_span]
2758 pub span: Span,
2759 #[subdiagnostic]
2760 pub sugg: Option<GuardedStringSugg>,
2761}
2762#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GuardedStringSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GuardedStringSugg(__binding_0) => {
let __code_157 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider inserting whitespace here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_157, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2763#[suggestion(
2764 "consider inserting whitespace here",
2765 code = " ",
2766 applicability = "maybe-incorrect",
2767 style = "verbose"
2768)]
2769pub(crate) struct GuardedStringSugg(#[primary_span] pub Span);
2770
2771#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TooManyHashes
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TooManyHashes { span: __binding_0, num: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}")));
;
diag.arg("num", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2772#[diag(
2773 "too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols, but found {$num}"
2774)]
2775pub(crate) struct TooManyHashes {
2776 #[primary_span]
2777 pub span: Span,
2778 pub num: u32,
2779}
2780
2781#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownTokenStart where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownTokenStart {
span: __binding_0,
escaped: __binding_1,
sugg: __binding_2,
null: __binding_3,
repeat: __binding_4,
invisible: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown start of token: {$escaped}")));
;
diag.arg("escaped", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
2782#[diag("unknown start of token: {$escaped}")]
2783pub(crate) struct UnknownTokenStart {
2784 #[primary_span]
2785 pub span: Span,
2786 pub escaped: String,
2787 #[subdiagnostic]
2788 pub sugg: Option<TokenSubstitution>,
2789 #[subdiagnostic]
2790 pub null: Option<UnknownTokenNull>,
2791 #[subdiagnostic]
2792 pub repeat: Option<UnknownTokenRepeat>,
2793 #[subdiagnostic]
2794 pub invisible: Option<InvisibleCharacter>,
2795}
2796
2797#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TokenSubstitution {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TokenSubstitution::DirectedQuotes {
span: __binding_0,
suggestion: __binding_1,
ascii_str: __binding_2,
ascii_name: __binding_3 } => {
let __code_158 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("suggestion", __binding_1);
diag.arg("ascii_str", __binding_2);
diag.arg("ascii_name", __binding_3);
let __message =
diag.eagerly_translate(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")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_158, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
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_159 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("suggestion", __binding_1);
diag.arg("ch", __binding_2);
diag.arg("u_name", __binding_3);
diag.arg("ascii_str", __binding_4);
diag.arg("ascii_name", __binding_5);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_159, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2798pub(crate) enum TokenSubstitution {
2799 #[suggestion(
2800 "Unicode characters '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '{$ascii_str}' ({$ascii_name}), but are not",
2801 code = "{suggestion}",
2802 applicability = "maybe-incorrect",
2803 style = "verbose"
2804 )]
2805 DirectedQuotes {
2806 #[primary_span]
2807 span: Span,
2808 suggestion: String,
2809 ascii_str: &'static str,
2810 ascii_name: &'static str,
2811 },
2812 #[suggestion(
2813 "Unicode character '{$ch}' ({$u_name}) looks like '{$ascii_str}' ({$ascii_name}), but it is not",
2814 code = "{suggestion}",
2815 applicability = "maybe-incorrect",
2816 style = "verbose"
2817 )]
2818 Other {
2819 #[primary_span]
2820 span: Span,
2821 suggestion: String,
2822 ch: String,
2823 u_name: &'static str,
2824 ascii_str: &'static str,
2825 ascii_name: &'static str,
2826 },
2827}
2828
2829#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownTokenRepeat {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownTokenRepeat { repeats: __binding_0 } => {
diag.store_args();
diag.arg("repeats", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("character appears {$repeats ->\n [one] once more\n *[other] {$repeats} more times\n }")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2830#[note(
2831 "character appears {$repeats ->
2832 [one] once more
2833 *[other] {$repeats} more times
2834 }"
2835)]
2836pub(crate) struct UnknownTokenRepeat {
2837 pub repeats: usize,
2838}
2839
2840#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvisibleCharacter {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvisibleCharacter => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invisible characters like '{$escaped}' are not usually visible in text editors")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2841#[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
2842pub(crate) struct InvisibleCharacter;
2843
2844#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownTokenNull {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownTokenNull => {
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
2845#[help(
2846 "source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
2847)]
2848pub(crate) struct UnknownTokenNull;
2849
2850#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnescapeError
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnescapeError::InvalidUnicodeEscape {
span: __binding_0, surrogate: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid unicode character escape")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unicode escape must {$surrogate ->\n [true] not be a surrogate\n *[false] be at most 10FFFF\n }")));
;
diag.arg("surrogate", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid escape")));
diag
}
UnescapeError::EscapeOnlyChar {
span: __binding_0,
char_span: __binding_1,
escaped_sugg: __binding_2,
escaped_msg: __binding_3,
byte: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$byte ->\n [true] byte\n *[false] character\n } constant must be escaped: `{$escaped_msg}`")));
let __code_160 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
;
diag.arg("escaped_sugg", __binding_2);
diag.arg("escaped_msg", __binding_3);
diag.arg("byte", __binding_4);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("escape the character")),
__code_160, 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_161 =
[::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_161, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
UnescapeError::BareCrRawString(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bare CR not allowed in raw string")));
;
diag.span(__binding_0);
diag
}
UnescapeError::TooShortHexEscape(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("numeric character escape is too short")));
;
diag.span(__binding_0);
diag
}
UnescapeError::InvalidCharInEscape {
span: __binding_0, is_hex: __binding_1, ch: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character in {$is_hex ->\n [true] numeric character\n *[false] unicode\n } escape: `{$ch}`")));
;
diag.arg("is_hex", __binding_1);
diag.arg("ch", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character in {$is_hex ->\n [true] numeric character\n *[false] unicode\n } escape")));
diag
}
UnescapeError::LeadingUnderscoreUnicodeEscape {
span: __binding_0, ch: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid start of unicode escape: `_`")));
;
diag.arg("ch", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid start of unicode escape")));
diag
}
UnescapeError::OverlongUnicodeEscape(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overlong unicode escape")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must have at most 6 hex digits")));
diag
}
UnescapeError::UnclosedUnicodeEscape(__binding_0,
__binding_1) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unterminated unicode escape")));
let __code_162 =
[::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_162, 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)]
2851pub(crate) enum UnescapeError {
2852 #[diag("invalid unicode character escape")]
2853 #[help(
2854 "unicode escape must {$surrogate ->
2855 [true] not be a surrogate
2856 *[false] be at most 10FFFF
2857 }"
2858 )]
2859 InvalidUnicodeEscape {
2860 #[primary_span]
2861 #[label("invalid escape")]
2862 span: Span,
2863 surrogate: bool,
2864 },
2865 #[diag(
2866 "{$byte ->
2867 [true] byte
2868 *[false] character
2869 } constant must be escaped: `{$escaped_msg}`"
2870 )]
2871 EscapeOnlyChar {
2872 #[primary_span]
2873 span: Span,
2874 #[suggestion(
2875 "escape the character",
2876 applicability = "machine-applicable",
2877 code = "{escaped_sugg}",
2878 style = "verbose"
2879 )]
2880 char_span: Span,
2881 escaped_sugg: String,
2882 escaped_msg: String,
2883 byte: bool,
2884 },
2885 #[diag(
2886 r#"{$double_quotes ->
2887 [true] bare CR not allowed in string, use `\r` instead
2888 *[false] character constant must be escaped: `\r`
2889 }"#
2890 )]
2891 BareCr {
2892 #[primary_span]
2893 #[suggestion(
2894 "escape the character",
2895 applicability = "machine-applicable",
2896 code = "\\r",
2897 style = "verbose"
2898 )]
2899 span: Span,
2900 double_quotes: bool,
2901 },
2902 #[diag("bare CR not allowed in raw string")]
2903 BareCrRawString(#[primary_span] Span),
2904 #[diag("numeric character escape is too short")]
2905 TooShortHexEscape(#[primary_span] Span),
2906 #[diag(
2907 "invalid character in {$is_hex ->
2908 [true] numeric character
2909 *[false] unicode
2910 } escape: `{$ch}`"
2911 )]
2912 InvalidCharInEscape {
2913 #[primary_span]
2914 #[label(
2915 "invalid character in {$is_hex ->
2916 [true] numeric character
2917 *[false] unicode
2918 } escape"
2919 )]
2920 span: Span,
2921 is_hex: bool,
2922 ch: String,
2923 },
2924 #[diag("invalid start of unicode escape: `_`")]
2925 LeadingUnderscoreUnicodeEscape {
2926 #[primary_span]
2927 #[label("invalid start of unicode escape")]
2928 span: Span,
2929 ch: String,
2930 },
2931 #[diag("overlong unicode escape")]
2932 OverlongUnicodeEscape(
2933 #[primary_span]
2934 #[label("must have at most 6 hex digits")]
2935 Span,
2936 ),
2937 #[diag("unterminated unicode escape")]
2938 UnclosedUnicodeEscape(
2939 #[primary_span]
2940 #[label(r#"missing a closing `{"}"}`"#)]
2941 Span,
2942 #[suggestion(
2943 "terminate the unicode escape",
2944 code = "}}",
2945 applicability = "maybe-incorrect",
2946 style = "verbose"
2947 )]
2948 Span,
2949 ),
2950 #[diag("incorrect unicode escape sequence")]
2951 NoBraceInUnicodeEscape {
2952 #[primary_span]
2953 span: Span,
2954 #[label("incorrect unicode escape sequence")]
2955 label: Option<Span>,
2956 #[subdiagnostic]
2957 sub: NoBraceUnicodeSub,
2958 },
2959 #[diag("unicode escape in byte string")]
2960 #[help("unicode escape sequences cannot be used as a byte or in a byte string")]
2961 UnicodeEscapeInByte(
2962 #[primary_span]
2963 #[label("unicode escape in byte string")]
2964 Span,
2965 ),
2966 #[diag("empty unicode escape")]
2967 EmptyUnicodeEscape(
2968 #[primary_span]
2969 #[label("this escape must have at least 1 hex digit")]
2970 Span,
2971 ),
2972 #[diag("empty character literal")]
2973 ZeroChars(
2974 #[primary_span]
2975 #[label("empty character literal")]
2976 Span,
2977 ),
2978 #[diag("invalid trailing slash in literal")]
2979 LoneSlash(
2980 #[primary_span]
2981 #[label("invalid trailing slash in literal")]
2982 Span,
2983 ),
2984 #[diag("whitespace symbol '{$ch}' is not skipped")]
2985 UnskippedWhitespace {
2986 #[primary_span]
2987 span: Span,
2988 #[label("whitespace symbol '{$ch}' is not skipped")]
2989 char_span: Span,
2990 ch: String,
2991 },
2992 #[diag("multiple lines skipped by escaped newline")]
2993 MultipleSkippedLinesWarning(
2994 #[primary_span]
2995 #[label("skipping everything up to and including this point")]
2996 Span,
2997 ),
2998 #[diag("character literal may only contain one codepoint")]
2999 MoreThanOneChar {
3000 #[primary_span]
3001 span: Span,
3002 #[subdiagnostic]
3003 note: Option<MoreThanOneCharNote>,
3004 #[subdiagnostic]
3005 suggestion: MoreThanOneCharSugg,
3006 },
3007 #[diag("null characters in C string literals are not supported")]
3008 NulInCStr {
3009 #[primary_span]
3010 span: Span,
3011 },
3012}
3013
3014#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoreThanOneCharSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoreThanOneCharSugg::NormalizedForm {
span: __binding_0, ch: __binding_1, normalized: __binding_2
} => {
let __code_163 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("ch", __binding_1);
diag.arg("normalized", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the normalized form `{$ch}` of this character")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_163, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
MoreThanOneCharSugg::RemoveNonPrinting {
span: __binding_0, ch: __binding_1 } => {
let __code_164 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("ch", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the non-printing characters")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_164, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
MoreThanOneCharSugg::QuotesFull {
span: __binding_0, is_byte: __binding_1, sugg: __binding_2 }
=> {
let __code_165 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("is_byte", __binding_1);
diag.arg("sugg", __binding_2);
let __message =
diag.eagerly_translate(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")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_165, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
MoreThanOneCharSugg::Quotes {
start: __binding_0,
end: __binding_1,
is_byte: __binding_2,
prefix: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_166 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}\"", __binding_3))
});
let __code_167 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\""))
});
suggestions.push((__binding_0, __code_166));
suggestions.push((__binding_1, __code_167));
diag.store_args();
diag.arg("is_byte", __binding_2);
diag.arg("prefix", __binding_3);
let __message =
diag.eagerly_translate(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")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3015pub(crate) enum MoreThanOneCharSugg {
3016 #[suggestion(
3017 "consider using the normalized form `{$ch}` of this character",
3018 code = "{normalized}",
3019 applicability = "machine-applicable",
3020 style = "verbose"
3021 )]
3022 NormalizedForm {
3023 #[primary_span]
3024 span: Span,
3025 ch: String,
3026 normalized: String,
3027 },
3028 #[suggestion(
3029 "consider removing the non-printing characters",
3030 code = "{ch}",
3031 applicability = "maybe-incorrect",
3032 style = "verbose"
3033 )]
3034 RemoveNonPrinting {
3035 #[primary_span]
3036 span: Span,
3037 ch: String,
3038 },
3039 #[suggestion(
3040 "if you meant to write a {$is_byte ->
3041 [true] byte string
3042 *[false] string
3043 } literal, use double quotes",
3044 code = "{sugg}",
3045 applicability = "machine-applicable",
3046 style = "verbose"
3047 )]
3048 QuotesFull {
3049 #[primary_span]
3050 span: Span,
3051 is_byte: bool,
3052 sugg: String,
3053 },
3054 #[multipart_suggestion(
3055 "if you meant to write a {$is_byte ->
3056 [true] byte string
3057 *[false] string
3058 } literal, use double quotes",
3059 applicability = "machine-applicable"
3060 )]
3061 Quotes {
3062 #[suggestion_part(code = "{prefix}\"")]
3063 start: Span,
3064 #[suggestion_part(code = "\"")]
3065 end: Span,
3066 is_byte: bool,
3067 prefix: &'static str,
3068 },
3069}
3070
3071#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoreThanOneCharNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoreThanOneCharNote::AllCombining {
span: __binding_0,
chr: __binding_1,
len: __binding_2,
escaped_marks: __binding_3 } => {
diag.store_args();
diag.arg("chr", __binding_1);
diag.arg("len", __binding_2);
diag.arg("escaped_marks", __binding_3);
let __message =
diag.eagerly_translate(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}`")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
MoreThanOneCharNote::NonPrinting {
span: __binding_0, escaped: __binding_1 } => {
diag.store_args();
diag.arg("escaped", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there are non-printing characters, the full sequence is `{$escaped}`")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3072pub(crate) enum MoreThanOneCharNote {
3073 #[note(
3074 "this `{$chr}` is followed by the combining {$len ->
3075 [one] mark
3076 *[other] marks
3077 } `{$escaped_marks}`"
3078 )]
3079 AllCombining {
3080 #[primary_span]
3081 span: Span,
3082 chr: String,
3083 len: usize,
3084 escaped_marks: String,
3085 },
3086 #[note("there are non-printing characters, the full sequence is `{$escaped}`")]
3087 NonPrinting {
3088 #[primary_span]
3089 span: Span,
3090 escaped: String,
3091 },
3092}
3093
3094#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NoBraceUnicodeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoBraceUnicodeSub::Suggestion {
span: __binding_0, suggestion: __binding_1 } => {
let __code_168 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("suggestion", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format of unicode escape sequences uses braces")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_168, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
NoBraceUnicodeSub::Help => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format of unicode escape sequences is `\\u{\"{...}\"}`")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3095pub(crate) enum NoBraceUnicodeSub {
3096 #[suggestion(
3097 "format of unicode escape sequences uses braces",
3098 code = "{suggestion}",
3099 applicability = "maybe-incorrect",
3100 style = "verbose"
3101 )]
3102 Suggestion {
3103 #[primary_span]
3104 span: Span,
3105 suggestion: String,
3106 },
3107 #[help(r#"format of unicode escape sequences is `\u{"{...}"}`"#)]
3108 Help,
3109}
3110
3111#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapInParens {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WrapInParens { lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_169 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_170 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_169));
suggestions.push((__binding_1, __code_170));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the pattern in parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3112#[multipart_suggestion("wrap the pattern in parentheses", applicability = "machine-applicable")]
3113pub(crate) struct WrapInParens {
3114 #[suggestion_part(code = "(")]
3115 pub(crate) lo: Span,
3116 #[suggestion_part(code = ")")]
3117 pub(crate) hi: Span,
3118}
3119
3120#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TopLevelOrPatternNotAllowedSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TopLevelOrPatternNotAllowedSugg::RemoveLeadingVert {
span: __binding_0 } => {
let __code_171 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `|`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_171, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.restore_args();
}
TopLevelOrPatternNotAllowedSugg::WrapInParens {
span: __binding_0, suggestion: __binding_1 } => {
__binding_1.add_to_diag(diag);
diag.store_args();
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3121pub(crate) enum TopLevelOrPatternNotAllowedSugg {
3122 #[suggestion(
3123 "remove the `|`",
3124 code = "",
3125 applicability = "machine-applicable",
3126 style = "tool-only"
3127 )]
3128 RemoveLeadingVert {
3129 #[primary_span]
3130 span: Span,
3131 },
3132 WrapInParens {
3133 #[primary_span]
3134 span: Span,
3135 #[subdiagnostic]
3136 suggestion: WrapInParens,
3137 },
3138}
3139
3140#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedVertVertBeforeFunctionParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedVertVertBeforeFunctionParam { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `||` before function parameter")));
let __code_172 =
[::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_172, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3141#[diag("unexpected `||` before function parameter")]
3142#[note("alternatives in or-patterns are separated with `|`, not `||`")]
3143pub(crate) struct UnexpectedVertVertBeforeFunctionParam {
3144 #[primary_span]
3145 #[suggestion(
3146 "remove the `||`",
3147 code = "",
3148 applicability = "machine-applicable",
3149 style = "verbose"
3150 )]
3151 pub span: Span,
3152}
3153
3154#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedVertVertInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedVertVertInPattern {
span: __binding_0, start: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token `||` in pattern")));
let __code_173 =
[::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_173, 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)]
3155#[diag("unexpected token `||` in pattern")]
3156pub(crate) struct UnexpectedVertVertInPattern {
3157 #[primary_span]
3158 #[suggestion(
3159 "use a single `|` to separate multiple alternative patterns",
3160 code = "|",
3161 applicability = "machine-applicable",
3162 style = "verbose"
3163 )]
3164 pub span: Span,
3165 #[label("while parsing this or-pattern starting here")]
3166 pub start: Option<Span>,
3167}
3168
3169#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TrailingVertSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TrailingVertSuggestion { span: __binding_0 } => {
let __code_174 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a trailing `{$token}` is not allowed in an or-pattern")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_174, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3170#[suggestion(
3171 "a trailing `{$token}` is not allowed in an or-pattern",
3172 code = "",
3173 applicability = "machine-applicable",
3174 style = "tool-only"
3175)]
3176pub(crate) struct TrailingVertSuggestion {
3177 #[primary_span]
3178 pub span: Span,
3179}
3180
3181#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TrailingVertNotAllowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TrailingVertNotAllowed {
span: __binding_0,
suggestion: __binding_1,
start: __binding_2,
token: __binding_3,
note_double_vert: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a trailing `{$token}` is not allowed in an or-pattern")));
;
diag.arg("token", __binding_3);
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this or-pattern starting here")));
}
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatives in or-patterns are separated with `|`, not `||`")));
}
diag
}
}
}
}
};Diagnostic)]
3182#[diag("a trailing `{$token}` is not allowed in an or-pattern")]
3183pub(crate) struct TrailingVertNotAllowed {
3184 #[primary_span]
3185 pub span: Span,
3186 #[subdiagnostic]
3187 pub suggestion: TrailingVertSuggestion,
3188 #[label("while parsing this or-pattern starting here")]
3189 pub start: Option<Span>,
3190 pub token: Token,
3191 #[note("alternatives in or-patterns are separated with `|`, not `||`")]
3192 pub note_double_vert: bool,
3193}
3194
3195#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotRestPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotRestPattern {
span: __binding_0,
suggestion: __binding_1,
var_args: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `...`")));
let __code_175 =
[::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_175, 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)]
3196#[diag("unexpected `...`")]
3197pub(crate) struct DotDotDotRestPattern {
3198 #[primary_span]
3199 #[label("not a valid pattern")]
3200 pub span: Span,
3201 #[suggestion(
3202 "for a rest pattern, use `..` instead of `...`",
3203 style = "verbose",
3204 code = "",
3205 applicability = "machine-applicable"
3206 )]
3207 pub suggestion: Option<Span>,
3208 #[note(
3209 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3210 )]
3211 pub var_args: Option<()>,
3212}
3213
3214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PatternOnWrongSideOfAt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternOnWrongSideOfAt {
whole_span: __binding_0,
whole_pat: __binding_1,
pattern: __binding_2,
binding: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern on wrong side of `@`")));
let __code_176 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("whole_pat", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("switch the order")),
__code_176, 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)]
3215#[diag("pattern on wrong side of `@`")]
3216pub(crate) struct PatternOnWrongSideOfAt {
3217 #[primary_span]
3218 #[suggestion(
3219 "switch the order",
3220 code = "{whole_pat}",
3221 applicability = "machine-applicable",
3222 style = "verbose"
3223 )]
3224 pub whole_span: Span,
3225 pub whole_pat: String,
3226 #[label("pattern on the left, should be on the right")]
3227 pub pattern: Span,
3228 #[label("binding on the right, should be on the left")]
3229 pub binding: Span,
3230}
3231
3232#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedBindingLeftOfAt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedBindingLeftOfAt {
whole_span: __binding_0, lhs: __binding_1, rhs: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("left-hand side of `@` must be a binding")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("interpreted as a pattern, not a binding")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("also a pattern")));
diag
}
}
}
}
};Diagnostic)]
3233#[diag("left-hand side of `@` must be a binding")]
3234#[note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")]
3235pub(crate) struct ExpectedBindingLeftOfAt {
3236 #[primary_span]
3237 pub whole_span: Span,
3238 #[label("interpreted as a pattern, not a binding")]
3239 pub lhs: Span,
3240 #[label("also a pattern")]
3241 pub rhs: Span,
3242}
3243
3244#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenRangeSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenRangeSuggestion { lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_177 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_178 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_177));
suggestions.push((__binding_1, __code_178));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses to clarify the precedence")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3245#[multipart_suggestion(
3246 "add parentheses to clarify the precedence",
3247 applicability = "machine-applicable"
3248)]
3249pub(crate) struct ParenRangeSuggestion {
3250 #[suggestion_part(code = "(")]
3251 pub lo: Span,
3252 #[suggestion_part(code = ")")]
3253 pub hi: Span,
3254}
3255
3256#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousRangePattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousRangePattern {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the range pattern here has ambiguous interpretation")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3257#[diag("the range pattern here has ambiguous interpretation")]
3258pub(crate) struct AmbiguousRangePattern {
3259 #[primary_span]
3260 pub span: Span,
3261 #[subdiagnostic]
3262 pub suggestion: ParenRangeSuggestion,
3263}
3264
3265#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedLifetimeInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedLifetimeInPattern {
span: __binding_0,
symbol: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected lifetime `{$symbol}` in pattern")));
let __code_179 =
[::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_179, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3266#[diag("unexpected lifetime `{$symbol}` in pattern")]
3267pub(crate) struct UnexpectedLifetimeInPattern {
3268 #[primary_span]
3269 pub span: Span,
3270 pub symbol: Symbol,
3271 #[suggestion(
3272 "remove the lifetime",
3273 code = "",
3274 applicability = "machine-applicable",
3275 style = "verbose"
3276 )]
3277 pub suggestion: Span,
3278}
3279
3280#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidMutInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidMutInPattern::NestedIdent {
span: __binding_0, pat: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` must be attached to each individual binding")));
let __code_180 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` may be followed by `variable` and `variable @ pattern`")));
;
diag.arg("pat", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `mut` to each binding")),
__code_180, 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_181 =
[::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_181, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3281pub(crate) enum InvalidMutInPattern {
3282 #[diag("`mut` must be attached to each individual binding")]
3283 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3284 NestedIdent {
3285 #[primary_span]
3286 #[suggestion(
3287 "add `mut` to each binding",
3288 code = "{pat}",
3289 applicability = "machine-applicable",
3290 style = "verbose"
3291 )]
3292 span: Span,
3293 pat: String,
3294 },
3295 #[diag("`mut` must be followed by a named binding")]
3296 #[note("`mut` may be followed by `variable` and `variable @ pattern`")]
3297 NonIdent {
3298 #[primary_span]
3299 #[suggestion(
3300 "remove the `mut` prefix",
3301 code = "",
3302 applicability = "machine-applicable",
3303 style = "verbose"
3304 )]
3305 span: Span,
3306 },
3307}
3308
3309#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RepeatedMutInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RepeatedMutInPattern {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` on a binding may not be repeated")));
let __code_182 =
[::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_182, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3310#[diag("`mut` on a binding may not be repeated")]
3311pub(crate) struct RepeatedMutInPattern {
3312 #[primary_span]
3313 pub span: Span,
3314 #[suggestion(
3315 "remove the additional `mut`s",
3316 code = "",
3317 applicability = "machine-applicable",
3318 style = "verbose"
3319 )]
3320 pub suggestion: Span,
3321}
3322
3323#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotRangeToPatternNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotRangeToPatternNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range-to patterns with `...` are not allowed")));
let __code_183 =
[::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_183, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3324#[diag("range-to patterns with `...` are not allowed")]
3325pub(crate) struct DotDotDotRangeToPatternNotAllowed {
3326 #[primary_span]
3327 #[suggestion(
3328 "use `..=` instead",
3329 style = "verbose",
3330 code = "..=",
3331 applicability = "machine-applicable"
3332 )]
3333 pub span: Span,
3334}
3335
3336#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EnumPatternInsteadOfIdentifier where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EnumPatternInsteadOfIdentifier { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier, found enum pattern")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3337#[diag("expected identifier, found enum pattern")]
3338pub(crate) struct EnumPatternInsteadOfIdentifier {
3339 #[primary_span]
3340 pub span: Span,
3341}
3342
3343#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtDotDotInStructPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtDotDotInStructPattern {
span: __binding_0, remove: __binding_1, ident: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`@ ..` is not supported in struct patterns")));
let __code_184 =
[::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_184, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3344#[diag("`@ ..` is not supported in struct patterns")]
3345pub(crate) struct AtDotDotInStructPattern {
3346 #[primary_span]
3347 pub span: Span,
3348 #[suggestion(
3349 "bind to each field separately or, if you don't need them, just remove `{$ident} @`",
3350 code = "",
3351 style = "verbose",
3352 applicability = "machine-applicable"
3353 )]
3354 pub remove: Span,
3355 pub ident: Ident,
3356}
3357
3358#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtInStructPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtInStructPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `@` in struct pattern")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct patterns use `field: pattern` syntax to bind to fields")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3359#[diag("unexpected `@` in struct pattern")]
3360#[note("struct patterns use `field: pattern` syntax to bind to fields")]
3361#[help(
3362 "consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended"
3363)]
3364pub(crate) struct AtInStructPattern {
3365 #[primary_span]
3366 pub span: Span,
3367}
3368
3369#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotDotForRemainingFields where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotDotForRemainingFields {
span: __binding_0, token_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected field pattern, found `{$token_str}`")));
let __code_185 =
[::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_185, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3370#[diag("expected field pattern, found `{$token_str}`")]
3371pub(crate) struct DotDotDotForRemainingFields {
3372 #[primary_span]
3373 #[suggestion(
3374 "to omit remaining fields, use `..`",
3375 code = "..",
3376 style = "verbose",
3377 applicability = "machine-applicable"
3378 )]
3379 pub span: Span,
3380 pub token_str: Cow<'static, str>,
3381}
3382
3383#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedCommaAfterPatternField where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedCommaAfterPatternField { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3384#[diag("expected `,`")]
3385pub(crate) struct ExpectedCommaAfterPatternField {
3386 #[primary_span]
3387 pub span: Span,
3388}
3389
3390#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedExpressionInPattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedExpressionInPattern {
span: __binding_0,
is_bound: __binding_1,
expr_precedence: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected {$is_bound ->\n [true] a pattern range bound\n *[false] a pattern\n }, found an expression")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>")));
;
diag.arg("is_bound", __binding_1);
diag.arg("expr_precedence", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a pattern")));
diag
}
}
}
}
};Diagnostic)]
3391#[diag(
3392 "expected {$is_bound ->
3393 [true] a pattern range bound
3394 *[false] a pattern
3395 }, found an expression"
3396)]
3397#[note(
3398 "arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>"
3399)]
3400pub(crate) struct UnexpectedExpressionInPattern {
3401 #[primary_span]
3403 #[label("not a pattern")]
3404 pub span: Span,
3405 pub is_bound: bool,
3407 pub expr_precedence: ExprPrecedence,
3409}
3410
3411#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedExpressionInPatternSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedExpressionInPatternSugg::CreateGuard {
ident_span: __binding_0,
pat_hi: __binding_1,
ident: __binding_2,
expr: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_186 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
let __code_187 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if {1} == {0}",
__binding_3, __binding_2))
});
suggestions.push((__binding_0, __code_186));
suggestions.push((__binding_1, __code_187));
diag.store_args();
diag.arg("ident", __binding_2);
diag.arg("expr", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the expression to a match arm guard")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
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_188 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
let __code_189 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_190 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1} && {2} == {0}",
__binding_5, __binding_3, __binding_4))
});
suggestions.push((__binding_0, __code_188));
if let Some(__binding_1) = __binding_1 {
suggestions.push((__binding_1, __code_189));
}
suggestions.push((__binding_2, __code_190));
diag.store_args();
diag.arg("guard_hi_paren", __binding_3);
diag.arg("ident", __binding_4);
diag.arg("expr", __binding_5);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the expression to the match arm guard")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
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_191 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{2}const {1}: /* Type */ = {0};\n",
__binding_3, __binding_2, __binding_4))
});
let __code_192 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
suggestions.push((__binding_0, __code_191));
suggestions.push((__binding_1, __code_192));
diag.store_args();
diag.arg("ident", __binding_2);
diag.arg("expr", __binding_3);
diag.arg("indentation", __binding_4);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider extracting the expression into a `const`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3412pub(crate) enum UnexpectedExpressionInPatternSugg {
3413 #[multipart_suggestion(
3414 "consider moving the expression to a match arm guard",
3415 applicability = "maybe-incorrect"
3416 )]
3417 CreateGuard {
3418 #[suggestion_part(code = "{ident}")]
3420 ident_span: Span,
3421 #[suggestion_part(code = " if {ident} == {expr}")]
3423 pat_hi: Span,
3424 ident: String,
3426 expr: String,
3428 },
3429
3430 #[multipart_suggestion(
3431 "consider moving the expression to the match arm guard",
3432 applicability = "maybe-incorrect"
3433 )]
3434 UpdateGuard {
3435 #[suggestion_part(code = "{ident}")]
3437 ident_span: Span,
3438 #[suggestion_part(code = "(")]
3440 guard_lo: Option<Span>,
3441 #[suggestion_part(code = "{guard_hi_paren} && {ident} == {expr}")]
3443 guard_hi: Span,
3444 guard_hi_paren: &'static str,
3446 ident: String,
3448 expr: String,
3450 },
3451
3452 #[multipart_suggestion(
3453 "consider extracting the expression into a `const`",
3454 applicability = "has-placeholders"
3455 )]
3456 Const {
3457 #[suggestion_part(code = "{indentation}const {ident}: /* Type */ = {expr};\n")]
3459 stmt_lo: Span,
3460 #[suggestion_part(code = "{ident}")]
3462 ident_span: Span,
3463 ident: String,
3465 expr: String,
3467 indentation: String,
3469 },
3470}
3471
3472#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedParenInRangePat where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedParenInRangePat {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range pattern bounds cannot have parentheses")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3473#[diag("range pattern bounds cannot have parentheses")]
3474pub(crate) struct UnexpectedParenInRangePat {
3475 #[primary_span]
3476 pub span: Vec<Span>,
3477 #[subdiagnostic]
3478 pub sugg: UnexpectedParenInRangePatSugg,
3479}
3480
3481#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedParenInRangePatSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedParenInRangePatSugg {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_193 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_194 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_193));
suggestions.push((__binding_1, __code_194));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove these parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3482#[multipart_suggestion("remove these parentheses", applicability = "machine-applicable")]
3483pub(crate) struct UnexpectedParenInRangePatSugg {
3484 #[suggestion_part(code = "")]
3485 pub start_span: Span,
3486 #[suggestion_part(code = "")]
3487 pub end_span: Span,
3488}
3489
3490#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnTypesUseThinArrow where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ReturnTypesUseThinArrow {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return types are denoted using `->`")));
let __code_195 =
[::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_195, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3491#[diag("return types are denoted using `->`")]
3492pub(crate) struct ReturnTypesUseThinArrow {
3493 #[primary_span]
3494 pub span: Span,
3495 #[suggestion(
3496 "use `->` instead",
3497 style = "verbose",
3498 code = " -> ",
3499 applicability = "machine-applicable"
3500 )]
3501 pub suggestion: Span,
3502}
3503
3504#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NeedPlusAfterTraitObjectLifetime where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NeedPlusAfterTraitObjectLifetime {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes must be followed by `+` to form a trait object type")));
let __code_196 =
[::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_196, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3505#[diag("lifetimes must be followed by `+` to form a trait object type")]
3506pub(crate) struct NeedPlusAfterTraitObjectLifetime {
3507 #[primary_span]
3508 pub span: Span,
3509 #[suggestion(
3510 "consider adding a trait bound after the potential lifetime bound",
3511 code = " + /* Trait */",
3512 applicability = "has-placeholders"
3513 )]
3514 pub suggestion: Span,
3515}
3516
3517#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedMutOrConstInRawPointerType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedMutOrConstInRawPointerType {
span: __binding_0, after_asterisk: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `mut` or `const` keyword in raw pointer type")));
let __code_197 =
[::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_197, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3518#[diag("expected `mut` or `const` keyword in raw pointer type")]
3519pub(crate) struct ExpectedMutOrConstInRawPointerType {
3520 #[primary_span]
3521 pub span: Span,
3522 #[suggestion(
3523 "add `mut` or `const` here",
3524 code("mut ", "const "),
3525 applicability = "has-placeholders",
3526 style = "verbose"
3527 )]
3528 pub after_asterisk: Span,
3529}
3530
3531#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeAfterMut where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeAfterMut {
span: __binding_0,
suggest_lifetime: __binding_1,
snippet: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime must precede `mut`")));
let __code_198 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&{0} mut", __binding_2))
})].into_iter();
;
diag.arg("snippet", __binding_2);
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place the lifetime before `mut`")),
__code_198, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
3532#[diag("lifetime must precede `mut`")]
3533pub(crate) struct LifetimeAfterMut {
3534 #[primary_span]
3535 pub span: Span,
3536 #[suggestion(
3537 "place the lifetime before `mut`",
3538 code = "&{snippet} mut",
3539 applicability = "maybe-incorrect",
3540 style = "verbose"
3541 )]
3542 pub suggest_lifetime: Option<Span>,
3543 pub snippet: String,
3544}
3545
3546#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DynAfterMut
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DynAfterMut { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`mut` must precede `dyn`")));
let __code_199 =
[::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_199, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3547#[diag("`mut` must precede `dyn`")]
3548pub(crate) struct DynAfterMut {
3549 #[primary_span]
3550 #[suggestion(
3551 "place `mut` before `dyn`",
3552 code = "&mut dyn",
3553 applicability = "machine-applicable",
3554 style = "verbose"
3555 )]
3556 pub span: Span,
3557}
3558
3559#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPointerCannotBeConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPointerCannotBeConst {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `fn` pointer type cannot be `const`")));
let __code_200 =
[::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_200, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3560#[diag("an `fn` pointer type cannot be `const`")]
3561#[note("allowed qualifiers are: `unsafe` and `extern`")]
3562pub(crate) struct FnPointerCannotBeConst {
3563 #[primary_span]
3564 #[label("`const` because of this")]
3565 pub span: Span,
3566 #[suggestion(
3567 "remove the `const` qualifier",
3568 code = "",
3569 applicability = "maybe-incorrect",
3570 style = "verbose"
3571 )]
3572 pub suggestion: Span,
3573}
3574
3575#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FnPointerCannotBeAsync where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnPointerCannotBeAsync {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `fn` pointer type cannot be `async`")));
let __code_201 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("allowed qualifiers are: `unsafe` and `extern`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` because of this")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `async` qualifier")),
__code_201, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3576#[diag("an `fn` pointer type cannot be `async`")]
3577#[note("allowed qualifiers are: `unsafe` and `extern`")]
3578pub(crate) struct FnPointerCannotBeAsync {
3579 #[primary_span]
3580 #[label("`async` because of this")]
3581 pub span: Span,
3582 #[suggestion(
3583 "remove the `async` qualifier",
3584 code = "",
3585 applicability = "maybe-incorrect",
3586 style = "verbose"
3587 )]
3588 pub suggestion: Span,
3589}
3590
3591#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NestedCVariadicType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NestedCVariadicType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic type `...` may not be nested inside another type")));
diag.code(E0743);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3592#[diag("C-variadic type `...` may not be nested inside another type", code = E0743)]
3593pub(crate) struct NestedCVariadicType {
3594 #[primary_span]
3595 pub span: Span,
3596}
3597
3598#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidCVariadicType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidCVariadicType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `...`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3599#[diag("unexpected `...`")]
3600#[note(
3601 "only `extern \"C\"` and `extern \"C-unwind\"` functions may have a C variable argument list"
3602)]
3603pub(crate) struct InvalidCVariadicType {
3604 #[primary_span]
3605 pub span: Span,
3606}
3607
3608#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidDynKeyword where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidDynKeyword {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `dyn` keyword")));
let __code_202 =
[::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_202, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3609#[diag("invalid `dyn` keyword")]
3610#[help("`dyn` is only needed at the start of a trait `+`-separated list")]
3611pub(crate) struct InvalidDynKeyword {
3612 #[primary_span]
3613 pub span: Span,
3614 #[suggestion(
3615 "remove this keyword",
3616 code = "",
3617 applicability = "machine-applicable",
3618 style = "verbose"
3619 )]
3620 pub suggestion: Span,
3621}
3622
3623#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HelpUseLatestEdition {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
HelpUseLatestEdition::Cargo { edition: __binding_0 } => {
diag.store_args();
diag.arg("edition", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("set `edition = \"{$edition}\"` in `Cargo.toml`")));
diag.help(__message);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")));
diag.note(__message);
diag.restore_args();
}
HelpUseLatestEdition::Standalone { edition: __binding_0 } =>
{
diag.store_args();
diag.arg("edition", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pass `--edition {$edition}` to `rustc`")));
diag.help(__message);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3624pub(crate) enum HelpUseLatestEdition {
3625 #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
3626 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3627 Cargo { edition: Edition },
3628 #[help("pass `--edition {$edition}` to `rustc`")]
3629 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
3630 Standalone { edition: Edition },
3631}
3632
3633impl HelpUseLatestEdition {
3634 pub(crate) fn new() -> Self {
3635 let edition = LATEST_STABLE_EDITION;
3636 if rustc_session::utils::was_invoked_from_cargo() {
3637 Self::Cargo { edition }
3638 } else {
3639 Self::Standalone { edition }
3640 }
3641 }
3642}
3643
3644#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BoxSyntaxRemoved where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoxSyntaxRemoved { span: __binding_0, sugg: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`box_syntax` has been removed")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3645#[diag("`box_syntax` has been removed")]
3646pub(crate) struct BoxSyntaxRemoved {
3647 #[primary_span]
3648 pub span: Span,
3649 #[subdiagnostic]
3650 pub sugg: AddBoxNew,
3651}
3652
3653#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddBoxNew {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddBoxNew { box_kw_and_lo: __binding_0, hi: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_203 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new("))
});
let __code_204 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_203));
suggestions.push((__binding_1, __code_204));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `Box::new()` instead")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3654#[multipart_suggestion(
3655 "use `Box::new()` instead",
3656 applicability = "machine-applicable",
3657 style = "verbose"
3658)]
3659pub(crate) struct AddBoxNew {
3660 #[suggestion_part(code = "Box::new(")]
3661 pub box_kw_and_lo: Span,
3662 #[suggestion_part(code = ")")]
3663 pub hi: Span,
3664}
3665
3666#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BadReturnTypeNotationOutput where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadReturnTypeNotationOutput {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type not allowed with return type notation")));
let __code_205 =
[::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_205, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3667#[diag("return type not allowed with return type notation")]
3668pub(crate) struct BadReturnTypeNotationOutput {
3669 #[primary_span]
3670 pub span: Span,
3671 #[suggestion(
3672 "remove the return type",
3673 code = "",
3674 applicability = "maybe-incorrect",
3675 style = "verbose"
3676 )]
3677 pub suggestion: Span,
3678}
3679
3680#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BadAssocTypeBounds where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadAssocTypeBounds { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on associated types do not belong here")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("belongs in `where` clause")));
diag
}
}
}
}
};Diagnostic)]
3681#[diag("bounds on associated types do not belong here")]
3682pub(crate) struct BadAssocTypeBounds {
3683 #[primary_span]
3684 #[label("belongs in `where` clause")]
3685 pub span: Span,
3686}
3687
3688#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrAfterGeneric where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrAfterGeneric { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trailing attribute after generic parameter")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes must go before parameters")));
diag
}
}
}
}
};Diagnostic)]
3689#[diag("trailing attribute after generic parameter")]
3690pub(crate) struct AttrAfterGeneric {
3691 #[primary_span]
3692 #[label("attributes must go before parameters")]
3693 pub span: Span,
3694}
3695
3696#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrWithoutGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrWithoutGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute without generic parameters")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are only permitted when preceding parameters")));
diag
}
}
}
}
};Diagnostic)]
3697#[diag("attribute without generic parameters")]
3698pub(crate) struct AttrWithoutGenerics {
3699 #[primary_span]
3700 #[label("attributes are only permitted when preceding parameters")]
3701 pub span: Span,
3702}
3703
3704#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereOnGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereOnGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters on `where` clauses are reserved for future use")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("currently unsupported")));
diag
}
}
}
}
};Diagnostic)]
3705#[diag("generic parameters on `where` clauses are reserved for future use")]
3706pub(crate) struct WhereOnGenerics {
3707 #[primary_span]
3708 #[label("currently unsupported")]
3709 pub span: Span,
3710}
3711
3712#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for GenericsInPath
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericsInPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected generic arguments in path")));
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
3713#[diag("unexpected generic arguments in path")]
3714pub(crate) struct GenericsInPath {
3715 #[primary_span]
3716 pub span: Vec<Span>,
3717}
3718
3719#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeInEqConstraint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeInEqConstraint {
span: __binding_0,
lifetime: __binding_1,
binding_label: __binding_2,
colon_sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes are not permitted in this context")));
let __code_206 =
[::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_206, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3720#[diag("lifetimes are not permitted in this context")]
3721#[help("if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}`")]
3722pub(crate) struct LifetimeInEqConstraint {
3723 #[primary_span]
3724 #[label("lifetime is not allowed here")]
3725 pub span: Span,
3726 pub lifetime: Ident,
3727 #[label("this introduces an associated item binding")]
3728 pub binding_label: Span,
3729 #[suggestion(
3730 "you might have meant to write a bound here",
3731 style = "verbose",
3732 applicability = "maybe-incorrect",
3733 code = ": "
3734 )]
3735 pub colon_sugg: Span,
3736}
3737
3738#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ModifierLifetime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModifierLifetime { span: __binding_0, modifier: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$modifier}` may only modify trait bounds, not lifetime bounds")));
let __code_207 =
[::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_207, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
3739#[diag("`{$modifier}` may only modify trait bounds, not lifetime bounds")]
3740pub(crate) struct ModifierLifetime {
3741 #[primary_span]
3742 #[suggestion(
3743 "remove the `{$modifier}`",
3744 style = "tool-only",
3745 applicability = "maybe-incorrect",
3746 code = ""
3747 )]
3748 pub span: Span,
3749 pub modifier: &'static str,
3750}
3751
3752#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnderscoreLiteralSuffix where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnderscoreLiteralSuffix { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("underscore literal suffix is not allowed")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3753#[diag("underscore literal suffix is not allowed")]
3754pub(crate) struct UnderscoreLiteralSuffix {
3755 #[primary_span]
3756 pub span: Span,
3757}
3758
3759#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedLabelFoundIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedLabelFoundIdent {
span: __binding_0, start: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a label, found an identifier")));
let __code_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("labels start with a tick")),
__code_208, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3760#[diag("expected a label, found an identifier")]
3761pub(crate) struct ExpectedLabelFoundIdent {
3762 #[primary_span]
3763 pub span: Span,
3764 #[suggestion(
3765 "labels start with a tick",
3766 code = "'",
3767 applicability = "machine-applicable",
3768 style = "verbose"
3769 )]
3770 pub start: Span,
3771}
3772
3773#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InappropriateDefault where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InappropriateDefault {
span: __binding_0, article: __binding_1, descr: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$article} {$descr} cannot be `default`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only associated `fn`, `const`, and `type` items can be `default`")));
;
diag.arg("article", __binding_1);
diag.arg("descr", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default` because of this")));
diag
}
}
}
}
};Diagnostic)]
3774#[diag("{$article} {$descr} cannot be `default`")]
3775#[note("only associated `fn`, `const`, and `type` items can be `default`")]
3776pub(crate) struct InappropriateDefault {
3777 #[primary_span]
3778 #[label("`default` because of this")]
3779 pub span: Span,
3780 pub article: &'static str,
3781 pub descr: &'static str,
3782}
3783
3784#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RecoverImportAsUse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RecoverImportAsUse {
span: __binding_0, token_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected item, found {$token_name}")));
let __code_209 =
[::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_209, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3785#[diag("expected item, found {$token_name}")]
3786pub(crate) struct RecoverImportAsUse {
3787 #[primary_span]
3788 #[suggestion(
3789 "items are imported using the `use` keyword",
3790 code = "use",
3791 applicability = "machine-applicable",
3792 style = "verbose"
3793 )]
3794 pub span: Span,
3795 pub token_name: String,
3796}
3797
3798#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SingleColonImportPath where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SingleColonImportPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `::`, found `:`")));
let __code_210 =
[::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_210, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3799#[diag("expected `::`, found `:`")]
3800#[note("import paths are delimited using `::`")]
3801pub(crate) struct SingleColonImportPath {
3802 #[primary_span]
3803 #[suggestion(
3804 "use double colon",
3805 code = "::",
3806 applicability = "machine-applicable",
3807 style = "verbose"
3808 )]
3809 pub span: Span,
3810}
3811
3812#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BadItemKind
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadItemKind {
span: __binding_0,
descr: __binding_1,
ctx: __binding_2,
help: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} is not supported in {$ctx}")));
;
diag.arg("descr", __binding_1);
diag.arg("ctx", __binding_2);
diag.span(__binding_0);
if __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the {$descr} out to a nearby module scope")));
}
diag
}
}
}
}
};Diagnostic)]
3813#[diag("{$descr} is not supported in {$ctx}")]
3814pub(crate) struct BadItemKind {
3815 #[primary_span]
3816 pub span: Span,
3817 pub descr: &'static str,
3818 pub ctx: &'static str,
3819 #[help("consider moving the {$descr} out to a nearby module scope")]
3820 pub help: bool,
3821}
3822
3823#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroRulesMissingBang where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroRulesMissingBang { span: __binding_0, hi: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `!` after `macro_rules`")));
let __code_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("add a `!`")),
__code_211, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3824#[diag("expected `!` after `macro_rules`")]
3825pub(crate) struct MacroRulesMissingBang {
3826 #[primary_span]
3827 pub span: Span,
3828 #[suggestion("add a `!`", code = "!", applicability = "machine-applicable", style = "verbose")]
3829 pub hi: Span,
3830}
3831
3832#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroNameRemoveBang where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroNameRemoveBang { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro names aren't followed by a `!`")));
let __code_212 =
[::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_212, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
3833#[diag("macro names aren't followed by a `!`")]
3834pub(crate) struct MacroNameRemoveBang {
3835 #[primary_span]
3836 #[suggestion(
3837 "remove the `!`",
3838 code = "",
3839 applicability = "machine-applicable",
3840 style = "short"
3841 )]
3842 pub span: Span,
3843}
3844
3845#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MacroRulesVisibility<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroRulesVisibility { span: __binding_0, vis: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't qualify macro_rules invocation with `{$vis}`")));
let __code_213 =
[::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_213, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3846#[diag("can't qualify macro_rules invocation with `{$vis}`")]
3847pub(crate) struct MacroRulesVisibility<'a> {
3848 #[primary_span]
3849 #[suggestion(
3850 "try exporting the macro",
3851 code = "#[macro_export]",
3852 applicability = "maybe-incorrect",
3853 style = "verbose"
3854 )]
3855 pub span: Span,
3856 pub vis: &'a str,
3857}
3858
3859#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MacroInvocationVisibility<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroInvocationVisibility {
span: __binding_0, vis: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't qualify macro invocation with `pub`")));
let __code_214 =
[::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_214, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3860#[diag("can't qualify macro invocation with `pub`")]
3861#[help("try adjusting the macro to put `{$vis}` inside the invocation")]
3862pub(crate) struct MacroInvocationVisibility<'a> {
3863 #[primary_span]
3864 #[suggestion(
3865 "remove the visibility",
3866 code = "",
3867 applicability = "machine-applicable",
3868 style = "verbose"
3869 )]
3870 pub span: Span,
3871 pub vis: &'a str,
3872}
3873
3874#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NestedAdt<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NestedAdt {
span: __binding_0,
item: __binding_1,
keyword: __binding_2,
kw_str: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kw_str}` definition cannot be nested inside `{$keyword}`")));
let __code_215 =
[::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_215, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3875#[diag("`{$kw_str}` definition cannot be nested inside `{$keyword}`")]
3876pub(crate) struct NestedAdt<'a> {
3877 #[primary_span]
3878 pub span: Span,
3879 #[suggestion(
3880 "consider creating a new `{$kw_str}` definition instead of nesting",
3881 code = "",
3882 applicability = "maybe-incorrect",
3883 style = "verbose"
3884 )]
3885 pub item: Span,
3886 pub keyword: &'a str,
3887 pub kw_str: Cow<'a, str>,
3888}
3889
3890#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionBodyEqualsExpr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FunctionBodyEqualsExpr {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function body cannot be `= expression;`")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3891#[diag("function body cannot be `= expression;`")]
3892pub(crate) struct FunctionBodyEqualsExpr {
3893 #[primary_span]
3894 pub span: Span,
3895 #[subdiagnostic]
3896 pub sugg: FunctionBodyEqualsExprSugg,
3897}
3898
3899#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FunctionBodyEqualsExprSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FunctionBodyEqualsExprSugg {
eq: __binding_0, semi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_216 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_217 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_216));
suggestions.push((__binding_1, __code_217));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surround the expression with `{\"{\"}` and `{\"}\"}` instead of `=` and `;`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3900#[multipart_suggestion(
3901 r#"surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`"#,
3902 applicability = "machine-applicable"
3903)]
3904pub(crate) struct FunctionBodyEqualsExprSugg {
3905 #[suggestion_part(code = "{{")]
3906 pub eq: Span,
3907 #[suggestion_part(code = " }}")]
3908 pub semi: Span,
3909}
3910
3911#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BoxNotPat
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BoxNotPat {
span: __binding_0,
kw: __binding_1,
lo: __binding_2,
descr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected pattern, found {$descr}")));
let __code_218 =
[::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_218, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3912#[diag("expected pattern, found {$descr}")]
3913pub(crate) struct BoxNotPat {
3914 #[primary_span]
3915 pub span: Span,
3916 #[note("`box` is a reserved keyword")]
3917 pub kw: Span,
3918 #[suggestion(
3919 "escape `box` to use it as an identifier",
3920 code = "r#",
3921 applicability = "maybe-incorrect",
3922 style = "verbose"
3923 )]
3924 pub lo: Span,
3925 pub descr: String,
3926}
3927
3928#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnmatchedAngle
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnmatchedAngle { span: __binding_0, plural: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unmatched angle {$plural ->\n [true] brackets\n *[false] bracket\n }")));
let __code_219 =
[::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_219, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3929#[diag(
3930 "unmatched angle {$plural ->
3931 [true] brackets
3932 *[false] bracket
3933 }"
3934)]
3935pub(crate) struct UnmatchedAngle {
3936 #[primary_span]
3937 #[suggestion(
3938 "remove extra angle {$plural ->
3939 [true] brackets
3940 *[false] bracket
3941 }",
3942 code = "",
3943 applicability = "machine-applicable",
3944 style = "verbose"
3945 )]
3946 pub span: Span,
3947 pub plural: bool,
3948}
3949
3950#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingPlusBounds where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingPlusBounds {
span: __binding_0, hi: __binding_1, sym: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `+` between lifetime and {$sym}")));
let __code_220 =
[::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_220, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3951#[diag("expected `+` between lifetime and {$sym}")]
3952pub(crate) struct MissingPlusBounds {
3953 #[primary_span]
3954 pub span: Span,
3955 #[suggestion("add `+`", code = " +", applicability = "maybe-incorrect", style = "verbose")]
3956 pub hi: Span,
3957 pub sym: Symbol,
3958}
3959
3960#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectParensTraitBounds where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectParensTraitBounds {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect parentheses around trait bounds")));
;
diag.span(__binding_0.clone());
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
3961#[diag("incorrect parentheses around trait bounds")]
3962pub(crate) struct IncorrectParensTraitBounds {
3963 #[primary_span]
3964 pub span: Vec<Span>,
3965 #[subdiagnostic]
3966 pub sugg: IncorrectParensTraitBoundsSugg,
3967}
3968
3969#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IncorrectParensTraitBoundsSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IncorrectParensTraitBoundsSugg {
wrong_span: __binding_0, new_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_221 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
let __code_222 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
suggestions.push((__binding_0, __code_221));
suggestions.push((__binding_1, __code_222));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fix the parentheses")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
3970#[multipart_suggestion("fix the parentheses", applicability = "machine-applicable")]
3971pub(crate) struct IncorrectParensTraitBoundsSugg {
3972 #[suggestion_part(code = " ")]
3973 pub wrong_span: Span,
3974 #[suggestion_part(code = "(")]
3975 pub new_span: Span,
3976}
3977
3978#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
KwBadCase<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
KwBadCase {
span: __binding_0, kw: __binding_1, case: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("keyword `{$kw}` is written in the wrong case")));
let __code_223 =
[::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_223, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
3979#[diag("keyword `{$kw}` is written in the wrong case")]
3980pub(crate) struct KwBadCase<'a> {
3981 #[primary_span]
3982 #[suggestion(
3983 "write it in {$case}",
3984 code = "{kw}",
3985 style = "verbose",
3986 applicability = "machine-applicable"
3987 )]
3988 pub span: Span,
3989 pub kw: &'a str,
3990 pub case: Case,
3991}
3992
3993pub(crate) enum Case {
3994 Upper,
3995 Lower,
3996 Mixed,
3997}
3998
3999impl IntoDiagArg for Case {
4000 fn into_diag_arg(self, path: &mut Option<PathBuf>) -> DiagArgValue {
4001 match self {
4002 Case::Upper => "uppercase",
4003 Case::Lower => "lowercase",
4004 Case::Mixed => "the correct case",
4005 }
4006 .into_diag_arg(path)
4007 }
4008}
4009
4010#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownBuiltinConstruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownBuiltinConstruct {
span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `builtin #` construct `{$name}`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4011#[diag("unknown `builtin #` construct `{$name}`")]
4012pub(crate) struct UnknownBuiltinConstruct {
4013 #[primary_span]
4014 pub span: Span,
4015 pub name: Ident,
4016}
4017
4018#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedBuiltinIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedBuiltinIdent { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected identifier after `builtin #`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4019#[diag("expected identifier after `builtin #`")]
4020pub(crate) struct ExpectedBuiltinIdent {
4021 #[primary_span]
4022 pub span: Span,
4023}
4024
4025#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticWithGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StaticWithGenerics { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("static items may not have generic parameters")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4026#[diag("static items may not have generic parameters")]
4027pub(crate) struct StaticWithGenerics {
4028 #[primary_span]
4029 pub span: Span,
4030}
4031
4032#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseBeforeConstBody where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WhereClauseBeforeConstBody {
span: __binding_0,
name: __binding_1,
body: __binding_2,
sugg: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses are not allowed before const item bodies")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected where clause")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("while parsing this const item")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item body")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
4033#[diag("where clauses are not allowed before const item bodies")]
4034pub(crate) struct WhereClauseBeforeConstBody {
4035 #[primary_span]
4036 #[label("unexpected where clause")]
4037 pub span: Span,
4038 #[label("while parsing this const item")]
4039 pub name: Span,
4040 #[label("the item body")]
4041 pub body: Span,
4042 #[subdiagnostic]
4043 pub sugg: Option<WhereClauseBeforeConstBodySugg>,
4044}
4045
4046#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WhereClauseBeforeConstBodySugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WhereClauseBeforeConstBodySugg {
left: __binding_0, snippet: __binding_1, right: __binding_2
} => {
let mut suggestions = Vec::new();
let __code_224 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("= {0} ", __binding_1))
});
let __code_225 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_224));
suggestions.push((__binding_2, __code_225));
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the body before the where clause")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
4047#[multipart_suggestion(
4048 "move the body before the where clause",
4049 applicability = "machine-applicable"
4050)]
4051pub(crate) struct WhereClauseBeforeConstBodySugg {
4052 #[suggestion_part(code = "= {snippet} ")]
4053 pub left: Span,
4054 pub snippet: String,
4055 #[suggestion_part(code = "")]
4056 pub right: Span,
4057}
4058
4059#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericArgsInPatRequireTurbofishSyntax where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericArgsInPatRequireTurbofishSyntax {
span: __binding_0, suggest_turbofish: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic args in patterns require the turbofish syntax")));
let __code_226 =
[::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_226, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4060#[diag("generic args in patterns require the turbofish syntax")]
4061pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
4062 #[primary_span]
4063 pub span: Span,
4064 #[suggestion(
4065 "use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
4066 style = "verbose",
4067 code = "::",
4068 applicability = "maybe-incorrect"
4069 )]
4070 pub suggest_turbofish: Span,
4071}
4072
4073#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
TransposeDynOrImpl<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TransposeDynOrImpl {
span: __binding_0, kw: __binding_1, sugg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` expected after `{$kw}`, not before")));
;
diag.arg("kw", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
4074#[diag("`for<...>` expected after `{$kw}`, not before")]
4075pub(crate) struct TransposeDynOrImpl<'a> {
4076 #[primary_span]
4077 pub span: Span,
4078 pub kw: &'a str,
4079 #[subdiagnostic]
4080 pub sugg: TransposeDynOrImplSugg<'a>,
4081}
4082
4083#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for TransposeDynOrImplSugg<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TransposeDynOrImplSugg {
removal_span: __binding_0,
insertion_span: __binding_1,
kw: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_227 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_228 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_2))
});
suggestions.push((__binding_0, __code_227));
suggestions.push((__binding_1, __code_228));
diag.store_args();
diag.arg("kw", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move `{$kw}` before the `for<...>`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
4084#[multipart_suggestion("move `{$kw}` before the `for<...>`", applicability = "machine-applicable")]
4085pub(crate) struct TransposeDynOrImplSugg<'a> {
4086 #[suggestion_part(code = "")]
4087 pub removal_span: Span,
4088 #[suggestion_part(code = "{kw} ")]
4089 pub insertion_span: Span,
4090 pub kw: &'a str,
4091}
4092
4093#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArrayIndexInOffsetOf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ArrayIndexInOffsetOf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("array indexing not supported in offset_of")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4094#[diag("array indexing not supported in offset_of")]
4095pub(crate) struct ArrayIndexInOffsetOf(#[primary_span] pub Span);
4096
4097#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidOffsetOf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidOffsetOf(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("offset_of expects dot-separated field and variant names")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4098#[diag("offset_of expects dot-separated field and variant names")]
4099pub(crate) struct InvalidOffsetOf(#[primary_span] pub Span);
4100
4101#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsyncImpl
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsyncImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async` trait implementations are unsupported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4102#[diag("`async` trait implementations are unsupported")]
4103pub(crate) struct AsyncImpl {
4104 #[primary_span]
4105 pub span: Span,
4106}
4107
4108#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ExprRArrowCall
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExprRArrowCall { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`->` is not valid syntax for field accesses and method calls")));
let __code_229 =
[::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_229, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4109#[diag("`->` is not valid syntax for field accesses and method calls")]
4110#[help(
4111 "the `.` operator will automatically dereference the value, except if the value is a raw pointer"
4112)]
4113pub(crate) struct ExprRArrowCall {
4114 #[primary_span]
4115 #[suggestion(
4116 "try using `.` instead",
4117 style = "verbose",
4118 applicability = "machine-applicable",
4119 code = "."
4120 )]
4121 pub span: Span,
4122}
4123
4124#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DotDotRangeAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DotDotRangeAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes are not allowed on range expressions starting with `..`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4125#[diag("attributes are not allowed on range expressions starting with `..`")]
4126pub(crate) struct DotDotRangeAttribute {
4127 #[primary_span]
4128 pub span: Span,
4129}
4130
4131#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BinderBeforeModifiers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BinderBeforeModifiers {
binder_span: __binding_0, modifiers_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` binder should be placed before trait bound modifiers")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("place the `for<...>` binder before any modifiers")));
diag
}
}
}
}
};Diagnostic)]
4132#[diag("`for<...>` binder should be placed before trait bound modifiers")]
4133pub(crate) struct BinderBeforeModifiers {
4134 #[primary_span]
4135 pub binder_span: Span,
4136 #[label("place the `for<...>` binder before any modifiers")]
4137 pub modifiers_span: Span,
4138}
4139
4140#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BinderAndPolarity where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BinderAndPolarity {
polarity_span: __binding_0,
binder_span: __binding_1,
polarity: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")));
;
diag.arg("polarity", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")));
diag
}
}
}
}
};Diagnostic)]
4141#[diag("`for<...>` binder not allowed with `{$polarity}` trait polarity modifier")]
4142pub(crate) struct BinderAndPolarity {
4143 #[primary_span]
4144 pub polarity_span: Span,
4145 #[label("there is not a well-defined meaning for a higher-ranked `{$polarity}` trait")]
4146 pub binder_span: Span,
4147 pub polarity: &'static str,
4148}
4149
4150#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PolarityAndModifiers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PolarityAndModifiers {
polarity_span: __binding_0,
modifiers_span: __binding_1,
polarity: __binding_2,
modifiers_concatenated: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")));
;
diag.arg("polarity", __binding_2);
diag.arg("modifiers_concatenated", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait")));
diag
}
}
}
}
};Diagnostic)]
4151#[diag("`{$modifiers_concatenated}` trait not allowed with `{$polarity}` trait polarity modifier")]
4152pub(crate) struct PolarityAndModifiers {
4153 #[primary_span]
4154 pub polarity_span: Span,
4155 #[label(
4156 "there is not a well-defined meaning for a `{$modifiers_concatenated} {$polarity}` trait"
4157 )]
4158 pub modifiers_span: Span,
4159 pub polarity: &'static str,
4160 pub modifiers_concatenated: String,
4161}
4162
4163#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectTypeOnSelf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncorrectTypeOnSelf {
span: __binding_0, move_self_modifier: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type not allowed for shorthand `self` parameter")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
4164#[diag("type not allowed for shorthand `self` parameter")]
4165pub(crate) struct IncorrectTypeOnSelf {
4166 #[primary_span]
4167 pub span: Span,
4168 #[subdiagnostic]
4169 pub move_self_modifier: MoveSelfModifier,
4170}
4171
4172#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MoveSelfModifier {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MoveSelfModifier {
removal_span: __binding_0,
insertion_span: __binding_1,
modifier: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_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));
diag.store_args();
diag.arg("modifier", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move the modifiers on `self` to the type")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
4173#[multipart_suggestion(
4174 "move the modifiers on `self` to the type",
4175 applicability = "machine-applicable"
4176)]
4177pub(crate) struct MoveSelfModifier {
4178 #[suggestion_part(code = "")]
4179 pub removal_span: Span,
4180 #[suggestion_part(code = "{modifier}")]
4181 pub insertion_span: Span,
4182 pub modifier: String,
4183}
4184
4185#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AsmUnsupportedOperand<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmUnsupportedOperand {
span: __binding_0,
symbol: __binding_1,
macro_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$symbol}` operand cannot be used with `{$macro_name}!`")));
;
diag.arg("symbol", __binding_1);
diag.arg("macro_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it")));
diag
}
}
}
}
};Diagnostic)]
4186#[diag("the `{$symbol}` operand cannot be used with `{$macro_name}!`")]
4187pub(crate) struct AsmUnsupportedOperand<'a> {
4188 #[primary_span]
4189 #[label(
4190 "the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it"
4191 )]
4192 pub(crate) span: Span,
4193 pub(crate) symbol: &'a str,
4194 pub(crate) macro_name: &'static str,
4195}
4196
4197#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmUnderscoreInput where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmUnderscoreInput { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("_ cannot be used for input operands")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4198#[diag("_ cannot be used for input operands")]
4199pub(crate) struct AsmUnderscoreInput {
4200 #[primary_span]
4201 pub(crate) span: Span,
4202}
4203
4204#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AsmSymNoPath
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmSymNoPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a path for argument to `sym`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4205#[diag("expected a path for argument to `sym`")]
4206pub(crate) struct AsmSymNoPath {
4207 #[primary_span]
4208 pub(crate) span: Span,
4209}
4210
4211#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmRequiresTemplate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmRequiresTemplate { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requires at least a template string argument")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4212#[diag("requires at least a template string argument")]
4213pub(crate) struct AsmRequiresTemplate {
4214 #[primary_span]
4215 pub(crate) span: Span,
4216}
4217
4218#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedComma where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedComma { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected token: `,`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `,`")));
diag
}
}
}
}
};Diagnostic)]
4219#[diag("expected token: `,`")]
4220pub(crate) struct AsmExpectedComma {
4221 #[primary_span]
4222 #[label("expected `,`")]
4223 pub(crate) span: Span,
4224}
4225
4226#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedOther where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedOther {
span: __binding_0, is_inline_asm: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected operand, {$is_inline_asm ->\n [false] options\n *[true] clobber_abi, options\n }, or additional template string")));
;
diag.arg("is_inline_asm", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected operand, {$is_inline_asm ->\n [false] options\n *[true] clobber_abi, options\n }, or additional template string")));
diag
}
}
}
}
};Diagnostic)]
4227#[diag(
4228 "expected operand, {$is_inline_asm ->
4229 [false] options
4230 *[true] clobber_abi, options
4231 }, or additional template string"
4232)]
4233pub(crate) struct AsmExpectedOther {
4234 #[primary_span]
4235 #[label(
4236 "expected operand, {$is_inline_asm ->
4237 [false] options
4238 *[true] clobber_abi, options
4239 }, or additional template string"
4240 )]
4241 pub(crate) span: Span,
4242 pub(crate) is_inline_asm: bool,
4243}
4244
4245#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NonABI where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonABI { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one abi must be provided as an argument to `clobber_abi`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4246#[diag("at least one abi must be provided as an argument to `clobber_abi`")]
4247pub(crate) struct NonABI {
4248 #[primary_span]
4249 pub(crate) span: Span,
4250}
4251
4252#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsmExpectedStringLiteral where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AsmExpectedStringLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected string literal")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a string literal")));
diag
}
}
}
}
};Diagnostic)]
4253#[diag("expected string literal")]
4254pub(crate) struct AsmExpectedStringLiteral {
4255 #[primary_span]
4256 #[label("not a string literal")]
4257 pub(crate) span: Span,
4258}
4259
4260#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedRegisterClassOrExplicitRegister where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedRegisterClassOrExplicitRegister { span: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected register class or explicit register")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4261#[diag("expected register class or explicit register")]
4262pub(crate) struct ExpectedRegisterClassOrExplicitRegister {
4263 #[primary_span]
4264 pub(crate) span: Span,
4265}
4266
4267#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
HiddenUnicodeCodepointsDiag {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
HiddenUnicodeCodepointsDiag {
label: __binding_0,
count: __binding_1,
span_label: __binding_2,
labels: __binding_3,
sub: __binding_4 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
4268#[diag("unicode codepoint changing visible direction of text present in {$label}")]
4269#[note(
4270 "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"
4271)]
4272pub(crate) struct HiddenUnicodeCodepointsDiag {
4273 pub label: String,
4274 pub count: usize,
4275 #[label(
4276 "this {$label} contains {$count ->
4277 [one] an invisible
4278 *[other] invisible
4279 } unicode text flow control {$count ->
4280 [one] codepoint
4281 *[other] codepoints
4282 }"
4283 )]
4284 pub span_label: Span,
4285 #[subdiagnostic]
4286 pub labels: Option<HiddenUnicodeCodepointsDiagLabels>,
4287 #[subdiagnostic]
4288 pub sub: HiddenUnicodeCodepointsDiagSub,
4289}
4290
4291pub(crate) struct HiddenUnicodeCodepointsDiagLabels {
4292 pub spans: Vec<(char, Span)>,
4293}
4294
4295impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
4296 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4297 for (c, span) in self.spans {
4298 diag.span_label(span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"));
4299 }
4300 }
4301}
4302
4303pub(crate) enum HiddenUnicodeCodepointsDiagSub {
4304 Escape { spans: Vec<(char, Span)> },
4305 NoEscape { spans: Vec<(char, Span)> },
4306}
4307
4308impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
4310 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
4311 match self {
4312 HiddenUnicodeCodepointsDiagSub::Escape { spans } => {
4313 diag.multipart_suggestion_with_style(
4314 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them"))inline_fluent!("if their presence wasn't intentional, you can remove them"),
4315 spans.iter().map(|(_, span)| (*span, "".to_string())).collect(),
4316 Applicability::MachineApplicable,
4317 SuggestionStyle::HideCodeAlways,
4318 );
4319 diag.multipart_suggestion(
4320 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"))inline_fluent!("if you want to keep them but make them visible in your source code, you can escape them"),
4321 spans
4322 .into_iter()
4323 .map(|(c, span)| {
4324 let c = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}");
4325 (span, c[1..c.len() - 1].to_string())
4326 })
4327 .collect(),
4328 Applicability::MachineApplicable,
4329 );
4330 }
4331 HiddenUnicodeCodepointsDiagSub::NoEscape { spans } => {
4332 diag.arg(
4336 "escaped",
4337 spans
4338 .into_iter()
4339 .map(|(c, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:?}", c))
})format!("{c:?}"))
4340 .collect::<Vec<String>>()
4341 .join(", "),
4342 );
4343 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if their presence wasn't intentional, you can remove them"))inline_fluent!(
4344 "if their presence wasn't intentional, you can remove them"
4345 ));
4346 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}"))inline_fluent!("if you want to keep them but make them visible in your source code, you can escape them: {$escaped}"));
4347 }
4348 }
4349 }
4350}
4351
4352#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
VarargsWithoutPattern {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
VarargsWithoutPattern { span: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing pattern for `...` argument")));
;
let __code_232 =
[::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_232, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
4353#[diag("missing pattern for `...` argument")]
4354pub(crate) struct VarargsWithoutPattern {
4355 #[suggestion(
4356 "name the argument, or use `_` to continue ignoring it",
4357 code = "_: ...",
4358 applicability = "machine-applicable"
4359 )]
4360 pub span: Span,
4361}
4362
4363#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImplReuseInherentImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ImplReuseInherentImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only trait impls can be reused")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
4364#[diag("only trait impls can be reused")]
4365pub(crate) struct ImplReuseInherentImpl {
4366 #[primary_span]
4367 pub span: Span,
4368}
4369
4370#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralPlaceholderPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralPlaceholderPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("placeholder `_` is not allowed for the path in struct literals")));
let __code_233 =
[::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_233, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4371#[diag("placeholder `_` is not allowed for the path in struct literals")]
4372pub(crate) struct StructLiteralPlaceholderPath {
4373 #[primary_span]
4374 #[label("not allowed in struct literals")]
4375 #[suggestion(
4376 "replace it with the correct type",
4377 applicability = "has-placeholders",
4378 code = "/* Type */",
4379 style = "verbose"
4380 )]
4381 pub span: Span,
4382}
4383
4384#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StructLiteralWithoutPathLate where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StructLiteralWithoutPathLate {
span: __binding_0, suggestion_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct literal body without path")));
let __code_234 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* Type */ "))
})].into_iter();
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("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_234, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
4385#[diag("struct literal body without path")]
4386pub(crate) struct StructLiteralWithoutPathLate {
4387 #[primary_span]
4388 #[label("struct name missing for struct literal")]
4389 pub span: Span,
4390 #[suggestion(
4391 "add the correct type",
4392 applicability = "has-placeholders",
4393 code = "/* Type */ ",
4394 style = "verbose"
4395 )]
4396 pub suggestion_span: Span,
4397}
4398
4399#[derive(#[automatically_derived]
impl ::core::clone::Clone for ForbiddenLetReason {
#[inline]
fn clone(&self) -> ForbiddenLetReason {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ForbiddenLetReason { }Copy, const _: () =
{
impl rustc_errors::Subdiagnostic for ForbiddenLetReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ForbiddenLetReason::OtherForbidden => {}
ForbiddenLetReason::NotSupportedOr(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`||` operators are not supported in let chain expressions")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
ForbiddenLetReason::NotSupportedParentheses(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`let`s wrapped in parentheses are not supported in a context with let chains")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
4401pub(crate) enum ForbiddenLetReason {
4402 OtherForbidden,
4404 #[note("`||` operators are not supported in let chain expressions")]
4406 NotSupportedOr(#[primary_span] Span),
4407 #[note("`let`s wrapped in parentheses are not supported in a context with let chains")]
4412 NotSupportedParentheses(#[primary_span] Span),
4413}
4414
4415#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MisspelledKw {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "MisspelledKw",
"similar_kw", &self.similar_kw, "span", &self.span,
"is_incorrect_case", &&self.is_incorrect_case)
}
}Debug, const _: () =
{
impl rustc_errors::Subdiagnostic for MisspelledKw {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MisspelledKw {
similar_kw: __binding_0,
span: __binding_1,
is_incorrect_case: __binding_2 } => {
let __code_235 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_0))
})].into_iter();
diag.store_args();
diag.arg("similar_kw", __binding_0);
diag.arg("is_incorrect_case", __binding_2);
let __message =
diag.eagerly_translate(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 }")));
diag.span_suggestions_with_style(__binding_1, __message,
__code_235, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};rustc_macros::Subdiagnostic)]
4416#[suggestion(
4417 "{$is_incorrect_case ->
4418 [true] write keyword `{$similar_kw}` in lowercase
4419 *[false] there is a keyword `{$similar_kw}` with a similar name
4420 }",
4421 applicability = "machine-applicable",
4422 code = "{similar_kw}",
4423 style = "verbose"
4424)]
4425pub(crate) struct MisspelledKw {
4426 pub similar_kw: String,
4429 #[primary_span]
4430 pub span: Span,
4431 pub is_incorrect_case: bool,
4432}
4433
4434#[derive(#[automatically_derived]
impl ::core::clone::Clone for TokenDescription {
#[inline]
fn clone(&self) -> TokenDescription {
let _: ::core::clone::AssertParamIsClone<MetaVarKind>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TokenDescription { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for TokenDescription {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TokenDescription::ReservedIdentifier =>
::core::fmt::Formatter::write_str(f, "ReservedIdentifier"),
TokenDescription::Keyword =>
::core::fmt::Formatter::write_str(f, "Keyword"),
TokenDescription::ReservedKeyword =>
::core::fmt::Formatter::write_str(f, "ReservedKeyword"),
TokenDescription::DocComment =>
::core::fmt::Formatter::write_str(f, "DocComment"),
TokenDescription::MetaVar(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"MetaVar", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for TokenDescription {
#[inline]
fn eq(&self, other: &TokenDescription) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(TokenDescription::MetaVar(__self_0),
TokenDescription::MetaVar(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TokenDescription {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<MetaVarKind>;
}
}Eq)]
4435pub(super) enum TokenDescription {
4436 ReservedIdentifier,
4437 Keyword,
4438 ReservedKeyword,
4439 DocComment,
4440
4441 MetaVar(MetaVarKind),
4446}
4447
4448impl TokenDescription {
4449 pub(super) fn from_token(token: &Token) -> Option<Self> {
4450 match token.kind {
4451 _ if token.is_special_ident() => Some(TokenDescription::ReservedIdentifier),
4452 _ if token.is_used_keyword() => Some(TokenDescription::Keyword),
4453 _ if token.is_unused_keyword() => Some(TokenDescription::ReservedKeyword),
4454 token::DocComment(..) => Some(TokenDescription::DocComment),
4455 token::OpenInvisible(InvisibleOrigin::MetaVar(kind)) => {
4456 Some(TokenDescription::MetaVar(kind))
4457 }
4458 _ => None,
4459 }
4460 }
4461}