]> git.lizzy.rs Git - rust.git/commitdiff
review comments
authorEsteban Küber <esteban@kuber.com.ar>
Fri, 18 Jan 2019 23:47:25 +0000 (15:47 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Thu, 24 Jan 2019 18:36:50 +0000 (10:36 -0800)
src/librustc_mir/borrow_check/error_reporting.rs
src/test/ui/borrowck/issue-41962.stderr

index d8a3cf9947024b516441bb68576461eb682ed25c..56b87feb82b2c34f2ce9bf93e14fe72489960f47 100644 (file)
@@ -203,20 +203,6 @@ pub(super) fn report_use_of_moved_or_uninitialized(
                     Some(ref name) => format!("`{}`", name),
                     None => "value".to_owned(),
                 };
-                let mut note = true;
-                for decl in &self.mir.local_decls {
-                    if decl.ty == ty && decl.name.map(|x| x.to_string()) == opt_name {
-                        err.span_label(
-                            decl.source_info.span,
-                            format!(
-                                "move occurs because {} has type `{}`, \
-                                 which does not implement the `Copy` trait",
-                                note_msg, ty,
-                        ));
-                        note = false;
-                        break;
-                    }
-                }
                 if let ty::TyKind::Param(param_ty) = ty.sty {
                     let tcx = self.infcx.tcx;
                     let generics = tcx.generics_of(self.mir_def_id);
@@ -228,7 +214,16 @@ pub(super) fn report_use_of_moved_or_uninitialized(
                         );
                     }
                 }
-                if note {
+                if let Place::Local(local) = place {
+                    let decl = &self.mir.local_decls[*local];
+                    err.span_label(
+                        decl.source_info.span,
+                        format!(
+                            "move occurs because {} has type `{}`, \
+                                which does not implement the `Copy` trait",
+                            note_msg, ty,
+                    ));
+                } else {
                     err.note(&format!(
                         "move occurs because {} has type `{}`, \
                          which does not implement the `Copy` trait",
index 3c0071f6b37453165564433cdc3474c3ceaec89a..fd4d318b5ddf1cea094b9bb9e73933e9febce6dc 100644 (file)
@@ -19,13 +19,10 @@ LL |         if let Some(thing) = maybe {
 error[E0382]: use of moved value (Mir)
   --> $DIR/issue-41962.rs:7:21
    |
-LL |     let maybe = Some(vec![true, true]);
-   |                      ---------------- move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
-...
 LL |         if let Some(thing) = maybe {
    |                     ^^^^^ value moved here, in previous iteration of loop
    |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
 
 error: aborting due to 3 previous errors