Skip to content

Commit c53d296

Browse files
author
Cameron Zwarich
committed
Change check_loans to use ExprUseVisitor.
1 parent 78934b0 commit c53d296

9 files changed

+223
-230
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 216 additions & 212 deletions
Large diffs are not rendered by default.

src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
142142
body);
143143

144144
check_loans::check_loans(this, &loan_dfcx, flowed_moves,
145-
all_loans.as_slice(), body);
145+
all_loans.as_slice(), decl, body);
146146

147147
visit::walk_fn(this, fk, decl, body, sp, ());
148148
}

src/librustc/middle/borrowck/move_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub struct MovePath {
115115
pub next_sibling: MovePathIndex,
116116
}
117117

118+
#[deriving(PartialEq)]
118119
pub enum MoveKind {
119120
Declared, // When declared, variables start out "moved".
120121
MoveExpr, // Expression or binding that moves a variable

src/test/compile-fail/borrowck-init-in-fru.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ struct point {
1616

1717
fn main() {
1818
let mut origin: point;
19-
origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin`
19+
origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin.y`
2020
origin.clone();
2121
}

src/test/compile-fail/liveness-use-after-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ extern crate debug;
1313
fn main() {
1414
let x = box 5;
1515
let y = x;
16-
println!("{:?}", *x); //~ ERROR use of moved value: `x`
16+
println!("{:?}", *x); //~ ERROR use of partially moved value: `*x`
1717
y.clone();
1818
}

src/test/compile-fail/moves-based-on-type-access-to-field.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ struct Foo { f: String, y: int }
1717
fn consume(_s: String) {}
1818
fn touch<A>(_a: &A) {}
1919

20-
fn f10() {
21-
let x = Foo { f: "hi".to_string(), y: 3 };
22-
consume(x.f);
23-
touch(&x.y); //~ ERROR use of partially moved value: `x`
24-
}
25-
2620
fn f20() {
2721
let x = vec!("hi".to_string());
2822
consume(x.move_iter().next().unwrap());

src/test/compile-fail/moves-sru-moved-field.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ fn test0(f: Foo, g: Noncopyable, h: Noncopyable) {
2626
fn test1(f: Foo, g: Noncopyable, h: Noncopyable) {
2727
// copying move-by-default fields from `f`, so move:
2828
let _b = Foo {noncopyable: g, ..f};
29-
let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of partially moved value: `f`
30-
}
31-
32-
fn test2(f: Foo, g: Noncopyable) {
33-
// move non-copyable field
34-
let _b = Foo {copied: 22, moved: box 23, ..f};
35-
let _c = Foo {noncopyable: g, ..f}; //~ ERROR use of partially moved value: `f`
29+
let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved`
3630
}
3731

3832
fn main() {}

src/test/compile-fail/use-after-move-self-based-on-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Drop for S {
1919
impl S {
2020
pub fn foo(self) -> int {
2121
self.bar();
22-
return self.x; //~ ERROR use of moved value: `self`
22+
return self.x; //~ ERROR use of partially moved value: `self.x`
2323
}
2424

2525
pub fn bar(self) {}

src/test/compile-fail/use-after-move-self.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct S {
1616
impl S {
1717
pub fn foo(self) -> int {
1818
self.bar();
19-
return *self.x; //~ ERROR use of moved value: `self`
19+
return *self.x; //~ ERROR use of partially moved value: `*self.x`
2020
}
2121

2222
pub fn bar(self) {}

0 commit comments

Comments
 (0)