mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 23:33:00 +00:00
Add mir test, review comments
This commit is contained in:
parent
48b684a40a
commit
e027f5a99e
@ -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))
|
||||
|
@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user