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,
crate::fluent_generated::borrowck_move_unsized);
diag.code(E0161);
;
diag.arg("ty", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
crate::fluent_generated::_subdiag::label);
diag
}
}
}
}
};Diagnostic)]
10#[diag(borrowck_move_unsized, code = E0161)]
11pub(crate) struct MoveUnsized<'tcx> {
12 pub ty: Ty<'tcx>,
13 #[primary_span]
14 #[label]
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,
crate::fluent_generated::borrowck_higher_ranked_lifetime_error);
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
19#[diag(borrowck_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(crate::fluent_generated::borrowck_could_not_prove);
diag.note(__message);
diag.restore_args();
}
HigherRankedErrorCause::CouldNotNormalize {
value: __binding_0 } => {
diag.store_args();
diag.arg("value", __binding_0);
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_could_not_normalize);
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
28pub(crate) enum HigherRankedErrorCause {
29 #[note(borrowck_could_not_prove)]
30 CouldNotProve { predicate: String },
31 #[note(borrowck_could_not_normalize)]
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,
crate::fluent_generated::borrowck_higher_ranked_subtype_error);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
36#[diag(borrowck_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,
crate::fluent_generated::borrowck_generic_does_not_live_long_enough);
;
diag.arg("kind", __binding_0);
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
43#[diag(borrowck_generic_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(crate::fluent_generated::borrowck_var_does_not_need_mut);
;
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
crate::fluent_generated::_subdiag::suggestion, __code_0,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
};
}
}
};LintDiagnostic)]
51#[diag(borrowck_var_does_not_need_mut)]
52pub(crate) struct VarNeedNotMut {
53 #[suggestion(style = "short", applicability = "machine-applicable", code = "")]
54 pub span: Span,
55}
56#[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,
crate::fluent_generated::borrowck_var_cannot_escape_closure);
diag.note(crate::fluent_generated::_subdiag::note);
diag.note(crate::fluent_generated::borrowck_cannot_escape);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
57#[diag(borrowck_var_cannot_escape_closure)]
58#[note]
59#[note(borrowck_cannot_escape)]
60pub(crate) struct FnMutError {
61 #[primary_span]
62 pub span: Span,
63 #[subdiagnostic]
64 pub ty_err: FnMutReturnTypeErr,
65}
66
67#[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(crate::fluent_generated::borrowck_var_here_captured);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
VarHereDenote::Defined { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_var_here_defined);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
VarHereDenote::FnMutInferred { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_closure_inferred_mut);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
68pub(crate) enum VarHereDenote {
69 #[label(borrowck_var_here_captured)]
70 Captured {
71 #[primary_span]
72 span: Span,
73 },
74 #[label(borrowck_var_here_defined)]
75 Defined {
76 #[primary_span]
77 span: Span,
78 },
79 #[label(borrowck_closure_inferred_mut)]
80 FnMutInferred {
81 #[primary_span]
82 span: Span,
83 },
84}
85
86#[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(crate::fluent_generated::borrowck_returned_closure_escaped);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
FnMutReturnTypeErr::ReturnAsyncBlock { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_returned_async_block_escaped);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
FnMutReturnTypeErr::ReturnRef { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_returned_ref_escaped);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
87pub(crate) enum FnMutReturnTypeErr {
88 #[label(borrowck_returned_closure_escaped)]
89 ReturnClosure {
90 #[primary_span]
91 span: Span,
92 },
93 #[label(borrowck_returned_async_block_escaped)]
94 ReturnAsyncBlock {
95 #[primary_span]
96 span: Span,
97 },
98 #[label(borrowck_returned_ref_escaped)]
99 ReturnRef {
100 #[primary_span]
101 span: Span,
102 },
103}
104
105#[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,
crate::fluent_generated::borrowck_lifetime_constraints_error);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
106#[diag(borrowck_lifetime_constraints_error)]
107pub(crate) struct LifetimeOutliveErr {
108 #[primary_span]
109 pub span: Span,
110}
111
112#[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(crate::fluent_generated::borrowck_returned_lifetime_wrong);
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(crate::fluent_generated::borrowck_returned_lifetime_short);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
113pub(crate) enum LifetimeReturnCategoryErr<'a> {
114 #[label(borrowck_returned_lifetime_wrong)]
115 WrongReturn {
116 #[primary_span]
117 span: Span,
118 mir_def_name: &'a str,
119 outlived_fr_name: RegionName,
120 fr_name: &'a RegionName,
121 },
122 #[label(borrowck_returned_lifetime_short)]
123 ShortReturn {
124 #[primary_span]
125 span: Span,
126 category_desc: &'static str,
127 free_region_name: &'a RegionName,
128 outlived_fr_name: RegionName,
129 },
130}
131
132#[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(crate::fluent_generated::borrowck_used_impl_require_static);
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
133pub(crate) enum RequireStaticErr {
134 #[note(borrowck_used_impl_require_static)]
135 UsedImpl {
136 #[primary_span]
137 multi_span: MultiSpan,
138 },
139}
140
141#[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(crate::fluent_generated::borrowck_borrow_due_to_use_coroutine);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::UseInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_use_due_to_use_coroutine);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_assign_due_to_use_coroutine);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignPartInCoroutine {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_assign_part_due_to_use_coroutine);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::BorrowInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_borrow_due_to_use_closure);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::UseInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_use_due_to_use_closure);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_assign_due_to_use_closure);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarPathUseCause::AssignPartInClosure {
path_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_assign_part_due_to_use_closure);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
142pub(crate) enum CaptureVarPathUseCause {
143 #[label(borrowck_borrow_due_to_use_coroutine)]
144 BorrowInCoroutine {
145 #[primary_span]
146 path_span: Span,
147 },
148 #[label(borrowck_use_due_to_use_coroutine)]
149 UseInCoroutine {
150 #[primary_span]
151 path_span: Span,
152 },
153 #[label(borrowck_assign_due_to_use_coroutine)]
154 AssignInCoroutine {
155 #[primary_span]
156 path_span: Span,
157 },
158 #[label(borrowck_assign_part_due_to_use_coroutine)]
159 AssignPartInCoroutine {
160 #[primary_span]
161 path_span: Span,
162 },
163 #[label(borrowck_borrow_due_to_use_closure)]
164 BorrowInClosure {
165 #[primary_span]
166 path_span: Span,
167 },
168 #[label(borrowck_use_due_to_use_closure)]
169 UseInClosure {
170 #[primary_span]
171 path_span: Span,
172 },
173 #[label(borrowck_assign_due_to_use_closure)]
174 AssignInClosure {
175 #[primary_span]
176 path_span: Span,
177 },
178 #[label(borrowck_assign_part_due_to_use_closure)]
179 AssignPartInClosure {
180 #[primary_span]
181 path_span: Span,
182 },
183}
184
185#[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(crate::fluent_generated::borrowck_capture_immute);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarKind::Mut { kind_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_capture_mut);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureVarKind::Move { kind_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_capture_move);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
186pub(crate) enum CaptureVarKind {
187 #[label(borrowck_capture_immute)]
188 Immut {
189 #[primary_span]
190 kind_span: Span,
191 },
192 #[label(borrowck_capture_mut)]
193 Mut {
194 #[primary_span]
195 kind_span: Span,
196 },
197 #[label(borrowck_capture_move)]
198 Move {
199 #[primary_span]
200 kind_span: Span,
201 },
202}
203
204#[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(crate::fluent_generated::borrowck_var_borrow_by_use_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(crate::fluent_generated::borrowck_var_borrow_by_use_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(crate::fluent_generated::borrowck_var_borrow_by_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(crate::fluent_generated::borrowck_var_borrow_by_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(crate::fluent_generated::borrowck_var_move_by_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(crate::fluent_generated::borrowck_var_move_by_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(crate::fluent_generated::borrowck_var_first_borrow_by_use_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(crate::fluent_generated::borrowck_var_first_borrow_by_use_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(crate::fluent_generated::borrowck_var_second_borrow_by_use_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(crate::fluent_generated::borrowck_var_second_borrow_by_use_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(crate::fluent_generated::borrowck_var_mutable_borrow_by_use_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(crate::fluent_generated::borrowck_partial_var_move_by_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(crate::fluent_generated::borrowck_partial_var_move_by_use_in_closure);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
205pub(crate) enum CaptureVarCause {
206 #[label(borrowck_var_borrow_by_use_place_in_coroutine)]
207 BorrowUsePlaceCoroutine {
208 is_single_var: bool,
209 place: String,
210 #[primary_span]
211 var_span: Span,
212 },
213 #[label(borrowck_var_borrow_by_use_place_in_closure)]
214 BorrowUsePlaceClosure {
215 is_single_var: bool,
216 place: String,
217 #[primary_span]
218 var_span: Span,
219 },
220 #[label(borrowck_var_borrow_by_use_in_coroutine)]
221 BorrowUseInCoroutine {
222 #[primary_span]
223 var_span: Span,
224 },
225 #[label(borrowck_var_borrow_by_use_in_closure)]
226 BorrowUseInClosure {
227 #[primary_span]
228 var_span: Span,
229 },
230 #[label(borrowck_var_move_by_use_in_coroutine)]
231 MoveUseInCoroutine {
232 #[primary_span]
233 var_span: Span,
234 },
235 #[label(borrowck_var_move_by_use_in_closure)]
236 MoveUseInClosure {
237 #[primary_span]
238 var_span: Span,
239 },
240 #[label(borrowck_var_first_borrow_by_use_place_in_coroutine)]
241 FirstBorrowUsePlaceCoroutine {
242 place: String,
243 #[primary_span]
244 var_span: Span,
245 },
246 #[label(borrowck_var_first_borrow_by_use_place_in_closure)]
247 FirstBorrowUsePlaceClosure {
248 place: String,
249 #[primary_span]
250 var_span: Span,
251 },
252 #[label(borrowck_var_second_borrow_by_use_place_in_coroutine)]
253 SecondBorrowUsePlaceCoroutine {
254 place: String,
255 #[primary_span]
256 var_span: Span,
257 },
258 #[label(borrowck_var_second_borrow_by_use_place_in_closure)]
259 SecondBorrowUsePlaceClosure {
260 place: String,
261 #[primary_span]
262 var_span: Span,
263 },
264 #[label(borrowck_var_mutable_borrow_by_use_place_in_closure)]
265 MutableBorrowUsePlaceClosure {
266 place: String,
267 #[primary_span]
268 var_span: Span,
269 },
270 #[label(borrowck_partial_var_move_by_use_in_coroutine)]
271 PartialMoveUseInCoroutine {
272 #[primary_span]
273 var_span: Span,
274 is_partial: bool,
275 },
276 #[label(borrowck_partial_var_move_by_use_in_closure)]
277 PartialMoveUseInClosure {
278 #[primary_span]
279 var_span: Span,
280 is_partial: bool,
281 },
282}
283
284#[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,
crate::fluent_generated::borrowck_cannot_move_when_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,
crate::fluent_generated::borrowck_move_label);
diag.span_label(__binding_4,
crate::fluent_generated::_subdiag::label);
diag
}
}
}
}
};Diagnostic)]
285#[diag(borrowck_cannot_move_when_borrowed, code = E0505)]
286pub(crate) struct MoveBorrow<'a> {
287 pub place: &'a str,
288 pub borrow_place: &'a str,
289 pub value_place: &'a str,
290 #[primary_span]
291 #[label(borrowck_move_label)]
292 pub span: Span,
293 #[label]
294 pub borrow_span: Span,
295}
296
297#[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,
crate::fluent_generated::borrowck_opaque_type_lifetime_mismatch);
;
diag.arg("arg", __binding_0);
diag.arg("prev", __binding_1);
diag.span(__binding_2);
diag.span_label(__binding_2,
crate::fluent_generated::_subdiag::label);
diag.span_note(__binding_2,
crate::fluent_generated::_subdiag::note);
diag.span_label(__binding_3,
crate::fluent_generated::borrowck_prev_lifetime_label);
diag
}
}
}
}
};Diagnostic)]
298#[diag(borrowck_opaque_type_lifetime_mismatch)]
299pub(crate) struct LifetimeMismatchOpaqueParam<'tcx> {
300 pub arg: GenericArg<'tcx>,
301 pub prev: GenericArg<'tcx>,
302 #[primary_span]
303 #[label]
304 #[note]
305 pub span: Span,
306 #[label(borrowck_prev_lifetime_label)]
307 pub prev_span: Span,
308}
309
310#[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(crate::fluent_generated::borrowck_moved_due_to_call);
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(crate::fluent_generated::borrowck_moved_due_to_usage_in_operator);
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(crate::fluent_generated::borrowck_moved_due_to_implicit_into_iter_call);
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(crate::fluent_generated::borrowck_moved_due_to_method_call);
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(crate::fluent_generated::borrowck_moved_due_to_await);
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(crate::fluent_generated::borrowck_value_moved_here);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
CaptureReasonLabel::BorrowContent { var_span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_consider_borrow_type_contents);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
311pub(crate) enum CaptureReasonLabel<'a> {
312 #[label(borrowck_moved_due_to_call)]
313 Call {
314 #[primary_span]
315 fn_call_span: Span,
316 place_name: &'a str,
317 is_partial: bool,
318 is_loop_message: bool,
319 },
320 #[label(borrowck_moved_due_to_usage_in_operator)]
321 OperatorUse {
322 #[primary_span]
323 fn_call_span: Span,
324 place_name: &'a str,
325 is_partial: bool,
326 is_loop_message: bool,
327 },
328 #[label(borrowck_moved_due_to_implicit_into_iter_call)]
329 ImplicitCall {
330 #[primary_span]
331 fn_call_span: Span,
332 place_name: &'a str,
333 is_partial: bool,
334 is_loop_message: bool,
335 },
336 #[label(borrowck_moved_due_to_method_call)]
337 MethodCall {
338 #[primary_span]
339 fn_call_span: Span,
340 place_name: &'a str,
341 is_partial: bool,
342 is_loop_message: bool,
343 },
344 #[label(borrowck_moved_due_to_await)]
345 Await {
346 #[primary_span]
347 fn_call_span: Span,
348 place_name: &'a str,
349 is_partial: bool,
350 is_loop_message: bool,
351 },
352 #[label(borrowck_value_moved_here)]
353 MovedHere {
354 #[primary_span]
355 move_span: Span,
356 is_partial: bool,
357 is_move_msg: bool,
358 is_loop_message: bool,
359 },
360 #[label(borrowck_consider_borrow_type_contents)]
361 BorrowContent {
362 #[primary_span]
363 var_span: Span,
364 },
365}
366
367#[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(crate::fluent_generated::borrowck_moved_a_fn_once_in_call);
diag.span_note(__binding_0, __message);
diag.restore_args();
}
CaptureReasonNote::UnOpMoveByOperator { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_calling_operator_moves);
diag.span_note(__binding_0, __message);
diag.restore_args();
}
CaptureReasonNote::LhsMoveByOperator { span: __binding_0 }
=> {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::borrowck_calling_operator_moves_lhs);
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(crate::fluent_generated::borrowck_func_take_self_moved_place);
diag.span_note(__binding_2, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
368pub(crate) enum CaptureReasonNote {
369 #[note(borrowck_moved_a_fn_once_in_call)]
370 FnOnceMoveInCall {
371 #[primary_span]
372 var_span: Span,
373 },
374 #[note(borrowck_calling_operator_moves)]
375 UnOpMoveByOperator {
376 #[primary_span]
377 span: Span,
378 },
379 #[note(borrowck_calling_operator_moves_lhs)]
380 LhsMoveByOperator {
381 #[primary_span]
382 span: Span,
383 },
384 #[note(borrowck_func_take_self_moved_place)]
385 FuncTakeSelf {
386 func: String,
387 place_name: String,
388 #[primary_span]
389 span: Span,
390 },
391}
392
393#[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(crate::fluent_generated::borrowck_suggest_iterate_over_slice);
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(crate::fluent_generated::borrowck_suggest_create_fresh_reborrow);
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
394pub(crate) enum CaptureReasonSuggest<'tcx> {
395 #[suggestion(
396 borrowck_suggest_iterate_over_slice,
397 applicability = "maybe-incorrect",
398 code = "&",
399 style = "verbose"
400 )]
401 IterateSlice {
402 ty: Ty<'tcx>,
403 #[primary_span]
404 span: Span,
405 },
406 #[suggestion(
407 borrowck_suggest_create_fresh_reborrow,
408 applicability = "maybe-incorrect",
409 code = ".as_mut()",
410 style = "verbose"
411 )]
412 FreshReborrow {
413 #[primary_span]
414 span: Span,
415 },
416}
417
418#[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(crate::fluent_generated::borrowck_value_capture_here);
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(crate::fluent_generated::borrowck_move_out_place_here);
diag.span_label(__binding_1, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
419pub(crate) enum CaptureArgLabel {
420 #[label(borrowck_value_capture_here)]
421 Capture {
422 is_within: bool,
423 #[primary_span]
424 args_span: Span,
425 },
426 #[label(borrowck_move_out_place_here)]
427 MoveOutPlace {
428 place: String,
429 #[primary_span]
430 args_span: Span,
431 },
432}
433
434#[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(crate::fluent_generated::borrowck_closure_invoked_twice);
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(crate::fluent_generated::borrowck_closure_moved_twice);
diag.span_note(__binding_1, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
435pub(crate) enum OnClosureNote<'a> {
436 #[note(borrowck_closure_invoked_twice)]
437 InvokedTwice {
438 place_name: &'a str,
439 #[primary_span]
440 span: Span,
441 },
442 #[note(borrowck_closure_moved_twice)]
443 MovedTwice {
444 place_name: &'a str,
445 #[primary_span]
446 span: Span,
447 },
448}
449
450#[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(crate::fluent_generated::borrowck_ty_no_impl_copy);
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(crate::fluent_generated::borrowck_ty_no_impl_copy);
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
451pub(crate) enum TypeNoCopy<'a, 'tcx> {
452 #[label(borrowck_ty_no_impl_copy)]
453 Label {
454 is_partial_move: bool,
455 ty: Ty<'tcx>,
456 place: &'a str,
457 #[primary_span]
458 span: Span,
459 },
460 #[note(borrowck_ty_no_impl_copy)]
461 Note { is_partial_move: bool, ty: Ty<'tcx>, place: &'a str },
462}
463
464#[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,
crate::fluent_generated::borrowck_simd_intrinsic_arg_const);
;
diag.arg("arg", __binding_1);
diag.arg("intrinsic", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
465#[diag(borrowck_simd_intrinsic_arg_const)]
466pub(crate) struct SimdIntrinsicArgConst {
467 #[primary_span]
468 pub span: Span,
469 pub arg: usize,
470 pub intrinsic: String,
471}
472
473#[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(crate::fluent_generated::borrowck_tail_expr_drop_order);
;
diag.span_label(__binding_0,
crate::fluent_generated::_subdiag::label);
diag
}
};
}
}
};LintDiagnostic)]
474#[diag(borrowck_tail_expr_drop_order)]
475pub(crate) struct TailExprDropOrder {
476 #[label]
477 pub borrowed: Span,
478}