Skip to content

Commit 764f46c

Browse files
author
Cameron Zwarich
committed
---
yaml --- r: 152310 b: refs/heads/try2 c: 5ccb764 h: refs/heads/master v: v3
1 parent e80bea5 commit 764f46c

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f63fad5d60f451013a6787fec4db12b77cab018c
8+
refs/heads/try2: 5ccb7644be0f0ab04a76bf88c93cecb63b1ba20d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a> euv::Delegate for GatherLoanCtxt<'a> {
7676

7777
match mode {
7878
euv::Copy => { return; }
79-
euv::Move => { }
79+
euv::Move(_) => { }
8080
}
8181

8282
gather_moves::gather_move_from_expr(
@@ -95,7 +95,7 @@ impl<'a> euv::Delegate for GatherLoanCtxt<'a> {
9595

9696
match mode {
9797
euv::Copy => { return; }
98-
euv::Move => { }
98+
euv::Move(_) => { }
9999
}
100100

101101
gather_moves::gather_move_from_pat(

branches/try2/src/librustc/middle/expr_use_visitor.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ pub enum LoanCause {
8080

8181
#[deriving(PartialEq,Show)]
8282
pub enum ConsumeMode {
83-
Copy, // reference to x where x has a type that copies
84-
Move, // reference to x where x has a type that moves
83+
Copy, // reference to x where x has a type that copies
84+
Move(MoveReason), // reference to x where x has a type that moves
85+
}
86+
87+
#[deriving(PartialEq,Show)]
88+
pub enum MoveReason {
89+
DirectRefMove,
90+
PatBindingMove,
91+
CaptureMove,
8592
}
8693

8794
#[deriving(PartialEq,Show)]
@@ -161,7 +168,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
161168
consume_id: ast::NodeId,
162169
consume_span: Span,
163170
cmt: mc::cmt) {
164-
let mode = copy_or_move(self.tcx(), cmt.ty);
171+
let mode = copy_or_move(self.tcx(), cmt.ty, DirectRefMove);
165172
self.delegate.consume(consume_id, consume_span, cmt, mode);
166173
}
167174

@@ -729,7 +736,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
729736
r, bk, RefBinding);
730737
}
731738
ast::PatIdent(ast::BindByValue(_), _, _) => {
732-
let mode = copy_or_move(typer.tcx(), cmt_pat.ty);
739+
let mode = copy_or_move(typer.tcx(), cmt_pat.ty, PatBindingMove);
733740
delegate.consume_pat(pat, cmt_pat, mode);
734741
}
735742
_ => {
@@ -835,7 +842,8 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
835842
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
836843
closure_expr.span,
837844
freevar.def));
838-
self.delegate_consume(closure_expr.id, freevar.span, cmt_var);
845+
let mode = copy_or_move(self.tcx(), cmt_var.ty, CaptureMove);
846+
self.delegate.consume(closure_expr.id, freevar.span, cmt_var, mode);
839847
}
840848
}
841849

@@ -852,7 +860,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
852860
}
853861
}
854862

855-
fn copy_or_move(tcx: &ty::ctxt, ty: ty::t) -> ConsumeMode {
856-
if ty::type_moves_by_default(tcx, ty) { Move } else { Copy }
863+
fn copy_or_move(tcx: &ty::ctxt, ty: ty::t, move_reason: MoveReason) -> ConsumeMode {
864+
if ty::type_moves_by_default(tcx, ty) { Move(move_reason) } else { Copy }
857865
}
858866

0 commit comments

Comments
 (0)