]> git.lizzy.rs Git - rust.git/commitdiff
Add mir test, review comments
authorEsteban Küber <esteban@kuber.com.ar>
Wed, 3 Jan 2018 21:55:40 +0000 (13:55 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Wed, 3 Jan 2018 21:55:40 +0000 (13:55 -0800)
src/librustc_borrowck/borrowck/mod.rs
src/test/ui/borrowck/issue-41962.rs
src/test/ui/borrowck/issue-41962.stderr

index 99403d012394f54891cf9ce859e017a6b436c946..ef5edf9c6b586ba992b87193197c3f87ed1f5e8d 100644 (file)
@@ -347,11 +347,11 @@ fn new(kind: LoanPathKind<'tcx>, ty: Ty<'tcx>) -> LoanPath<'tcx> {
 
     fn to_type(&self) -> Ty<'tcx> { self.ty }
 
-    fn is_downcast(&self) -> bool {
+    fn has_downcast(&self) -> bool {
         match self.kind {
             LpDowncast(_, _) => true,
             LpExtend(ref lp, _, LpInterior(_, _)) => {
-                lp.is_downcast()
+                lp.has_downcast()
             }
             _ => false,
         }
@@ -733,7 +733,7 @@ pub fn report_use_of_moved_value(&self,
         if need_note {
             err.note(&format!(
                 "move occurs because {} has type `{}`, which does not implement the `Copy` trait",
-                if moved_lp.is_downcast() {
+                if moved_lp.has_downcast() {
                     "the value".to_string()
                 } else {
                     format!("`{}`", self.loan_path_to_string(moved_lp))
index d8a4436532a0d8b3d9fa955499388f8e5cbba6b3..d592be11335e0254148657a343d5cdf19c10c733 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,13 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Z borrowck=compare
+
 pub fn main(){
     let maybe = Some(vec![true, true]);
 
     loop {
         if let Some(thing) = maybe {
-        //~^ ERROR use of partially moved value
-        //~| ERROR use of moved value
+        //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
+        //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
+        //~| ERROR use of moved value: `maybe` (Mir) [E0382]
+        //~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
         }
     }
 }
index 51e4409c81f80fb71e01baeea5c954d291dfc506..4522029593fa1f33ef379fe327734c6b5cca3d64 100644 (file)
@@ -1,20 +1,42 @@
-error[E0382]: use of partially moved value: `maybe`
-  --> $DIR/issue-41962.rs:15:30
+error[E0382]: use of partially moved value: `maybe` (Ast)
+  --> $DIR/issue-41962.rs:17:30
    |
-15 |         if let Some(thing) = maybe {
+17 |         if let Some(thing) = maybe {
    |                     -----    ^^^^^ value used here after move
    |                     |
    |                     value moved here
    |
    = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
 
-error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0`
-  --> $DIR/issue-41962.rs:15:21
+error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast)
+  --> $DIR/issue-41962.rs:17:21
    |
-15 |         if let Some(thing) = maybe {
+17 |         if let Some(thing) = maybe {
    |                     ^^^^^ value moved here in previous iteration of loop
    |
    = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
 
-error: aborting due to 2 previous errors
+error[E0382]: use of moved value: `maybe` (Mir)
+  --> $DIR/issue-41962.rs:17:16
+   |
+17 |         if let Some(thing) = maybe {
+   |                ^^^^^-----^
+   |                |    |
+   |                |    value moved here
+   |                value used here after move
+   |
+   = note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `maybe.0` (Mir)
+  --> $DIR/issue-41962.rs:17:21
+   |
+17 |         if let Some(thing) = maybe {
+   |                     ^^^^^
+   |                     |
+   |                     value used here after move
+   |                     value moved here in previous iteration of loop
+   |
+   = note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
+
+error: aborting due to 4 previous errors