1use rustc_errors::MultiSpan;
2use rustc_errors::codes::*;
3use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
4use rustc_middle::ty::{GenericArg, Ty};
5use rustc_span::Span;
6
7use crate::diagnostics::RegionName;
8
9#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
MoveUnsized<'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 {
MoveUnsized { ty: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot move a value of type `{$ty}`")));
diag.code(E0161);
;
diag.arg("ty", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the size of `{$ty}` cannot be statically determined")));
diag
}
}
}
}
};Diagnostic)]
10#[diag("cannot move a value of type `{$ty}`", code = E0161)]
11pub(crate) struct MoveUnsized<'tcx> {
12 pub ty: Ty<'tcx>,
13 #[primary_span]
14 #[label("the size of `{$ty}` cannot be statically determined")]
15 pub span: Span,
16}
17
18#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
HigherRankedLifetimeError where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
HigherRankedLifetimeError {
cause: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("higher-ranked lifetime error")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
19#[diag("higher-ranked lifetime error")]
20pub(crate) struct HigherRankedLifetimeError {
21 #[subdiagnostic]
22 pub cause: Option<HigherRankedErrorCause>,
23 #[primary_span]
24 pub span: Span,
25}
26
27#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for HigherRankedErrorCause {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
HigherRankedErrorCause::CouldNotProve {
predicate: __binding_0 } => {
diag.store_args();
diag.arg("predicate", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not prove `{$predicate}`")));
diag.note(__message);
diag.restore_args();
}
HigherRankedErrorCause::CouldNotNormalize {
value: __binding_0 } => {
diag.store_args();
diag.arg("value", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not normalize `{$value}`")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
28pub(crate) enum HigherRankedErrorCause {
29 #[note("could not prove `{$predicate}`")]
30 CouldNotProve { predicate: String },
31 #[note("could not normalize `{$value}`")]
32 CouldNotNormalize { value: String },
33}
34
35#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
HigherRankedSubtypeError where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
HigherRankedSubtypeError { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("higher-ranked subtype error")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
36#[diag("higher-ranked subtype error")]
37pub(crate) struct HigherRankedSubtypeError {
38 #[primary_span]
39 pub span: Span,
40}
41
42#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericDoesNotLiveLongEnough where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericDoesNotLiveLongEnough {
kind: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kind}` does not live long enough")));
;
diag.arg("kind", __binding_0);
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
43#[diag("`{$kind}` does not live long enough")]
44pub(crate) struct GenericDoesNotLiveLongEnough {
45 pub kind: String,
46 #[primary_span]
47 pub span: Span,
48}
49
50#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for VarNeedNotMut {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
VarNeedNotMut { span: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable does not need to be mutable")));
;
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this `mut`")),
__code_0, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
};
}
}
};LintDiagnostic)]
51#[diag("variable does not need to be mutable")]
52pub(crate) struct VarNeedNotMut {
53 #[suggestion(
54 "remove this `mut`",
55 style = "short",
56 applicability = "machine-applicable",
57 code = ""
58 )]
59 pub span: Span,
60}
61#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FnMutError
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FnMutError { span: __binding_0, ty_err: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("captured variable cannot escape `FnMut` closure body")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`FnMut` closures only have access to their captured variables while they are executing...")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...therefore, they cannot allow references to captured variables to escape")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
62#[diag("captured variable cannot escape `FnMut` closure body")]
63#[note("`FnMut` closures only have access to their captured variables while they are executing...")]
64#[note("...therefore, they cannot allow references to captured variables to escape")]
65pub(crate) struct FnMutError {
66 #[primary_span]
67 pub span: Span,
68 #[subdiagnostic]
69 pub ty_err: FnMutReturnTypeErr,
70}
71
72#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VarHereDenote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VarHereDenote::Captured { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable captured here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
VarHereDenote::Defined { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable defined here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
VarHereDenote::FnMutInferred { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inferred to be a `FnMut` closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
73pub(crate) enum VarHereDenote {
74 #[label("variable captured here")]
75 Captured {
76 #[primary_span]
77 span: Span,
78 },
79 #[label("variable defined here")]
80 Defined {
81 #[primary_span]
82 span: Span,
83 },
84 #[label("inferred to be a `FnMut` closure")]
85 FnMutInferred {
86 #[primary_span]
87 span: Span,
88 },
89}
90
91#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FnMutReturnTypeErr {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FnMutReturnTypeErr::ReturnClosure { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returns a closure that contains a reference to a captured variable, which then escapes the closure body")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
FnMutReturnTypeErr::ReturnAsyncBlock { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returns an `async` block that contains a reference to a captured variable, which then escapes the closure body")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
FnMutReturnTypeErr::ReturnRef { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returns a reference to a captured variable which escapes the closure body")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
92pub(crate) enum FnMutReturnTypeErr {
93 #[label(
94 "returns a closure that contains a reference to a captured variable, which then escapes the closure body"
95 )]
96 ReturnClosure {
97 #[primary_span]
98 span: Span,
99 },
100 #[label(
101 "returns an `async` block that contains a reference to a captured variable, which then escapes the closure body"
102 )]
103 ReturnAsyncBlock {
104 #[primary_span]
105 span: Span,
106 },
107 #[label("returns a reference to a captured variable which escapes the closure body")]
108 ReturnRef {
109 #[primary_span]
110 span: Span,
111 },
112}
113
114#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeOutliveErr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LifetimeOutliveErr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime may not live long enough")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
115#[diag("lifetime may not live long enough")]
116pub(crate) struct LifetimeOutliveErr {
117 #[primary_span]
118 pub span: Span,
119}
120
121#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for LifetimeReturnCategoryErr<'a>
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
LifetimeReturnCategoryErr::WrongReturn {
span: __binding_0,
mir_def_name: __binding_1,
outlived_fr_name: __binding_2,
fr_name: __binding_3 } => {
diag.store_args();
diag.arg("mir_def_name", __binding_1);
diag.arg("outlived_fr_name", __binding_2);
diag.arg("fr_name", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$mir_def_name} was supposed to return data with lifetime `{$outlived_fr_name}` but it is returning data with lifetime `{$fr_name}`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
LifetimeReturnCategoryErr::ShortReturn {
span: __binding_0,
category_desc: __binding_1,
free_region_name: __binding_2,
outlived_fr_name: __binding_3 } => {
diag.store_args();
diag.arg("category_desc", __binding_1);
diag.arg("free_region_name", __binding_2);
diag.arg("outlived_fr_name", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$category_desc}requires that `{$free_region_name}` must outlive `{$outlived_fr_name}`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
122pub(crate) enum LifetimeReturnCategoryErr<'a> {
123 #[label(
124 "{$mir_def_name} was supposed to return data with lifetime `{$outlived_fr_name}` but it is returning data with lifetime `{$fr_name}`"
125 )]
126 WrongReturn {
127 #[primary_span]
128 span: Span,
129 mir_def_name: &'a str,
130 outlived_fr_name: RegionName,
131 fr_name: &'a RegionName,
132 },
133 #[label(
134 "{$category_desc}requires that `{$free_region_name}` must outlive `{$outlived_fr_name}`"
135 )]
136 ShortReturn {
137 #[primary_span]
138 span: Span,
139 category_desc: &'static str,
140 free_region_name: &'a RegionName,
141 outlived_fr_name: RegionName,
142 },
143}
144
145#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RequireStaticErr {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RequireStaticErr::UsedImpl { multi_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the used `impl` has a `'static` requirement")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
146pub(crate) enum RequireStaticErr {
147 #[note("the used `impl` has a `'static` requirement")]
148 UsedImpl {
149 #[primary_span]
150 multi_span: MultiSpan,
151 },
152}
153
154#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CaptureVarPathUseCause {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureVarPathUseCause::BorrowInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::UseInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assign occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignPartInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assign to part occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::BorrowInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::UseInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assignment occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignPartInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assignment to part occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
155pub(crate) enum CaptureVarPathUseCause {
156 #[label("borrow occurs due to use in coroutine")]
157 BorrowInCoroutine {
158 #[primary_span]
159 path_span: Span,
160 },
161 #[label("use occurs due to use in coroutine")]
162 UseInCoroutine {
163 #[primary_span]
164 path_span: Span,
165 },
166 #[label("assign occurs due to use in coroutine")]
167 AssignInCoroutine {
168 #[primary_span]
169 path_span: Span,
170 },
171 #[label("assign to part occurs due to use in coroutine")]
172 AssignPartInCoroutine {
173 #[primary_span]
174 path_span: Span,
175 },
176 #[label("borrow occurs due to use in closure")]
177 BorrowInClosure {
178 #[primary_span]
179 path_span: Span,
180 },
181 #[label("use occurs due to use in closure")]
182 UseInClosure {
183 #[primary_span]
184 path_span: Span,
185 },
186 #[label("assignment occurs due to use in closure")]
187 AssignInClosure {
188 #[primary_span]
189 path_span: Span,
190 },
191 #[label("assignment to part occurs due to use in closure")]
192 AssignPartInClosure {
193 #[primary_span]
194 path_span: Span,
195 },
196}
197
198#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CaptureVarKind {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureVarKind::Immut { kind_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("capture is immutable because of use here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarKind::Mut { kind_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("capture is mutable because of use here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarKind::Move { kind_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("capture is moved because of use here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
199pub(crate) enum CaptureVarKind {
200 #[label("capture is immutable because of use here")]
201 Immut {
202 #[primary_span]
203 kind_span: Span,
204 },
205 #[label("capture is mutable because of use here")]
206 Mut {
207 #[primary_span]
208 kind_span: Span,
209 },
210 #[label("capture is moved because of use here")]
211 Move {
212 #[primary_span]
213 kind_span: Span,
214 },
215}
216
217#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CaptureVarCause {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureVarCause::BorrowUsePlaceCoroutine {
is_single_var: __binding_0,
place: __binding_1,
var_span: __binding_2 } => {
diag.store_args();
diag.arg("is_single_var", __binding_0);
diag.arg("place", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_single_var ->\n *[true] borrow occurs\n [false] borrows occur\n } due to use of {$place} in coroutine")));
diag.span_label(__binding_2, __message);
diag.restore_args();
}
CaptureVarCause::BorrowUsePlaceClosure {
is_single_var: __binding_0,
place: __binding_1,
var_span: __binding_2 } => {
diag.store_args();
diag.arg("is_single_var", __binding_0);
diag.arg("place", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_single_var ->\n *[true] borrow occurs\n [false] borrows occur\n } due to use of {$place} in closure")));
diag.span_label(__binding_2, __message);
diag.restore_args();
}
CaptureVarCause::BorrowUseInCoroutine {
var_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarCause::BorrowUseInClosure { var_span: __binding_0
} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarCause::MoveUseInCoroutine { var_span: __binding_0
} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move occurs due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarCause::MoveUseInClosure { var_span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move occurs due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarCause::FirstBorrowUsePlaceCoroutine {
place: __binding_0, var_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first borrow occurs due to use of {$place} in coroutine")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureVarCause::FirstBorrowUsePlaceClosure {
place: __binding_0, var_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first borrow occurs due to use of {$place} in closure")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureVarCause::SecondBorrowUsePlaceCoroutine {
place: __binding_0, var_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second borrow occurs due to use of {$place} in coroutine")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureVarCause::SecondBorrowUsePlaceClosure {
place: __binding_0, var_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second borrow occurs due to use of {$place} in closure")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureVarCause::MutableBorrowUsePlaceClosure {
place: __binding_0, var_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable borrow occurs due to use of {$place} in closure")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureVarCause::PartialMoveUseInCoroutine {
var_span: __binding_0, is_partial: __binding_1 } => {
diag.store_args();
diag.arg("is_partial", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to use in coroutine")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarCause::PartialMoveUseInClosure {
var_span: __binding_0, is_partial: __binding_1 } => {
diag.store_args();
diag.arg("is_partial", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to use in closure")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
218pub(crate) enum CaptureVarCause {
219 #[label(
220 "{$is_single_var ->
221 *[true] borrow occurs
222 [false] borrows occur
223 } due to use of {$place} in coroutine"
224 )]
225 BorrowUsePlaceCoroutine {
226 is_single_var: bool,
227 place: String,
228 #[primary_span]
229 var_span: Span,
230 },
231 #[label(
232 "{$is_single_var ->
233 *[true] borrow occurs
234 [false] borrows occur
235 } due to use of {$place} in closure"
236 )]
237 BorrowUsePlaceClosure {
238 is_single_var: bool,
239 place: String,
240 #[primary_span]
241 var_span: Span,
242 },
243 #[label("borrow occurs due to use in coroutine")]
244 BorrowUseInCoroutine {
245 #[primary_span]
246 var_span: Span,
247 },
248 #[label("borrow occurs due to use in closure")]
249 BorrowUseInClosure {
250 #[primary_span]
251 var_span: Span,
252 },
253 #[label("move occurs due to use in coroutine")]
254 MoveUseInCoroutine {
255 #[primary_span]
256 var_span: Span,
257 },
258 #[label("move occurs due to use in closure")]
259 MoveUseInClosure {
260 #[primary_span]
261 var_span: Span,
262 },
263 #[label("first borrow occurs due to use of {$place} in coroutine")]
264 FirstBorrowUsePlaceCoroutine {
265 place: String,
266 #[primary_span]
267 var_span: Span,
268 },
269 #[label("first borrow occurs due to use of {$place} in closure")]
270 FirstBorrowUsePlaceClosure {
271 place: String,
272 #[primary_span]
273 var_span: Span,
274 },
275 #[label("second borrow occurs due to use of {$place} in coroutine")]
276 SecondBorrowUsePlaceCoroutine {
277 place: String,
278 #[primary_span]
279 var_span: Span,
280 },
281 #[label("second borrow occurs due to use of {$place} in closure")]
282 SecondBorrowUsePlaceClosure {
283 place: String,
284 #[primary_span]
285 var_span: Span,
286 },
287 #[label("mutable borrow occurs due to use of {$place} in closure")]
288 MutableBorrowUsePlaceClosure {
289 place: String,
290 #[primary_span]
291 var_span: Span,
292 },
293 #[label(
294 "variable {$is_partial ->
295 [true] partially moved
296 *[false] moved
297 } due to use in coroutine"
298 )]
299 PartialMoveUseInCoroutine {
300 #[primary_span]
301 var_span: Span,
302 is_partial: bool,
303 },
304 #[label(
305 "variable {$is_partial ->
306 [true] partially moved
307 *[false] moved
308 } due to use in closure"
309 )]
310 PartialMoveUseInClosure {
311 #[primary_span]
312 var_span: Span,
313 is_partial: bool,
314 },
315}
316
317#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MoveBorrow<'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 {
MoveBorrow {
place: __binding_0,
borrow_place: __binding_1,
value_place: __binding_2,
span: __binding_3,
borrow_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot move out of {$place ->\n [value] value\n *[other] {$place}\n} because it is borrowed")));
diag.code(E0505);
;
diag.arg("place", __binding_0);
diag.arg("borrow_place", __binding_1);
diag.arg("value_place", __binding_2);
diag.span(__binding_3);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move out of {$value_place ->\n [value] value\n *[other] {$value_place}\n } occurs here")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of {$borrow_place ->\n [value] value\n *[other] {$borrow_place}\n } occurs here")));
diag
}
}
}
}
};Diagnostic)]
318#[diag("cannot move out of {$place ->
319 [value] value
320 *[other] {$place}
321} because it is borrowed", code = E0505)]
322pub(crate) struct MoveBorrow<'a> {
323 pub place: &'a str,
324 pub borrow_place: &'a str,
325 pub value_place: &'a str,
326 #[primary_span]
327 #[label(
328 "move out of {$value_place ->
329 [value] value
330 *[other] {$value_place}
331 } occurs here"
332 )]
333 pub span: Span,
334 #[label(
335 "borrow of {$borrow_place ->
336 [value] value
337 *[other] {$borrow_place}
338 } occurs here"
339 )]
340 pub borrow_span: Span,
341}
342
343#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimeMismatchOpaqueParam<'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 {
LifetimeMismatchOpaqueParam {
arg: __binding_0,
prev: __binding_1,
span: __binding_2,
prev_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("opaque type used twice with different lifetimes")));
;
diag.arg("arg", __binding_0);
diag.arg("prev", __binding_1);
diag.span(__binding_2);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime `{$arg}` used here")));
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime `{$prev}` previously used here")));
diag
}
}
}
}
};Diagnostic)]
344#[diag("opaque type used twice with different lifetimes")]
345pub(crate) struct LifetimeMismatchOpaqueParam<'tcx> {
346 pub arg: GenericArg<'tcx>,
347 pub prev: GenericArg<'tcx>,
348 #[primary_span]
349 #[label("lifetime `{$arg}` used here")]
350 #[note(
351 "if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types"
352 )]
353 pub span: Span,
354 #[label("lifetime `{$prev}` previously used here")]
355 pub prev_span: Span,
356}
357
358#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for CaptureReasonLabel<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureReasonLabel::Call {
fn_call_span: __binding_0,
place_name: __binding_1,
is_partial: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("place_name", __binding_1);
diag.arg("is_partial", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place_name} {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to this {$is_loop_message ->\n [true] call, in previous iteration of loop\n *[false] call\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::OperatorUse {
fn_call_span: __binding_0,
place_name: __binding_1,
is_partial: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("place_name", __binding_1);
diag.arg("is_partial", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place_name} {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to usage in {$is_loop_message ->\n [true] operator, in previous iteration of loop\n *[false] operator\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::ImplicitCall {
fn_call_span: __binding_0,
place_name: __binding_1,
is_partial: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("place_name", __binding_1);
diag.arg("is_partial", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place_name} {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to this implicit call to {$is_loop_message ->\n [true] `.into_iter()`, in previous iteration of loop\n *[false] `.into_iter()`\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::MethodCall {
fn_call_span: __binding_0,
place_name: __binding_1,
is_partial: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("place_name", __binding_1);
diag.arg("is_partial", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place_name} {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to this method {$is_loop_message ->\n [true] call, in previous iteration of loop\n *[false] call\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::Await {
fn_call_span: __binding_0,
place_name: __binding_1,
is_partial: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("place_name", __binding_1);
diag.arg("is_partial", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place_name} {$is_partial ->\n [true] partially moved\n *[false] moved\n } due to this {$is_loop_message ->\n [true] await, in previous iteration of loop\n *[false] await\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::MovedHere {
move_span: __binding_0,
is_partial: __binding_1,
is_move_msg: __binding_2,
is_loop_message: __binding_3 } => {
diag.store_args();
diag.arg("is_partial", __binding_1);
diag.arg("is_move_msg", __binding_2);
diag.arg("is_loop_message", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value {$is_partial ->\n [true] partially moved\n *[false] moved\n } {$is_move_msg ->\n [true] into closure here\n *[false] here\n }{$is_loop_message ->\n [true] , in previous iteration of loop\n *[false] {\"\"}\n }")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::BorrowContent { var_span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
359pub(crate) enum CaptureReasonLabel<'a> {
360 #[label(
361 "{$place_name} {$is_partial ->
362 [true] partially moved
363 *[false] moved
364 } due to this {$is_loop_message ->
365 [true] call, in previous iteration of loop
366 *[false] call
367 }"
368 )]
369 Call {
370 #[primary_span]
371 fn_call_span: Span,
372 place_name: &'a str,
373 is_partial: bool,
374 is_loop_message: bool,
375 },
376 #[label(
377 "{$place_name} {$is_partial ->
378 [true] partially moved
379 *[false] moved
380 } due to usage in {$is_loop_message ->
381 [true] operator, in previous iteration of loop
382 *[false] operator
383 }"
384 )]
385 OperatorUse {
386 #[primary_span]
387 fn_call_span: Span,
388 place_name: &'a str,
389 is_partial: bool,
390 is_loop_message: bool,
391 },
392 #[label(
393 "{$place_name} {$is_partial ->
394 [true] partially moved
395 *[false] moved
396 } due to this implicit call to {$is_loop_message ->
397 [true] `.into_iter()`, in previous iteration of loop
398 *[false] `.into_iter()`
399 }"
400 )]
401 ImplicitCall {
402 #[primary_span]
403 fn_call_span: Span,
404 place_name: &'a str,
405 is_partial: bool,
406 is_loop_message: bool,
407 },
408 #[label(
409 "{$place_name} {$is_partial ->
410 [true] partially moved
411 *[false] moved
412 } due to this method {$is_loop_message ->
413 [true] call, in previous iteration of loop
414 *[false] call
415 }"
416 )]
417 MethodCall {
418 #[primary_span]
419 fn_call_span: Span,
420 place_name: &'a str,
421 is_partial: bool,
422 is_loop_message: bool,
423 },
424 #[label(
425 "{$place_name} {$is_partial ->
426 [true] partially moved
427 *[false] moved
428 } due to this {$is_loop_message ->
429 [true] await, in previous iteration of loop
430 *[false] await
431 }"
432 )]
433 Await {
434 #[primary_span]
435 fn_call_span: Span,
436 place_name: &'a str,
437 is_partial: bool,
438 is_loop_message: bool,
439 },
440 #[label(
441 "value {$is_partial ->
442 [true] partially moved
443 *[false] moved
444 } {$is_move_msg ->
445 [true] into closure here
446 *[false] here
447 }{$is_loop_message ->
448 [true] , in previous iteration of loop
449 *[false] {\"\"}
450 }"
451 )]
452 MovedHere {
453 #[primary_span]
454 move_span: Span,
455 is_partial: bool,
456 is_move_msg: bool,
457 is_loop_message: bool,
458 },
459 #[label("help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents")]
460 BorrowContent {
461 #[primary_span]
462 var_span: Span,
463 },
464}
465
466#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CaptureReasonNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureReasonNote::FnOnceMoveInCall { var_span: __binding_0
} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this value implements `FnOnce`, which causes it to be moved when called")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
CaptureReasonNote::UnOpMoveByOperator { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this operator moves the value")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
CaptureReasonNote::LhsMoveByOperator { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this operator moves the left-hand side")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
CaptureReasonNote::FuncTakeSelf {
func: __binding_0,
place_name: __binding_1,
span: __binding_2 } => {
diag.store_args();
diag.arg("func", __binding_0);
diag.arg("place_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$func}` takes ownership of the receiver `self`, which moves {$place_name}")));
diag.span_note(__binding_2, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
467pub(crate) enum CaptureReasonNote {
468 #[note("this value implements `FnOnce`, which causes it to be moved when called")]
469 FnOnceMoveInCall {
470 #[primary_span]
471 var_span: Span,
472 },
473 #[note("calling this operator moves the value")]
474 UnOpMoveByOperator {
475 #[primary_span]
476 span: Span,
477 },
478 #[note("calling this operator moves the left-hand side")]
479 LhsMoveByOperator {
480 #[primary_span]
481 span: Span,
482 },
483 #[note("`{$func}` takes ownership of the receiver `self`, which moves {$place_name}")]
484 FuncTakeSelf {
485 func: String,
486 place_name: String,
487 #[primary_span]
488 span: Span,
489 },
490}
491
492#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for CaptureReasonSuggest<'tcx>
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureReasonSuggest::IterateSlice {
ty: __binding_0, span: __binding_1 } => {
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&"))
})].into_iter();
diag.store_args();
diag.arg("ty", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider iterating over a slice of the `{$ty}`'s content to avoid moving into the `for` loop")));
diag.span_suggestions_with_style(__binding_1, __message,
__code_1, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
CaptureReasonSuggest::FreshReborrow { span: __binding_0 } =>
{
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".as_mut()"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider reborrowing the `Pin` instead of moving it")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
493pub(crate) enum CaptureReasonSuggest<'tcx> {
494 #[suggestion(
495 "consider iterating over a slice of the `{$ty}`'s content to avoid moving into the `for` loop",
496 applicability = "maybe-incorrect",
497 code = "&",
498 style = "verbose"
499 )]
500 IterateSlice {
501 ty: Ty<'tcx>,
502 #[primary_span]
503 span: Span,
504 },
505 #[suggestion(
506 "consider reborrowing the `Pin` instead of moving it",
507 applicability = "maybe-incorrect",
508 code = ".as_mut()",
509 style = "verbose"
510 )]
511 FreshReborrow {
512 #[primary_span]
513 span: Span,
514 },
515}
516
517#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CaptureArgLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CaptureArgLabel::Capture {
is_within: __binding_0, args_span: __binding_1 } => {
diag.store_args();
diag.arg("is_within", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value captured {$is_within ->\n [true] here by coroutine\n *[false] here\n }")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
CaptureArgLabel::MoveOutPlace {
place: __binding_0, args_span: __binding_1 } => {
diag.store_args();
diag.arg("place", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$place} is moved here")));
diag.span_label(__binding_1, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
518pub(crate) enum CaptureArgLabel {
519 #[label(
520 "value captured {$is_within ->
521 [true] here by coroutine
522 *[false] here
523 }"
524 )]
525 Capture {
526 is_within: bool,
527 #[primary_span]
528 args_span: Span,
529 },
530 #[label("{$place} is moved here")]
531 MoveOutPlace {
532 place: String,
533 #[primary_span]
534 args_span: Span,
535 },
536}
537
538#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnClosureNote<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnClosureNote::InvokedTwice {
place_name: __binding_0, span: __binding_1 } => {
diag.store_args();
diag.arg("place_name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closure cannot be invoked more than once because it moves the variable `{$place_name}` out of its environment")));
diag.span_note(__binding_1, __message);
diag.restore_args();
}
OnClosureNote::MovedTwice {
place_name: __binding_0, span: __binding_1 } => {
diag.store_args();
diag.arg("place_name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closure cannot be moved more than once as it is not `Copy` due to moving the variable `{$place_name}` out of its environment")));
diag.span_note(__binding_1, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
539pub(crate) enum OnClosureNote<'a> {
540 #[note(
541 "closure cannot be invoked more than once because it moves the variable `{$place_name}` out of its environment"
542 )]
543 InvokedTwice {
544 place_name: &'a str,
545 #[primary_span]
546 span: Span,
547 },
548 #[note(
549 "closure cannot be moved more than once as it is not `Copy` due to moving the variable `{$place_name}` out of its environment"
550 )]
551 MovedTwice {
552 place_name: &'a str,
553 #[primary_span]
554 span: Span,
555 },
556}
557
558#[derive(const _: () =
{
impl<'a, 'tcx> rustc_errors::Subdiagnostic for TypeNoCopy<'a, 'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TypeNoCopy::Label {
is_partial_move: __binding_0,
ty: __binding_1,
place: __binding_2,
span: __binding_3 } => {
diag.store_args();
diag.arg("is_partial_move", __binding_0);
diag.arg("ty", __binding_1);
diag.arg("place", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_partial_move ->\n [true] partial move\n *[false] move\n } occurs because {$place} has type `{$ty}`, which does not implement the `Copy` trait")));
diag.span_label(__binding_3, __message);
diag.restore_args();
}
TypeNoCopy::Note {
is_partial_move: __binding_0,
ty: __binding_1,
place: __binding_2 } => {
diag.store_args();
diag.arg("is_partial_move", __binding_0);
diag.arg("ty", __binding_1);
diag.arg("place", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_partial_move ->\n [true] partial move\n *[false] move\n } occurs because {$place} has type `{$ty}`, which does not implement the `Copy` trait")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
559pub(crate) enum TypeNoCopy<'a, 'tcx> {
560 #[label(
561 "{$is_partial_move ->
562 [true] partial move
563 *[false] move
564 } occurs because {$place} has type `{$ty}`, which does not implement the `Copy` trait"
565 )]
566 Label {
567 is_partial_move: bool,
568 ty: Ty<'tcx>,
569 place: &'a str,
570 #[primary_span]
571 span: Span,
572 },
573 #[note(
574 "{$is_partial_move ->
575 [true] partial move
576 *[false] move
577 } occurs because {$place} has type `{$ty}`, which does not implement the `Copy` trait"
578 )]
579 Note { is_partial_move: bool, ty: Ty<'tcx>, place: &'a str },
580}
581
582#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SimdIntrinsicArgConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SimdIntrinsicArgConst {
span: __binding_0, arg: __binding_1, intrinsic: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$arg ->\n [1] 1st\n [2] 2nd\n [3] 3rd\n *[other] {$arg}th\n } argument of `{$intrinsic}` is required to be a `const` item")));
;
diag.arg("arg", __binding_1);
diag.arg("intrinsic", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
583#[diag(
584 "{$arg ->
585 [1] 1st
586 [2] 2nd
587 [3] 3rd
588 *[other] {$arg}th
589 } argument of `{$intrinsic}` is required to be a `const` item"
590)]
591pub(crate) struct SimdIntrinsicArgConst {
592 #[primary_span]
593 pub span: Span,
594 pub arg: usize,
595 pub intrinsic: String,
596}
597
598#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
TailExprDropOrder {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
TailExprDropOrder { borrowed: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("relative drop order changing in Rust 2024")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this temporary value will be dropped at the end of the block")));
diag
}
};
}
}
};LintDiagnostic)]
599#[diag("relative drop order changing in Rust 2024")]
600pub(crate) struct TailExprDropOrder {
601 #[label("this temporary value will be dropped at the end of the block")]
602 pub borrowed: Span,
603}