@@ -80,8 +80,15 @@ pub enum LoanCause {
80
80
81
81
#[ deriving( PartialEq , Show ) ]
82
82
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 ,
85
92
}
86
93
87
94
#[ deriving( PartialEq , Show ) ]
@@ -161,7 +168,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
161
168
consume_id : ast:: NodeId ,
162
169
consume_span : Span ,
163
170
cmt : mc:: cmt ) {
164
- let mode = copy_or_move ( self . tcx ( ) , cmt. ty ) ;
171
+ let mode = copy_or_move ( self . tcx ( ) , cmt. ty , DirectRefMove ) ;
165
172
self . delegate . consume ( consume_id, consume_span, cmt, mode) ;
166
173
}
167
174
@@ -729,7 +736,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
729
736
r, bk, RefBinding ) ;
730
737
}
731
738
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 ) ;
733
740
delegate. consume_pat( pat, cmt_pat, mode) ;
734
741
}
735
742
_ => {
@@ -835,7 +842,8 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
835
842
let cmt_var = return_if_err ! ( self . cat_captured_var( closure_expr. id,
836
843
closure_expr. span,
837
844
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) ;
839
847
}
840
848
}
841
849
@@ -852,7 +860,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
852
860
}
853
861
}
854
862
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 }
857
865
}
858
866
0 commit comments