1use std::borrow::Cow;
4
5use rustc_abi::ExternAbi;
6use rustc_ast::{AssignOpKind, Label};
7use rustc_errors::codes::*;
8use rustc_errors::{
9 Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagSymbolList, Diagnostic, IntoDiagArg,
10 Level, MultiSpan, Subdiagnostic, msg,
11};
12use rustc_hir as hir;
13use rustc_hir::ExprKind;
14use rustc_macros::{Diagnostic, Subdiagnostic};
15use rustc_middle::ty::Ty;
16use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
17use rustc_span::{Ident, Span, Spanned, Symbol};
18
19use crate::FnCtxt;
20
21#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AsmConstPtrUnstable
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AsmConstPtrUnstable { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using pointers in asm `const` operand is experimental")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
22#[diag("using pointers in asm `const` operand is experimental")]
23pub(crate) struct AsmConstPtrUnstable {
24 #[primary_span]
25 pub span: Span,
26}
27
28#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
BaseExpressionDoubleDot {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BaseExpressionDoubleDot {
span: __binding_0,
default_field_values_suggestion: __binding_1,
add_expr: __binding_2,
remove_dots: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("base expression required after `..`")));
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#![feature(default_field_values)]\n"))
})].into_iter();
diag.code(E0797);
;
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("add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields")),
__code_0, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
29#[diag("base expression required after `..`", code = E0797)]
30pub(crate) struct BaseExpressionDoubleDot {
31 #[primary_span]
32 pub span: Span,
33 #[suggestion(
34 "add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields",
35 code = "#![feature(default_field_values)]\n",
36 applicability = "machine-applicable",
37 style = "verbose"
38 )]
39 pub default_field_values_suggestion: Option<Span>,
40 #[subdiagnostic]
41 pub add_expr: Option<BaseExpressionDoubleDotAddExpr>,
42 #[subdiagnostic]
43 pub remove_dots: Option<BaseExpressionDoubleDotRemove>,
44}
45
46#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BaseExpressionDoubleDotRemove {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
BaseExpressionDoubleDotRemove { span: __binding_0 } => {
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `..` as all the fields are already present")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_1, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
47#[suggestion(
48 "remove the `..` as all the fields are already present",
49 code = "",
50 applicability = "machine-applicable",
51 style = "verbose"
52)]
53pub(crate) struct BaseExpressionDoubleDotRemove {
54 #[primary_span]
55 pub span: Span,
56}
57
58#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BaseExpressionDoubleDotAddExpr {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
BaseExpressionDoubleDotAddExpr { span: __binding_0 } => {
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* expr */"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a base expression here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
59#[suggestion(
60 "add a base expression here",
61 code = "/* expr */",
62 applicability = "has-placeholders",
63 style = "verbose"
64)]
65pub(crate) struct BaseExpressionDoubleDotAddExpr {
66 #[primary_span]
67 pub span: Span,
68}
69
70#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FieldMultiplySpecifiedInInitializer {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FieldMultiplySpecifiedInInitializer {
span: __binding_0,
prev_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$ident}` specified more than once")));
diag.code(E0062);
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("used more than once")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first use of `{$ident}`")));
diag
}
}
}
}
};Diagnostic)]
71#[diag("field `{$ident}` specified more than once", code = E0062)]
72pub(crate) struct FieldMultiplySpecifiedInInitializer {
73 #[primary_span]
74 #[label("used more than once")]
75 pub span: Span,
76 #[label("first use of `{$ident}`")]
77 pub prev_span: Span,
78 pub ident: Ident,
79}
80
81#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReturnStmtOutsideOfFnBody {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnStmtOutsideOfFnBody {
span: __binding_0,
encl_body_span: __binding_1,
encl_fn_span: __binding_2,
statement_kind: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$statement_kind} statement outside of function body")));
diag.code(E0572);
;
diag.arg("statement_kind", __binding_3);
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$statement_kind} is part of this body...")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...not the enclosing function body")));
}
diag
}
}
}
}
};Diagnostic)]
82#[diag("{$statement_kind} statement outside of function body", code = E0572)]
83pub(crate) struct ReturnStmtOutsideOfFnBody {
84 #[primary_span]
85 pub span: Span,
86 #[label("the {$statement_kind} is part of this body...")]
87 pub encl_body_span: Option<Span>,
88 #[label("...not the enclosing function body")]
89 pub encl_fn_span: Option<Span>,
90 pub statement_kind: ReturnLikeStatementKind,
91}
92
93pub(crate) enum ReturnLikeStatementKind {
94 Return,
95 Become,
96}
97
98impl IntoDiagArg for ReturnLikeStatementKind {
99 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
100 let kind = match self {
101 Self::Return => "return",
102 Self::Become => "become",
103 }
104 .into();
105
106 DiagArgValue::Str(kind)
107 }
108}
109
110#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RustCallIncorrectArgs {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RustCallIncorrectArgs { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"rust-call\" ABI must take a single non-self tuple argument")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
112#[diag("functions with the \"rust-call\" ABI must take a single non-self tuple argument")]
113pub(crate) struct RustCallIncorrectArgs {
114 #[primary_span]
115 pub span: Span,
116}
117
118#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
YieldExprOutsideOfCoroutine {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
YieldExprOutsideOfCoroutine { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("yield expression outside of coroutine literal")));
diag.code(E0627);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
119#[diag("yield expression outside of coroutine literal", code = E0627)]
120pub(crate) struct YieldExprOutsideOfCoroutine {
121 #[primary_span]
122 pub span: Span,
123}
124
125#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
StructExprNonExhaustive {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StructExprNonExhaustive {
span: __binding_0, what: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot create non-exhaustive {$what} using struct expression")));
diag.code(E0639);
;
diag.arg("what", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
126#[diag("cannot create non-exhaustive {$what} using struct expression", code = E0639)]
127pub(crate) struct StructExprNonExhaustive {
128 #[primary_span]
129 pub span: Span,
130 pub what: &'static str,
131}
132
133#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FunctionalRecordUpdateOnNonStruct {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FunctionalRecordUpdateOnNonStruct { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functional record update syntax requires a struct")));
diag.code(E0436);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
134#[diag("functional record update syntax requires a struct", code = E0436)]
135pub(crate) struct FunctionalRecordUpdateOnNonStruct {
136 #[primary_span]
137 pub span: Span,
138}
139
140#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AddressOfTemporaryTaken {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AddressOfTemporaryTaken { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot take address of a temporary")));
diag.code(E0745);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("temporary value")));
diag
}
}
}
}
};Diagnostic)]
141#[diag("cannot take address of a temporary", code = E0745)]
142pub(crate) struct AddressOfTemporaryTaken {
143 #[primary_span]
144 #[label("temporary value")]
145 pub span: Span,
146}
147
148#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddReturnTypeSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AddReturnTypeSuggestion::Add {
span: __binding_0, found: __binding_1 } => {
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" -> {0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding a return type")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_3, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
AddReturnTypeSuggestion::MissingHere { span: __binding_0 }
=> {
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" -> _"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a return type might be missing here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_4, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
149pub(crate) enum AddReturnTypeSuggestion {
150 #[suggestion(
151 "try adding a return type",
152 code = " -> {found}",
153 applicability = "machine-applicable"
154 )]
155 Add {
156 #[primary_span]
157 span: Span,
158 found: String,
159 },
160 #[suggestion(
161 "a return type might be missing here",
162 code = " -> _",
163 applicability = "has-placeholders"
164 )]
165 MissingHere {
166 #[primary_span]
167 span: Span,
168 },
169}
170
171#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
ExpectedReturnTypeLabel<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ExpectedReturnTypeLabel::Unit { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `()` because of default return type")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedReturnTypeLabel::Other {
span: __binding_0, expected: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("expected".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$expected}` because of return type")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ExpectedReturnTypeLabel::ImplTrait {
span: __binding_0, trait_name: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("trait_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a single type implementing `{$trait_name}` because of return type")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
172pub(crate) enum ExpectedReturnTypeLabel<'tcx> {
173 #[label("expected `()` because of default return type")]
174 Unit {
175 #[primary_span]
176 span: Span,
177 },
178 #[label("expected `{$expected}` because of return type")]
179 Other {
180 #[primary_span]
181 span: Span,
182 expected: Ty<'tcx>,
183 },
184 #[label("expected a single type implementing `{$trait_name}` because of return type")]
185 ImplTrait {
186 #[primary_span]
187 span: Span,
188 trait_name: String,
189 },
190}
191
192#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ExplicitDestructorCall {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExplicitDestructorCall {
span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit use of destructor method")));
diag.code(E0040);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit destructor calls not allowed")));
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
193#[diag("explicit use of destructor method", code = E0040)]
194pub(crate) struct ExplicitDestructorCall {
195 #[primary_span]
196 #[label("explicit destructor calls not allowed")]
197 pub span: Span,
198 #[subdiagnostic]
199 pub sugg: ExplicitDestructorCallSugg,
200}
201
202#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExplicitDestructorCallSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ExplicitDestructorCallSugg::Empty(__binding_0) => {
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("drop"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `drop` function")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_5, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
ExplicitDestructorCallSugg::Snippet {
lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("drop("))
});
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_6));
suggestions.push((__binding_1, __code_7));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `drop` function")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::HideCodeInline);
}
}
}
}
};Subdiagnostic)]
203pub(crate) enum ExplicitDestructorCallSugg {
204 #[suggestion(
205 "consider using `drop` function",
206 code = "drop",
207 applicability = "maybe-incorrect"
208 )]
209 Empty(#[primary_span] Span),
210 #[multipart_suggestion("consider using `drop` function", style = "short")]
211 Snippet {
212 #[suggestion_part(code = "drop(")]
213 lo: Span,
214 #[suggestion_part(code = ")")]
215 hi: Span,
216 },
217}
218
219#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
MissingParenthesesInRange<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingParenthesesInRange {
span: __binding_0,
ty: __binding_1,
method_name: __binding_2,
add_missing_parentheses: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't call method `{$method_name}` on type `{$ty}`")));
diag.code(E0689);
;
diag.arg("ty", __binding_1);
diag.arg("method_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't call method `{$method_name}` on type `{$ty}`")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
220#[diag("can't call method `{$method_name}` on type `{$ty}`", code = E0689)]
221pub(crate) struct MissingParenthesesInRange<'tcx> {
222 #[primary_span]
223 #[label("can't call method `{$method_name}` on type `{$ty}`")]
224 pub span: Span,
225 pub ty: Ty<'tcx>,
226 pub method_name: String,
227 #[subdiagnostic]
228 pub add_missing_parentheses: Option<AddMissingParenthesesInRange>,
229}
230
231#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NeverTypeFallbackFlowingIntoUnsafe {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NeverTypeFallbackFlowingIntoUnsafe::Call { sugg: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this call to an `unsafe` function")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
;
diag.subdiagnostic(__binding_0);
diag
}
NeverTypeFallbackFlowingIntoUnsafe::Method {
sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this call to an `unsafe` method")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
;
diag.subdiagnostic(__binding_0);
diag
}
NeverTypeFallbackFlowingIntoUnsafe::Path { sugg: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this `unsafe` function")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
;
diag.subdiagnostic(__binding_0);
diag
}
NeverTypeFallbackFlowingIntoUnsafe::UnionField {
sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this union access")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
;
diag.subdiagnostic(__binding_0);
diag
}
NeverTypeFallbackFlowingIntoUnsafe::Deref {
sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this raw pointer dereference")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
232pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe {
233 #[help("specify the type explicitly")]
234 #[diag("never type fallback affects this call to an `unsafe` function")]
235 Call {
236 #[subdiagnostic]
237 sugg: SuggestAnnotations,
238 },
239 #[help("specify the type explicitly")]
240 #[diag("never type fallback affects this call to an `unsafe` method")]
241 Method {
242 #[subdiagnostic]
243 sugg: SuggestAnnotations,
244 },
245 #[help("specify the type explicitly")]
246 #[diag("never type fallback affects this `unsafe` function")]
247 Path {
248 #[subdiagnostic]
249 sugg: SuggestAnnotations,
250 },
251 #[help("specify the type explicitly")]
252 #[diag("never type fallback affects this union access")]
253 UnionField {
254 #[subdiagnostic]
255 sugg: SuggestAnnotations,
256 },
257 #[help("specify the type explicitly")]
258 #[diag("never type fallback affects this raw pointer dereference")]
259 Deref {
260 #[subdiagnostic]
261 sugg: SuggestAnnotations,
262 },
263}
264
265#[derive(#[automatically_derived]impl ::core::clone::Clone for SuggestAnnotation {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Unit(__self_0) =>
SuggestAnnotation::Unit(::core::clone::Clone::clone(__self_0)),
Self::Path(__self_0) =>
SuggestAnnotation::Path(::core::clone::Clone::clone(__self_0)),
Self::Local(__self_0) =>
SuggestAnnotation::Local(::core::clone::Clone::clone(__self_0)),
Self::Turbo(__self_0, __self_1, __self_2) =>
SuggestAnnotation::Turbo(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1),
::core::clone::Clone::clone(__self_2)),
}
}
}Clone)]
266pub(crate) enum SuggestAnnotation {
267 Unit(Span),
268 Path(Span),
269 Local(Span),
270 Turbo(Span, usize, usize),
271}
272
273#[derive(#[automatically_derived]impl ::core::clone::Clone for SuggestAnnotations {
#[inline]
fn clone(&self) -> Self {
SuggestAnnotations {
suggestions: ::core::clone::Clone::clone(&self.suggestions),
}
}
}Clone)]
274pub(crate) struct SuggestAnnotations {
275 pub suggestions: Vec<SuggestAnnotation>,
276}
277impl Subdiagnostic for SuggestAnnotations {
278 fn add_to_diag(self, diag: &mut Diag<'_>) {
279 if self.suggestions.is_empty() {
280 return;
281 }
282
283 let mut suggestions = ::alloc::vec::Vec::new()vec![];
284 for suggestion in self.suggestions {
285 match suggestion {
286 SuggestAnnotation::Unit(span) => {
287 suggestions.push((span, "()".to_string()));
288 }
289 SuggestAnnotation::Path(span) => {
290 suggestions.push((span.shrink_to_lo(), "<() as ".to_string()));
291 suggestions.push((span.shrink_to_hi(), ">".to_string()));
292 }
293 SuggestAnnotation::Local(span) => {
294 suggestions.push((span, ": ()".to_string()));
295 }
296 SuggestAnnotation::Turbo(span, n_args, idx) => suggestions.push((
297 span,
298 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("::<{0}>",
(0..n_args).map(|i|
if i == idx {
"()"
} else { "_" }).collect::<Vec<_>>().join(", ")))
})format!(
299 "::<{}>",
300 (0..n_args)
301 .map(|i| if i == idx { "()" } else { "_" })
302 .collect::<Vec<_>>()
303 .join(", "),
304 ),
305 )),
306 }
307 }
308
309 diag.multipart_suggestion(
310 "use `()` annotations to avoid fallback changes",
311 suggestions,
312 Applicability::MachineApplicable,
313 );
314 }
315}
316
317#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddMissingParenthesesInRange {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AddMissingParenthesesInRange {
func_name: __binding_0,
left: __binding_1,
right: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_1, __code_8));
suggestions.push((__binding_2, __code_9));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("func_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you must surround the range in parentheses to call its `{$func_name}` function")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
318#[multipart_suggestion(
319 "you must surround the range in parentheses to call its `{$func_name}` function",
320 style = "verbose",
321 applicability = "maybe-incorrect"
322)]
323pub(crate) struct AddMissingParenthesesInRange {
324 pub func_name: String,
325 #[suggestion_part(code = "(")]
326 pub left: Span,
327 #[suggestion_part(code = ")")]
328 pub right: Span,
329}
330
331pub(crate) struct TypeMismatchFruTypo {
332 pub expr_span: Span,
334 pub fru_span: Span,
336 pub expr: Option<String>,
338}
339
340impl Subdiagnostic for TypeMismatchFruTypo {
341 fn add_to_diag(self, diag: &mut Diag<'_>) {
342 diag.arg("expr", self.expr.as_deref().unwrap_or("NONE"));
343
344 if self.expr_span.between(self.fru_span).is_empty() {
346 diag.span_note(
347 self.expr_span.to(self.fru_span),
348 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression may have been misinterpreted as a `..` range expression"))msg!("this expression may have been misinterpreted as a `..` range expression"),
349 );
350 } else {
351 let mut multispan: MultiSpan = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.expr_span, self.fru_span]))vec![self.expr_span, self.fru_span].into();
352 multispan.push_span_label(
353 self.expr_span,
354 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression does not end in a comma..."))msg!("this expression does not end in a comma..."),
355 );
356 multispan.push_span_label(self.fru_span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... so this is interpreted as a `..` range expression, instead of functional record update syntax"))msg!("... so this is interpreted as a `..` range expression, instead of functional record update syntax"));
357 diag.span_note(
358 multispan,
359 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression may have been misinterpreted as a `..` range expression"))msg!("this expression may have been misinterpreted as a `..` range expression"),
360 );
361 }
362
363 diag.span_suggestion_verbose(
364 self.expr_span.shrink_to_hi(),
365 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to set the remaining fields{$expr ->\n [NONE]{\"\"}\n *[other] {\" \"}from `{$expr}`\n }, separate the last named field with a comma"))msg!(
366 "to set the remaining fields{$expr ->
367 [NONE]{\"\"}
368 *[other] {\" \"}from `{$expr}`
369 }, separate the last named field with a comma"
370 ),
371 ", ",
372 Applicability::MaybeIncorrect,
373 );
374 }
375}
376
377#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PtrCastAddAutoToObject {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PtrCastAddAutoToObject {
span: __binding_0,
traits_len: __binding_1,
traits: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot add {$traits_len ->\n [1] auto trait {$traits}\n *[other] auto traits {$traits}\n} to dyn bound via pointer cast")));
diag.code(E0804);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this could allow UB elsewhere")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `transmute` if you're sure this is sound")));
;
diag.arg("traits_len", __binding_1);
diag.arg("traits", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsupported cast")));
diag
}
}
}
}
};Diagnostic)]
378#[diag("cannot add {$traits_len ->
379 [1] auto trait {$traits}
380 *[other] auto traits {$traits}
381} to dyn bound via pointer cast", code = E0804)]
382#[note("this could allow UB elsewhere")]
383#[help("use `transmute` if you're sure this is sound")]
384pub(crate) struct PtrCastAddAutoToObject {
385 #[primary_span]
386 #[label("unsupported cast")]
387 pub span: Span,
388 pub traits_len: usize,
389 pub traits: DiagSymbolList<String>,
390}
391
392#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HelpUseLatestEdition {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
HelpUseLatestEdition::Cargo { edition: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("edition".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("set `edition = \"{$edition}\"` in `Cargo.toml`")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
&sub_args);
diag.note(__message);
}
HelpUseLatestEdition::Standalone { edition: __binding_0 } =>
{
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("edition".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pass `--edition {$edition}` to `rustc`")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
393pub(crate) enum HelpUseLatestEdition {
394 #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
395 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
396 Cargo { edition: Edition },
397 #[help("pass `--edition {$edition}` to `rustc`")]
398 #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
399 Standalone { edition: Edition },
400}
401
402impl HelpUseLatestEdition {
403 pub(crate) fn new() -> Self {
404 let edition = LATEST_STABLE_EDITION;
405 if rustc_session::utils::was_invoked_from_cargo() {
406 Self::Cargo { edition }
407 } else {
408 Self::Standalone { edition }
409 }
410 }
411}
412
413#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
NoFieldOnVariant<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoFieldOnVariant {
span: __binding_0,
container: __binding_1,
ident: __binding_2,
field: __binding_3,
enum_span: __binding_4,
field_span: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no field named `{$field}` on enum variant `{$container}::{$ident}`")));
diag.code(E0609);
;
diag.arg("container", __binding_1);
diag.arg("ident", __binding_2);
diag.arg("field", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this enum variant...")));
diag.span_label(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...does not have this field")));
diag
}
}
}
}
};Diagnostic)]
414#[diag("no field named `{$field}` on enum variant `{$container}::{$ident}`", code = E0609)]
415pub(crate) struct NoFieldOnVariant<'tcx> {
416 #[primary_span]
417 pub(crate) span: Span,
418 pub(crate) container: Ty<'tcx>,
419 pub(crate) ident: Ident,
420 pub(crate) field: Ident,
421 #[label("this enum variant...")]
422 pub(crate) enum_span: Span,
423 #[label("...does not have this field")]
424 pub(crate) field_span: Span,
425}
426
427#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CantDereference<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CantDereference { span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$ty}` cannot be dereferenced")));
diag.code(E0614);
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be dereferenced")));
diag
}
}
}
}
};Diagnostic)]
428#[diag("type `{$ty}` cannot be dereferenced", code = E0614)]
429pub(crate) struct CantDereference<'tcx> {
430 #[primary_span]
431 #[label("can't be dereferenced")]
432 pub(crate) span: Span,
433 pub(crate) ty: Ty<'tcx>,
434}
435
436#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
ExpectedArrayOrSlice<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExpectedArrayOrSlice {
span: __binding_0,
ty: __binding_1,
slice_pat_semantics: __binding_2,
as_deref: __binding_3,
slicing: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an array or slice, found `{$ty}`")));
diag.code(E0529);
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern cannot match with input type `{$ty}`")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
437#[diag("expected an array or slice, found `{$ty}`", code = E0529)]
438pub(crate) struct ExpectedArrayOrSlice<'tcx> {
439 #[primary_span]
440 #[label("pattern cannot match with input type `{$ty}`")]
441 pub(crate) span: Span,
442 pub(crate) ty: Ty<'tcx>,
443 pub(crate) slice_pat_semantics: bool,
444 #[subdiagnostic]
445 pub(crate) as_deref: Option<AsDerefSuggestion>,
446 #[subdiagnostic]
447 pub(crate) slicing: Option<SlicingSuggestion>,
448}
449
450#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AsDerefSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AsDerefSuggestion { span: __binding_0 } => {
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".as_deref()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `as_deref` here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_10, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
451#[suggestion(
452 "consider using `as_deref` here",
453 code = ".as_deref()",
454 style = "verbose",
455 applicability = "maybe-incorrect"
456)]
457pub(crate) struct AsDerefSuggestion {
458 #[primary_span]
459 pub(crate) span: Span,
460}
461
462#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SlicingSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SlicingSuggestion { span: __binding_0 } => {
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("[..]"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider slicing here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
463#[suggestion(
464 "consider slicing here",
465 code = "[..]",
466 style = "verbose",
467 applicability = "maybe-incorrect"
468)]
469pub(crate) struct SlicingSuggestion {
470 #[primary_span]
471 pub(crate) span: Span,
472}
473
474#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InvalidCallee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidCallee { span: __binding_0, found: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected function, found {$found}")));
diag.code(E0618);
;
diag.arg("found", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
475#[diag("expected function, found {$found}", code = E0618)]
476pub(crate) struct InvalidCallee {
477 #[primary_span]
478 pub span: Span,
479 pub found: String,
480}
481
482#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
ScalableVectorCtor<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ScalableVectorCtor { span: __binding_0, ty: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("scalable vector types cannot be initialised using their constructor")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
483#[diag("scalable vector types cannot be initialised using their constructor")]
484pub(crate) struct ScalableVectorCtor<'tcx> {
485 #[primary_span]
486 pub span: Span,
487 pub ty: Ty<'tcx>,
488}
489
490#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
IntToWide<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IntToWide {
span: __binding_0,
metadata: __binding_1,
expr_ty: __binding_2,
cast_ty: __binding_3,
expr_if_nightly: __binding_4,
known_wide: __binding_5,
param_note: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->\n [true] is\n *[false] may be\n} wide")));
diag.code(E0606);
;
diag.arg("metadata", __binding_1);
diag.arg("expr_ty", __binding_2);
diag.arg("cast_ty", __binding_3);
diag.arg("known_wide", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a `{$cast_ty}` requires both an address and {$metadata}")));
if let Some(__binding_4) = __binding_4 {
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`")));
}
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
diag
}
}
}
}
};Diagnostic)]
491#[diag("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
492 [true] is
493 *[false] may be
494} wide", code = E0606)]
495pub(crate) struct IntToWide<'tcx> {
496 #[primary_span]
497 #[label("creating a `{$cast_ty}` requires both an address and {$metadata}")]
498 pub span: Span,
499 pub metadata: &'tcx str,
500 pub expr_ty: Ty<'tcx>,
501 pub cast_ty: Ty<'tcx>,
502 #[label(
503 "consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`"
504 )]
505 pub expr_if_nightly: Option<Span>,
506 pub known_wide: bool,
507 #[subdiagnostic]
508 pub param_note: Option<IntToWideParamNote>,
509}
510
511#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IntToWideParamNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
IntToWideParamNote { param: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("param".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type parameter `{$param}` is not known to be `Sized`, so this pointer may be wide")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
512#[note("the type parameter `{$param}` is not known to be `Sized`, so this pointer may be wide")]
513pub(crate) struct IntToWideParamNote {
514 pub param: Symbol,
515}
516
517#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OptionResultRefMismatch {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OptionResultRefMismatch::Copied {
span: __binding_0, def_path: __binding_1 } => {
let __code_12 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".copied()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("def_path".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `{$def_path}::copied` to copy the value inside the `{$def_path}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_12, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
OptionResultRefMismatch::Cloned {
span: __binding_0, def_path: __binding_1 } => {
let __code_13 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".cloned()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("def_path".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `{$def_path}::cloned` to clone the value inside the `{$def_path}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_13, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
518pub(crate) enum OptionResultRefMismatch {
519 #[suggestion(
520 "use `{$def_path}::copied` to copy the value inside the `{$def_path}`",
521 code = ".copied()",
522 style = "verbose",
523 applicability = "machine-applicable"
524 )]
525 Copied {
526 #[primary_span]
527 span: Span,
528 def_path: String,
529 },
530 #[suggestion(
531 "use `{$def_path}::cloned` to clone the value inside the `{$def_path}`",
532 code = ".cloned()",
533 style = "verbose",
534 applicability = "machine-applicable"
535 )]
536 Cloned {
537 #[primary_span]
538 span: Span,
539 def_path: String,
540 },
541 }
556
557pub(crate) struct RemoveSemiForCoerce {
558 pub expr: Span,
559 pub ret: Span,
560 pub semi: Span,
561}
562
563impl Subdiagnostic for RemoveSemiForCoerce {
564 fn add_to_diag(self, diag: &mut Diag<'_>) {
565 let mut multispan: MultiSpan = self.semi.into();
566 multispan.push_span_label(
567 self.expr,
568 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this could be implicitly returned but it is a statement, not a tail expression"))msg!("this could be implicitly returned but it is a statement, not a tail expression"),
569 );
570 multispan
571 .push_span_label(self.ret, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `match` arms can conform to this return type"))msg!("the `match` arms can conform to this return type"));
572 multispan.push_span_label(
573 self.semi,
574 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `match` is a statement because of this semicolon, consider removing it"))msg!("the `match` is a statement because of this semicolon, consider removing it"),
575 );
576 diag.span_note(multispan, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to return the `match` expression"))msg!("you might have meant to return the `match` expression"));
577
578 diag.tool_only_span_suggestion(
579 self.semi,
580 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this semicolon"))msg!("remove this semicolon"),
581 "",
582 Applicability::MaybeIncorrect,
583 );
584 }
585}
586
587#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NonConstPathInPattern {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NonConstPathInPattern { spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("runtime values cannot be referenced in patterns")));
diag.code(E0080);
;
diag.span(__binding_0.clone());
for __binding_0 in __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references a runtime value")));
}
diag
}
}
}
}
};Diagnostic)]
588#[diag("runtime values cannot be referenced in patterns", code = E0080)]
589pub(crate) struct NonConstPathInPattern {
590 #[primary_span]
591 #[label("references a runtime value")]
592 pub spans: Vec<Span>,
593}
594
595#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnionPatMultipleFields {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnionPatMultipleFields { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("union patterns should have exactly one field")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
596#[diag("union patterns should have exactly one field")]
597pub(crate) struct UnionPatMultipleFields {
598 #[primary_span]
599 pub span: Span,
600}
601
602#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnionPatDotDot {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnionPatDotDot { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`..` cannot be used in union patterns")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
603#[diag("`..` cannot be used in union patterns")]
604pub(crate) struct UnionPatDotDot {
605 #[primary_span]
606 pub span: Span,
607}
608
609#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for UseIsEmpty<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UseIsEmpty {
lo: __binding_0, hi: __binding_1, expr_ty: __binding_2 } =>
{
let mut suggestions = Vec::new();
let __code_14 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
});
let __code_15 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".is_empty()"))
});
suggestions.push((__binding_0, __code_14));
suggestions.push((__binding_1, __code_15));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("expr_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
610#[multipart_suggestion(
611 "consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything",
612 applicability = "maybe-incorrect",
613 style = "verbose"
614)]
615pub(crate) struct UseIsEmpty<'tcx> {
616 #[suggestion_part(code = "!")]
617 pub lo: Span,
618 #[suggestion_part(code = ".is_empty()")]
619 pub hi: Span,
620 pub expr_ty: Ty<'tcx>,
621}
622
623#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ArgMismatchIndeterminate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ArgMismatchIndeterminate { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument type mismatch was detected, but rustc had trouble determining where")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
624#[diag("argument type mismatch was detected, but rustc had trouble determining where")]
625pub(crate) struct ArgMismatchIndeterminate {
626 #[primary_span]
627 pub span: Span,
628}
629
630#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestBoxing {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestBoxing::Unit { start: __binding_0, end: __binding_1 }
=> {
let mut suggestions = Vec::new();
let __code_16 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new(())"))
});
let __code_17 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_16));
suggestions.push((__binding_1, __code_17));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
SuggestBoxing::AsyncBody => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
&sub_args);
diag.note(__message);
}
SuggestBoxing::ExprFieldShorthand {
start: __binding_0, end: __binding_1, ident: __binding_2 }
=> {
let mut suggestions = Vec::new();
let __code_18 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}: Box::new(",
__binding_2))
});
let __code_19 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_18));
suggestions.push((__binding_1, __code_19));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
SuggestBoxing::Other { start: __binding_0, end: __binding_1
} => {
let mut suggestions = Vec::new();
let __code_20 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new("))
});
let __code_21 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_20));
suggestions.push((__binding_1, __code_21));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
631pub(crate) enum SuggestBoxing {
632 #[note(
633 "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
634 )]
635 #[multipart_suggestion(
636 "store this in the heap by calling `Box::new`",
637 applicability = "machine-applicable"
638 )]
639 Unit {
640 #[suggestion_part(code = "Box::new(())")]
641 start: Span,
642 #[suggestion_part(code = "")]
643 end: Span,
644 },
645 #[note(
646 "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
647 )]
648 AsyncBody,
649 #[note(
650 "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
651 )]
652 #[multipart_suggestion(
653 "store this in the heap by calling `Box::new`",
654 applicability = "machine-applicable"
655 )]
656 ExprFieldShorthand {
657 #[suggestion_part(code = "{ident}: Box::new(")]
658 start: Span,
659 #[suggestion_part(code = ")")]
660 end: Span,
661 ident: Ident,
662 },
663 #[note(
664 "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
665 )]
666 #[multipart_suggestion(
667 "store this in the heap by calling `Box::new`",
668 applicability = "machine-applicable"
669 )]
670 Other {
671 #[suggestion_part(code = "Box::new(")]
672 start: Span,
673 #[suggestion_part(code = ")")]
674 end: Span,
675 },
676}
677
678#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestPtrNullMut {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestPtrNullMut { span: __binding_0 } => {
let __code_22 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("core::ptr::null_mut()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `core::ptr::null_mut` instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_22, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
679#[suggestion(
680 "consider using `core::ptr::null_mut` instead",
681 applicability = "maybe-incorrect",
682 style = "verbose",
683 code = "core::ptr::null_mut()"
684)]
685pub(crate) struct SuggestPtrNullMut {
686 #[primary_span]
687 pub span: Span,
688}
689
690#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestRefMut {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestRefMut { span: __binding_0 } => {
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&mut "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `&mut` instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_23, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
691#[suggestion(
692 "consider using `&mut` instead",
693 applicability = "maybe-incorrect",
694 style = "verbose",
695 code = "&mut "
696)]
697pub(crate) struct SuggestRefMut {
698 #[primary_span]
699 pub span: Span,
700}
701
702#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestRawMut {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestRawMut { span: __binding_0 } => {
let __code_24 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&raw mut "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `&raw mut` instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_24, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
703#[suggestion(
704 "consider using `&raw mut` instead",
705 applicability = "maybe-incorrect",
706 style = "verbose",
707 code = "&raw mut "
708)]
709pub(crate) struct SuggestRawMut {
710 #[primary_span]
711 pub span: Span,
712}
713
714#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
TrivialCast<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TrivialCast {
numeric: __binding_0,
expr_ty: __binding_1,
cast_ty: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trivial {$numeric ->\n [true] numeric cast\n *[false] cast\n }: `{$expr_ty}` as `{$cast_ty}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cast can be replaced by coercion; this might require a temporary variable")));
;
diag.arg("numeric", __binding_0);
diag.arg("expr_ty", __binding_1);
diag.arg("cast_ty", __binding_2);
diag
}
}
}
}
};Diagnostic)]
715#[diag(
716 "trivial {$numeric ->
717 [true] numeric cast
718 *[false] cast
719 }: `{$expr_ty}` as `{$cast_ty}`"
720)]
721#[help("cast can be replaced by coercion; this might require a temporary variable")]
722pub(crate) struct TrivialCast<'tcx> {
723 pub numeric: bool,
724 pub expr_ty: Ty<'tcx>,
725 pub cast_ty: Ty<'tcx>,
726}
727
728pub(crate) struct BreakNonLoop<'a> {
729 pub span: Span,
730 pub head: Option<Span>,
731 pub kind: &'a str,
732 pub suggestion: String,
733 pub loop_label: Option<Label>,
734 pub break_label: Option<Label>,
735 pub break_expr_kind: &'a ExprKind<'a>,
736 pub break_expr_span: Span,
737}
738
739impl<'a> Diagnostic<'_> for BreakNonLoop<'a> {
740 #[track_caller]
741 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
742 let mut diag = Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`break` with value from a `{$kind}` loop"))msg!("`break` with value from a `{$kind}` loop"));
743 diag.span(self.span);
744 diag.code(E0571);
745 diag.arg("kind", self.kind);
746 diag.span_label(
747 self.span,
748 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can only break with a value inside `loop` or breakable block"))msg!("can only break with a value inside `loop` or breakable block"),
749 );
750 if let Some(head) = self.head {
751 diag.span_label(head, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can't `break` with a value in a `{$kind}` loop"))msg!("you can't `break` with a value in a `{$kind}` loop"));
752 }
753 diag.span_suggestion_verbose(
754 self.span,
755 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `break` on its own without a value inside this `{$kind}` loop"))msg!("use `break` on its own without a value inside this `{$kind}` loop"),
756 self.suggestion,
757 Applicability::MaybeIncorrect,
758 );
759 if let (Some(label), None) = (self.loop_label, self.break_label) {
760 match self.break_expr_kind {
761 ExprKind::Path(hir::QPath::Resolved(
762 None,
763 hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
764 )) if label.ident.to_string() == ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\'{0}", segment.ident))
})format!("'{}", segment.ident) => {
765 diag.downgrade_to_delayed_bug();
769 }
770 _ => {
771 diag.span_suggestion_verbose(
772 self.break_expr_span,
773 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively, you might have meant to use the available loop label"))msg!("alternatively, you might have meant to use the available loop label"),
774 label.ident,
775 Applicability::MaybeIncorrect,
776 );
777 }
778 }
779 }
780 diag
781 }
782}
783
784#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ContinueLabeledBlock
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ContinueLabeledBlock {
span: __binding_0, block_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`continue` pointing to a labeled block")));
diag.code(E0696);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled blocks cannot be `continue`'d")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled block the `continue` points to")));
diag
}
}
}
}
};Diagnostic)]
785#[diag("`continue` pointing to a labeled block", code = E0696)]
786pub(crate) struct ContinueLabeledBlock {
787 #[primary_span]
788 #[label("labeled blocks cannot be `continue`'d")]
789 pub span: Span,
790 #[label("labeled block the `continue` points to")]
791 pub block_span: Span,
792}
793
794#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
BreakInsideClosure<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BreakInsideClosure {
span: __binding_0,
closure_span: __binding_1,
name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` inside of a closure")));
diag.code(E0267);
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` inside of a closure")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclosing closure")));
diag
}
}
}
}
};Diagnostic)]
795#[diag("`{$name}` inside of a closure", code = E0267)]
796pub(crate) struct BreakInsideClosure<'a> {
797 #[primary_span]
798 #[label("cannot `{$name}` inside of a closure")]
799 pub span: Span,
800 #[label("enclosing closure")]
801 pub closure_span: Span,
802 pub name: &'a str,
803}
804
805#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
BreakInsideCoroutine<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BreakInsideCoroutine {
span: __binding_0,
coroutine_span: __binding_1,
name: __binding_2,
kind: __binding_3,
source: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` inside `{$kind}` {$source}")));
diag.code(E0267);
;
diag.arg("name", __binding_2);
diag.arg("kind", __binding_3);
diag.arg("source", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` inside `{$kind}` {$source}")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclosing `{$kind}` {$source}")));
diag
}
}
}
}
};Diagnostic)]
806#[diag("`{$name}` inside `{$kind}` {$source}", code = E0267)]
807pub(crate) struct BreakInsideCoroutine<'a> {
808 #[primary_span]
809 #[label("cannot `{$name}` inside `{$kind}` {$source}")]
810 pub span: Span,
811 #[label("enclosing `{$kind}` {$source}")]
812 pub coroutine_span: Span,
813 pub name: &'a str,
814 pub kind: &'a str,
815 pub source: &'a str,
816}
817
818#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for OutsideLoop<'a>
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OutsideLoop {
spans: __binding_0,
name: __binding_1,
is_break: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` outside of a loop{$is_break ->\n [true] {\" or labeled block\"}\n *[false] {\"\"}\n }")));
diag.code(E0268);
;
diag.arg("name", __binding_1);
diag.arg("is_break", __binding_2);
diag.span(__binding_0.clone());
for __binding_0 in __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` outside of a loop{$is_break ->\n [true] {\" or labeled block\"}\n *[false] {\"\"}\n }")));
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
819#[diag("`{$name}` outside of a loop{$is_break ->
820 [true] {\" or labeled block\"}
821 *[false] {\"\"}
822 }", code = E0268)]
823pub(crate) struct OutsideLoop<'a> {
824 #[primary_span]
825 #[label(
826 "cannot `{$name}` outside of a loop{$is_break ->
827 [true] {\" or labeled block\"}
828 *[false] {\"\"}
829 }"
830 )]
831 pub spans: Vec<Span>,
832 pub name: &'a str,
833 pub is_break: bool,
834 #[subdiagnostic]
835 pub suggestion: Option<OutsideLoopSuggestion>,
836}
837#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OutsideLoopSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OutsideLoopSuggestion {
block_span: __binding_0,
break_spans: __binding_1,
wrap_end: __binding_2,
block_prefix: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_25 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
let __code_26 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" \'block"))
});
let __code_27 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_25));
for __binding_1 in __binding_1 {
suggestions.push((__binding_1, __code_26.clone()));
}
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_27));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider labeling this block to be able to break within it")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
838#[multipart_suggestion(
839 "consider labeling this block to be able to break within it",
840 applicability = "maybe-incorrect"
841)]
842pub(crate) struct OutsideLoopSuggestion {
843 #[suggestion_part(code = "{block_prefix}")]
844 pub block_span: Span,
845 #[suggestion_part(code = " 'block")]
846 pub break_spans: Vec<Span>,
847 #[suggestion_part(code = " }}")]
848 pub wrap_end: Option<Span>,
849 pub block_prefix: &'static str,
850}
851
852#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
UnlabeledInLabeledBlock<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnlabeledInLabeledBlock {
span: __binding_0, cf_type: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlabeled `{$cf_type}` inside of a labeled block")));
diag.code(E0695);
;
diag.arg("cf_type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$cf_type}` statements that would diverge to or through a labeled block need to bear a label")));
diag
}
}
}
}
};Diagnostic)]
853#[diag("unlabeled `{$cf_type}` inside of a labeled block", code = E0695)]
854pub(crate) struct UnlabeledInLabeledBlock<'a> {
855 #[primary_span]
856 #[label(
857 "`{$cf_type}` statements that would diverge to or through a labeled block need to bear a label"
858 )]
859 pub span: Span,
860 pub cf_type: &'a str,
861}
862
863#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
UnlabeledCfInWhileCondition<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnlabeledCfInWhileCondition {
span: __binding_0, cf_type: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`break` or `continue` with no label in the condition of a `while` loop")));
diag.code(E0590);
;
diag.arg("cf_type", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlabeled `{$cf_type}` in the condition of a `while` loop")));
diag
}
}
}
}
};Diagnostic)]
864#[diag("`break` or `continue` with no label in the condition of a `while` loop", code = E0590)]
865pub(crate) struct UnlabeledCfInWhileCondition<'a> {
866 #[primary_span]
867 #[label("unlabeled `{$cf_type}` in the condition of a `while` loop")]
868 pub span: Span,
869 pub cf_type: &'a str,
870}
871
872#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
NoAssociatedItem<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoAssociatedItem {
span: __binding_0,
item_kind: __binding_1,
item_ident: __binding_2,
ty_prefix: __binding_3,
ty: __binding_4,
trait_missing_method: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->\n [true] {\"\"}\n *[other] {\" \"}in the current scope\n}")));
diag.code(E0599);
;
diag.arg("item_kind", __binding_1);
diag.arg("item_ident", __binding_2);
diag.arg("ty_prefix", __binding_3);
diag.arg("ty", __binding_4);
diag.arg("trait_missing_method", __binding_5);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
873#[diag("no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->
874 [true] {\"\"}
875 *[other] {\" \"}in the current scope
876}", code = E0599)]
877pub(crate) struct NoAssociatedItem<'tcx> {
878 #[primary_span]
879 pub span: Span,
880 pub item_kind: &'static str,
881 pub item_ident: Ident,
882 pub ty_prefix: Cow<'static, str>,
883 pub ty: Ty<'tcx>,
884 pub trait_missing_method: bool,
885}
886
887#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CandidateTraitNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
CandidateTraitNote {
span: __binding_0,
trait_name: __binding_1,
item_name: __binding_2,
action_or_ty: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("trait_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("item_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("action_or_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->\n [NONE] {\"\"}\n [implement] , perhaps you need to implement it\n *[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it\n }")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
888#[note(
889 "`{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->
890 [NONE] {\"\"}
891 [implement] , perhaps you need to implement it
892 *[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
893 }"
894)]
895pub(crate) struct CandidateTraitNote {
896 #[primary_span]
897 pub span: MultiSpan,
898 pub trait_name: String,
899 pub item_name: Ident,
900 pub action_or_ty: String,
901}
902
903#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CannotCastToBool<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotCastToBool {
span: __binding_0, expr_ty: __binding_1, help: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast `{$expr_ty}` as `bool`")));
diag.code(E0054);
;
diag.arg("expr_ty", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
904#[diag("cannot cast `{$expr_ty}` as `bool`", code = E0054)]
905pub(crate) struct CannotCastToBool<'tcx> {
906 #[primary_span]
907 pub span: Span,
908 pub expr_ty: Ty<'tcx>,
909 #[subdiagnostic]
910 pub help: CannotCastToBoolHelp,
911}
912
913#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CastEnumDrop<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CastEnumDrop {
span: __binding_0,
expr_ty: __binding_1,
cast_ty: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`")));
;
diag.arg("expr_ty", __binding_1);
diag.arg("cast_ty", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
914#[diag("cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`")]
915pub(crate) struct CastEnumDrop<'tcx> {
916 #[primary_span]
917 pub span: Span,
918 pub expr_ty: Ty<'tcx>,
919 pub cast_ty: Ty<'tcx>,
920}
921
922#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CastUnknownPointer {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CastUnknownPointer {
span: __binding_0, to: __binding_1, sub: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast {$to ->\n [true] to\n *[false] from\n} a pointer of an unknown kind")));
diag.code(E0641);
;
diag.arg("to", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
923#[diag("cannot cast {$to ->
924 [true] to
925 *[false] from
926} a pointer of an unknown kind", code = E0641)]
927pub(crate) struct CastUnknownPointer {
928 #[primary_span]
929 pub span: Span,
930 pub to: bool,
931 #[subdiagnostic]
932 pub sub: CastUnknownPointerSub,
933}
934
935pub(crate) enum CastUnknownPointerSub {
936 To(Span),
937 From(Span),
938}
939
940impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
941 fn add_to_diag(self, diag: &mut Diag<'_>) {
942 match self {
943 CastUnknownPointerSub::To(span) => {
944 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs more type information"))msg!("needs more type information");
945 diag.span_label(span, msg);
946 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type information given here is insufficient to check whether the pointer cast is valid"))msg!(
947 "the type information given here is insufficient to check whether the pointer cast is valid"
948 );
949 diag.note(msg);
950 }
951 CastUnknownPointerSub::From(span) => {
952 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type information given here is insufficient to check whether the pointer cast is valid"))msg!(
953 "the type information given here is insufficient to check whether the pointer cast is valid"
954 );
955 diag.span_label(span, msg);
956 }
957 }
958 }
959}
960
961#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CannotCastToBoolHelp {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
CannotCastToBoolHelp::Numeric(__binding_0) => {
let __code_28 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" != 0"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("compare with zero instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_28, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
CannotCastToBoolHelp::Unsupported(__binding_0) => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsupported cast")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
962pub(crate) enum CannotCastToBoolHelp {
963 #[suggestion(
964 "compare with zero instead",
965 applicability = "machine-applicable",
966 code = " != 0",
967 style = "verbose"
968 )]
969 Numeric(#[primary_span] Span),
970 #[label("unsupported cast")]
971 Unsupported(#[primary_span] Span),
972}
973
974#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CtorIsPrivate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CtorIsPrivate { span: __binding_0, def: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("tuple struct constructor `{$def}` is private")));
diag.code(E0603);
;
diag.arg("def", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
975#[diag("tuple struct constructor `{$def}` is private", code = E0603)]
976pub(crate) struct CtorIsPrivate {
977 #[primary_span]
978 pub span: Span,
979 pub def: String,
980}
981
982#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for DerefImplsIsEmpty<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
DerefImplsIsEmpty { span: __binding_0, deref_ty: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("deref_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression `Deref`s to `{$deref_ty}` which implements `is_empty`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
983#[note("this expression `Deref`s to `{$deref_ty}` which implements `is_empty`")]
984pub(crate) struct DerefImplsIsEmpty<'tcx> {
985 #[primary_span]
986 pub span: Span,
987 pub deref_ty: Ty<'tcx>,
988}
989
990#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
SuggestConvertViaMethod<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestConvertViaMethod {
span: __binding_0,
borrow_removal_span: __binding_1,
sugg: __binding_2,
expected: __binding_3,
found: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_29 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
let __code_30 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_29));
if let Some(__binding_1) = __binding_1 {
suggestions.push((__binding_1, __code_30));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("sugg".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("expected".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("found".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `{$sugg}` to convert `{$found}` to `{$expected}`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
991#[multipart_suggestion(
992 "try using `{$sugg}` to convert `{$found}` to `{$expected}`",
993 applicability = "machine-applicable",
994 style = "verbose"
995)]
996pub(crate) struct SuggestConvertViaMethod<'tcx> {
997 #[suggestion_part(code = "{sugg}")]
998 pub span: Span,
999 #[suggestion_part(code = "")]
1000 pub borrow_removal_span: Option<Span>,
1001 pub sugg: String,
1002 pub expected: Ty<'tcx>,
1003 pub found: Ty<'tcx>,
1004}
1005
1006#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
NoteCallerChoosesTyForTyParam<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
NoteCallerChoosesTyForTyParam {
ty_param_name: __binding_0, found_ty: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty_param_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("found_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1007#[note(
1008 "the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`"
1009)]
1010pub(crate) struct NoteCallerChoosesTyForTyParam<'tcx> {
1011 pub ty_param_name: Symbol,
1012 pub found_ty: Ty<'tcx>,
1013}
1014
1015#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestBoxingForReturnImplTrait {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SuggestBoxingForReturnImplTrait::ChangeReturnType {
start_sp: __binding_0, end_sp: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_31 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box<dyn"))
});
let __code_32 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_31));
suggestions.push((__binding_1, __code_32));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you could change the return type to be a boxed trait object")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
SuggestBoxingForReturnImplTrait::BoxReturnExpr {
starts: __binding_0, ends: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_33 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Box::new("))
});
let __code_34 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_33.clone()));
}
for __binding_1 in __binding_1 {
suggestions.push((__binding_1, __code_34.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you change the return type to expect trait objects, box the returned expressions")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1016pub(crate) enum SuggestBoxingForReturnImplTrait {
1017 #[multipart_suggestion(
1018 "you could change the return type to be a boxed trait object",
1019 applicability = "maybe-incorrect"
1020 )]
1021 ChangeReturnType {
1022 #[suggestion_part(code = "Box<dyn")]
1023 start_sp: Span,
1024 #[suggestion_part(code = ">")]
1025 end_sp: Span,
1026 },
1027 #[multipart_suggestion(
1028 "if you change the return type to expect trait objects, box the returned expressions",
1029 applicability = "maybe-incorrect"
1030 )]
1031 BoxReturnExpr {
1032 #[suggestion_part(code = "Box::new(")]
1033 starts: Vec<Span>,
1034 #[suggestion_part(code = ")")]
1035 ends: Vec<Span>,
1036 },
1037}
1038
1039#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SelfCtorFromOuterItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SelfCtorFromOuterItem {
span: __binding_0,
impl_span: __binding_1,
sugg: __binding_2,
item: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reference `Self` constructor from outer item")));
diag.code(E0401);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
1040#[diag("can't reference `Self` constructor from outer item", code = E0401)]
1041pub(crate) struct SelfCtorFromOuterItem {
1042 #[primary_span]
1043 pub span: Span,
1044 #[label(
1045 "the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference"
1046 )]
1047 pub impl_span: Span,
1048 #[subdiagnostic]
1049 pub sugg: Option<ReplaceWithName>,
1050 #[subdiagnostic]
1051 pub item: Option<InnerItem>,
1052}
1053
1054#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InnerItem {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
InnerItem { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Self` used in this inner item")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1055#[label("`Self` used in this inner item")]
1056pub(crate) struct InnerItem {
1057 #[primary_span]
1058 pub span: Span,
1059}
1060
1061#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SelfCtorFromOuterItemLint {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SelfCtorFromOuterItemLint {
impl_span: __binding_0, sugg: __binding_1, item: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reference `Self` constructor from outer item")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1062#[diag("can't reference `Self` constructor from outer item")]
1063pub(crate) struct SelfCtorFromOuterItemLint {
1064 #[label(
1065 "the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference"
1066 )]
1067 pub impl_span: Span,
1068 #[subdiagnostic]
1069 pub sugg: Option<ReplaceWithName>,
1070 #[subdiagnostic]
1071 pub item: Option<InnerItem>,
1072}
1073
1074#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ReplaceWithName {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ReplaceWithName { span: __binding_0, name: __binding_1 } =>
{
let __code_35 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `Self` with the actual type")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_35, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1075#[suggestion(
1076 "replace `Self` with the actual type",
1077 code = "{name}",
1078 applicability = "machine-applicable"
1079)]
1080pub(crate) struct ReplaceWithName {
1081 #[primary_span]
1082 pub span: Span,
1083 pub name: String,
1084}
1085
1086#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CastThinPointerToWidePointer<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CastThinPointerToWidePointer {
span: __binding_0,
expr_ty: __binding_1,
cast_ty: __binding_2,
teach: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`")));
diag.code(E0607);
;
diag.arg("expr_ty", __binding_1);
diag.arg("cast_ty", __binding_2);
diag.span(__binding_0);
if __binding_3 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("thin pointers are \"simple\" pointers: they are purely a reference to a\n memory address.\n\n Wide pointers are pointers referencing \"Dynamically Sized Types\" (also\n called DST). DST don't have a statically known size, therefore they can\n only exist behind some kind of pointers that contain additional\n information. Slices and trait objects are DSTs. In the case of slices,\n the additional information the wide pointer holds is their size.\n\n To fix this error, don't try to cast directly between thin and wide\n pointers.\n\n For more information about casts, take a look at The Book:\n https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions")));
}
diag
}
}
}
}
};Diagnostic)]
1087#[diag("cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`", code = E0607)]
1088pub(crate) struct CastThinPointerToWidePointer<'tcx> {
1089 #[primary_span]
1090 pub span: Span,
1091 pub expr_ty: Ty<'tcx>,
1092 pub cast_ty: Ty<'tcx>,
1093 #[note(
1094 "thin pointers are \"simple\" pointers: they are purely a reference to a
1095 memory address.
1096
1097 Wide pointers are pointers referencing \"Dynamically Sized Types\" (also
1098 called DST). DST don't have a statically known size, therefore they can
1099 only exist behind some kind of pointers that contain additional
1100 information. Slices and trait objects are DSTs. In the case of slices,
1101 the additional information the wide pointer holds is their size.
1102
1103 To fix this error, don't try to cast directly between thin and wide
1104 pointers.
1105
1106 For more information about casts, take a look at The Book:
1107 https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions"
1108 )]
1109 pub(crate) teach: bool,
1110}
1111
1112#[derive(const _: () =
{
impl<'_sess, 'a, 'tcx> rustc_errors::Diagnostic<'_sess> for
PassToVariadicFunction<'a, 'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PassToVariadicFunction {
span: __binding_0,
ty: __binding_1,
cast_ty: __binding_2,
sugg_span: __binding_3,
teach: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't pass `{$ty}` to variadic function")));
let __code_36 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as {0}", __binding_2))
})].into_iter();
diag.code(E0617);
;
diag.arg("ty", __binding_1);
diag.arg("cast_ty", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cast the value to `{$cast_ty}`")),
__code_36, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules")));
}
diag
}
}
}
}
};Diagnostic)]
1113#[diag("can't pass `{$ty}` to variadic function", code = E0617)]
1114pub(crate) struct PassToVariadicFunction<'a, 'tcx> {
1115 #[primary_span]
1116 pub span: Span,
1117 pub ty: Ty<'tcx>,
1118 pub cast_ty: &'a str,
1119 #[suggestion(
1120 "cast the value to `{$cast_ty}`",
1121 code = " as {cast_ty}",
1122 applicability = "machine-applicable",
1123 style = "verbose"
1124 )]
1125 pub sugg_span: Span,
1126 #[note(
1127 "certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules"
1128 )]
1129 pub(crate) teach: bool,
1130}
1131
1132#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PassFnItemToVariadicFunction {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PassFnItemToVariadicFunction {
span: __binding_0,
sugg_span: __binding_1,
replace: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't pass a function item to a variadic function")));
let __code_37 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as {0}", __binding_2))
})].into_iter();
diag.code(E0617);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a function item is zero-sized and needs to be cast into a function pointer to be used in FFI")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html")));
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a function pointer instead")),
__code_37, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1133#[diag("can't pass a function item to a variadic function", code = E0617)]
1134#[help(
1135 "a function item is zero-sized and needs to be cast into a function pointer to be used in FFI"
1136)]
1137#[note(
1138 "for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html"
1139)]
1140pub(crate) struct PassFnItemToVariadicFunction {
1141 #[primary_span]
1142 pub span: Span,
1143 #[suggestion(
1144 "use a function pointer instead",
1145 code = " as {replace}",
1146 applicability = "machine-applicable",
1147 style = "verbose"
1148 )]
1149 pub sugg_span: Span,
1150 pub replace: String,
1151}
1152
1153#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ReplaceCommaWithSemicolon {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ReplaceCommaWithSemicolon {
comma_span: __binding_0, descr: __binding_1 } => {
let __code_38 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("; "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace the comma with a semicolon to create {$descr}")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_38, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1154#[suggestion(
1155 "replace the comma with a semicolon to create {$descr}",
1156 applicability = "machine-applicable",
1157 style = "verbose",
1158 code = "; "
1159)]
1160pub(crate) struct ReplaceCommaWithSemicolon {
1161 #[primary_span]
1162 pub comma_span: Span,
1163 pub descr: &'static str,
1164}
1165
1166#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SupertraitItemShadowing {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SupertraitItemShadowing {
item: __binding_0,
subtrait: __binding_1,
shadower: __binding_2,
shadowee: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")));
;
diag.arg("item", __binding_0);
diag.arg("subtrait", __binding_1);
diag.subdiagnostic(__binding_2);
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1167#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1168pub(crate) struct SupertraitItemShadowing {
1169 pub item: Symbol,
1170 pub subtrait: Symbol,
1171 #[subdiagnostic]
1172 pub shadower: SupertraitItemShadower,
1173 #[subdiagnostic]
1174 pub shadowee: SupertraitItemShadowee,
1175}
1176
1177#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SupertraitItemShadower {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SupertraitItemShadower {
subtrait: __binding_0, span: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("subtrait".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$subtrait}` shadows a supertrait item")),
&sub_args);
diag.span_note(__binding_1, __message);
}
}
}
}
};Subdiagnostic)]
1178#[note("item from `{$subtrait}` shadows a supertrait item")]
1179pub(crate) struct SupertraitItemShadower {
1180 pub subtrait: Symbol,
1181 #[primary_span]
1182 pub span: Span,
1183}
1184
1185#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SupertraitItemShadowee {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SupertraitItemShadowee::Labeled {
span: __binding_0, supertrait: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("supertrait".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$supertrait}` is shadowed by a subtrait item")),
&sub_args);
diag.span_note(__binding_0, __message);
}
SupertraitItemShadowee::Several {
spans: __binding_0, traits: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("traits".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items from several supertraits are shadowed: {$traits}")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1186pub(crate) enum SupertraitItemShadowee {
1187 #[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1188 Labeled {
1189 #[primary_span]
1190 span: Span,
1191 supertrait: Symbol,
1192 },
1193 #[note("items from several supertraits are shadowed: {$traits}")]
1194 Several {
1195 #[primary_span]
1196 spans: MultiSpan,
1197 traits: DiagSymbolList,
1198 },
1199}
1200
1201#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
RegisterTypeUnstable<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RegisterTypeUnstable { span: __binding_0, ty: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$ty}` cannot be used with this register class in stable")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1202#[diag("type `{$ty}` cannot be used with this register class in stable")]
1203pub(crate) struct RegisterTypeUnstable<'a> {
1204 #[primary_span]
1205 pub span: Span,
1206 pub ty: Ty<'a>,
1207}
1208
1209#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NakedAsmOutsideNakedFn {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NakedAsmOutsideNakedFn { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1210#[diag("the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`")]
1211pub(crate) struct NakedAsmOutsideNakedFn {
1212 #[primary_span]
1213 pub span: Span,
1214}
1215
1216#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NoPatterns {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoPatterns { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns not allowed in naked function parameters")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1217#[diag("patterns not allowed in naked function parameters")]
1218pub(crate) struct NoPatterns {
1219 #[primary_span]
1220 pub span: Span,
1221}
1222
1223#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ParamsNotAllowed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamsNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("referencing function parameters is not allowed in naked functions")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("follow the calling convention in asm block to use parameters")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1224#[diag("referencing function parameters is not allowed in naked functions")]
1225#[help("follow the calling convention in asm block to use parameters")]
1226pub(crate) struct ParamsNotAllowed {
1227 #[primary_span]
1228 pub span: Span,
1229}
1230
1231pub(crate) struct NakedFunctionsAsmBlock {
1232 pub span: Span,
1233 pub multiple_asms: Vec<Span>,
1234 pub non_asms: Vec<Span>,
1235}
1236
1237impl Diagnostic<'_> for NakedFunctionsAsmBlock {
1238 #[track_caller]
1239 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
1240 let mut diag = Diag::new(
1241 dcx,
1242 level,
1243 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("naked functions must contain a single `naked_asm!` invocation"))msg!("naked functions must contain a single `naked_asm!` invocation"),
1244 );
1245 diag.span(self.span);
1246 diag.code(E0787);
1247 for span in self.multiple_asms.iter() {
1248 diag.span_label(
1249 *span,
1250 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `naked_asm!` invocations are not allowed in naked functions"))msg!("multiple `naked_asm!` invocations are not allowed in naked functions"),
1251 );
1252 }
1253 for span in self.non_asms.iter() {
1254 diag.span_label(*span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not allowed in naked functions"))msg!("not allowed in naked functions"));
1255 }
1256 diag
1257 }
1258}
1259
1260pub(crate) fn maybe_emit_plus_equals_diagnostic<'a>(
1261 fnctxt: &FnCtxt<'a, '_>,
1262 assign_op: Spanned<AssignOpKind>,
1263 lhs_expr: &hir::Expr<'_>,
1264) -> Result<(), Diag<'a>> {
1265 if assign_op.node == hir::AssignOpKind::AddAssign
1266 && let hir::ExprKind::Binary(bin_op, left, right) = &lhs_expr.kind
1267 && bin_op.node == hir::BinOpKind::And
1268 && crate::op::contains_let_in_chain(left)
1269 && let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &right.kind
1270 && #[allow(non_exhaustive_omitted_patterns)] match path.res {
hir::def::Res::Local(_) => true,
_ => false,
}matches!(path.res, hir::def::Res::Local(_))
1271 {
1272 let mut err = fnctxt.dcx().struct_span_err(
1273 assign_op.span,
1274 "binary assignment operation `+=` cannot be used in a let chain",
1275 );
1276
1277 err.span_label(
1278 lhs_expr.span,
1279 "you are add-assigning the right-hand side expression to the result of this let-chain",
1280 );
1281
1282 err.span_label(assign_op.span, "cannot use `+=` in a let chain");
1283
1284 err.span_suggestion_short(
1285 assign_op.span,
1286 "you might have meant to compare with `==` instead of assigning with `+=`",
1287 "==",
1288 Applicability::MaybeIncorrect,
1289 );
1290
1291 return Err(err);
1292 }
1293 Ok(())
1294}
1295
1296#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NakedFunctionsMustNakedAsm {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NakedFunctionsMustNakedAsm { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `asm!` macro is not allowed in naked functions")));
diag.code(E0787);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the `naked_asm!` macro instead")));
diag
}
}
}
}
};Diagnostic)]
1297#[diag("the `asm!` macro is not allowed in naked functions", code = E0787)]
1298pub(crate) struct NakedFunctionsMustNakedAsm {
1299 #[primary_span]
1300 #[label("consider using the `naked_asm!` macro instead")]
1301 pub span: Span,
1302}
1303
1304#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AbiCannotBeCalled {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AbiCannotBeCalled { span: __binding_0, abi: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the {$abi} ABI cannot be called")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `extern {$abi}` function can only be called using inline assembly")));
diag
}
}
}
}
};Diagnostic)]
1305#[diag("functions with the {$abi} ABI cannot be called")]
1306pub(crate) struct AbiCannotBeCalled {
1307 #[primary_span]
1308 #[note("an `extern {$abi}` function can only be called using inline assembly")]
1309 pub span: Span,
1310 pub abi: ExternAbi,
1311}
1312
1313#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
GpuKernelAbiCannotBeCalled {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GpuKernelAbiCannotBeCalled { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"gpu-kernel\" ABI cannot be called")));
;
diag.span(__binding_0);
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `extern \"gpu-kernel\"` function must be launched on the GPU by the runtime")));
diag
}
}
}
}
};Diagnostic)]
1314#[diag("functions with the \"gpu-kernel\" ABI cannot be called")]
1315pub(crate) struct GpuKernelAbiCannotBeCalled {
1316 #[primary_span]
1317 #[note("an `extern \"gpu-kernel\"` function must be launched on the GPU by the runtime")]
1318 pub span: Span,
1319}
1320
1321#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstContinueBadLabel {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstContinueBadLabel { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1322#[diag("`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`")]
1323pub(crate) struct ConstContinueBadLabel {
1324 #[primary_span]
1325 pub span: Span,
1326}
1327
1328#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ProjectOnNonPinProjectType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ProjectOnNonPinProjectType {
span: __binding_0,
def_span: __binding_1,
sugg_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot project on type that is not `#[pin_v2]`")));
let __code_39 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#[pin_v2]\n"))
})].into_iter();
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type defined here")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[pin_v2]` here")),
__code_39, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1329#[diag("cannot project on type that is not `#[pin_v2]`")]
1330pub(crate) struct ProjectOnNonPinProjectType {
1331 #[primary_span]
1332 pub span: Span,
1333 #[note("type defined here")]
1334 pub def_span: Option<Span>,
1335 #[suggestion(
1336 "add `#[pin_v2]` here",
1337 code = "#[pin_v2]\n",
1338 applicability = "machine-applicable"
1339 )]
1340 pub sugg_span: Option<Span>,
1341}
1342
1343#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FloatLiteralF32Fallback {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FloatLiteralF32Fallback {
literal: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied")));
let __code_40 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}_f32", __binding_0))
})].into_iter();
;
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the type as `f32`")),
__code_40, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1344#[diag("falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied")]
1345pub(crate) struct FloatLiteralF32Fallback {
1346 pub literal: String,
1347 #[suggestion(
1348 "explicitly specify the type as `f32`",
1349 code = "{literal}_f32",
1350 applicability = "machine-applicable"
1351 )]
1352 pub span: Option<Span>,
1353}
1354
1355#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExprParenthesesNeeded {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ExprParenthesesNeeded {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_41 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_42 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_41));
suggestions.push((__binding_1, __code_42));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parentheses are required to parse this as an expression")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1356#[multipart_suggestion(
1357 "parentheses are required to parse this as an expression",
1358 applicability = "machine-applicable"
1359)]
1360pub(crate) struct ExprParenthesesNeeded {
1361 #[suggestion_part(code = "(")]
1362 left: Span,
1363 #[suggestion_part(code = ")")]
1364 right: Span,
1365}
1366
1367impl ExprParenthesesNeeded {
1368 pub(crate) fn surrounding(s: Span) -> Self {
1369 ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
1370 }
1371}
1372
1373#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnsafePanicHandlers
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnsafePanicHandlers => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[panic_handler]` functions can't be `unsafe`")));
;
diag
}
}
}
}
};Diagnostic)]
1374#[diag("`#[panic_handler]` functions can't be `unsafe`")]
1375pub(crate) struct UnsafePanicHandlers;
1376
1377#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ComptimeFnCalledOutsideConstContext {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ComptimeFnCalledOutsideConstContext {
span: __binding_0, const_block: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("comptime functions can only be called at compile time")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1378#[diag("comptime functions can only be called at compile time")]
1379pub(crate) struct ComptimeFnCalledOutsideConstContext {
1380 #[primary_span]
1381 pub span: Span,
1382 #[subdiagnostic]
1383 pub const_block: WrapConstBlock,
1384}
1385
1386#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WrapConstBlock {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
WrapConstBlock { left: __binding_0, right: __binding_1 } =>
{
let mut suggestions = Vec::new();
let __code_43 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const {{ "))
});
let __code_44 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_43));
suggestions.push((__binding_1, __code_44));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the call in a const block to force compile time evaluation")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1387#[multipart_suggestion(
1388 "wrap the call in a const block to force compile time evaluation",
1389 applicability = "maybe-incorrect"
1390)]
1391pub(crate) struct WrapConstBlock {
1392 #[suggestion_part(code = "const {{ ")]
1393 pub left: Span,
1394 #[suggestion_part(code = " }}")]
1395 pub right: Span,
1396}