diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 99403d01239..ef5edf9c6b5 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -347,11 +347,11 @@ impl<'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 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { 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)) diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index d8a4436532a..d592be11335 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -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] } } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index 51e4409c81f..4522029593f 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -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`, 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`, 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>`, 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`, which does not implement the `Copy` trait + +error: aborting due to 4 previous errors