Skip to content

Commit 90eb44a

Browse files
committed
Auto merge of #47837 - eddyb:going-places, r=nikomatsakis
Replace "lvalue" terminology with "place". See #46425 for the previous PR (which only changed MIR-related code). r? @nikomatsakis
2 parents 70f7d58 + bba81c9 commit 90eb44a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+470
-483
lines changed

src/librustc/middle/liveness.rs

+34-34
Original file line numberDiff line numberDiff line change
@@ -1034,10 +1034,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10341034
}
10351035

10361036
hir::ExprAssign(ref l, ref r) => {
1037-
// see comment on lvalues in
1038-
// propagate_through_lvalue_components()
1039-
let succ = self.write_lvalue(&l, succ, ACC_WRITE);
1040-
let succ = self.propagate_through_lvalue_components(&l, succ);
1037+
// see comment on places in
1038+
// propagate_through_place_components()
1039+
let succ = self.write_place(&l, succ, ACC_WRITE);
1040+
let succ = self.propagate_through_place_components(&l, succ);
10411041
self.propagate_through_expr(&r, succ)
10421042
}
10431043

@@ -1047,11 +1047,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10471047
let succ = self.propagate_through_expr(&l, succ);
10481048
self.propagate_through_expr(&r, succ)
10491049
} else {
1050-
// see comment on lvalues in
1051-
// propagate_through_lvalue_components()
1052-
let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ);
1050+
// see comment on places in
1051+
// propagate_through_place_components()
1052+
let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ);
10531053
let succ = self.propagate_through_expr(&r, succ);
1054-
self.propagate_through_lvalue_components(&l, succ)
1054+
self.propagate_through_place_components(&l, succ)
10551055
}
10561056
}
10571057

@@ -1121,14 +1121,14 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11211121

11221122
hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => {
11231123
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
1124-
// see comment on lvalues
1125-
// in propagate_through_lvalue_components()
1124+
// see comment on places
1125+
// in propagate_through_place_components()
11261126
if o.is_indirect {
11271127
self.propagate_through_expr(output, succ)
11281128
} else {
11291129
let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE };
1130-
let succ = self.write_lvalue(output, succ, acc);
1131-
self.propagate_through_lvalue_components(output, succ)
1130+
let succ = self.write_place(output, succ, acc);
1131+
self.propagate_through_place_components(output, succ)
11321132
}
11331133
});
11341134

@@ -1146,11 +1146,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11461146
}
11471147
}
11481148

1149-
fn propagate_through_lvalue_components(&mut self,
1149+
fn propagate_through_place_components(&mut self,
11501150
expr: &Expr,
11511151
succ: LiveNode)
11521152
-> LiveNode {
1153-
// # Lvalues
1153+
// # Places
11541154
//
11551155
// In general, the full flow graph structure for an
11561156
// assignment/move/etc can be handled in one of two ways,
@@ -1160,15 +1160,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11601160
//
11611161
// The two kinds of graphs are:
11621162
//
1163-
// Tracked lvalue Untracked lvalue
1163+
// Tracked place Untracked place
11641164
// ----------------------++-----------------------
11651165
// ||
11661166
// | || |
11671167
// v || v
11681168
// (rvalue) || (rvalue)
11691169
// | || |
11701170
// v || v
1171-
// (write of lvalue) || (lvalue components)
1171+
// (write of place) || (place components)
11721172
// | || |
11731173
// v || v
11741174
// (succ) || (succ)
@@ -1177,25 +1177,25 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11771177
//
11781178
// I will cover the two cases in turn:
11791179
//
1180-
// # Tracked lvalues
1180+
// # Tracked places
11811181
//
1182-
// A tracked lvalue is a local variable/argument `x`. In
1182+
// A tracked place is a local variable/argument `x`. In
11831183
// these cases, the link_node where the write occurs is linked
1184-
// to node id of `x`. The `write_lvalue()` routine generates
1184+
// to node id of `x`. The `write_place()` routine generates
11851185
// the contents of this node. There are no subcomponents to
11861186
// consider.
11871187
//
1188-
// # Non-tracked lvalues
1188+
// # Non-tracked places
11891189
//
1190-
// These are lvalues like `x[5]` or `x.f`. In that case, we
1190+
// These are places like `x[5]` or `x.f`. In that case, we
11911191
// basically ignore the value which is written to but generate
11921192
// reads for the components---`x` in these two examples. The
11931193
// components reads are generated by
1194-
// `propagate_through_lvalue_components()` (this fn).
1194+
// `propagate_through_place_components()` (this fn).
11951195
//
1196-
// # Illegal lvalues
1196+
// # Illegal places
11971197
//
1198-
// It is still possible to observe assignments to non-lvalues;
1198+
// It is still possible to observe assignments to non-places;
11991199
// these errors are detected in the later pass borrowck. We
12001200
// just ignore such cases and treat them as reads.
12011201

@@ -1207,17 +1207,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
12071207
}
12081208
}
12091209

1210-
// see comment on propagate_through_lvalue()
1211-
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
1210+
// see comment on propagate_through_place()
1211+
fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
12121212
-> LiveNode {
12131213
match expr.node {
12141214
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
12151215
self.access_path(expr.id, path, succ, acc)
12161216
}
12171217

1218-
// We do not track other lvalues, so just propagate through
1218+
// We do not track other places, so just propagate through
12191219
// to their subcomponents. Also, it may happen that
1220-
// non-lvalues occur here, because those are detected in the
1220+
// non-places occur here, because those are detected in the
12211221
// later pass borrowck.
12221222
_ => succ
12231223
}
@@ -1363,14 +1363,14 @@ fn check_arm<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, arm: &'tcx hir::Arm) {
13631363
fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
13641364
match expr.node {
13651365
hir::ExprAssign(ref l, _) => {
1366-
this.check_lvalue(&l);
1366+
this.check_place(&l);
13671367

13681368
intravisit::walk_expr(this, expr);
13691369
}
13701370

13711371
hir::ExprAssignOp(_, ref l, _) => {
13721372
if !this.tables.is_method_call(expr) {
1373-
this.check_lvalue(&l);
1373+
this.check_place(&l);
13741374
}
13751375

13761376
intravisit::walk_expr(this, expr);
@@ -1381,10 +1381,10 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
13811381
this.visit_expr(input);
13821382
}
13831383

1384-
// Output operands must be lvalues
1384+
// Output operands must be places
13851385
for (o, output) in ia.outputs.iter().zip(outputs) {
13861386
if !o.is_indirect {
1387-
this.check_lvalue(output);
1387+
this.check_place(output);
13881388
}
13891389
this.visit_expr(output);
13901390
}
@@ -1409,7 +1409,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
14091409
}
14101410

14111411
impl<'a, 'tcx> Liveness<'a, 'tcx> {
1412-
fn check_lvalue(&mut self, expr: &'tcx Expr) {
1412+
fn check_place(&mut self, expr: &'tcx Expr) {
14131413
match expr.node {
14141414
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
14151415
if let Def::Local(nid) = path.def {
@@ -1423,7 +1423,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
14231423
}
14241424
}
14251425
_ => {
1426-
// For other kinds of lvalues, no checks are required,
1426+
// For other kinds of places, no checks are required,
14271427
// and any embedded expressions are actually rvalues
14281428
intravisit::walk_expr(self, expr);
14291429
}

src/librustc/middle/mem_categorization.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
//! | E.comp // access to an interior component
2727
//!
2828
//! Imagine a routine ToAddr(Expr) that evaluates an expression and returns an
29-
//! address where the result is to be found. If Expr is an lvalue, then this
30-
//! is the address of the lvalue. If Expr is an rvalue, this is the address of
29+
//! address where the result is to be found. If Expr is a place, then this
30+
//! is the address of the place. If Expr is an rvalue, this is the address of
3131
//! some temporary spot in memory where the result is stored.
3232
//!
3333
//! Now, cat_expr() classifies the expression Expr and the address A=ToAddr(Expr)
@@ -182,7 +182,7 @@ pub struct cmt_<'tcx> {
182182
pub id: ast::NodeId, // id of expr/pat producing this value
183183
pub span: Span, // span of same expr/pat
184184
pub cat: Categorization<'tcx>, // categorization of expr
185-
pub mutbl: MutabilityCategory, // mutability of expr as lvalue
185+
pub mutbl: MutabilityCategory, // mutability of expr as place
186186
pub ty: Ty<'tcx>, // type of the expr (*see WARNING above*)
187187
pub note: Note, // Note about the provenance of this cmt
188188
}
@@ -517,7 +517,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
517517
// a bind-by-ref means that the base_ty will be the type of the ident itself,
518518
// but what we want here is the type of the underlying value being borrowed.
519519
// So peel off one-level, turning the &T into T.
520-
match base_ty.builtin_deref(false, ty::NoPreference) {
520+
match base_ty.builtin_deref(false) {
521521
Some(t) => t.ty,
522522
None => {
523523
debug!("By-ref binding of non-derefable type {:?}", base_ty);
@@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
603603
match expr.node {
604604
hir::ExprUnary(hir::UnDeref, ref e_base) => {
605605
if self.tables.is_method_call(expr) {
606-
self.cat_overloaded_lvalue(expr, e_base, false)
606+
self.cat_overloaded_place(expr, e_base, false)
607607
} else {
608608
let base_cmt = self.cat_expr(&e_base)?;
609609
self.cat_deref(expr, base_cmt, false)
@@ -631,7 +631,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
631631
// The call to index() returns a `&T` value, which
632632
// is an rvalue. That is what we will be
633633
// dereferencing.
634-
self.cat_overloaded_lvalue(expr, base, true)
634+
self.cat_overloaded_place(expr, base, true)
635635
} else {
636636
let base_cmt = self.cat_expr(&base)?;
637637
self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index)
@@ -983,27 +983,27 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
983983
ret
984984
}
985985

986-
fn cat_overloaded_lvalue(&self,
986+
fn cat_overloaded_place(&self,
987987
expr: &hir::Expr,
988988
base: &hir::Expr,
989989
implicit: bool)
990990
-> McResult<cmt<'tcx>> {
991-
debug!("cat_overloaded_lvalue: implicit={}", implicit);
991+
debug!("cat_overloaded_place: implicit={}", implicit);
992992

993993
// Reconstruct the output assuming it's a reference with the
994994
// same region and mutability as the receiver. This holds for
995995
// `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`.
996-
let lvalue_ty = self.expr_ty(expr)?;
996+
let place_ty = self.expr_ty(expr)?;
997997
let base_ty = self.expr_ty_adjusted(base)?;
998998

999999
let (region, mutbl) = match base_ty.sty {
10001000
ty::TyRef(region, mt) => (region, mt.mutbl),
10011001
_ => {
1002-
span_bug!(expr.span, "cat_overloaded_lvalue: base is not a reference")
1002+
span_bug!(expr.span, "cat_overloaded_place: base is not a reference")
10031003
}
10041004
};
10051005
let ref_ty = self.tcx.mk_ref(region, ty::TypeAndMut {
1006-
ty: lvalue_ty,
1006+
ty: place_ty,
10071007
mutbl,
10081008
});
10091009

@@ -1019,7 +1019,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
10191019
debug!("cat_deref: base_cmt={:?}", base_cmt);
10201020

10211021
let base_cmt_ty = base_cmt.ty;
1022-
let deref_ty = match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
1022+
let deref_ty = match base_cmt_ty.builtin_deref(true) {
10231023
Some(mt) => mt.ty,
10241024
None => {
10251025
debug!("Explicit deref of non-derefable type: {:?}",
@@ -1386,7 +1386,7 @@ impl<'tcx> cmt_<'tcx> {
13861386
}
13871387
}
13881388

1389-
/// Returns `FreelyAliasable(_)` if this lvalue represents a freely aliasable pointer type.
1389+
/// Returns `FreelyAliasable(_)` if this place represents a freely aliasable pointer type.
13901390
pub fn freely_aliasable(&self) -> Aliasability {
13911391
// Maybe non-obvious: copied upvars can only be considered
13921392
// non-aliasable in once closures, since any other kind can be
@@ -1453,7 +1453,7 @@ impl<'tcx> cmt_<'tcx> {
14531453
"static item".to_string()
14541454
}
14551455
Categorization::Rvalue(..) => {
1456-
"non-lvalue".to_string()
1456+
"non-place".to_string()
14571457
}
14581458
Categorization::Local(vid) => {
14591459
if tcx.hir.is_argument(vid) {

src/librustc/middle/region.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
11121112
// I mean that creating a binding into a ref-counted or managed value
11131113
// would still count.)
11141114
//
1115-
// 3. `ET`, which matches both rvalues like `foo()` as well as lvalues
1115+
// 3. `ET`, which matches both rvalues like `foo()` as well as places
11161116
// based on rvalues like `foo().x[2].y`.
11171117
//
11181118
// A subexpression `<rvalue>` that appears in a let initializer
@@ -1283,7 +1283,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
12831283
/// | (ET)
12841284
/// | <rvalue>
12851285
///
1286-
/// Note: ET is intended to match "rvalues or lvalues based on rvalues".
1286+
/// Note: ET is intended to match "rvalues or places based on rvalues".
12871287
fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
12881288
expr: &hir::Expr,
12891289
blk_scope: Option<Scope>) {

src/librustc/mir/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -733,29 +733,29 @@ pub enum TerminatorKind<'tcx> {
733733
},
734734

735735
/// Drop the Place and assign the new value over it. This ensures
736-
/// that the assignment to LV occurs *even if* the destructor for
736+
/// that the assignment to `P` occurs *even if* the destructor for
737737
/// place unwinds. Its semantics are best explained by by the
738738
/// elaboration:
739739
///
740740
/// ```
741741
/// BB0 {
742-
/// DropAndReplace(LV <- RV, goto BB1, unwind BB2)
742+
/// DropAndReplace(P <- V, goto BB1, unwind BB2)
743743
/// }
744744
/// ```
745745
///
746746
/// becomes
747747
///
748748
/// ```
749749
/// BB0 {
750-
/// Drop(LV, goto BB1, unwind BB2)
750+
/// Drop(P, goto BB1, unwind BB2)
751751
/// }
752752
/// BB1 {
753-
/// // LV is now unitialized
754-
/// LV <- RV
753+
/// // P is now unitialized
754+
/// P <- V
755755
/// }
756756
/// BB2 {
757-
/// // LV is now unitialized -- its dtor panicked
758-
/// LV <- RV
757+
/// // P is now unitialized -- its dtor panicked
758+
/// P <- V
759759
/// }
760760
/// ```
761761
DropAndReplace {

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
5252
match *elem {
5353
ProjectionElem::Deref => {
5454
let ty = self.to_ty(tcx)
55-
.builtin_deref(true, ty::LvaluePreference::NoPreference)
55+
.builtin_deref(true)
5656
.unwrap_or_else(|| {
5757
bug!("deref projection of non-dereferencable ty {:?}", self)
5858
})

src/librustc/ty/adjustment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub enum Adjust<'tcx> {
7777
/// Go from a mut raw pointer to a const raw pointer.
7878
MutToConstPointer,
7979

80-
/// Dereference once, producing an lvalue.
80+
/// Dereference once, producing a place.
8181
Deref(Option<OverloadedDeref<'tcx>>),
8282

8383
/// Take the address and produce either a `&` or `*` pointer.

0 commit comments

Comments
 (0)