summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_borrowck/src/diagnostics/move_errors.rs')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/move_errors.rs55
1 files changed, 35 insertions, 20 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
index 3662bec0c..8b77477a3 100644
--- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
@@ -6,6 +6,7 @@ use rustc_mir_dataflow::move_paths::{
};
use rustc_span::{BytePos, Span};
+use crate::diagnostics::CapturedMessageOpt;
use crate::diagnostics::{DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet;
use crate::MirBorrowckCtxt;
@@ -397,10 +398,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
}
};
+ let msg_opt = CapturedMessageOpt {
+ is_partial_move: false,
+ is_loop_message: false,
+ is_move_msg: false,
+ is_loop_move: false,
+ maybe_reinitialized_locations_is_empty: true,
+ };
if let Some(use_spans) = use_spans {
- self.explain_captures(
- &mut err, span, span, use_spans, move_place, "", "", "", false, true,
- );
+ self.explain_captures(&mut err, span, span, use_spans, move_place, msg_opt);
}
err
}
@@ -416,13 +422,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
None => "value".to_string(),
};
- self.note_type_does_not_implement_copy(
- err,
- &place_desc,
- place_ty,
- Some(span),
- "",
- );
+ err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
+ is_partial_move: false,
+ ty: place_ty,
+ place: &place_desc,
+ span,
+ });
} else {
binds_to.sort();
binds_to.dedup();
@@ -444,9 +449,19 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
Some(desc) => format!("`{desc}`"),
None => "value".to_string(),
};
- self.note_type_does_not_implement_copy(err, &place_desc, place_ty, Some(span), "");
+ err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
+ is_partial_move: false,
+ ty: place_ty,
+ place: &place_desc,
+ span,
+ });
- use_spans.args_span_label(err, format!("{place_desc} is moved here"));
+ use_spans.args_subdiag(err, |args_span| {
+ crate::session_diagnostics::CaptureArgLabel::MoveOutPlace {
+ place: place_desc,
+ args_span,
+ }
+ });
}
}
}
@@ -518,7 +533,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
suggestions.sort_unstable_by_key(|&(span, _, _)| span);
suggestions.dedup_by_key(|&mut (span, _, _)| span);
for (span, msg, suggestion) in suggestions {
- err.span_suggestion_verbose(span, &msg, suggestion, Applicability::MachineApplicable);
+ err.span_suggestion_verbose(span, msg, suggestion, Applicability::MachineApplicable);
}
}
@@ -534,13 +549,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
if binds_to.len() == 1 {
- self.note_type_does_not_implement_copy(
- err,
- &format!("`{}`", self.local_names[*local].unwrap()),
- bind_to.ty,
- Some(binding_span),
- "",
- );
+ let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
+ err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
+ is_partial_move: false,
+ ty: bind_to.ty,
+ place: &place_desc,
+ span: binding_span,
+ });
}
}