Skip to content

Commit e027f5a

Browse files
committed
Add mir test, review comments
1 parent 48b684a commit e027f5a

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

src/librustc_borrowck/borrowck/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ impl<'tcx> LoanPath<'tcx> {
347347

348348
fn to_type(&self) -> Ty<'tcx> { self.ty }
349349

350-
fn is_downcast(&self) -> bool {
350+
fn has_downcast(&self) -> bool {
351351
match self.kind {
352352
LpDowncast(_, _) => true,
353353
LpExtend(ref lp, _, LpInterior(_, _)) => {
354-
lp.is_downcast()
354+
lp.has_downcast()
355355
}
356356
_ => false,
357357
}
@@ -733,7 +733,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
733733
if need_note {
734734
err.note(&format!(
735735
"move occurs because {} has type `{}`, which does not implement the `Copy` trait",
736-
if moved_lp.is_downcast() {
736+
if moved_lp.has_downcast() {
737737
"the value".to_string()
738738
} else {
739739
format!("`{}`", self.loan_path_to_string(moved_lp))

src/test/ui/borrowck/issue-41962.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,13 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// compile-flags: -Z borrowck=compare
12+
1113
pub fn main(){
1214
let maybe = Some(vec![true, true]);
1315

1416
loop {
1517
if let Some(thing) = maybe {
16-
//~^ ERROR use of partially moved value
17-
//~| ERROR use of moved value
18+
//~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
19+
//~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
20+
//~| ERROR use of moved value: `maybe` (Mir) [E0382]
21+
//~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
1822
}
1923
}
2024
}
+29-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
1-
error[E0382]: use of partially moved value: `maybe`
2-
--> $DIR/issue-41962.rs:15:30
1+
error[E0382]: use of partially moved value: `maybe` (Ast)
2+
--> $DIR/issue-41962.rs:17:30
33
|
4-
15 | if let Some(thing) = maybe {
4+
17 | if let Some(thing) = maybe {
55
| ----- ^^^^^ value used here after move
66
| |
77
| value moved here
88
|
99
= note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
1010

11-
error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0`
12-
--> $DIR/issue-41962.rs:15:21
11+
error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast)
12+
--> $DIR/issue-41962.rs:17:21
1313
|
14-
15 | if let Some(thing) = maybe {
14+
17 | if let Some(thing) = maybe {
1515
| ^^^^^ value moved here in previous iteration of loop
1616
|
1717
= note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
1818

19-
error: aborting due to 2 previous errors
19+
error[E0382]: use of moved value: `maybe` (Mir)
20+
--> $DIR/issue-41962.rs:17:16
21+
|
22+
17 | if let Some(thing) = maybe {
23+
| ^^^^^-----^
24+
| | |
25+
| | value moved here
26+
| value used here after move
27+
|
28+
= note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait
29+
30+
error[E0382]: use of moved value: `maybe.0` (Mir)
31+
--> $DIR/issue-41962.rs:17:21
32+
|
33+
17 | if let Some(thing) = maybe {
34+
| ^^^^^
35+
| |
36+
| value used here after move
37+
| value moved here in previous iteration of loop
38+
|
39+
= note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
40+
41+
error: aborting due to 4 previous errors
2042

0 commit comments

Comments
 (0)