Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace "lvalue" terminology with "place". #47837

Merged
merged 7 commits into from
Jan 29, 2018
Merged
68 changes: 34 additions & 34 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}

hir::ExprAssign(ref l, ref r) => {
// see comment on lvalues in
// propagate_through_lvalue_components()
let succ = self.write_lvalue(&l, succ, ACC_WRITE);
let succ = self.propagate_through_lvalue_components(&l, succ);
// see comment on places in
// propagate_through_place_components()
let succ = self.write_place(&l, succ, ACC_WRITE);
let succ = self.propagate_through_place_components(&l, succ);
self.propagate_through_expr(&r, succ)
}

Expand All @@ -1047,11 +1047,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let succ = self.propagate_through_expr(&l, succ);
self.propagate_through_expr(&r, succ)
} else {
// see comment on lvalues in
// propagate_through_lvalue_components()
let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ);
// see comment on places in
// propagate_through_place_components()
let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ);
let succ = self.propagate_through_expr(&r, succ);
self.propagate_through_lvalue_components(&l, succ)
self.propagate_through_place_components(&l, succ)
}
}

Expand Down Expand Up @@ -1121,14 +1121,14 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {

hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => {
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
// see comment on lvalues
// in propagate_through_lvalue_components()
// see comment on places
// in propagate_through_place_components()
if o.is_indirect {
self.propagate_through_expr(output, succ)
} else {
let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE };
let succ = self.write_lvalue(output, succ, acc);
self.propagate_through_lvalue_components(output, succ)
let succ = self.write_place(output, succ, acc);
self.propagate_through_place_components(output, succ)
}
});

Expand All @@ -1146,11 +1146,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}

fn propagate_through_lvalue_components(&mut self,
fn propagate_through_place_components(&mut self,
expr: &Expr,
succ: LiveNode)
-> LiveNode {
// # Lvalues
// # Places
//
// In general, the full flow graph structure for an
// assignment/move/etc can be handled in one of two ways,
Expand All @@ -1160,15 +1160,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
//
// The two kinds of graphs are:
//
// Tracked lvalue Untracked lvalue
// Tracked place Untracked place
// ----------------------++-----------------------
// ||
// | || |
// v || v
// (rvalue) || (rvalue)
// | || |
// v || v
// (write of lvalue) || (lvalue components)
// (write of place) || (place components)
// | || |
// v || v
// (succ) || (succ)
Expand All @@ -1177,25 +1177,25 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
//
// I will cover the two cases in turn:
//
// # Tracked lvalues
// # Tracked places
//
// A tracked lvalue is a local variable/argument `x`. In
// A tracked place is a local variable/argument `x`. In
// these cases, the link_node where the write occurs is linked
// to node id of `x`. The `write_lvalue()` routine generates
// to node id of `x`. The `write_place()` routine generates
// the contents of this node. There are no subcomponents to
// consider.
//
// # Non-tracked lvalues
// # Non-tracked places
//
// These are lvalues like `x[5]` or `x.f`. In that case, we
// These are places like `x[5]` or `x.f`. In that case, we
// basically ignore the value which is written to but generate
// reads for the components---`x` in these two examples. The
// components reads are generated by
// `propagate_through_lvalue_components()` (this fn).
// `propagate_through_place_components()` (this fn).
//
// # Illegal lvalues
// # Illegal places
//
// It is still possible to observe assignments to non-lvalues;
// It is still possible to observe assignments to non-places;
// these errors are detected in the later pass borrowck. We
// just ignore such cases and treat them as reads.

Expand All @@ -1207,17 +1207,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}

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

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

intravisit::walk_expr(this, expr);
}

hir::ExprAssignOp(_, ref l, _) => {
if !this.tables.is_method_call(expr) {
this.check_lvalue(&l);
this.check_place(&l);
}

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

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

impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn check_lvalue(&mut self, expr: &'tcx Expr) {
fn check_place(&mut self, expr: &'tcx Expr) {
match expr.node {
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
if let Def::Local(nid) = path.def {
Expand All @@ -1423,7 +1423,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
_ => {
// For other kinds of lvalues, no checks are required,
// For other kinds of places, no checks are required,
// and any embedded expressions are actually rvalues
intravisit::walk_expr(self, expr);
}
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
//! | E.comp // access to an interior component
//!
//! Imagine a routine ToAddr(Expr) that evaluates an expression and returns an
//! address where the result is to be found. If Expr is an lvalue, then this
//! is the address of the lvalue. If Expr is an rvalue, this is the address of
//! address where the result is to be found. If Expr is a place, then this
//! is the address of the place. If Expr is an rvalue, this is the address of
//! some temporary spot in memory where the result is stored.
//!
//! Now, cat_expr() classifies the expression Expr and the address A=ToAddr(Expr)
Expand Down Expand Up @@ -182,7 +182,7 @@ pub struct cmt_<'tcx> {
pub id: ast::NodeId, // id of expr/pat producing this value
pub span: Span, // span of same expr/pat
pub cat: Categorization<'tcx>, // categorization of expr
pub mutbl: MutabilityCategory, // mutability of expr as lvalue
pub mutbl: MutabilityCategory, // mutability of expr as place
pub ty: Ty<'tcx>, // type of the expr (*see WARNING above*)
pub note: Note, // Note about the provenance of this cmt
}
Expand Down Expand Up @@ -517,7 +517,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// a bind-by-ref means that the base_ty will be the type of the ident itself,
// but what we want here is the type of the underlying value being borrowed.
// So peel off one-level, turning the &T into T.
match base_ty.builtin_deref(false, ty::NoPreference) {
match base_ty.builtin_deref(false) {
Some(t) => t.ty,
None => {
debug!("By-ref binding of non-derefable type {:?}", base_ty);
Expand Down Expand Up @@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
match expr.node {
hir::ExprUnary(hir::UnDeref, ref e_base) => {
if self.tables.is_method_call(expr) {
self.cat_overloaded_lvalue(expr, e_base, false)
self.cat_overloaded_place(expr, e_base, false)
} else {
let base_cmt = self.cat_expr(&e_base)?;
self.cat_deref(expr, base_cmt, false)
Expand Down Expand Up @@ -631,7 +631,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// The call to index() returns a `&T` value, which
// is an rvalue. That is what we will be
// dereferencing.
self.cat_overloaded_lvalue(expr, base, true)
self.cat_overloaded_place(expr, base, true)
} else {
let base_cmt = self.cat_expr(&base)?;
self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index)
Expand Down Expand Up @@ -983,27 +983,27 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
ret
}

fn cat_overloaded_lvalue(&self,
fn cat_overloaded_place(&self,
expr: &hir::Expr,
base: &hir::Expr,
implicit: bool)
-> McResult<cmt<'tcx>> {
debug!("cat_overloaded_lvalue: implicit={}", implicit);
debug!("cat_overloaded_place: implicit={}", implicit);

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

let (region, mutbl) = match base_ty.sty {
ty::TyRef(region, mt) => (region, mt.mutbl),
_ => {
span_bug!(expr.span, "cat_overloaded_lvalue: base is not a reference")
span_bug!(expr.span, "cat_overloaded_place: base is not a reference")
}
};
let ref_ty = self.tcx.mk_ref(region, ty::TypeAndMut {
ty: lvalue_ty,
ty: place_ty,
mutbl,
});

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

let base_cmt_ty = base_cmt.ty;
let deref_ty = match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
let deref_ty = match base_cmt_ty.builtin_deref(true) {
Some(mt) => mt.ty,
None => {
debug!("Explicit deref of non-derefable type: {:?}",
Expand Down Expand Up @@ -1386,7 +1386,7 @@ impl<'tcx> cmt_<'tcx> {
}
}

/// Returns `FreelyAliasable(_)` if this lvalue represents a freely aliasable pointer type.
/// Returns `FreelyAliasable(_)` if this place represents a freely aliasable pointer type.
pub fn freely_aliasable(&self) -> Aliasability {
// Maybe non-obvious: copied upvars can only be considered
// non-aliasable in once closures, since any other kind can be
Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl<'tcx> cmt_<'tcx> {
"static item".to_string()
}
Categorization::Rvalue(..) => {
"non-lvalue".to_string()
"non-place".to_string()
}
Categorization::Local(vid) => {
if tcx.hir.is_argument(vid) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
// I mean that creating a binding into a ref-counted or managed value
// would still count.)
//
// 3. `ET`, which matches both rvalues like `foo()` as well as lvalues
// 3. `ET`, which matches both rvalues like `foo()` as well as places
// based on rvalues like `foo().x[2].y`.
//
// A subexpression `<rvalue>` that appears in a let initializer
Expand Down Expand Up @@ -1283,7 +1283,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
/// | (ET)
/// | <rvalue>
///
/// Note: ET is intended to match "rvalues or lvalues based on rvalues".
/// Note: ET is intended to match "rvalues or places based on rvalues".
fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
expr: &hir::Expr,
blk_scope: Option<Scope>) {
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,29 +733,29 @@ pub enum TerminatorKind<'tcx> {
},

/// Drop the Place and assign the new value over it. This ensures
/// that the assignment to LV occurs *even if* the destructor for
/// that the assignment to `P` occurs *even if* the destructor for
/// place unwinds. Its semantics are best explained by by the
/// elaboration:
///
/// ```
/// BB0 {
/// DropAndReplace(LV <- RV, goto BB1, unwind BB2)
/// DropAndReplace(P <- V, goto BB1, unwind BB2)
/// }
/// ```
///
/// becomes
///
/// ```
/// BB0 {
/// Drop(LV, goto BB1, unwind BB2)
/// Drop(P, goto BB1, unwind BB2)
/// }
/// BB1 {
/// // LV is now unitialized
/// LV <- RV
/// // P is now unitialized
/// P <- V
/// }
/// BB2 {
/// // LV is now unitialized -- its dtor panicked
/// LV <- RV
/// // P is now unitialized -- its dtor panicked
/// P <- V
/// }
/// ```
DropAndReplace {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
match *elem {
ProjectionElem::Deref => {
let ty = self.to_ty(tcx)
.builtin_deref(true, ty::LvaluePreference::NoPreference)
.builtin_deref(true)
.unwrap_or_else(|| {
bug!("deref projection of non-dereferencable ty {:?}", self)
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum Adjust<'tcx> {
/// Go from a mut raw pointer to a const raw pointer.
MutToConstPointer,

/// Dereference once, producing an lvalue.
/// Dereference once, producing a place.
Deref(Option<OverloadedDeref<'tcx>>),

/// Take the address and produce either a `&` or `*` pointer.
Expand Down
Loading