mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 14:57:14 +00:00
rustc: replace "lvalue" terminology with "place" in the code.
This commit is contained in:
parent
06a0e4f7ae
commit
46a9bdda78
@ -1034,10 +1034,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprAssign(ref l, ref r) => {
|
hir::ExprAssign(ref l, ref r) => {
|
||||||
// see comment on lvalues in
|
// see comment on places in
|
||||||
// propagate_through_lvalue_components()
|
// propagate_through_place_components()
|
||||||
let succ = self.write_lvalue(&l, succ, ACC_WRITE);
|
let succ = self.write_place(&l, succ, ACC_WRITE);
|
||||||
let succ = self.propagate_through_lvalue_components(&l, succ);
|
let succ = self.propagate_through_place_components(&l, succ);
|
||||||
self.propagate_through_expr(&r, succ)
|
self.propagate_through_expr(&r, succ)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,11 +1047,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
let succ = self.propagate_through_expr(&l, succ);
|
let succ = self.propagate_through_expr(&l, succ);
|
||||||
self.propagate_through_expr(&r, succ)
|
self.propagate_through_expr(&r, succ)
|
||||||
} else {
|
} else {
|
||||||
// see comment on lvalues in
|
// see comment on places in
|
||||||
// propagate_through_lvalue_components()
|
// propagate_through_place_components()
|
||||||
let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ);
|
let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ);
|
||||||
let succ = self.propagate_through_expr(&r, succ);
|
let succ = self.propagate_through_expr(&r, succ);
|
||||||
self.propagate_through_lvalue_components(&l, succ)
|
self.propagate_through_place_components(&l, succ)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1121,14 +1121,14 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
|
|
||||||
hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => {
|
hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => {
|
||||||
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
|
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
|
||||||
// see comment on lvalues
|
// see comment on places
|
||||||
// in propagate_through_lvalue_components()
|
// in propagate_through_place_components()
|
||||||
if o.is_indirect {
|
if o.is_indirect {
|
||||||
self.propagate_through_expr(output, succ)
|
self.propagate_through_expr(output, succ)
|
||||||
} else {
|
} else {
|
||||||
let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE };
|
let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE };
|
||||||
let succ = self.write_lvalue(output, succ, acc);
|
let succ = self.write_place(output, succ, acc);
|
||||||
self.propagate_through_lvalue_components(output, succ)
|
self.propagate_through_place_components(output, succ)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -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,
|
expr: &Expr,
|
||||||
succ: LiveNode)
|
succ: LiveNode)
|
||||||
-> LiveNode {
|
-> LiveNode {
|
||||||
// # Lvalues
|
// # Places
|
||||||
//
|
//
|
||||||
// In general, the full flow graph structure for an
|
// In general, the full flow graph structure for an
|
||||||
// assignment/move/etc can be handled in one of two ways,
|
// assignment/move/etc can be handled in one of two ways,
|
||||||
@ -1160,7 +1160,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
//
|
//
|
||||||
// The two kinds of graphs are:
|
// The two kinds of graphs are:
|
||||||
//
|
//
|
||||||
// Tracked lvalue Untracked lvalue
|
// Tracked place Untracked place
|
||||||
// ----------------------++-----------------------
|
// ----------------------++-----------------------
|
||||||
// ||
|
// ||
|
||||||
// | || |
|
// | || |
|
||||||
@ -1168,7 +1168,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
// (rvalue) || (rvalue)
|
// (rvalue) || (rvalue)
|
||||||
// | || |
|
// | || |
|
||||||
// v || v
|
// v || v
|
||||||
// (write of lvalue) || (lvalue components)
|
// (write of place) || (place components)
|
||||||
// | || |
|
// | || |
|
||||||
// v || v
|
// v || v
|
||||||
// (succ) || (succ)
|
// (succ) || (succ)
|
||||||
@ -1177,25 +1177,25 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
//
|
//
|
||||||
// I will cover the two cases in turn:
|
// 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
|
// 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
|
// the contents of this node. There are no subcomponents to
|
||||||
// consider.
|
// 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
|
// basically ignore the value which is written to but generate
|
||||||
// reads for the components---`x` in these two examples. The
|
// reads for the components---`x` in these two examples. The
|
||||||
// components reads are generated by
|
// 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
|
// these errors are detected in the later pass borrowck. We
|
||||||
// just ignore such cases and treat them as reads.
|
// just ignore such cases and treat them as reads.
|
||||||
|
|
||||||
@ -1207,17 +1207,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// see comment on propagate_through_lvalue()
|
// see comment on propagate_through_place()
|
||||||
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
|
fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
|
||||||
-> LiveNode {
|
-> LiveNode {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
|
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
|
||||||
self.access_path(expr.id, path, succ, acc)
|
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
|
// 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.
|
// later pass borrowck.
|
||||||
_ => succ
|
_ => succ
|
||||||
}
|
}
|
||||||
@ -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) {
|
fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprAssign(ref l, _) => {
|
hir::ExprAssign(ref l, _) => {
|
||||||
this.check_lvalue(&l);
|
this.check_place(&l);
|
||||||
|
|
||||||
intravisit::walk_expr(this, expr);
|
intravisit::walk_expr(this, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprAssignOp(_, ref l, _) => {
|
hir::ExprAssignOp(_, ref l, _) => {
|
||||||
if !this.tables.is_method_call(expr) {
|
if !this.tables.is_method_call(expr) {
|
||||||
this.check_lvalue(&l);
|
this.check_place(&l);
|
||||||
}
|
}
|
||||||
|
|
||||||
intravisit::walk_expr(this, expr);
|
intravisit::walk_expr(this, expr);
|
||||||
@ -1381,10 +1381,10 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
|
|||||||
this.visit_expr(input);
|
this.visit_expr(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output operands must be lvalues
|
// Output operands must be places
|
||||||
for (o, output) in ia.outputs.iter().zip(outputs) {
|
for (o, output) in ia.outputs.iter().zip(outputs) {
|
||||||
if !o.is_indirect {
|
if !o.is_indirect {
|
||||||
this.check_lvalue(output);
|
this.check_place(output);
|
||||||
}
|
}
|
||||||
this.visit_expr(output);
|
this.visit_expr(output);
|
||||||
}
|
}
|
||||||
@ -1409,7 +1409,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
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 {
|
match expr.node {
|
||||||
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
|
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
|
||||||
if let Def::Local(nid) = path.def {
|
if let Def::Local(nid) = path.def {
|
||||||
@ -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
|
// and any embedded expressions are actually rvalues
|
||||||
intravisit::walk_expr(self, expr);
|
intravisit::walk_expr(self, expr);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
//! | E.comp // access to an interior component
|
//! | E.comp // access to an interior component
|
||||||
//!
|
//!
|
||||||
//! Imagine a routine ToAddr(Expr) that evaluates an expression and returns an
|
//! 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
|
//! address where the result is to be found. If Expr is a place, then this
|
||||||
//! is the address of the lvalue. If Expr is an rvalue, this is the address of
|
//! 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.
|
//! some temporary spot in memory where the result is stored.
|
||||||
//!
|
//!
|
||||||
//! Now, cat_expr() classifies the expression Expr and the address A=ToAddr(Expr)
|
//! Now, cat_expr() classifies the expression Expr and the address A=ToAddr(Expr)
|
||||||
@ -182,7 +182,7 @@ pub struct cmt_<'tcx> {
|
|||||||
pub id: ast::NodeId, // id of expr/pat producing this value
|
pub id: ast::NodeId, // id of expr/pat producing this value
|
||||||
pub span: Span, // span of same expr/pat
|
pub span: Span, // span of same expr/pat
|
||||||
pub cat: Categorization<'tcx>, // categorization of expr
|
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 ty: Ty<'tcx>, // type of the expr (*see WARNING above*)
|
||||||
pub note: Note, // Note about the provenance of this cmt
|
pub note: Note, // Note about the provenance of this cmt
|
||||||
}
|
}
|
||||||
@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprUnary(hir::UnDeref, ref e_base) => {
|
hir::ExprUnary(hir::UnDeref, ref e_base) => {
|
||||||
if self.tables.is_method_call(expr) {
|
if self.tables.is_method_call(expr) {
|
||||||
self.cat_overloaded_lvalue(expr, e_base, false)
|
self.cat_overloaded_place(expr, e_base, false)
|
||||||
} else {
|
} else {
|
||||||
let base_cmt = self.cat_expr(&e_base)?;
|
let base_cmt = self.cat_expr(&e_base)?;
|
||||||
self.cat_deref(expr, base_cmt, false)
|
self.cat_deref(expr, base_cmt, false)
|
||||||
@ -631,7 +631,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||||||
// The call to index() returns a `&T` value, which
|
// The call to index() returns a `&T` value, which
|
||||||
// is an rvalue. That is what we will be
|
// is an rvalue. That is what we will be
|
||||||
// dereferencing.
|
// dereferencing.
|
||||||
self.cat_overloaded_lvalue(expr, base, true)
|
self.cat_overloaded_place(expr, base, true)
|
||||||
} else {
|
} else {
|
||||||
let base_cmt = self.cat_expr(&base)?;
|
let base_cmt = self.cat_expr(&base)?;
|
||||||
self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index)
|
self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index)
|
||||||
@ -983,27 +983,27 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_overloaded_lvalue(&self,
|
fn cat_overloaded_place(&self,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
base: &hir::Expr,
|
base: &hir::Expr,
|
||||||
implicit: bool)
|
implicit: bool)
|
||||||
-> McResult<cmt<'tcx>> {
|
-> 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
|
// Reconstruct the output assuming it's a reference with the
|
||||||
// same region and mutability as the receiver. This holds for
|
// same region and mutability as the receiver. This holds for
|
||||||
// `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`.
|
// `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 base_ty = self.expr_ty_adjusted(base)?;
|
||||||
|
|
||||||
let (region, mutbl) = match base_ty.sty {
|
let (region, mutbl) = match base_ty.sty {
|
||||||
ty::TyRef(region, mt) => (region, mt.mutbl),
|
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 {
|
let ref_ty = self.tcx.mk_ref(region, ty::TypeAndMut {
|
||||||
ty: lvalue_ty,
|
ty: place_ty,
|
||||||
mutbl,
|
mutbl,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -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 {
|
pub fn freely_aliasable(&self) -> Aliasability {
|
||||||
// Maybe non-obvious: copied upvars can only be considered
|
// Maybe non-obvious: copied upvars can only be considered
|
||||||
// non-aliasable in once closures, since any other kind can be
|
// non-aliasable in once closures, since any other kind can be
|
||||||
@ -1453,7 +1453,7 @@ impl<'tcx> cmt_<'tcx> {
|
|||||||
"static item".to_string()
|
"static item".to_string()
|
||||||
}
|
}
|
||||||
Categorization::Rvalue(..) => {
|
Categorization::Rvalue(..) => {
|
||||||
"non-lvalue".to_string()
|
"non-place".to_string()
|
||||||
}
|
}
|
||||||
Categorization::Local(vid) => {
|
Categorization::Local(vid) => {
|
||||||
if tcx.hir.is_argument(vid) {
|
if tcx.hir.is_argument(vid) {
|
||||||
|
@ -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
|
// I mean that creating a binding into a ref-counted or managed value
|
||||||
// would still count.)
|
// 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`.
|
// based on rvalues like `foo().x[2].y`.
|
||||||
//
|
//
|
||||||
// A subexpression `<rvalue>` that appears in a let initializer
|
// A subexpression `<rvalue>` that appears in a let initializer
|
||||||
@ -1283,7 +1283,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
|
|||||||
/// | (ET)
|
/// | (ET)
|
||||||
/// | <rvalue>
|
/// | <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>,
|
fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
blk_scope: Option<Scope>) {
|
blk_scope: Option<Scope>) {
|
||||||
|
@ -733,13 +733,13 @@ pub enum TerminatorKind<'tcx> {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// Drop the Place and assign the new value over it. This ensures
|
/// 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
|
/// place unwinds. Its semantics are best explained by by the
|
||||||
/// elaboration:
|
/// elaboration:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// BB0 {
|
/// BB0 {
|
||||||
/// DropAndReplace(LV <- RV, goto BB1, unwind BB2)
|
/// DropAndReplace(P <- V, goto BB1, unwind BB2)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -747,15 +747,15 @@ pub enum TerminatorKind<'tcx> {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// BB0 {
|
/// BB0 {
|
||||||
/// Drop(LV, goto BB1, unwind BB2)
|
/// Drop(P, goto BB1, unwind BB2)
|
||||||
/// }
|
/// }
|
||||||
/// BB1 {
|
/// BB1 {
|
||||||
/// // LV is now unitialized
|
/// // P is now unitialized
|
||||||
/// LV <- RV
|
/// P <- V
|
||||||
/// }
|
/// }
|
||||||
/// BB2 {
|
/// BB2 {
|
||||||
/// // LV is now unitialized -- its dtor panicked
|
/// // P is now unitialized -- its dtor panicked
|
||||||
/// LV <- RV
|
/// P <- V
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
DropAndReplace {
|
DropAndReplace {
|
||||||
|
@ -77,7 +77,7 @@ pub enum Adjust<'tcx> {
|
|||||||
/// Go from a mut raw pointer to a const raw pointer.
|
/// Go from a mut raw pointer to a const raw pointer.
|
||||||
MutToConstPointer,
|
MutToConstPointer,
|
||||||
|
|
||||||
/// Dereference once, producing an lvalue.
|
/// Dereference once, producing a place.
|
||||||
Deref(Option<OverloadedDeref<'tcx>>),
|
Deref(Option<OverloadedDeref<'tcx>>),
|
||||||
|
|
||||||
/// Take the address and produce either a `&` or `*` pointer.
|
/// Take the address and produce either a `&` or `*` pointer.
|
||||||
|
@ -104,7 +104,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
|
|||||||
|
|
||||||
fn scope(&self, cmt: &mc::cmt<'tcx>) -> ty::Region<'tcx> {
|
fn scope(&self, cmt: &mc::cmt<'tcx>) -> ty::Region<'tcx> {
|
||||||
//! Returns the maximal region scope for the which the
|
//! Returns the maximal region scope for the which the
|
||||||
//! lvalue `cmt` is guaranteed to be valid without any
|
//! place `cmt` is guaranteed to be valid without any
|
||||||
//! rooting etc, and presuming `cmt` is not mutated.
|
//! rooting etc, and presuming `cmt` is not mutated.
|
||||||
|
|
||||||
match cmt.cat {
|
match cmt.cat {
|
||||||
|
@ -170,7 +170,7 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
|
|||||||
if !force_analysis && move_data.is_empty() && all_loans.is_empty() {
|
if !force_analysis && move_data.is_empty() && all_loans.is_empty() {
|
||||||
// large arrays of data inserted as constants can take a lot of
|
// large arrays of data inserted as constants can take a lot of
|
||||||
// time and memory to borrow-check - see issue #36799. However,
|
// time and memory to borrow-check - see issue #36799. However,
|
||||||
// they don't have lvalues, so no borrow-check is actually needed.
|
// they don't have places, so no borrow-check is actually needed.
|
||||||
// Recognize that case and skip borrow-checking.
|
// Recognize that case and skip borrow-checking.
|
||||||
debug!("skipping loan propagation for {:?} because of no loans", body_id);
|
debug!("skipping loan propagation for {:?} because of no loans", body_id);
|
||||||
return None;
|
return None;
|
||||||
|
@ -153,7 +153,7 @@ pub struct Assignment {
|
|||||||
/// span of node where assignment occurs
|
/// span of node where assignment occurs
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
||||||
/// id for l-value expression on lhs of assignment
|
/// id for place expression on lhs of assignment
|
||||||
pub assignee_id: hir::ItemLocalId,
|
pub assignee_id: hir::ItemLocalId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
use rustc::mir::{BasicBlock, Location};
|
use rustc::mir::{BasicBlock, Location};
|
||||||
|
|
||||||
use dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
|
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use dataflow::{EverInitializedLvals, MovingOutStatements};
|
use dataflow::{EverInitializedPlaces, MovingOutStatements};
|
||||||
use dataflow::{ActiveBorrows, FlowAtLocation, FlowsAtLocation};
|
use dataflow::{ActiveBorrows, FlowAtLocation, FlowsAtLocation};
|
||||||
use dataflow::move_paths::HasMoveData;
|
use dataflow::move_paths::HasMoveData;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -24,19 +24,19 @@ use std::fmt;
|
|||||||
// (forced to be `pub` due to its use as an associated type below.)
|
// (forced to be `pub` due to its use as an associated type below.)
|
||||||
pub(crate) struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
|
pub(crate) struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
|
||||||
pub borrows: FlowAtLocation<ActiveBorrows<'b, 'gcx, 'tcx>>,
|
pub borrows: FlowAtLocation<ActiveBorrows<'b, 'gcx, 'tcx>>,
|
||||||
pub inits: FlowAtLocation<MaybeInitializedLvals<'b, 'gcx, 'tcx>>,
|
pub inits: FlowAtLocation<MaybeInitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
pub uninits: FlowAtLocation<MaybeUninitializedLvals<'b, 'gcx, 'tcx>>,
|
pub uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
|
pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
|
||||||
pub ever_inits: FlowAtLocation<EverInitializedLvals<'b, 'gcx, 'tcx>>,
|
pub ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
|
impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
borrows: FlowAtLocation<ActiveBorrows<'b, 'gcx, 'tcx>>,
|
borrows: FlowAtLocation<ActiveBorrows<'b, 'gcx, 'tcx>>,
|
||||||
inits: FlowAtLocation<MaybeInitializedLvals<'b, 'gcx, 'tcx>>,
|
inits: FlowAtLocation<MaybeInitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
uninits: FlowAtLocation<MaybeUninitializedLvals<'b, 'gcx, 'tcx>>,
|
uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
|
move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
|
||||||
ever_inits: FlowAtLocation<EverInitializedLvals<'b, 'gcx, 'tcx>>,
|
ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Flows {
|
Flows {
|
||||||
borrows,
|
borrows,
|
||||||
|
@ -35,8 +35,8 @@ use dataflow::{do_dataflow, DebugFormatted};
|
|||||||
use dataflow::FlowAtLocation;
|
use dataflow::FlowAtLocation;
|
||||||
use dataflow::MoveDataParamEnv;
|
use dataflow::MoveDataParamEnv;
|
||||||
use dataflow::{DataflowAnalysis, DataflowResultsConsumer};
|
use dataflow::{DataflowAnalysis, DataflowResultsConsumer};
|
||||||
use dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
|
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use dataflow::{EverInitializedLvals, MovingOutStatements};
|
use dataflow::{EverInitializedPlaces, MovingOutStatements};
|
||||||
use dataflow::{BorrowData, Borrows, ReserveOrActivateIndex};
|
use dataflow::{BorrowData, Borrows, ReserveOrActivateIndex};
|
||||||
use dataflow::{ActiveBorrows, Reservations};
|
use dataflow::{ActiveBorrows, Reservations};
|
||||||
use dataflow::indexes::BorrowIndex;
|
use dataflow::indexes::BorrowIndex;
|
||||||
@ -160,7 +160,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||||||
id,
|
id,
|
||||||
&attributes,
|
&attributes,
|
||||||
&dead_unwinds,
|
&dead_unwinds,
|
||||||
MaybeInitializedLvals::new(tcx, mir, &mdpe),
|
MaybeInitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
|
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
|
||||||
));
|
));
|
||||||
let flow_uninits = FlowAtLocation::new(do_dataflow(
|
let flow_uninits = FlowAtLocation::new(do_dataflow(
|
||||||
@ -169,7 +169,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||||||
id,
|
id,
|
||||||
&attributes,
|
&attributes,
|
||||||
&dead_unwinds,
|
&dead_unwinds,
|
||||||
MaybeUninitializedLvals::new(tcx, mir, &mdpe),
|
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
|
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
|
||||||
));
|
));
|
||||||
let flow_move_outs = FlowAtLocation::new(do_dataflow(
|
let flow_move_outs = FlowAtLocation::new(do_dataflow(
|
||||||
@ -187,7 +187,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||||||
id,
|
id,
|
||||||
&attributes,
|
&attributes,
|
||||||
&dead_unwinds,
|
&dead_unwinds,
|
||||||
EverInitializedLvals::new(tcx, mir, &mdpe),
|
EverInitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
|
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use std::io;
|
|||||||
use transform::MirSource;
|
use transform::MirSource;
|
||||||
use util::liveness::{LivenessResults, LocalSet};
|
use util::liveness::{LivenessResults, LocalSet};
|
||||||
use dataflow::FlowAtLocation;
|
use dataflow::FlowAtLocation;
|
||||||
use dataflow::MaybeInitializedLvals;
|
use dataflow::MaybeInitializedPlaces;
|
||||||
use dataflow::move_paths::MoveData;
|
use dataflow::move_paths::MoveData;
|
||||||
|
|
||||||
use util as mir_util;
|
use util as mir_util;
|
||||||
@ -71,7 +71,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
|||||||
universal_regions: UniversalRegions<'tcx>,
|
universal_regions: UniversalRegions<'tcx>,
|
||||||
mir: &Mir<'tcx>,
|
mir: &Mir<'tcx>,
|
||||||
param_env: ty::ParamEnv<'gcx>,
|
param_env: ty::ParamEnv<'gcx>,
|
||||||
flow_inits: &mut FlowAtLocation<MaybeInitializedLvals<'cx, 'gcx, 'tcx>>,
|
flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'cx, 'gcx, 'tcx>>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
) -> (
|
) -> (
|
||||||
RegionInferenceContext<'tcx>,
|
RegionInferenceContext<'tcx>,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
use dataflow::{FlowAtLocation, FlowsAtLocation};
|
use dataflow::{FlowAtLocation, FlowsAtLocation};
|
||||||
use borrow_check::nll::region_infer::Cause;
|
use borrow_check::nll::region_infer::Cause;
|
||||||
use dataflow::MaybeInitializedLvals;
|
use dataflow::MaybeInitializedPlaces;
|
||||||
use dataflow::move_paths::{HasMoveData, MoveData};
|
use dataflow::move_paths::{HasMoveData, MoveData};
|
||||||
use rustc::mir::{BasicBlock, Location, Mir};
|
use rustc::mir::{BasicBlock, Location, Mir};
|
||||||
use rustc::mir::Local;
|
use rustc::mir::Local;
|
||||||
@ -34,7 +34,7 @@ pub(super) fn generate<'gcx, 'tcx>(
|
|||||||
cx: &mut TypeChecker<'_, 'gcx, 'tcx>,
|
cx: &mut TypeChecker<'_, 'gcx, 'tcx>,
|
||||||
mir: &Mir<'tcx>,
|
mir: &Mir<'tcx>,
|
||||||
liveness: &LivenessResults,
|
liveness: &LivenessResults,
|
||||||
flow_inits: &mut FlowAtLocation<MaybeInitializedLvals<'_, 'gcx, 'tcx>>,
|
flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
@ -63,7 +63,7 @@ where
|
|||||||
tcx: TyCtxt<'typeck, 'gcx, 'tcx>,
|
tcx: TyCtxt<'typeck, 'gcx, 'tcx>,
|
||||||
mir: &'gen Mir<'tcx>,
|
mir: &'gen Mir<'tcx>,
|
||||||
liveness: &'gen LivenessResults,
|
liveness: &'gen LivenessResults,
|
||||||
flow_inits: &'gen mut FlowAtLocation<MaybeInitializedLvals<'flow, 'gcx, 'tcx>>,
|
flow_inits: &'gen mut FlowAtLocation<MaybeInitializedPlaces<'flow, 'gcx, 'tcx>>,
|
||||||
move_data: &'gen MoveData<'tcx>,
|
move_data: &'gen MoveData<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use borrow_check::nll::region_infer::Cause;
|
|||||||
use borrow_check::nll::region_infer::ClosureRegionRequirementsExt;
|
use borrow_check::nll::region_infer::ClosureRegionRequirementsExt;
|
||||||
use borrow_check::nll::universal_regions::UniversalRegions;
|
use borrow_check::nll::universal_regions::UniversalRegions;
|
||||||
use dataflow::FlowAtLocation;
|
use dataflow::FlowAtLocation;
|
||||||
use dataflow::MaybeInitializedLvals;
|
use dataflow::MaybeInitializedPlaces;
|
||||||
use dataflow::move_paths::MoveData;
|
use dataflow::move_paths::MoveData;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::infer::{InferCtxt, InferOk, InferResult, LateBoundRegionConversionTime, UnitResult};
|
use rustc::infer::{InferCtxt, InferOk, InferResult, LateBoundRegionConversionTime, UnitResult};
|
||||||
@ -100,7 +100,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
|
|||||||
mir_def_id: DefId,
|
mir_def_id: DefId,
|
||||||
universal_regions: &UniversalRegions<'tcx>,
|
universal_regions: &UniversalRegions<'tcx>,
|
||||||
liveness: &LivenessResults,
|
liveness: &LivenessResults,
|
||||||
flow_inits: &mut FlowAtLocation<MaybeInitializedLvals<'_, 'gcx, 'tcx>>,
|
flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
) -> MirTypeckRegionConstraints<'tcx> {
|
) -> MirTypeckRegionConstraints<'tcx> {
|
||||||
let body_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
|
let body_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
|
||||||
|
@ -575,10 +575,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
|
|||||||
/// has a reservation at the time).
|
/// has a reservation at the time).
|
||||||
fn is_potential_use(context: PlaceContext) -> bool {
|
fn is_potential_use(context: PlaceContext) -> bool {
|
||||||
match context {
|
match context {
|
||||||
// storage effects on an place do not activate it
|
// storage effects on a place do not activate it
|
||||||
PlaceContext::StorageLive | PlaceContext::StorageDead => false,
|
PlaceContext::StorageLive | PlaceContext::StorageDead => false,
|
||||||
|
|
||||||
// validation effects do not activate an place
|
// validation effects do not activate a place
|
||||||
//
|
//
|
||||||
// FIXME: Should they? Is it just another read? Or can we
|
// FIXME: Should they? Is it just another read? Or can we
|
||||||
// guarantee it won't dereference the stored address? How
|
// guarantee it won't dereference the stored address? How
|
||||||
@ -589,11 +589,11 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
|
|||||||
// AsmOutput existed, but it's not necessarily a pure overwrite.
|
// AsmOutput existed, but it's not necessarily a pure overwrite.
|
||||||
// so it's possible this should activate the place.
|
// so it's possible this should activate the place.
|
||||||
PlaceContext::AsmOutput |
|
PlaceContext::AsmOutput |
|
||||||
// pure overwrites of an place do not activate it. (note
|
// pure overwrites of a place do not activate it. (note
|
||||||
// PlaceContext::Call is solely about dest place)
|
// PlaceContext::Call is solely about dest place)
|
||||||
PlaceContext::Store | PlaceContext::Call => false,
|
PlaceContext::Store | PlaceContext::Call => false,
|
||||||
|
|
||||||
// reads of an place *do* activate it
|
// reads of a place *do* activate it
|
||||||
PlaceContext::Move |
|
PlaceContext::Move |
|
||||||
PlaceContext::Copy |
|
PlaceContext::Copy |
|
||||||
PlaceContext::Drop |
|
PlaceContext::Drop |
|
||||||
|
@ -36,7 +36,7 @@ pub use self::storage_liveness::*;
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(super) mod borrows;
|
pub(super) mod borrows;
|
||||||
|
|
||||||
/// `MaybeInitializedLvals` tracks all l-values that might be
|
/// `MaybeInitializedPlaces` tracks all places that might be
|
||||||
/// initialized upon reaching a particular point in the control flow
|
/// initialized upon reaching a particular point in the control flow
|
||||||
/// for a function.
|
/// for a function.
|
||||||
///
|
///
|
||||||
@ -63,35 +63,35 @@ pub(super) mod borrows;
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// To determine whether an l-value *must* be initialized at a
|
/// To determine whether a place *must* be initialized at a
|
||||||
/// particular control-flow point, one can take the set-difference
|
/// particular control-flow point, one can take the set-difference
|
||||||
/// between this data and the data from `MaybeUninitializedLvals` at the
|
/// between this data and the data from `MaybeUninitializedPlaces` at the
|
||||||
/// corresponding control-flow point.
|
/// corresponding control-flow point.
|
||||||
///
|
///
|
||||||
/// Similarly, at a given `drop` statement, the set-intersection
|
/// Similarly, at a given `drop` statement, the set-intersection
|
||||||
/// between this data and `MaybeUninitializedLvals` yields the set of
|
/// between this data and `MaybeUninitializedPlaces` yields the set of
|
||||||
/// l-values that would require a dynamic drop-flag at that statement.
|
/// places that would require a dynamic drop-flag at that statement.
|
||||||
pub struct MaybeInitializedLvals<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
pub struct MaybeInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
MaybeInitializedLvals { tcx: tcx, mir: mir, mdpe: mdpe }
|
MaybeInitializedPlaces { tcx: tcx, mir: mir, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `MaybeUninitializedLvals` tracks all l-values that might be
|
/// `MaybeUninitializedPlaces` tracks all places that might be
|
||||||
/// uninitialized upon reaching a particular point in the control flow
|
/// uninitialized upon reaching a particular point in the control flow
|
||||||
/// for a function.
|
/// for a function.
|
||||||
///
|
///
|
||||||
@ -118,42 +118,42 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedLvals<'a, 'gcx, 'tcx>
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// To determine whether an l-value *must* be uninitialized at a
|
/// To determine whether a place *must* be uninitialized at a
|
||||||
/// particular control-flow point, one can take the set-difference
|
/// particular control-flow point, one can take the set-difference
|
||||||
/// between this data and the data from `MaybeInitializedLvals` at the
|
/// between this data and the data from `MaybeInitializedPlaces` at the
|
||||||
/// corresponding control-flow point.
|
/// corresponding control-flow point.
|
||||||
///
|
///
|
||||||
/// Similarly, at a given `drop` statement, the set-intersection
|
/// Similarly, at a given `drop` statement, the set-intersection
|
||||||
/// between this data and `MaybeInitializedLvals` yields the set of
|
/// between this data and `MaybeInitializedPlaces` yields the set of
|
||||||
/// l-values that would require a dynamic drop-flag at that statement.
|
/// places that would require a dynamic drop-flag at that statement.
|
||||||
pub struct MaybeUninitializedLvals<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
pub struct MaybeUninitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
MaybeUninitializedLvals { tcx: tcx, mir: mir, mdpe: mdpe }
|
MaybeUninitializedPlaces { tcx: tcx, mir: mir, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `DefinitelyInitializedLvals` tracks all l-values that are definitely
|
/// `DefinitelyInitializedPlaces` tracks all places that are definitely
|
||||||
/// initialized upon reaching a particular point in the control flow
|
/// initialized upon reaching a particular point in the control flow
|
||||||
/// for a function.
|
/// for a function.
|
||||||
///
|
///
|
||||||
/// FIXME: Note that once flow-analysis is complete, this should be
|
/// FIXME: Note that once flow-analysis is complete, this should be
|
||||||
/// the set-complement of MaybeUninitializedLvals; thus we can get rid
|
/// the set-complement of MaybeUninitializedPlaces; thus we can get rid
|
||||||
/// of one or the other of these two. I'm inclined to get rid of
|
/// of one or the other of these two. I'm inclined to get rid of
|
||||||
/// MaybeUninitializedLvals, simply because the sets will tend to be
|
/// MaybeUninitializedPlaces, simply because the sets will tend to be
|
||||||
/// smaller in this analysis and thus easier for humans to process
|
/// smaller in this analysis and thus easier for humans to process
|
||||||
/// when debugging.
|
/// when debugging.
|
||||||
///
|
///
|
||||||
@ -180,43 +180,43 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedLvals<'a, 'gcx, 'tc
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// To determine whether an l-value *may* be uninitialized at a
|
/// To determine whether a place *may* be uninitialized at a
|
||||||
/// particular control-flow point, one can take the set-complement
|
/// particular control-flow point, one can take the set-complement
|
||||||
/// of this data.
|
/// of this data.
|
||||||
///
|
///
|
||||||
/// Similarly, at a given `drop` statement, the set-difference between
|
/// Similarly, at a given `drop` statement, the set-difference between
|
||||||
/// this data and `MaybeInitializedLvals` yields the set of l-values
|
/// this data and `MaybeInitializedPlaces` yields the set of places
|
||||||
/// that would require a dynamic drop-flag at that statement.
|
/// that would require a dynamic drop-flag at that statement.
|
||||||
pub struct DefinitelyInitializedLvals<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
DefinitelyInitializedLvals { tcx: tcx, mir: mir, mdpe: mdpe }
|
DefinitelyInitializedPlaces { tcx: tcx, mir: mir, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `MovingOutStatements` tracks the statements that perform moves out
|
/// `MovingOutStatements` tracks the statements that perform moves out
|
||||||
/// of particular l-values. More precisely, it tracks whether the
|
/// of particular places. More precisely, it tracks whether the
|
||||||
/// *effect* of such moves (namely, the uninitialization of the
|
/// *effect* of such moves (namely, the uninitialization of the
|
||||||
/// l-value in question) can reach some point in the control-flow of
|
/// place in question) can reach some point in the control-flow of
|
||||||
/// the function, or if that effect is "killed" by some intervening
|
/// the function, or if that effect is "killed" by some intervening
|
||||||
/// operation reinitializing that l-value.
|
/// operation reinitializing that place.
|
||||||
///
|
///
|
||||||
/// The resulting dataflow is a more enriched version of
|
/// The resulting dataflow is a more enriched version of
|
||||||
/// `MaybeUninitializedLvals`. Both structures on their own only tell
|
/// `MaybeUninitializedPlaces`. Both structures on their own only tell
|
||||||
/// you if an l-value *might* be uninitialized at a given point in the
|
/// you if a place *might* be uninitialized at a given point in the
|
||||||
/// control flow. But `MovingOutStatements` also includes the added
|
/// control flow. But `MovingOutStatements` also includes the added
|
||||||
/// data of *which* particular statement causing the deinitialization
|
/// data of *which* particular statement causing the deinitialization
|
||||||
/// that the borrow checker's error message may need to report.
|
/// that the borrow checker's error message may need to report.
|
||||||
@ -241,7 +241,7 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MovingOutStatements<'a, 'gcx, 'tcx> {
|
|||||||
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `EverInitializedLvals` tracks all l-values that might have ever been
|
/// `EverInitializedPlaces` tracks all places that might have ever been
|
||||||
/// initialized upon reaching a particular point in the control flow
|
/// initialized upon reaching a particular point in the control flow
|
||||||
/// for a function, without an intervening `Storage Dead`.
|
/// for a function, without an intervening `Storage Dead`.
|
||||||
///
|
///
|
||||||
@ -270,28 +270,28 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MovingOutStatements<'a, 'gcx, 'tcx> {
|
|||||||
/// c = S; // {a, b, c, d }
|
/// c = S; // {a, b, c, d }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct EverInitializedLvals<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
pub struct EverInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
EverInitializedLvals { tcx: tcx, mir: mir, mdpe: mdpe }
|
EverInitializedPlaces { tcx: tcx, mir: mir, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
||||||
state: DropFlagState)
|
state: DropFlagState)
|
||||||
{
|
{
|
||||||
@ -302,7 +302,7 @@ impl<'a, 'gcx, 'tcx> MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
||||||
state: DropFlagState)
|
state: DropFlagState)
|
||||||
{
|
{
|
||||||
@ -313,7 +313,7 @@ impl<'a, 'gcx, 'tcx> MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
|
||||||
state: DropFlagState)
|
state: DropFlagState)
|
||||||
{
|
{
|
||||||
@ -324,7 +324,7 @@ impl<'a, 'gcx, 'tcx> DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
type Idx = MovePathIndex;
|
type Idx = MovePathIndex;
|
||||||
fn name() -> &'static str { "maybe_init" }
|
fn name() -> &'static str { "maybe_init" }
|
||||||
fn bits_per_block(&self) -> usize {
|
fn bits_per_block(&self) -> usize {
|
||||||
@ -375,7 +375,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
type Idx = MovePathIndex;
|
type Idx = MovePathIndex;
|
||||||
fn name() -> &'static str { "maybe_uninit" }
|
fn name() -> &'static str { "maybe_uninit" }
|
||||||
fn bits_per_block(&self) -> usize {
|
fn bits_per_block(&self) -> usize {
|
||||||
@ -430,7 +430,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
type Idx = MovePathIndex;
|
type Idx = MovePathIndex;
|
||||||
fn name() -> &'static str { "definite_init" }
|
fn name() -> &'static str { "definite_init" }
|
||||||
fn bits_per_block(&self) -> usize {
|
fn bits_per_block(&self) -> usize {
|
||||||
@ -561,7 +561,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitDenotation for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitDenotation for EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
type Idx = InitIndex;
|
type Idx = InitIndex;
|
||||||
fn name() -> &'static str { "ever_init" }
|
fn name() -> &'static str { "ever_init" }
|
||||||
fn bits_per_block(&self) -> usize {
|
fn bits_per_block(&self) -> usize {
|
||||||
@ -657,21 +657,21 @@ impl<'a, 'gcx, 'tcx> BitDenotation for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
||||||
pred1 | pred2 // "maybe" means we union effects of both preds
|
pred1 | pred2 // "maybe" means we union effects of both preds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
||||||
pred1 | pred2 // "maybe" means we union effects of both preds
|
pred1 | pred2 // "maybe" means we union effects of both preds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitwiseOperator for DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitwiseOperator for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
||||||
pred1 & pred2 // "definitely" means we intersect effects of both preds
|
pred1 & pred2 // "definitely" means we intersect effects of both preds
|
||||||
@ -685,7 +685,7 @@ impl<'a, 'gcx, 'tcx> BitwiseOperator for MovingOutStatements<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> BitwiseOperator for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> BitwiseOperator for EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
fn join(&self, pred1: usize, pred2: usize) -> usize {
|
||||||
pred1 | pred2 // inits from both preds are in scope
|
pred1 | pred2 // inits from both preds are in scope
|
||||||
@ -702,21 +702,21 @@ impl<'a, 'gcx, 'tcx> BitwiseOperator for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
|||||||
// propagating, or you start at all-ones and then use Intersect as
|
// propagating, or you start at all-ones and then use Intersect as
|
||||||
// your merge when propagating.
|
// your merge when propagating.
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InitialFlow for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InitialFlow for MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn bottom_value() -> bool {
|
fn bottom_value() -> bool {
|
||||||
false // bottom = uninitialized
|
false // bottom = uninitialized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InitialFlow for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InitialFlow for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn bottom_value() -> bool {
|
fn bottom_value() -> bool {
|
||||||
false // bottom = initialized (start_block_effect counters this at outset)
|
false // bottom = initialized (start_block_effect counters this at outset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InitialFlow for DefinitelyInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InitialFlow for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn bottom_value() -> bool {
|
fn bottom_value() -> bool {
|
||||||
true // bottom = initialized (start_block_effect counters this at outset)
|
true // bottom = initialized (start_block_effect counters this at outset)
|
||||||
@ -730,7 +730,7 @@ impl<'a, 'gcx, 'tcx> InitialFlow for MovingOutStatements<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InitialFlow for EverInitializedLvals<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InitialFlow for EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn bottom_value() -> bool {
|
fn bottom_value() -> bool {
|
||||||
false // bottom = no initialized variables by default
|
false // bottom = no initialized variables by default
|
||||||
|
@ -26,9 +26,9 @@ use std::path::PathBuf;
|
|||||||
use std::usize;
|
use std::usize;
|
||||||
|
|
||||||
pub use self::impls::{MaybeStorageLive};
|
pub use self::impls::{MaybeStorageLive};
|
||||||
pub use self::impls::{MaybeInitializedLvals, MaybeUninitializedLvals};
|
pub use self::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
pub use self::impls::{DefinitelyInitializedLvals, MovingOutStatements};
|
pub use self::impls::{DefinitelyInitializedPlaces, MovingOutStatements};
|
||||||
pub use self::impls::EverInitializedLvals;
|
pub use self::impls::EverInitializedPlaces;
|
||||||
pub use self::impls::borrows::{Borrows, BorrowData};
|
pub use self::impls::borrows::{Borrows, BorrowData};
|
||||||
pub(crate) use self::impls::borrows::{ActiveBorrows, Reservations, ReserveOrActivateIndex};
|
pub(crate) use self::impls::borrows::{ActiveBorrows, Reservations, ReserveOrActivateIndex};
|
||||||
pub use self::at_location::{FlowAtLocation, FlowsAtLocation};
|
pub use self::at_location::{FlowAtLocation, FlowsAtLocation};
|
||||||
|
@ -86,7 +86,7 @@ impl MoveOutIndex {
|
|||||||
/// It follows a tree structure.
|
/// It follows a tree structure.
|
||||||
///
|
///
|
||||||
/// Given `struct X { m: M, n: N }` and `x: X`, moves like `drop x.m;`
|
/// Given `struct X { m: M, n: N }` and `x: X`, moves like `drop x.m;`
|
||||||
/// move *out* of the l-value `x.m`.
|
/// move *out* of the place `x.m`.
|
||||||
///
|
///
|
||||||
/// The MovePaths representing `x.m` and `x.n` are siblings (that is,
|
/// The MovePaths representing `x.m` and `x.n` are siblings (that is,
|
||||||
/// one of them will link to the other via the `next_sibling` field,
|
/// one of them will link to the other via the `next_sibling` field,
|
||||||
@ -222,7 +222,7 @@ impl fmt::Debug for Init {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tables mapping from an l-value to its MovePathIndex.
|
/// Tables mapping from a place to its MovePathIndex.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MovePathLookup<'tcx> {
|
pub struct MovePathLookup<'tcx> {
|
||||||
locals: IndexVec<Local, MovePathIndex>,
|
locals: IndexVec<Local, MovePathIndex>,
|
||||||
@ -247,7 +247,7 @@ pub enum LookupResult {
|
|||||||
impl<'tcx> MovePathLookup<'tcx> {
|
impl<'tcx> MovePathLookup<'tcx> {
|
||||||
// Unlike the builder `fn move_path_for` below, this lookup
|
// Unlike the builder `fn move_path_for` below, this lookup
|
||||||
// alternative will *not* create a MovePath on the fly for an
|
// alternative will *not* create a MovePath on the fly for an
|
||||||
// unknown l-value, but will rather return the nearest available
|
// unknown place, but will rather return the nearest available
|
||||||
// parent.
|
// parent.
|
||||||
pub fn find(&self, place: &Place<'tcx>) -> LookupResult {
|
pub fn find(&self, place: &Place<'tcx>) -> LookupResult {
|
||||||
match *place {
|
match *place {
|
||||||
|
@ -9,9 +9,9 @@ use interpret::memory::HasMemory;
|
|||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum Place {
|
pub enum Place {
|
||||||
/// An place referring to a value allocated in the `Memory` system.
|
/// A place referring to a value allocated in the `Memory` system.
|
||||||
Ptr {
|
Ptr {
|
||||||
/// An place may have an invalid (integral or undef) pointer,
|
/// A place may have an invalid (integral or undef) pointer,
|
||||||
/// since it might be turned back into a reference
|
/// since it might be turned back into a reference
|
||||||
/// before ever being dereferenced.
|
/// before ever being dereferenced.
|
||||||
ptr: Pointer,
|
ptr: Pointer,
|
||||||
@ -19,7 +19,7 @@ pub enum Place {
|
|||||||
extra: PlaceExtra,
|
extra: PlaceExtra,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// An place referring to a value on the stack. Represented by a stack frame index paired with
|
/// A place referring to a value on the stack. Represented by a stack frame index paired with
|
||||||
/// a Mir local index.
|
/// a Mir local index.
|
||||||
Local { frame: usize, local: mir::Local },
|
Local { frame: usize, local: mir::Local },
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ pub enum PlaceExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Place {
|
impl<'tcx> Place {
|
||||||
/// Produces an Place that will error if attempted to be read from
|
/// Produces a Place that will error if attempted to be read from
|
||||||
pub fn undef() -> Self {
|
pub fn undef() -> Self {
|
||||||
Self::from_primval_ptr(PrimVal::Undef.into(), Align::from_bytes(1, 1).unwrap())
|
Self::from_primval_ptr(PrimVal::Undef.into(), Align::from_bytes(1, 1).unwrap())
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult};
|
use dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult};
|
||||||
use dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
|
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use dataflow::{DataflowResults};
|
use dataflow::{DataflowResults};
|
||||||
use dataflow::{on_all_children_bits, on_all_drop_children_bits};
|
use dataflow::{on_all_children_bits, on_all_drop_children_bits};
|
||||||
use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
|
use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
|
||||||
@ -60,11 +60,11 @@ impl MirPass for ElaborateDrops {
|
|||||||
let dead_unwinds = find_dead_unwinds(tcx, mir, id, &env);
|
let dead_unwinds = find_dead_unwinds(tcx, mir, id, &env);
|
||||||
let flow_inits =
|
let flow_inits =
|
||||||
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
||||||
MaybeInitializedLvals::new(tcx, mir, &env),
|
MaybeInitializedPlaces::new(tcx, mir, &env),
|
||||||
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
||||||
let flow_uninits =
|
let flow_uninits =
|
||||||
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
||||||
MaybeUninitializedLvals::new(tcx, mir, &env),
|
MaybeUninitializedPlaces::new(tcx, mir, &env),
|
||||||
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
||||||
|
|
||||||
ElaborateDropsCtxt {
|
ElaborateDropsCtxt {
|
||||||
@ -97,7 +97,7 @@ fn find_dead_unwinds<'a, 'tcx>(
|
|||||||
let mut dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());
|
let mut dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());
|
||||||
let flow_inits =
|
let flow_inits =
|
||||||
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
do_dataflow(tcx, mir, id, &[], &dead_unwinds,
|
||||||
MaybeInitializedLvals::new(tcx, mir, &env),
|
MaybeInitializedPlaces::new(tcx, mir, &env),
|
||||||
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
|bd, p| DebugFormatted::new(&bd.move_data().move_paths[p]));
|
||||||
for (bb, bb_data) in mir.basic_blocks().iter_enumerated() {
|
for (bb, bb_data) in mir.basic_blocks().iter_enumerated() {
|
||||||
let location = match bb_data.terminator().kind {
|
let location = match bb_data.terminator().kind {
|
||||||
@ -300,8 +300,8 @@ struct ElaborateDropsCtxt<'a, 'tcx: 'a> {
|
|||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
env: &'a MoveDataParamEnv<'tcx, 'tcx>,
|
env: &'a MoveDataParamEnv<'tcx, 'tcx>,
|
||||||
flow_inits: DataflowResults<MaybeInitializedLvals<'a, 'tcx, 'tcx>>,
|
flow_inits: DataflowResults<MaybeInitializedPlaces<'a, 'tcx, 'tcx>>,
|
||||||
flow_uninits: DataflowResults<MaybeUninitializedLvals<'a, 'tcx, 'tcx>>,
|
flow_uninits: DataflowResults<MaybeUninitializedPlaces<'a, 'tcx, 'tcx>>,
|
||||||
drop_flags: FxHashMap<MovePathIndex, Local>,
|
drop_flags: FxHashMap<MovePathIndex, Local>,
|
||||||
patch: MirPatch<'tcx>,
|
patch: MirPatch<'tcx>,
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ use dataflow::{do_dataflow, DebugFormatted};
|
|||||||
use dataflow::MoveDataParamEnv;
|
use dataflow::MoveDataParamEnv;
|
||||||
use dataflow::BitDenotation;
|
use dataflow::BitDenotation;
|
||||||
use dataflow::DataflowResults;
|
use dataflow::DataflowResults;
|
||||||
use dataflow::{DefinitelyInitializedLvals, MaybeInitializedLvals, MaybeUninitializedLvals};
|
use dataflow::{DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use dataflow::move_paths::{MovePathIndex, LookupResult};
|
use dataflow::move_paths::{MovePathIndex, LookupResult};
|
||||||
use dataflow::move_paths::{HasMoveData, MoveData};
|
use dataflow::move_paths::{HasMoveData, MoveData};
|
||||||
use dataflow;
|
use dataflow;
|
||||||
@ -50,15 +50,15 @@ impl MirPass for SanityCheck {
|
|||||||
let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());
|
let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());
|
||||||
let flow_inits =
|
let flow_inits =
|
||||||
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
||||||
MaybeInitializedLvals::new(tcx, mir, &mdpe),
|
MaybeInitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
||||||
let flow_uninits =
|
let flow_uninits =
|
||||||
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
||||||
MaybeUninitializedLvals::new(tcx, mir, &mdpe),
|
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
||||||
let flow_def_inits =
|
let flow_def_inits =
|
||||||
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
do_dataflow(tcx, mir, id, &attributes, &dead_unwinds,
|
||||||
DefinitelyInitializedLvals::new(tcx, mir, &mdpe),
|
DefinitelyInitializedPlaces::new(tcx, mir, &mdpe),
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]));
|
||||||
|
|
||||||
if has_rustc_mir_with(&attributes, "rustc_peek_maybe_init").is_some() {
|
if has_rustc_mir_with(&attributes, "rustc_peek_maybe_init").is_some() {
|
||||||
|
@ -560,7 +560,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
|
|||||||
/// ptr = cur
|
/// ptr = cur
|
||||||
/// cur = cur.offset(1)
|
/// cur = cur.offset(1)
|
||||||
/// } else {
|
/// } else {
|
||||||
/// ptr = &mut LV[cur]
|
/// ptr = &mut P[cur]
|
||||||
/// cur = cur + 1
|
/// cur = cur + 1
|
||||||
/// }
|
/// }
|
||||||
/// drop(ptr)
|
/// drop(ptr)
|
||||||
@ -731,7 +731,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
|
|||||||
if ptr_based {
|
if ptr_based {
|
||||||
let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
|
let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
|
||||||
let tmp = Place::Local(self.new_temp(tmp_ty));
|
let tmp = Place::Local(self.new_temp(tmp_ty));
|
||||||
// tmp = &LV;
|
// tmp = &P;
|
||||||
// cur = tmp as *mut T;
|
// cur = tmp as *mut T;
|
||||||
// end = Offset(cur, len);
|
// end = Offset(cur, len);
|
||||||
drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref(
|
drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref(
|
||||||
|
@ -545,7 +545,7 @@ impl<'a, 'tcx> ArgType<'tcx> {
|
|||||||
self.mode == PassMode::Ignore
|
self.mode == PassMode::Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the LLVM type for an place of the original Rust type of
|
/// Get the LLVM type for a place of the original Rust type of
|
||||||
/// this argument/return, i.e. the result of `type_of::type_of`.
|
/// this argument/return, i.e. the result of `type_of::type_of`.
|
||||||
pub fn memory_ty(&self, cx: &CodegenCx<'a, 'tcx>) -> Type {
|
pub fn memory_ty(&self, cx: &CodegenCx<'a, 'tcx>) -> Type {
|
||||||
self.layout.llvm_type(cx)
|
self.layout.llvm_type(cx)
|
||||||
|
@ -209,7 +209,7 @@ enum Base {
|
|||||||
Static(ValueRef)
|
Static(ValueRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An place as seen from a constant.
|
/// A place as seen from a constant.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
struct ConstPlace<'tcx> {
|
struct ConstPlace<'tcx> {
|
||||||
base: Base,
|
base: Base,
|
||||||
|
@ -136,7 +136,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(hir::MutMutable) = pick.autoref {
|
if let Some(hir::MutMutable) = pick.autoref {
|
||||||
self.convert_lvalue_derefs_to_mutable();
|
self.convert_place_derefs_to_mutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmResult { callee, illegal_sized_bound }
|
ConfirmResult { callee, illegal_sized_bound }
|
||||||
@ -416,7 +416,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||||||
/// When we select a method with a mutable autoref, we have to go convert any
|
/// When we select a method with a mutable autoref, we have to go convert any
|
||||||
/// auto-derefs, indices, etc from `Deref` and `Index` into `DerefMut` and `IndexMut`
|
/// auto-derefs, indices, etc from `Deref` and `Index` into `DerefMut` and `IndexMut`
|
||||||
/// respectively.
|
/// respectively.
|
||||||
fn convert_lvalue_derefs_to_mutable(&self) {
|
fn convert_place_derefs_to_mutable(&self) {
|
||||||
// Gather up expressions we want to munge.
|
// Gather up expressions we want to munge.
|
||||||
let mut exprs = Vec::new();
|
let mut exprs = Vec::new();
|
||||||
exprs.push(self.self_expr);
|
exprs.push(self.self_expr);
|
||||||
@ -431,11 +431,11 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("convert_lvalue_derefs_to_mutable: exprs={:?}", exprs);
|
debug!("convert_place_derefs_to_mutable: exprs={:?}", exprs);
|
||||||
|
|
||||||
// Fix up autoderefs and derefs.
|
// Fix up autoderefs and derefs.
|
||||||
for (i, &expr) in exprs.iter().rev().enumerate() {
|
for (i, &expr) in exprs.iter().rev().enumerate() {
|
||||||
debug!("convert_lvalue_derefs_to_mutable: i={} expr={:?}", i, expr);
|
debug!("convert_place_derefs_to_mutable: i={} expr={:?}", i, expr);
|
||||||
|
|
||||||
// Fix up the autoderefs. Autorefs can only occur immediately preceding
|
// Fix up the autoderefs. Autorefs can only occur immediately preceding
|
||||||
// overloaded place ops, and will be fixed by them in order to get
|
// overloaded place ops, and will be fixed by them in order to get
|
||||||
|
@ -557,7 +557,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
|||||||
/// foo();}` or `{return; 22}`, where we would warn on the
|
/// foo();}` or `{return; 22}`, where we would warn on the
|
||||||
/// `foo()` or `22`.
|
/// `foo()` or `22`.
|
||||||
///
|
///
|
||||||
/// - To permit assignment into a local variable or other lvalue
|
/// - To permit assignment into a local variable or other place
|
||||||
/// (including the "return slot") of type `!`. This is allowed
|
/// (including the "return slot") of type `!`. This is allowed
|
||||||
/// if **either** the type of value being assigned is `!`, which
|
/// if **either** the type of value being assigned is `!`, which
|
||||||
/// means the current code is dead, **or** the expression's
|
/// means the current code is dead, **or** the expression's
|
||||||
@ -2275,11 +2275,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For the overloaded lvalue expressions (`*x`, `x[3]`), the trait
|
/// For the overloaded place expressions (`*x`, `x[3]`), the trait
|
||||||
/// returns a type of `&T`, but the actual type we assign to the
|
/// returns a type of `&T`, but the actual type we assign to the
|
||||||
/// *expression* is `T`. So this function just peels off the return
|
/// *expression* is `T`. So this function just peels off the return
|
||||||
/// type by one layer to yield `T`.
|
/// type by one layer to yield `T`.
|
||||||
fn make_overloaded_lvalue_return_type(&self,
|
fn make_overloaded_place_return_type(&self,
|
||||||
method: MethodCallee<'tcx>)
|
method: MethodCallee<'tcx>)
|
||||||
-> ty::TypeAndMut<'tcx>
|
-> ty::TypeAndMut<'tcx>
|
||||||
{
|
{
|
||||||
@ -2373,7 +2373,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
self.apply_adjustments(base_expr, adjustments);
|
self.apply_adjustments(base_expr, adjustments);
|
||||||
|
|
||||||
self.write_method_call(expr.hir_id, method);
|
self.write_method_call(expr.hir_id, method);
|
||||||
(input_ty, self.make_overloaded_lvalue_return_type(method).ty)
|
(input_ty, self.make_overloaded_place_return_type(method).ty)
|
||||||
});
|
});
|
||||||
if result.is_some() {
|
if result.is_some() {
|
||||||
return result;
|
return result;
|
||||||
@ -3650,7 +3650,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
target: method.sig.inputs()[0]
|
target: method.sig.inputs()[0]
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
oprnd_t = self.make_overloaded_lvalue_return_type(method).ty;
|
oprnd_t = self.make_overloaded_place_return_type(method).ty;
|
||||||
self.write_method_call(expr.hir_id, method);
|
self.write_method_call(expr.hir_id, method);
|
||||||
} else {
|
} else {
|
||||||
type_error_struct!(tcx.sess, expr.span, oprnd_t, E0614,
|
type_error_struct!(tcx.sess, expr.span, oprnd_t, E0614,
|
||||||
@ -3682,7 +3682,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => {
|
ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => {
|
||||||
if self.is_place_expr(&oprnd) {
|
if self.is_place_expr(&oprnd) {
|
||||||
// Lvalues may legitimately have unsized types.
|
// Places may legitimately have unsized types.
|
||||||
// For example, dereferences of a fat pointer and
|
// For example, dereferences of a fat pointer and
|
||||||
// the last field of a struct can be unsized.
|
// the last field of a struct can be unsized.
|
||||||
ExpectHasType(mt.ty)
|
ExpectHasType(mt.ty)
|
||||||
@ -4245,7 +4245,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
// ref mut, for soundness (issue #23116). In particular, in
|
// ref mut, for soundness (issue #23116). In particular, in
|
||||||
// the latter case, we need to be clear that the type of the
|
// the latter case, we need to be clear that the type of the
|
||||||
// referent for the reference that results is *equal to* the
|
// referent for the reference that results is *equal to* the
|
||||||
// type of the lvalue it is referencing, and not some
|
// type of the place it is referencing, and not some
|
||||||
// supertype thereof.
|
// supertype thereof.
|
||||||
let init_ty = self.check_expr_with_needs(init, Needs::maybe_mut_place(m));
|
let init_ty = self.check_expr_with_needs(init, Needs::maybe_mut_place(m));
|
||||||
self.demand_eqtype(init.span, local_ty, init_ty);
|
self.demand_eqtype(init.span, local_ty, init_ty);
|
||||||
|
@ -732,8 +732,8 @@ and [RFC 809] for more details.
|
|||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0067: r##"
|
E0067: r##"
|
||||||
The left-hand side of a compound assignment expression must be an lvalue
|
The left-hand side of a compound assignment expression must be a place
|
||||||
expression. An lvalue expression represents a memory location and includes
|
expression. A place expression represents a memory location and includes
|
||||||
item paths (ie, namespaced variables), dereferences, indexing expressions,
|
item paths (ie, namespaced variables), dereferences, indexing expressions,
|
||||||
and field references.
|
and field references.
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ Let's start with some erroneous code examples:
|
|||||||
```compile_fail,E0067
|
```compile_fail,E0067
|
||||||
use std::collections::LinkedList;
|
use std::collections::LinkedList;
|
||||||
|
|
||||||
// Bad: assignment to non-lvalue expression
|
// Bad: assignment to non-place expression
|
||||||
LinkedList::new() += 1;
|
LinkedList::new() += 1;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
@ -783,14 +783,14 @@ function's return type and the value being returned.
|
|||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0070: r##"
|
E0070: r##"
|
||||||
The left-hand side of an assignment operator must be an lvalue expression. An
|
The left-hand side of an assignment operator must be a place expression. An
|
||||||
lvalue expression represents a memory location and can be a variable (with
|
place expression represents a memory location and can be a variable (with
|
||||||
optional namespacing), a dereference, an indexing expression or a field
|
optional namespacing), a dereference, an indexing expression or a field
|
||||||
reference.
|
reference.
|
||||||
|
|
||||||
More details can be found in the [Expressions] section of the Reference.
|
More details can be found in the [Expressions] section of the Reference.
|
||||||
|
|
||||||
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#lvalues-rvalues-and-temporaries
|
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries
|
||||||
|
|
||||||
Now, we can go further. Here are some erroneous code examples:
|
Now, we can go further. Here are some erroneous code examples:
|
||||||
|
|
||||||
@ -806,7 +806,7 @@ fn some_other_func() {}
|
|||||||
|
|
||||||
fn some_function() {
|
fn some_function() {
|
||||||
SOME_CONST = 14; // error : a constant value cannot be changed!
|
SOME_CONST = 14; // error : a constant value cannot be changed!
|
||||||
1 = 3; // error : 1 isn't a valid lvalue!
|
1 = 3; // error : 1 isn't a valid place!
|
||||||
some_other_func() = 4; // error : we can't assign value to a function!
|
some_other_func() = 4; // error : we can't assign value to a function!
|
||||||
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
|
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
|
||||||
// like a variable!
|
// like a variable!
|
||||||
|
@ -1439,7 +1439,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
&catch_all_substructure);
|
&catch_all_substructure);
|
||||||
|
|
||||||
// Final wrinkle: the self_args are expressions that deref
|
// Final wrinkle: the self_args are expressions that deref
|
||||||
// down to desired l-values, but we cannot actually deref
|
// down to desired places, but we cannot actually deref
|
||||||
// them when they are fed as r-values into a tuple
|
// them when they are fed as r-values into a tuple
|
||||||
// expression; here add a layer of borrowing, turning
|
// expression; here add a layer of borrowing, turning
|
||||||
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
||||||
@ -1516,7 +1516,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Final wrinkle: the self_args are expressions that deref
|
// Final wrinkle: the self_args are expressions that deref
|
||||||
// down to desired l-values, but we cannot actually deref
|
// down to desired places, but we cannot actually deref
|
||||||
// them when they are fed as r-values into a tuple
|
// them when they are fed as r-values into a tuple
|
||||||
// expression; here add a layer of borrowing, turning
|
// expression; here add a layer of borrowing, turning
|
||||||
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
||||||
|
Loading…
Reference in New Issue
Block a user