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