Skip to content

Commit 3e50a07

Browse files
committed
pass without effor
1 parent 44e4e3a commit 3e50a07

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
2222
use rustc_target::abi::VariantIdx;
2323
use rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions;
2424

25-
use crate::session_diagnostics::{CaptureCausedBy, ClosureCannotAgain};
25+
use crate::session_diagnostics::{CaptureCausedBy, ClosureCannotAgain, NotImplCopy};
2626

2727
use super::borrow_set::BorrowData;
2828
use super::MirBorrowckCtxt;
@@ -391,14 +391,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
391391
span: Option<Span>,
392392
move_prefix: &str,
393393
) {
394-
let message = format!(
395-
"{}move occurs because {} has type `{}`, which does not implement the `Copy` trait",
396-
move_prefix, place_desc, ty,
397-
);
398394
if let Some(span) = span {
399-
err.span_label(span, message);
395+
err.subdiagnostic(NotImplCopy::Label { span, place_desc, ty, move_prefix });
400396
} else {
401-
err.note(&message);
397+
err.subdiagnostic(NotImplCopy::Note { place_desc, ty, move_prefix });
402398
}
403399
}
404400

@@ -988,6 +984,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
988984
loop_message,
989985
span: fn_call_span,
990986
};
987+
err.subdiagnostic(label);
991988
let note = CaptureCausedBy::FnOnceVal { span: var_span };
992989
err.subdiagnostic(note);
993990
}

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,17 @@ pub(crate) enum CaptureCausedBy<'a> {
424424
span: Span,
425425
},
426426
}
427+
428+
#[derive(SessionSubdiagnostic)]
429+
pub(crate) enum NotImplCopy<'a, 'tcx> {
430+
#[label(borrowck::type_not_impl_Copy)]
431+
Label {
432+
place_desc: &'a str,
433+
ty: Ty<'tcx>,
434+
move_prefix: &'a str,
435+
#[primary_span]
436+
span: Span,
437+
},
438+
#[note(borrowck::type_not_impl_Copy)]
439+
Note { place_desc: &'a str, ty: Ty<'tcx>, move_prefix: &'a str },
440+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,6 @@ borrowck_moved_fnonce_value =
171171
172172
borrowck_moved_by_call =
173173
{$place_name} {$partially_str}moved due to this call{$loop_message}
174+
175+
borrowck_type_not_impl_Copy =
176+
{$move_prefix}move occurs because {$place_desc} has type `{$ty}`, which does not implement the `Copy` trait

0 commit comments

Comments
 (0)