about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-06-23 10:42:17 -0700
committerEsteban Küber <esteban@kuber.com.ar>2022-07-07 12:25:56 -0700
commitd09851cfba9ff151d293f38526fd148e22a00092 (patch)
tree4182809bb5f3791234b78b4efd8d32b9f9c934f5 /compiler/rustc_borrowck/src
parent5f91614d12f1aed56c8c9ea1d9d39a6f0db98892 (diff)
downloadrust-d09851cfba9ff151d293f38526fd148e22a00092.tar.gz
rust-d09851cfba9ff151d293f38526fd148e22a00092.zip
Wording tweak
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs29
1 files changed, 21 insertions, 8 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index c5420cee05e..b9cfc3732dc 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -98,8 +98,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                 return;
             }
 
-            let err =
-                self.report_use_of_uninitialized(mpi, used_place, desired_action, span, use_spans);
+            let err = self.report_use_of_uninitialized(
+                mpi,
+                used_place,
+                moved_place,
+                desired_action,
+                span,
+                use_spans,
+            );
             self.buffer_error(err);
         } else {
             if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
@@ -316,6 +322,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         &self,
         mpi: MovePathIndex,
         used_place: PlaceRef<'tcx>,
+        moved_place: PlaceRef<'tcx>,
         desired_action: InitializationRequiringAction,
         span: Span,
         use_spans: UseSpans<'tcx>,
@@ -334,11 +341,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             }
         }
 
-        let (binding, name, desc) =
-            match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
-                Some(name) => (format!("`{name}`"), format!("`{name}`"), format!("`{name}` ")),
-                None => ("value".to_string(), "the variable".to_string(), String::new()),
+        let (name, desc) =
+            match self.describe_place_with_options(moved_place, IncludingDowncast(true)) {
+                Some(name) => (format!("`{name}`"), format!("`{name}` ")),
+                None => ("the variable".to_string(), String::new()),
             };
+        let path = match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
+            Some(name) => format!("`{name}`"),
+            None => "value".to_string(),
+        };
 
         // We use the statements were the binding was initialized, and inspect the HIR to look
         // for the branching codepaths that aren't covered, to point at them.
@@ -390,13 +401,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
         );
 
-        if let InitializationRequiringAction::PartialAssignment = desired_action {
+        if let InitializationRequiringAction::PartialAssignment
+        | InitializationRequiringAction::Assignment = desired_action
+        {
             err.help(
                 "partial initialization isn't supported, fully initialize the binding with a \
                  default value and mutate it, or use `std::mem::MaybeUninit`",
             );
         }
-        err.span_label(span, format!("{binding} {used} here but it {isnt_initialized}"));
+        err.span_label(span, format!("{path} {used} here but it {isnt_initialized}"));
 
         let mut shown = false;
         for (sp, label) in visitor.errors {