Skip to content

Commit 4195b60

Browse files
committed
Rename cmt_ to Place
1 parent 04e69e4 commit 4195b60

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

src/librustc/middle/expr_use_visitor.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use syntax_pos::Span;
2525
pub trait Delegate<'tcx> {
2626
// The value found at `cmt` is either copied or moved, depending
2727
// on mode.
28-
fn consume(&mut self, cmt: &mc::cmt_<'tcx>, mode: ConsumeMode);
28+
fn consume(&mut self, cmt: &mc::Place<'tcx>, mode: ConsumeMode);
2929

3030
// The value found at `cmt` is being borrowed with kind `bk`.
31-
fn borrow(&mut self, cmt: &mc::cmt_<'tcx>, bk: ty::BorrowKind);
31+
fn borrow(&mut self, cmt: &mc::Place<'tcx>, bk: ty::BorrowKind);
3232

3333
// The path at `cmt` is being assigned to.
34-
fn mutate(&mut self, assignee_cmt: &mc::cmt_<'tcx>);
34+
fn mutate(&mut self, assignee_cmt: &mc::Place<'tcx>);
3535
}
3636

3737
#[derive(Copy, Clone, PartialEq, Debug)]
@@ -180,7 +180,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
180180
self.mc.tcx
181181
}
182182

183-
fn delegate_consume(&mut self, cmt: &mc::cmt_<'tcx>) {
183+
fn delegate_consume(&mut self, cmt: &mc::Place<'tcx>) {
184184
debug!("delegate_consume(cmt={:?})", cmt);
185185

186186
let mode = copy_or_move(&self.mc, self.param_env, cmt);
@@ -528,7 +528,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
528528
/// after all relevant autoderefs have occurred.
529529
fn walk_autoref(&mut self,
530530
expr: &hir::Expr,
531-
cmt_base: &mc::cmt_<'tcx>,
531+
cmt_base: &mc::Place<'tcx>,
532532
autoref: &adjustment::AutoBorrow<'tcx>) {
533533
debug!("walk_autoref(expr.hir_id={} cmt_base={:?} autoref={:?})",
534534
expr.hir_id,
@@ -645,7 +645,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
645645
closure_hir_id: hir::HirId,
646646
closure_span: Span,
647647
var_id: hir::HirId)
648-
-> mc::McResult<mc::cmt_<'tcx>> {
648+
-> mc::McResult<mc::Place<'tcx>> {
649649
// Create the cmt for the variable being borrowed, from the
650650
// perspective of the creator (parent) of the closure.
651651
let var_ty = self.mc.node_ty(var_id)?;
@@ -656,7 +656,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
656656
fn copy_or_move<'a, 'tcx>(
657657
mc: &mc::MemCategorizationContext<'a, 'tcx>,
658658
param_env: ty::ParamEnv<'tcx>,
659-
cmt: &mc::cmt_<'tcx>,
659+
cmt: &mc::Place<'tcx>,
660660
) -> ConsumeMode {
661661
if !mc.type_is_copy_modulo_regions(param_env, cmt.ty, cmt.span) {
662662
Move

src/librustc/middle/mem_categorization.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub enum Note {
184184
// dereference (`@T`). So use `cmt.ty` to find the type of the value in
185185
// a consistent fashion. For more details, see the method `cat_pattern`
186186
#[derive(Clone, Debug, PartialEq)]
187-
pub struct cmt_<'tcx> {
187+
pub struct Place<'tcx> {
188188
pub hir_id: hir::HirId, // HIR id of expr/pat producing this value
189189
pub span: Span, // span of same expr/pat
190190
pub cat: Categorization<'tcx>, // categorization of expr
@@ -193,7 +193,7 @@ pub struct cmt_<'tcx> {
193193
pub note: Note, // Note about the provenance of this cmt
194194
}
195195

196-
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
196+
pub type cmt<'tcx> = Rc<Place<'tcx>>;
197197

198198
pub trait HirNode {
199199
fn hir_id(&self) -> hir::HirId;
@@ -504,14 +504,14 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
504504
Ok(ret_ty)
505505
}
506506

507-
pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
507+
pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
508508
// This recursion helper avoids going through *too many*
509509
// adjustments, since *only* non-overloaded deref recurses.
510510
fn helper<'a, 'tcx>(
511511
mc: &MemCategorizationContext<'a, 'tcx>,
512512
expr: &hir::Expr,
513513
adjustments: &[adjustment::Adjustment<'tcx>],
514-
) -> McResult<cmt_<'tcx>> {
514+
) -> McResult<Place<'tcx>> {
515515
match adjustments.split_last() {
516516
None => mc.cat_expr_unadjusted(expr),
517517
Some((adjustment, previous)) => {
@@ -524,17 +524,17 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
524524
}
525525

526526
pub fn cat_expr_adjusted(&self, expr: &hir::Expr,
527-
previous: cmt_<'tcx>,
527+
previous: Place<'tcx>,
528528
adjustment: &adjustment::Adjustment<'tcx>)
529-
-> McResult<cmt_<'tcx>> {
529+
-> McResult<Place<'tcx>> {
530530
self.cat_expr_adjusted_with(expr, || Ok(previous), adjustment)
531531
}
532532

533533
fn cat_expr_adjusted_with<F>(&self, expr: &hir::Expr,
534534
previous: F,
535535
adjustment: &adjustment::Adjustment<'tcx>)
536-
-> McResult<cmt_<'tcx>>
537-
where F: FnOnce() -> McResult<cmt_<'tcx>>
536+
-> McResult<Place<'tcx>>
537+
where F: FnOnce() -> McResult<Place<'tcx>>
538538
{
539539
debug!("cat_expr_adjusted_with({:?}): {:?}", adjustment, expr);
540540
let target = self.resolve_vars_if_possible(&adjustment.target);
@@ -562,7 +562,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
562562
}
563563
}
564564

565-
pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
565+
pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
566566
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
567567

568568
let expr_ty = self.expr_ty(expr)?;
@@ -630,7 +630,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
630630
span: Span,
631631
expr_ty: Ty<'tcx>,
632632
res: Res)
633-
-> McResult<cmt_<'tcx>> {
633+
-> McResult<Place<'tcx>> {
634634
debug!("cat_res: id={:?} expr={:?} def={:?}",
635635
hir_id, expr_ty, res);
636636

@@ -658,7 +658,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
658658
Categorization::StaticItem
659659
};
660660

661-
Ok(cmt_ {
661+
Ok(Place {
662662
hir_id,
663663
span,
664664
cat,
@@ -675,7 +675,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
675675
if self.upvars.map_or(false, |upvars| upvars.contains_key(&var_id)) {
676676
self.cat_upvar(hir_id, span, var_id)
677677
} else {
678-
Ok(cmt_ {
678+
Ok(Place {
679679
hir_id,
680680
span,
681681
cat: Categorization::Local(var_id),
@@ -697,7 +697,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
697697
hir_id: hir::HirId,
698698
span: Span,
699699
var_id: hir::HirId,
700-
) -> McResult<cmt_<'tcx>> {
700+
) -> McResult<Place<'tcx>> {
701701
// An upvar can have up to 3 components. We translate first to a
702702
// `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the
703703
// field from the environment.
@@ -758,7 +758,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
758758
// Construct the upvar. This represents access to the field
759759
// from the environment (perhaps we should eventually desugar
760760
// this field further, but it will do for now).
761-
let cmt_result = cmt_ {
761+
let cmt_result = Place {
762762
hir_id,
763763
span,
764764
cat: Categorization::Upvar(Upvar {id: upvar_id, kind: kind}),
@@ -792,7 +792,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
792792
}
793793
ty::UpvarCapture::ByRef(upvar_borrow) => {
794794
let ptr = BorrowedPtr(upvar_borrow.kind, upvar_borrow.region);
795-
cmt_ {
795+
Place {
796796
hir_id,
797797
span,
798798
cat: Categorization::Deref(Rc::new(cmt_result), ptr),
@@ -814,8 +814,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
814814
upvar_id: ty::UpvarId,
815815
upvar_mutbl: MutabilityCategory,
816816
env_borrow_kind: ty::BorrowKind,
817-
cmt_result: cmt_<'tcx>)
818-
-> cmt_<'tcx>
817+
cmt_result: Place<'tcx>)
818+
-> Place<'tcx>
819819
{
820820
// Region of environment pointer
821821
let env_region = self.tcx.mk_region(ty::ReFree(ty::FreeRegion {
@@ -837,7 +837,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
837837
// away with stuffing a `Error` in there
838838
// instead of bothering to construct a proper
839839
// one.
840-
let cmt_result = cmt_ {
840+
let cmt_result = Place {
841841
mutbl: McImmutable,
842842
ty: self.tcx.types.err,
843843
..cmt_result
@@ -852,7 +852,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
852852
McDeclared | McInherited => { }
853853
}
854854

855-
let ret = cmt_ {
855+
let ret = Place {
856856
hir_id,
857857
span,
858858
cat: Categorization::Deref(Rc::new(cmt_result), env_ptr),
@@ -870,7 +870,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
870870
hir_id: hir::HirId,
871871
span: Span,
872872
expr_ty: Ty<'tcx>)
873-
-> cmt_<'tcx> {
873+
-> Place<'tcx> {
874874
debug!("cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})",
875875
hir_id, span, expr_ty);
876876

@@ -882,8 +882,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
882882
pub fn cat_rvalue(&self,
883883
cmt_hir_id: hir::HirId,
884884
span: Span,
885-
expr_ty: Ty<'tcx>) -> cmt_<'tcx> {
886-
let ret = cmt_ {
885+
expr_ty: Ty<'tcx>) -> Place<'tcx> {
886+
let ret = Place {
887887
hir_id: cmt_hir_id,
888888
span:span,
889889
cat:Categorization::Rvalue,
@@ -901,8 +901,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
901901
f_index: usize,
902902
f_ident: ast::Ident,
903903
f_ty: Ty<'tcx>)
904-
-> cmt_<'tcx> {
905-
let ret = cmt_ {
904+
-> Place<'tcx> {
905+
let ret = Place {
906906
hir_id: node.hir_id(),
907907
span: node.span(),
908908
mutbl: base_cmt.mutbl.inherit(),
@@ -920,7 +920,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
920920
expr: &hir::Expr,
921921
base: &hir::Expr,
922922
note: Note,
923-
) -> McResult<cmt_<'tcx>> {
923+
) -> McResult<Place<'tcx>> {
924924
debug!("cat_overloaded_place(expr={:?}, base={:?}, note={:?})",
925925
expr,
926926
base,
@@ -950,7 +950,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
950950
node: &impl HirNode,
951951
base_cmt: cmt<'tcx>,
952952
note: Note,
953-
) -> McResult<cmt_<'tcx>> {
953+
) -> McResult<Place<'tcx>> {
954954
debug!("cat_deref: base_cmt={:?}", base_cmt);
955955

956956
let base_cmt_ty = base_cmt.ty;
@@ -971,7 +971,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
971971
}
972972
_ => bug!("unexpected type in cat_deref: {:?}", base_cmt.ty)
973973
};
974-
let ret = cmt_ {
974+
let ret = Place {
975975
hir_id: node.hir_id(),
976976
span: node.span(),
977977
// For unique ptrs, we inherit mutability from the owning reference.
@@ -989,7 +989,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
989989
base_cmt: cmt<'tcx>,
990990
element_ty: Ty<'tcx>,
991991
context: InteriorOffsetKind)
992-
-> McResult<cmt_<'tcx>> {
992+
-> McResult<Place<'tcx>> {
993993
//! Creates a cmt for an indexing operation (`[]`).
994994
//!
995995
//! One subtle aspect of indexing that may not be
@@ -1018,8 +1018,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
10181018
base_cmt: cmt<'tcx>,
10191019
interior_ty: Ty<'tcx>,
10201020
interior: InteriorKind)
1021-
-> cmt_<'tcx> {
1022-
let ret = cmt_ {
1021+
-> Place<'tcx> {
1022+
let ret = Place {
10231023
hir_id: node.hir_id(),
10241024
span: node.span(),
10251025
mutbl: base_cmt.mutbl.inherit(),
@@ -1040,7 +1040,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
10401040
let base_did = self.tcx.parent(variant_did).unwrap();
10411041
if self.tcx.adt_def(base_did).variants.len() != 1 {
10421042
let base_ty = base_cmt.ty;
1043-
let ret = Rc::new(cmt_ {
1043+
let ret = Rc::new(Place {
10441044
hir_id: node.hir_id(),
10451045
span: node.span(),
10461046
mutbl: base_cmt.mutbl.inherit(),
@@ -1327,8 +1327,8 @@ pub enum AliasableReason {
13271327
AliasableStaticMut,
13281328
}
13291329

1330-
impl<'tcx> cmt_<'tcx> {
1331-
pub fn guarantor(&self) -> cmt_<'tcx> {
1330+
impl<'tcx> Place<'tcx> {
1331+
pub fn guarantor(&self) -> Place<'tcx> {
13321332
//! Returns `self` after stripping away any derefs or
13331333
//! interior content. The return value is basically the `cmt` which
13341334
//! determines how long the value in `self` remains live.

src/librustc_typeck/check/regionck.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
825825

826826
/// Invoked on any adjustments that occur. Checks that if this is a region pointer being
827827
/// dereferenced, the lifetime of the pointer includes the deref expr.
828-
fn constrain_adjustments(&mut self, expr: &hir::Expr) -> mc::McResult<mc::cmt_<'tcx>> {
828+
fn constrain_adjustments(&mut self, expr: &hir::Expr) -> mc::McResult<mc::Place<'tcx>> {
829829
debug!("constrain_adjustments(expr={:?})", expr);
830830

831831
let mut cmt = self.with_mc(|mc| mc.cat_expr_unadjusted(expr))?;
@@ -921,7 +921,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
921921
)
922922
}
923923

924-
fn check_safety_of_rvalue_destructor_if_necessary(&mut self, cmt: &mc::cmt_<'tcx>, span: Span) {
924+
fn check_safety_of_rvalue_destructor_if_necessary(&mut self, cmt: &mc::Place<'tcx>, span: Span) {
925925
if let Categorization::Rvalue = cmt.cat {
926926
let typ = self.resolve_type(cmt.ty);
927927
let body_id = self.body_id;
@@ -1100,7 +1100,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
11001100
fn link_autoref(
11011101
&self,
11021102
expr: &hir::Expr,
1103-
expr_cmt: &mc::cmt_<'tcx>,
1103+
expr_cmt: &mc::Place<'tcx>,
11041104
autoref: &adjustment::AutoBorrow<'tcx>,
11051105
) {
11061106
debug!(
@@ -1130,7 +1130,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
11301130
span: Span,
11311131
id: hir::HirId,
11321132
mutbl: hir::Mutability,
1133-
cmt_borrowed: &mc::cmt_<'tcx>,
1133+
cmt_borrowed: &mc::Place<'tcx>,
11341134
) {
11351135
debug!(
11361136
"link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={:?})",
@@ -1153,7 +1153,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
11531153
span: Span,
11541154
borrow_region: ty::Region<'tcx>,
11551155
borrow_kind: ty::BorrowKind,
1156-
borrow_cmt: &mc::cmt_<'tcx>,
1156+
borrow_cmt: &mc::Place<'tcx>,
11571157
) {
11581158
let origin = infer::DataBorrowed(borrow_cmt.ty, span);
11591159
self.type_must_outlive(origin, borrow_cmt.ty, borrow_region);

0 commit comments

Comments
 (0)