Skip to content

Commit c87de41

Browse files
committed
Remove remaining uses of "cmt"
1 parent 1d53e43 commit c87de41

File tree

3 files changed

+51
-49
lines changed

3 files changed

+51
-49
lines changed

src/librustc/middle/expr_use_visitor.rs

+40-38
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ use syntax_pos::Span;
2121
/// This trait defines the callbacks you can expect to receive when
2222
/// employing the ExprUseVisitor.
2323
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
2525
// on mode.
26-
fn consume(&mut self, cmt: &mc::Place<'tcx>, mode: ConsumeMode);
26+
fn consume(&mut self, place: &mc::Place<'tcx>, mode: ConsumeMode);
2727

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);
3030

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>);
3333
}
3434

3535
#[derive(Copy, Clone, PartialEq, Debug)]
@@ -163,22 +163,22 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
163163
pub fn consume_expr(&mut self, expr: &hir::Expr) {
164164
debug!("consume_expr(expr={:?})", expr);
165165

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);
168168
self.walk_expr(expr);
169169
}
170170

171171
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);
174174
self.walk_expr(expr);
175175
}
176176

177177
fn borrow_expr(&mut self, expr: &hir::Expr, bk: ty::BorrowKind) {
178178
debug!("borrow_expr(expr={:?}, bk={:?})", expr, bk);
179179

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);
182182

183183
self.walk_expr(expr)
184184
}
@@ -230,12 +230,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
230230
}
231231

232232
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));
234234
self.borrow_expr(&discr, ty::ImmBorrow);
235235

236236
// treatment of the discriminant is handled while walking the arms.
237237
for arm in arms {
238-
self.walk_arm(&discr_cmt, arm);
238+
self.walk_arm(&discr_place, arm);
239239
}
240240
}
241241

@@ -381,8 +381,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
381381
// "assigns", which is handled by
382382
// `walk_pat`:
383383
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);
386386
}
387387
}
388388

@@ -457,15 +457,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
457457
// process.
458458
fn walk_adjustment(&mut self, expr: &hir::Expr) {
459459
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));
461461
for adjustment in adjustments {
462462
debug!("walk_adjustment expr={:?} adj={:?}", expr, adjustment);
463463
match adjustment.kind {
464464
adjustment::Adjust::NeverToAny |
465465
adjustment::Adjust::Pointer(_) => {
466466
// Creating a closure/fn-pointer or unsizing consumes
467467
// the input and stores it into the resulting rvalue.
468-
self.delegate_consume(&cmt);
468+
self.delegate_consume(&place);
469469
}
470470

471471
adjustment::Adjust::Deref(None) => {}
@@ -477,41 +477,41 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
477477
// this is an autoref of `x`.
478478
adjustment::Adjust::Deref(Some(ref deref)) => {
479479
let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
480-
self.delegate.borrow(&cmt, bk);
480+
self.delegate.borrow(&place, bk);
481481
}
482482

483483
adjustment::Adjust::Borrow(ref autoref) => {
484-
self.walk_autoref(expr, &cmt, autoref);
484+
self.walk_autoref(expr, &place, autoref);
485485
}
486486
}
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));
488488
}
489489
}
490490

491491
/// 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`
493493
/// after all relevant autoderefs have occurred.
494494
fn walk_autoref(&mut self,
495495
expr: &hir::Expr,
496-
cmt_base: &mc::Place<'tcx>,
496+
base_place: &mc::Place<'tcx>,
497497
autoref: &adjustment::AutoBorrow<'tcx>) {
498-
debug!("walk_autoref(expr.hir_id={} cmt_base={:?} autoref={:?})",
498+
debug!("walk_autoref(expr.hir_id={} base_place={:?} autoref={:?})",
499499
expr.hir_id,
500-
cmt_base,
500+
base_place,
501501
autoref);
502502

503503
match *autoref {
504504
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()));
506506
}
507507

508508
adjustment::AutoBorrow::RawPtr(m) => {
509-
debug!("walk_autoref: expr.hir_id={} cmt_base={:?}",
509+
debug!("walk_autoref: expr.hir_id={} base_place={:?}",
510510
expr.hir_id,
511-
cmt_base);
511+
base_place);
512512

513513

514-
self.delegate.borrow(cmt_base, ty::BorrowKind::from_mutbl(m));
514+
self.delegate.borrow(base_place, ty::BorrowKind::from_mutbl(m));
515515
}
516516
}
517517
}
@@ -556,8 +556,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
556556
// Each match binding is effectively an assignment to the
557557
// binding being produced.
558558
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);
561561
}
562562

563563
// It is also a borrow or copy/move of the value being matched.
@@ -590,16 +590,18 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
590590
closure_expr_id: closure_def_id.to_local(),
591591
};
592592
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+
));
596598
match upvar_capture {
597599
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);
600602
}
601603
ty::UpvarCapture::ByRef(upvar_borrow) => {
602-
self.delegate.borrow(&cmt_var, upvar_borrow.kind);
604+
self.delegate.borrow(&captured_place, upvar_borrow.kind);
603605
}
604606
}
605607
}
@@ -611,7 +613,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
611613
closure_span: Span,
612614
var_id: hir::HirId)
613615
-> 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
615617
// perspective of the creator (parent) of the closure.
616618
let var_ty = self.mc.node_ty(var_id)?;
617619
self.mc.cat_res(closure_hir_id, closure_span, var_ty, Res::Local(var_id))

src/librustc/middle/mem_categorization.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,16 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
529529
mutbl,
530530
});
531531

532-
let base_cmt = self.cat_rvalue(expr.hir_id, expr.span, ref_ty);
533-
self.cat_deref(expr, base_cmt)
532+
let base = self.cat_rvalue(expr.hir_id, expr.span, ref_ty);
533+
self.cat_deref(expr, base)
534534
}
535535

536536
fn cat_deref(
537537
&self,
538538
node: &impl HirNode,
539539
base_place: Place<'tcx>,
540540
) -> McResult<Place<'tcx>> {
541-
debug!("cat_deref: base_cmt={:?}", base_place);
541+
debug!("cat_deref: base_place={:?}", base_place);
542542

543543
let base_ty = base_place.ty;
544544
let deref_ty = match base_ty.builtin_deref(true) {
@@ -598,7 +598,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
598598
// `&&Some(x,)` `place_foo`
599599
// `&Some(x,)` `deref { place_foo}`
600600
// `Some(x,)` `deref { deref { place_foo }}`
601-
// (x,)` `field0 { deref { deref { place_foo }}}` <- resulting cmt
601+
// (x,)` `field0 { deref { deref { place_foo }}}` <- resulting place
602602
//
603603
// The above example has no adjustments. If the code were instead the (after adjustments,
604604
// equivalent) version
@@ -625,14 +625,14 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
625625
let place = place; // lose mutability
626626
debug!("cat_pattern: applied adjustment derefs to get place={:?}", place);
627627

628-
// Invoke the callback, but only now, after the `cmt` has adjusted.
628+
// Invoke the callback, but only now, after the `place` has adjusted.
629629
//
630630
// To see that this makes sense, consider `match &Some(3) { Some(x) => { ... }}`. In that
631-
// case, the initial `cmt` will be that for `&Some(3)` and the pattern is `Some(x)`. We
631+
// case, the initial `place` will be that for `&Some(3)` and the pattern is `Some(x)`. We
632632
// don't want to call `op` with these incompatible values. As written, what happens instead
633-
// is that `op` is called with the adjusted cmt (that for `*&Some(3)`) and the pattern
633+
// is that `op` is called with the adjusted place (that for `*&Some(3)`) and the pattern
634634
// `Some(x)` (which matches). Recursing once more, `*&Some(3)` and the pattern `Some(x)`
635-
// result in the cmt `Downcast<Some>(*&Some(3)).0` associated to `x` and invoke `op` with
635+
// result in the place `Downcast<Some>(*&Some(3)).0` associated to `x` and invoke `op` with
636636
// that (where the `ref` on `x` is implied).
637637
op(&place, pat);
638638

@@ -651,8 +651,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
651651
// S { f1: p1, ..., fN: pN }
652652
for fp in field_pats {
653653
let field_ty = self.pat_ty_adjusted(&fp.pat)?;
654-
let cmt_field = self.cat_projection(pat, place.clone(), field_ty);
655-
self.cat_pattern_(cmt_field, &fp.pat, op)?;
654+
let field_place = self.cat_projection(pat, place.clone(), field_ty);
655+
self.cat_pattern_(field_place, &fp.pat, op)?;
656656
}
657657
}
658658

src/librustc_typeck/check/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
341341
self.adjust_upvar_captures.insert(upvar_id, ty::UpvarCapture::ByValue);
342342
}
343343

344-
/// Indicates that `cmt` is being directly mutated (e.g., assigned
344+
/// Indicates that `place` is being directly mutated (e.g., assigned
345345
/// to). If the place is based on a by-ref upvar, this implies that
346346
/// the upvar must be borrowed using an `&mut` borrow.
347347
fn adjust_upvar_borrow_kind_for_mut(&mut self, place: &mc::Place<'tcx>) {

0 commit comments

Comments
 (0)