@@ -21,15 +21,15 @@ use syntax_pos::Span;
21
21
/// This trait defines the callbacks you can expect to receive when
22
22
/// employing the ExprUseVisitor.
23
23
pub trait Delegate < ' tcx > {
24
- // The value found at `cmt ` is either copied or moved, depending
24
+ // The value found at `place ` is either copied or moved, depending
25
25
// on mode.
26
- fn consume ( & mut self , cmt : & mc:: Place < ' tcx > , mode : ConsumeMode ) ;
26
+ fn consume ( & mut self , place : & mc:: Place < ' tcx > , mode : ConsumeMode ) ;
27
27
28
- // The value found at `cmt ` is being borrowed with kind `bk`.
29
- fn borrow ( & mut self , cmt : & mc:: Place < ' tcx > , bk : ty:: BorrowKind ) ;
28
+ // The value found at `place ` is being borrowed with kind `bk`.
29
+ fn borrow ( & mut self , place : & mc:: Place < ' tcx > , bk : ty:: BorrowKind ) ;
30
30
31
- // The path at `cmt ` is being assigned to.
32
- fn mutate ( & mut self , assignee_cmt : & mc:: Place < ' tcx > ) ;
31
+ // The path at `place ` is being assigned to.
32
+ fn mutate ( & mut self , assignee_place : & mc:: Place < ' tcx > ) ;
33
33
}
34
34
35
35
#[ derive( Copy , Clone , PartialEq , Debug ) ]
@@ -163,22 +163,22 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
163
163
pub fn consume_expr ( & mut self , expr : & hir:: Expr ) {
164
164
debug ! ( "consume_expr(expr={:?})" , expr) ;
165
165
166
- let cmt = return_if_err ! ( self . mc. cat_expr( expr) ) ;
167
- self . delegate_consume ( & cmt ) ;
166
+ let place = return_if_err ! ( self . mc. cat_expr( expr) ) ;
167
+ self . delegate_consume ( & place ) ;
168
168
self . walk_expr ( expr) ;
169
169
}
170
170
171
171
fn mutate_expr ( & mut self , expr : & hir:: Expr ) {
172
- let cmt = return_if_err ! ( self . mc. cat_expr( expr) ) ;
173
- self . delegate . mutate ( & cmt ) ;
172
+ let place = return_if_err ! ( self . mc. cat_expr( expr) ) ;
173
+ self . delegate . mutate ( & place ) ;
174
174
self . walk_expr ( expr) ;
175
175
}
176
176
177
177
fn borrow_expr ( & mut self , expr : & hir:: Expr , bk : ty:: BorrowKind ) {
178
178
debug ! ( "borrow_expr(expr={:?}, bk={:?})" , expr, bk) ;
179
179
180
- let cmt = return_if_err ! ( self . mc. cat_expr( expr) ) ;
181
- self . delegate . borrow ( & cmt , bk) ;
180
+ let place = return_if_err ! ( self . mc. cat_expr( expr) ) ;
181
+ self . delegate . borrow ( & place , bk) ;
182
182
183
183
self . walk_expr ( expr)
184
184
}
@@ -230,12 +230,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
230
230
}
231
231
232
232
hir:: ExprKind :: Match ( ref discr, ref arms, _) => {
233
- let discr_cmt = return_if_err ! ( self . mc. cat_expr( & discr) ) ;
233
+ let discr_place = return_if_err ! ( self . mc. cat_expr( & discr) ) ;
234
234
self . borrow_expr ( & discr, ty:: ImmBorrow ) ;
235
235
236
236
// treatment of the discriminant is handled while walking the arms.
237
237
for arm in arms {
238
- self . walk_arm ( & discr_cmt , arm) ;
238
+ self . walk_arm ( & discr_place , arm) ;
239
239
}
240
240
}
241
241
@@ -381,8 +381,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
381
381
// "assigns", which is handled by
382
382
// `walk_pat`:
383
383
self . walk_expr ( & expr) ;
384
- let init_cmt = return_if_err ! ( self . mc. cat_expr( & expr) ) ;
385
- self . walk_irrefutable_pat ( & init_cmt , & local. pat ) ;
384
+ let init_place = return_if_err ! ( self . mc. cat_expr( & expr) ) ;
385
+ self . walk_irrefutable_pat ( & init_place , & local. pat ) ;
386
386
}
387
387
}
388
388
@@ -457,15 +457,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
457
457
// process.
458
458
fn walk_adjustment ( & mut self , expr : & hir:: Expr ) {
459
459
let adjustments = self . mc . tables . expr_adjustments ( expr) ;
460
- let mut cmt = return_if_err ! ( self . mc. cat_expr_unadjusted( expr) ) ;
460
+ let mut place = return_if_err ! ( self . mc. cat_expr_unadjusted( expr) ) ;
461
461
for adjustment in adjustments {
462
462
debug ! ( "walk_adjustment expr={:?} adj={:?}" , expr, adjustment) ;
463
463
match adjustment. kind {
464
464
adjustment:: Adjust :: NeverToAny |
465
465
adjustment:: Adjust :: Pointer ( _) => {
466
466
// Creating a closure/fn-pointer or unsizing consumes
467
467
// the input and stores it into the resulting rvalue.
468
- self . delegate_consume ( & cmt ) ;
468
+ self . delegate_consume ( & place ) ;
469
469
}
470
470
471
471
adjustment:: Adjust :: Deref ( None ) => { }
@@ -477,41 +477,41 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
477
477
// this is an autoref of `x`.
478
478
adjustment:: Adjust :: Deref ( Some ( ref deref) ) => {
479
479
let bk = ty:: BorrowKind :: from_mutbl ( deref. mutbl ) ;
480
- self . delegate . borrow ( & cmt , bk) ;
480
+ self . delegate . borrow ( & place , bk) ;
481
481
}
482
482
483
483
adjustment:: Adjust :: Borrow ( ref autoref) => {
484
- self . walk_autoref ( expr, & cmt , autoref) ;
484
+ self . walk_autoref ( expr, & place , autoref) ;
485
485
}
486
486
}
487
- cmt = return_if_err ! ( self . mc. cat_expr_adjusted( expr, cmt , & adjustment) ) ;
487
+ place = return_if_err ! ( self . mc. cat_expr_adjusted( expr, place , & adjustment) ) ;
488
488
}
489
489
}
490
490
491
491
/// Walks the autoref `autoref` applied to the autoderef'd
492
- /// `expr`. `cmt_base ` is the mem-categorized form of `expr`
492
+ /// `expr`. `base_place ` is the mem-categorized form of `expr`
493
493
/// after all relevant autoderefs have occurred.
494
494
fn walk_autoref ( & mut self ,
495
495
expr : & hir:: Expr ,
496
- cmt_base : & mc:: Place < ' tcx > ,
496
+ base_place : & mc:: Place < ' tcx > ,
497
497
autoref : & adjustment:: AutoBorrow < ' tcx > ) {
498
- debug ! ( "walk_autoref(expr.hir_id={} cmt_base ={:?} autoref={:?})" ,
498
+ debug ! ( "walk_autoref(expr.hir_id={} base_place ={:?} autoref={:?})" ,
499
499
expr. hir_id,
500
- cmt_base ,
500
+ base_place ,
501
501
autoref) ;
502
502
503
503
match * autoref {
504
504
adjustment:: AutoBorrow :: Ref ( _, m) => {
505
- self . delegate . borrow ( cmt_base , ty:: BorrowKind :: from_mutbl ( m. into ( ) ) ) ;
505
+ self . delegate . borrow ( base_place , ty:: BorrowKind :: from_mutbl ( m. into ( ) ) ) ;
506
506
}
507
507
508
508
adjustment:: AutoBorrow :: RawPtr ( m) => {
509
- debug ! ( "walk_autoref: expr.hir_id={} cmt_base ={:?}" ,
509
+ debug ! ( "walk_autoref: expr.hir_id={} base_place ={:?}" ,
510
510
expr. hir_id,
511
- cmt_base ) ;
511
+ base_place ) ;
512
512
513
513
514
- self . delegate . borrow ( cmt_base , ty:: BorrowKind :: from_mutbl ( m) ) ;
514
+ self . delegate . borrow ( base_place , ty:: BorrowKind :: from_mutbl ( m) ) ;
515
515
}
516
516
}
517
517
}
@@ -556,8 +556,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
556
556
// Each match binding is effectively an assignment to the
557
557
// binding being produced.
558
558
let def = Res :: Local ( canonical_id) ;
559
- if let Ok ( ref binding_cmt ) = mc. cat_res( pat. hir_id, pat. span, pat_ty, def) {
560
- delegate. mutate( binding_cmt ) ;
559
+ if let Ok ( ref binding_place ) = mc. cat_res( pat. hir_id, pat. span, pat_ty, def) {
560
+ delegate. mutate( binding_place ) ;
561
561
}
562
562
563
563
// It is also a borrow or copy/move of the value being matched.
@@ -590,16 +590,18 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
590
590
closure_expr_id : closure_def_id. to_local ( ) ,
591
591
} ;
592
592
let upvar_capture = self . mc . tables . upvar_capture ( upvar_id) ;
593
- let cmt_var = return_if_err ! ( self . cat_captured_var( closure_expr. hir_id,
594
- fn_decl_span,
595
- var_id) ) ;
593
+ let captured_place = return_if_err ! ( self . cat_captured_var(
594
+ closure_expr. hir_id,
595
+ fn_decl_span,
596
+ var_id,
597
+ ) ) ;
596
598
match upvar_capture {
597
599
ty:: UpvarCapture :: ByValue => {
598
- let mode = copy_or_move ( & self . mc , & cmt_var ) ;
599
- self . delegate . consume ( & cmt_var , mode) ;
600
+ let mode = copy_or_move ( & self . mc , & captured_place ) ;
601
+ self . delegate . consume ( & captured_place , mode) ;
600
602
}
601
603
ty:: UpvarCapture :: ByRef ( upvar_borrow) => {
602
- self . delegate . borrow ( & cmt_var , upvar_borrow. kind ) ;
604
+ self . delegate . borrow ( & captured_place , upvar_borrow. kind ) ;
603
605
}
604
606
}
605
607
}
@@ -611,7 +613,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
611
613
closure_span : Span ,
612
614
var_id : hir:: HirId )
613
615
-> mc:: McResult < mc:: Place < ' tcx > > {
614
- // Create the cmt for the variable being borrowed, from the
616
+ // Create the place for the variable being borrowed, from the
615
617
// perspective of the creator (parent) of the closure.
616
618
let var_ty = self . mc . node_ty ( var_id) ?;
617
619
self . mc . cat_res ( closure_hir_id, closure_span, var_ty, Res :: Local ( var_id) )
0 commit comments