Skip to content

Commit 6533f2b

Browse files
committed
pass
1 parent b42244c commit 6533f2b

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
25
use rustc_middle::mir::*;
36
use rustc_middle::ty;
@@ -8,6 +11,7 @@ use rustc_span::Span;
811

912
use crate::diagnostics::{DescribePlaceOpt, UseSpans};
1013
use crate::prefixes::PrefixSet;
14+
use crate::session_diagnostics::AddMoveErr;
1115
use crate::MirBorrowckCtxt;
1216

1317
// Often when desugaring a pattern match we may have many individual moves in
@@ -503,9 +507,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
503507
let binding_span = bind_to.source_info.span;
504508

505509
if j == 0 {
506-
err.span_label(binding_span, "data moved here");
510+
err.subdiagnostic(AddMoveErr::Here { binding_span });
507511
} else {
508-
err.span_label(binding_span, "...and here");
512+
err.subdiagnostic(AddMoveErr::AndHere { binding_span });
509513
}
510514

511515
if binds_to.len() == 1 {
@@ -520,10 +524,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
520524
}
521525

522526
if binds_to.len() > 1 {
523-
err.note(
524-
"move occurs because these variables have types that \
525-
don't implement the `Copy` trait",
526-
);
527+
err.subdiagnostic(AddMoveErr::MovedNotCopy {});
527528
}
528529
}
529530
}

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,21 @@ pub(crate) enum RequireStaticErr {
157157
multi_span: MultiSpan,
158158
},
159159
}
160+
161+
//move_errors.rs
162+
163+
#[derive(SessionSubdiagnostic)]
164+
pub(crate) enum AddMoveErr {
165+
#[label(borrowck::data_moved_here)]
166+
Here {
167+
#[primary_span]
168+
binding_span: Span,
169+
},
170+
#[label(borrowck::and_data_moved_here)]
171+
AndHere {
172+
#[primary_span]
173+
binding_span: Span,
174+
},
175+
#[note(borrowck::moved_var_cannot_copy)]
176+
MovedNotCopy {},
177+
}

compiler/rustc_error_messages/locales/en-US/borrowck.ftl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,11 @@ borrowck_returned_lifetime_short =
5858
5959
borrowck_used_impl_require_static =
6060
the used `impl` has a `'static` requirement
61+
62+
borrowck_data_moved_here =
63+
data moved here
64+
65+
borrowck_and_data_moved_here = ...and here
66+
67+
borrowck_moved_var_cannot_copy =
68+
move occurs because these variables have types that don't implement the `Copy` trait

0 commit comments

Comments
 (0)