about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-01-01 22:10:04 -0800
committerEsteban Küber <esteban@kuber.com.ar>2018-01-01 22:10:13 -0800
commit6c506d4c71f957fa5ca50d364c7f56daa0872064 (patch)
tree231249dfc71c5304f46e0a770405647acf6835bb
parentbe6734a7e719f8744c4618fe109475a626fe118e (diff)
downloadrust-6c506d4c71f957fa5ca50d364c7f56daa0872064.tar.gz
rust-6c506d4c71f957fa5ca50d364c7f56daa0872064.zip
Address review comments: make label shorter
-rw-r--r--src/librustc_borrowck/borrowck/mod.rs22
-rw-r--r--src/test/ui/borrowck/issue-41962.stderr3
2 files changed, 16 insertions, 9 deletions
diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs
index 4b72b698708..b33cd19b7a9 100644
--- a/src/librustc_borrowck/borrowck/mod.rs
+++ b/src/librustc_borrowck/borrowck/mod.rs
@@ -705,12 +705,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                 }, " (into closure)"),
         };
 
-        let extra_move_label = if need_note {
-            format!(" because it has type `{}`, which does not implement the `Copy` trait",
-                    moved_lp.ty)
-        } else {
-            String::new()
-        };
         // Annotate the use and the move in the span. Watch out for
         // the case where the use and the move are the same. This
         // means the use is in a loop.
@@ -720,10 +714,22 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                 format!("value moved{} here in previous iteration of loop{}",
                          move_note,
                          extra_move_label));
+
+            if need_note {
+                err.note(&format!("value moved because it has type `{}`, \
+                                   which does not implement the `Copy` trait",
+                                  moved_lp.ty)
+            }
             err
         } else {
-            err.span_label(use_span, format!("value {} here after move", verb_participle))
-               .span_label(move_span, format!("value moved{} here{}", move_note, extra_move_label));
+            err.span_label(use_span, format!("value {} here after move", verb_participle));
+            let extra_move_label = if need_note {
+               &format!(" because it has type `{}`, which does not implement the `Copy` trait",
+                        moved_lp.ty)
+            } else {
+                ""
+            };
+            err.span_label(move_span,format!("value moved{} here{}", move_note, extra_move_label));
             err
         };
 
diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr
index 4ee11798123..caa67835ee5 100644
--- a/src/test/ui/borrowck/issue-41962.stderr
+++ b/src/test/ui/borrowck/issue-41962.stderr
@@ -10,7 +10,8 @@ error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0`
   --> $DIR/issue-41962.rs:15:21
    |
 15 |         if let Some(thing) = maybe {
-   |                     ^^^^^ value moved here in previous iteration of loop because it has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
+   |                     ^^^^^ value moved here in previous iteration of loop
+   = note: value moved because it has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
 
 error: aborting due to 2 previous errors