Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
46a9bdda
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
46a9bdda
编写于
1月 29, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: replace "lvalue" terminology with "place" in the code.
上级
06a0e4f7
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
179 addition
and
179 deletion
+179
-179
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+34
-34
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+12
-12
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+2
-2
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+7
-7
src/librustc/ty/adjustment.rs
src/librustc/ty/adjustment.rs
+1
-1
src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
+1
-1
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/borrowck/mod.rs
+1
-1
src/librustc_borrowck/borrowck/move_data.rs
src/librustc_borrowck/borrowck/move_data.rs
+1
-1
src/librustc_mir/borrow_check/flows.rs
src/librustc_mir/borrow_check/flows.rs
+8
-8
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mod.rs
+5
-5
src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/borrow_check/nll/mod.rs
+2
-2
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
+3
-3
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
+2
-2
src/librustc_mir/dataflow/impls/borrows.rs
src/librustc_mir/dataflow/impls/borrows.rs
+4
-4
src/librustc_mir/dataflow/impls/mod.rs
src/librustc_mir/dataflow/impls/mod.rs
+52
-52
src/librustc_mir/dataflow/mod.rs
src/librustc_mir/dataflow/mod.rs
+3
-3
src/librustc_mir/dataflow/move_paths/mod.rs
src/librustc_mir/dataflow/move_paths/mod.rs
+3
-3
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+4
-4
src/librustc_mir/transform/elaborate_drops.rs
src/librustc_mir/transform/elaborate_drops.rs
+6
-6
src/librustc_mir/transform/rustc_peek.rs
src/librustc_mir/transform/rustc_peek.rs
+4
-4
src/librustc_mir/util/elaborate_drops.rs
src/librustc_mir/util/elaborate_drops.rs
+2
-2
src/librustc_trans/abi.rs
src/librustc_trans/abi.rs
+1
-1
src/librustc_trans/mir/constant.rs
src/librustc_trans/mir/constant.rs
+1
-1
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+4
-4
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+7
-7
src/librustc_typeck/diagnostics.rs
src/librustc_typeck/diagnostics.rs
+7
-7
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+2
-2
未找到文件。
src/librustc/middle/liveness.rs
浏览文件 @
46a9bdda
...
...
@@ -1034,10 +1034,10 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
}
hir
::
ExprAssign
(
ref
l
,
ref
r
)
=>
{
// see comment on
lvalu
es in
// propagate_through_
lvalu
e_components()
let
succ
=
self
.write_
lvalu
e
(
&
l
,
succ
,
ACC_WRITE
);
let
succ
=
self
.propagate_through_
lvalu
e_components
(
&
l
,
succ
);
// see comment on
plac
es in
// propagate_through_
plac
e_components()
let
succ
=
self
.write_
plac
e
(
&
l
,
succ
,
ACC_WRITE
);
let
succ
=
self
.propagate_through_
plac
e_components
(
&
l
,
succ
);
self
.propagate_through_expr
(
&
r
,
succ
)
}
...
...
@@ -1047,11 +1047,11 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
let
succ
=
self
.propagate_through_expr
(
&
l
,
succ
);
self
.propagate_through_expr
(
&
r
,
succ
)
}
else
{
// see comment on
lvalu
es in
// propagate_through_
lvalu
e_components()
let
succ
=
self
.write_
lvalu
e
(
&
l
,
succ
,
ACC_WRITE
|
ACC_READ
);
// see comment on
plac
es in
// propagate_through_
plac
e_components()
let
succ
=
self
.write_
plac
e
(
&
l
,
succ
,
ACC_WRITE
|
ACC_READ
);
let
succ
=
self
.propagate_through_expr
(
&
r
,
succ
);
self
.propagate_through_
lvalu
e_components
(
&
l
,
succ
)
self
.propagate_through_
plac
e_components
(
&
l
,
succ
)
}
}
...
...
@@ -1121,14 +1121,14 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
hir
::
ExprInlineAsm
(
ref
ia
,
ref
outputs
,
ref
inputs
)
=>
{
let
succ
=
ia
.outputs
.iter
()
.zip
(
outputs
)
.rev
()
.fold
(
succ
,
|
succ
,
(
o
,
output
)|
{
// see comment on
lvalu
es
// in propagate_through_
lvalu
e_components()
// see comment on
plac
es
// in propagate_through_
plac
e_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_
lvalu
e
(
output
,
succ
,
acc
);
self
.propagate_through_
lvalu
e_components
(
output
,
succ
)
let
succ
=
self
.write_
plac
e
(
output
,
succ
,
acc
);
self
.propagate_through_
plac
e_components
(
output
,
succ
)
}
});
...
...
@@ -1146,11 +1146,11 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
}
}
fn
propagate_through_
lvalu
e_components
(
&
mut
self
,
fn
propagate_through_
plac
e_components
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
)
->
LiveNode
{
// #
Lvalu
es
// #
Plac
es
//
// In general, the full flow graph structure for an
// assignment/move/etc can be handled in one of two ways,
...
...
@@ -1160,7 +1160,7 @@ fn propagate_through_lvalue_components(&mut self,
//
// The two kinds of graphs are:
//
// Tracked
lvalue Untracked lvalu
e
// Tracked
place Untracked plac
e
// ----------------------++-----------------------
// ||
// | || |
...
...
@@ -1168,7 +1168,7 @@ fn propagate_through_lvalue_components(&mut self,
// (rvalue) || (rvalue)
// | || |
// v || v
// (write of
lvalue) || (lvalu
e components)
// (write of
place) || (plac
e components)
// | || |
// v || v
// (succ) || (succ)
...
...
@@ -1177,25 +1177,25 @@ fn propagate_through_lvalue_components(&mut self,
//
// I will cover the two cases in turn:
//
// # Tracked
lvalu
es
// # Tracked
plac
es
//
// A tracked
lvalu
e is a local variable/argument `x`. In
// A tracked
plac
e 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_
lvalu
e()` routine generates
// to node id of `x`. The `write_
plac
e()` routine generates
// the contents of this node. There are no subcomponents to
// consider.
//
// # Non-tracked
lvalu
es
// # Non-tracked
plac
es
//
// These are
lvalu
es like `x[5]` or `x.f`. In that case, we
// These are
plac
es 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_
lvalu
e_components()` (this fn).
// `propagate_through_
plac
e_components()` (this fn).
//
// # Illegal
lvalu
es
// # Illegal
plac
es
//
// It is still possible to observe assignments to non-
lvalu
es;
// It is still possible to observe assignments to non-
plac
es;
// these errors are detected in the later pass borrowck. We
// just ignore such cases and treat them as reads.
...
...
@@ -1207,17 +1207,17 @@ fn propagate_through_lvalue_components(&mut self,
}
}
// see comment on propagate_through_
lvalu
e()
fn
write_
lvalu
e
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
u32
)
// see comment on propagate_through_
plac
e()
fn
write_
plac
e
(
&
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
lvalu
es, so just propagate through
// We do not track other
plac
es, so just propagate through
// to their subcomponents. Also, it may happen that
// non-
lvalu
es occur here, because those are detected in the
// non-
plac
es occur here, because those are detected in the
// later pass borrowck.
_
=>
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
)
{
match
expr
.node
{
hir
::
ExprAssign
(
ref
l
,
_
)
=>
{
this
.check_
lvalu
e
(
&
l
);
this
.check_
plac
e
(
&
l
);
intravisit
::
walk_expr
(
this
,
expr
);
}
hir
::
ExprAssignOp
(
_
,
ref
l
,
_
)
=>
{
if
!
this
.tables
.is_method_call
(
expr
)
{
this
.check_
lvalu
e
(
&
l
);
this
.check_
plac
e
(
&
l
);
}
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
);
}
// Output operands must be
lvalu
es
// Output operands must be
plac
es
for
(
o
,
output
)
in
ia
.outputs
.iter
()
.zip
(
outputs
)
{
if
!
o
.is_indirect
{
this
.check_
lvalu
e
(
output
);
this
.check_
plac
e
(
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
>
{
fn
check_
lvalu
e
(
&
mut
self
,
expr
:
&
'tcx
Expr
)
{
fn
check_
plac
e
(
&
mut
self
,
expr
:
&
'tcx
Expr
)
{
match
expr
.node
{
hir
::
ExprPath
(
hir
::
QPath
::
Resolved
(
_
,
ref
path
))
=>
{
if
let
Def
::
Local
(
nid
)
=
path
.def
{
...
...
@@ -1423,7 +1423,7 @@ fn check_lvalue(&mut self, expr: &'tcx Expr) {
}
}
_
=>
{
// For other kinds of
lvalu
es, no checks are required,
// For other kinds of
plac
es, no checks are required,
// and any embedded expressions are actually rvalues
intravisit
::
walk_expr
(
self
,
expr
);
}
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
46a9bdda
...
...
@@ -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 a
n lvalu
e, then this
//! is the address of the
lvalu
e. If Expr is an rvalue, this is the address of
//! address where the result is to be found. If Expr is a
plac
e, then this
//! is the address of the
plac
e. 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)
...
...
@@ -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
lvalu
e
pub
mutbl
:
MutabilityCategory
,
// mutability of expr as
plac
e
pub
ty
:
Ty
<
'tcx
>
,
// type of the expr (*see WARNING above*)
pub
note
:
Note
,
// Note about the provenance of this cmt
}
...
...
@@ -603,7 +603,7 @@ pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt<'tcx>> {
match
expr
.node
{
hir
::
ExprUnary
(
hir
::
UnDeref
,
ref
e_base
)
=>
{
if
self
.tables
.is_method_call
(
expr
)
{
self
.cat_overloaded_
lvalu
e
(
expr
,
e_base
,
false
)
self
.cat_overloaded_
plac
e
(
expr
,
e_base
,
false
)
}
else
{
let
base_cmt
=
self
.cat_expr
(
&
e_base
)
?
;
self
.cat_deref
(
expr
,
base_cmt
,
false
)
...
...
@@ -631,7 +631,7 @@ pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt<'tcx>> {
// The call to index() returns a `&T` value, which
// is an rvalue. That is what we will be
// dereferencing.
self
.cat_overloaded_
lvalu
e
(
expr
,
base
,
true
)
self
.cat_overloaded_
plac
e
(
expr
,
base
,
true
)
}
else
{
let
base_cmt
=
self
.cat_expr
(
&
base
)
?
;
self
.cat_index
(
expr
,
base_cmt
,
expr_ty
,
InteriorOffsetKind
::
Index
)
...
...
@@ -983,27 +983,27 @@ pub fn cat_tup_field<N:ast_node>(&self,
ret
}
fn
cat_overloaded_
lvalu
e
(
&
self
,
fn
cat_overloaded_
plac
e
(
&
self
,
expr
:
&
hir
::
Expr
,
base
:
&
hir
::
Expr
,
implicit
:
bool
)
->
McResult
<
cmt
<
'tcx
>>
{
debug!
(
"cat_overloaded_
lvalu
e: implicit={}"
,
implicit
);
debug!
(
"cat_overloaded_
plac
e: 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
lvalu
e_ty
=
self
.expr_ty
(
expr
)
?
;
let
plac
e_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_
lvalu
e: base is not a reference"
)
span_bug!
(
expr
.span
,
"cat_overloaded_
plac
e: base is not a reference"
)
}
};
let
ref_ty
=
self
.tcx
.mk_ref
(
region
,
ty
::
TypeAndMut
{
ty
:
lvalu
e_ty
,
ty
:
plac
e_ty
,
mutbl
,
});
...
...
@@ -1386,7 +1386,7 @@ pub fn guarantor(&self) -> cmt<'tcx> {
}
}
/// Returns `FreelyAliasable(_)` if this
lvalu
e represents a freely aliasable pointer type.
/// Returns `FreelyAliasable(_)` if this
plac
e 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
...
...
@@ -1453,7 +1453,7 @@ pub fn descriptive_string(&self, tcx: TyCtxt) -> String {
"static item"
.to_string
()
}
Categorization
::
Rvalue
(
..
)
=>
{
"non-
lvalu
e"
.to_string
()
"non-
plac
e"
.to_string
()
}
Categorization
::
Local
(
vid
)
=>
{
if
tcx
.hir
.is_argument
(
vid
)
{
...
...
src/librustc/middle/region.rs
浏览文件 @
46a9bdda
...
...
@@ -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
lvalu
es
// 3. `ET`, which matches both rvalues like `foo()` as well as
plac
es
// based on rvalues like `foo().x[2].y`.
//
// A subexpression `<rvalue>` that appears in a let initializer
...
...
@@ -1283,7 +1283,7 @@ fn record_rvalue_scope_if_borrow_expr<'a, 'tcx>(
/// | (ET)
/// | <rvalue>
///
/// Note: ET is intended to match "rvalues or
lvalu
es based on rvalues".
/// Note: ET is intended to match "rvalues or
plac
es based on rvalues".
fn
record_rvalue_scope
<
'a
,
'tcx
>
(
visitor
:
&
mut
RegionResolutionVisitor
<
'a
,
'tcx
>
,
expr
:
&
hir
::
Expr
,
blk_scope
:
Option
<
Scope
>
)
{
...
...
src/librustc/mir/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -733,13 +733,13 @@ 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 <- R
V, goto BB1, unwind BB2)
/// DropAndReplace(
P <-
V, goto BB1, unwind BB2)
/// }
/// ```
///
...
...
@@ -747,15 +747,15 @@ pub enum TerminatorKind<'tcx> {
///
/// ```
/// BB0 {
/// Drop(
LV
, goto BB1, unwind BB2)
/// Drop(
P
, goto BB1, unwind BB2)
/// }
/// BB1 {
/// //
LV
is now unitialized
///
LV <- R
V
/// //
P
is now unitialized
///
P <-
V
/// }
/// BB2 {
/// //
LV
is now unitialized -- its dtor panicked
///
LV <- R
V
/// //
P
is now unitialized -- its dtor panicked
///
P <-
V
/// }
/// ```
DropAndReplace
{
...
...
src/librustc/ty/adjustment.rs
浏览文件 @
46a9bdda
...
...
@@ -77,7 +77,7 @@ pub enum Adjust<'tcx> {
/// Go from a mut raw pointer to a const raw pointer.
MutToConstPointer
,
/// Dereference once, producing a
n lvalu
e.
/// Dereference once, producing a
plac
e.
Deref
(
Option
<
OverloadedDeref
<
'tcx
>>
),
/// Take the address and produce either a `&` or `*` pointer.
...
...
src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
浏览文件 @
46a9bdda
...
...
@@ -104,7 +104,7 @@ fn check_scope(&self, max_scope: ty::Region<'tcx>) -> R {
fn
scope
(
&
self
,
cmt
:
&
mc
::
cmt
<
'tcx
>
)
->
ty
::
Region
<
'tcx
>
{
//! Returns the maximal region scope for the which the
//!
lvalu
e `cmt` is guaranteed to be valid without any
//!
plac
e `cmt` is guaranteed to be valid without any
//! rooting etc, and presuming `cmt` is not mutated.
match
cmt
.cat
{
...
...
src/librustc_borrowck/borrowck/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -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
()
{
// large arrays of data inserted as constants can take a lot of
// time and memory to borrow-check - see issue #36799. However,
// they don't have
lvalu
es, so no borrow-check is actually needed.
// they don't have
plac
es, so no borrow-check is actually needed.
// Recognize that case and skip borrow-checking.
debug!
(
"skipping loan propagation for {:?} because of no loans"
,
body_id
);
return
None
;
...
...
src/librustc_borrowck/borrowck/move_data.rs
浏览文件 @
46a9bdda
...
...
@@ -153,7 +153,7 @@ pub struct Assignment {
/// span of node where assignment occurs
pub
span
:
Span
,
/// id for
l-valu
e expression on lhs of assignment
/// id for
plac
e expression on lhs of assignment
pub
assignee_id
:
hir
::
ItemLocalId
,
}
...
...
src/librustc_mir/borrow_check/flows.rs
浏览文件 @
46a9bdda
...
...
@@ -15,8 +15,8 @@
use
rustc
::
mir
::{
BasicBlock
,
Location
};
use
dataflow
::{
MaybeInitialized
Lvals
,
MaybeUninitializedLval
s
};
use
dataflow
::{
EverInitialized
Lval
s
,
MovingOutStatements
};
use
dataflow
::{
MaybeInitialized
Places
,
MaybeUninitializedPlace
s
};
use
dataflow
::{
EverInitialized
Place
s
,
MovingOutStatements
};
use
dataflow
::{
ActiveBorrows
,
FlowAtLocation
,
FlowsAtLocation
};
use
dataflow
::
move_paths
::
HasMoveData
;
use
std
::
fmt
;
...
...
@@ -24,19 +24,19 @@
// (forced to be `pub` due to its use as an associated type below.)
pub
(
crate
)
struct
Flows
<
'b
,
'gcx
:
'tcx
,
'tcx
:
'b
>
{
pub
borrows
:
FlowAtLocation
<
ActiveBorrows
<
'b
,
'gcx
,
'tcx
>>
,
pub
inits
:
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
pub
uninits
:
FlowAtLocation
<
MaybeUninitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
pub
inits
:
FlowAtLocation
<
MaybeInitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
pub
uninits
:
FlowAtLocation
<
MaybeUninitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
pub
move_outs
:
FlowAtLocation
<
MovingOutStatements
<
'b
,
'gcx
,
'tcx
>>
,
pub
ever_inits
:
FlowAtLocation
<
EverInitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
pub
ever_inits
:
FlowAtLocation
<
EverInitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
}
impl
<
'b
,
'gcx
,
'tcx
>
Flows
<
'b
,
'gcx
,
'tcx
>
{
pub
fn
new
(
borrows
:
FlowAtLocation
<
ActiveBorrows
<
'b
,
'gcx
,
'tcx
>>
,
inits
:
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
uninits
:
FlowAtLocation
<
MaybeUninitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
inits
:
FlowAtLocation
<
MaybeInitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
uninits
:
FlowAtLocation
<
MaybeUninitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
move_outs
:
FlowAtLocation
<
MovingOutStatements
<
'b
,
'gcx
,
'tcx
>>
,
ever_inits
:
FlowAtLocation
<
EverInitialized
Lval
s
<
'b
,
'gcx
,
'tcx
>>
,
ever_inits
:
FlowAtLocation
<
EverInitialized
Place
s
<
'b
,
'gcx
,
'tcx
>>
,
)
->
Self
{
Flows
{
borrows
,
...
...
src/librustc_mir/borrow_check/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -35,8 +35,8 @@
use
dataflow
::
FlowAtLocation
;
use
dataflow
::
MoveDataParamEnv
;
use
dataflow
::{
DataflowAnalysis
,
DataflowResultsConsumer
};
use
dataflow
::{
MaybeInitialized
Lvals
,
MaybeUninitializedLval
s
};
use
dataflow
::{
EverInitialized
Lval
s
,
MovingOutStatements
};
use
dataflow
::{
MaybeInitialized
Places
,
MaybeUninitializedPlace
s
};
use
dataflow
::{
EverInitialized
Place
s
,
MovingOutStatements
};
use
dataflow
::{
BorrowData
,
Borrows
,
ReserveOrActivateIndex
};
use
dataflow
::{
ActiveBorrows
,
Reservations
};
use
dataflow
::
indexes
::
BorrowIndex
;
...
...
@@ -160,7 +160,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
id
,
&
attributes
,
&
dead_unwinds
,
MaybeInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
MaybeInitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
i
]),
));
let
flow_uninits
=
FlowAtLocation
::
new
(
do_dataflow
(
...
...
@@ -169,7 +169,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
id
,
&
attributes
,
&
dead_unwinds
,
MaybeUninitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
MaybeUninitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
i
]),
));
let
flow_move_outs
=
FlowAtLocation
::
new
(
do_dataflow
(
...
...
@@ -187,7 +187,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
id
,
&
attributes
,
&
dead_unwinds
,
EverInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
EverInitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.inits
[
i
]),
));
...
...
src/librustc_mir/borrow_check/nll/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -19,7 +19,7 @@
use
transform
::
MirSource
;
use
util
::
liveness
::{
LivenessResults
,
LocalSet
};
use
dataflow
::
FlowAtLocation
;
use
dataflow
::
MaybeInitialized
Lval
s
;
use
dataflow
::
MaybeInitialized
Place
s
;
use
dataflow
::
move_paths
::
MoveData
;
use
util
as
mir_util
;
...
...
@@ -71,7 +71,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
universal_regions
:
UniversalRegions
<
'tcx
>
,
mir
:
&
Mir
<
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'gcx
>
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'cx
,
'gcx
,
'tcx
>>
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Place
s
<
'cx
,
'gcx
,
'tcx
>>
,
move_data
:
&
MoveData
<
'tcx
>
,
)
->
(
RegionInferenceContext
<
'tcx
>
,
...
...
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
浏览文件 @
46a9bdda
...
...
@@ -10,7 +10,7 @@
use
dataflow
::{
FlowAtLocation
,
FlowsAtLocation
};
use
borrow_check
::
nll
::
region_infer
::
Cause
;
use
dataflow
::
MaybeInitialized
Lval
s
;
use
dataflow
::
MaybeInitialized
Place
s
;
use
dataflow
::
move_paths
::{
HasMoveData
,
MoveData
};
use
rustc
::
mir
::{
BasicBlock
,
Location
,
Mir
};
use
rustc
::
mir
::
Local
;
...
...
@@ -34,7 +34,7 @@ pub(super) fn generate<'gcx, 'tcx>(
cx
:
&
mut
TypeChecker
<
'_
,
'gcx
,
'tcx
>
,
mir
:
&
Mir
<
'tcx
>
,
liveness
:
&
LivenessResults
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'_
,
'gcx
,
'tcx
>>
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Place
s
<
'_
,
'gcx
,
'tcx
>>
,
move_data
:
&
MoveData
<
'tcx
>
,
)
{
let
tcx
=
cx
.tcx
();
...
...
@@ -63,7 +63,7 @@ struct TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx>
tcx
:
TyCtxt
<
'typeck
,
'gcx
,
'tcx
>
,
mir
:
&
'gen
Mir
<
'tcx
>
,
liveness
:
&
'gen
LivenessResults
,
flow_inits
:
&
'gen
mut
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'flow
,
'gcx
,
'tcx
>>
,
flow_inits
:
&
'gen
mut
FlowAtLocation
<
MaybeInitialized
Place
s
<
'flow
,
'gcx
,
'tcx
>>
,
move_data
:
&
'gen
MoveData
<
'tcx
>
,
}
...
...
src/librustc_mir/borrow_check/nll/type_check/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -15,7 +15,7 @@
use
borrow_check
::
nll
::
region_infer
::
ClosureRegionRequirementsExt
;
use
borrow_check
::
nll
::
universal_regions
::
UniversalRegions
;
use
dataflow
::
FlowAtLocation
;
use
dataflow
::
MaybeInitialized
Lval
s
;
use
dataflow
::
MaybeInitialized
Place
s
;
use
dataflow
::
move_paths
::
MoveData
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
infer
::{
InferCtxt
,
InferOk
,
InferResult
,
LateBoundRegionConversionTime
,
UnitResult
};
...
...
@@ -100,7 +100,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
mir_def_id
:
DefId
,
universal_regions
:
&
UniversalRegions
<
'tcx
>
,
liveness
:
&
LivenessResults
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Lval
s
<
'_
,
'gcx
,
'tcx
>>
,
flow_inits
:
&
mut
FlowAtLocation
<
MaybeInitialized
Place
s
<
'_
,
'gcx
,
'tcx
>>
,
move_data
:
&
MoveData
<
'tcx
>
,
)
->
MirTypeckRegionConstraints
<
'tcx
>
{
let
body_id
=
infcx
.tcx.hir
.as_local_node_id
(
mir_def_id
)
.unwrap
();
...
...
src/librustc_mir/dataflow/impls/borrows.rs
浏览文件 @
46a9bdda
...
...
@@ -575,10 +575,10 @@ fn has_been_reserved(&self, b: &BorrowIndex) -> bool {
/// has a reservation at the time).
fn
is_potential_use
(
context
:
PlaceContext
)
->
bool
{
match
context
{
// storage effects on a
n
place do not activate it
// storage effects on a place do not activate it
PlaceContext
::
StorageLive
|
PlaceContext
::
StorageDead
=>
false
,
// validation effects do not activate a
n
place
// validation effects do not activate a place
//
// FIXME: Should they? Is it just another read? Or can we
// guarantee it won't dereference the stored address? How
...
...
@@ -589,11 +589,11 @@ fn is_potential_use(context: PlaceContext) -> bool {
// AsmOutput existed, but it's not necessarily a pure overwrite.
// so it's possible this should activate the place.
PlaceContext
::
AsmOutput
|
// pure overwrites of a
n
place do not activate it. (note
// pure overwrites of a place do not activate it. (note
// PlaceContext::Call is solely about dest place)
PlaceContext
::
Store
|
PlaceContext
::
Call
=>
false
,
// reads of a
n
place *do* activate it
// reads of a place *do* activate it
PlaceContext
::
Move
|
PlaceContext
::
Copy
|
PlaceContext
::
Drop
|
...
...
src/librustc_mir/dataflow/impls/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -36,7 +36,7 @@
#[allow(dead_code)]
pub
(
super
)
mod
borrows
;
/// `MaybeInitialized
Lvals` tracks all l-valu
es that might be
/// `MaybeInitialized
Places` tracks all plac
es that might be
/// initialized upon reaching a particular point in the control flow
/// for a function.
///
...
...
@@ -63,35 +63,35 @@
/// }
/// ```
///
/// To determine whether a
n l-valu
e *must* be initialized at a
/// To determine whether a
plac
e *must* be initialized at a
/// particular control-flow point, one can take the set-difference
/// between this data and the data from `MaybeUninitialized
Lval
s` at the
/// between this data and the data from `MaybeUninitialized
Place
s` at the
/// corresponding control-flow point.
///
/// Similarly, at a given `drop` statement, the set-intersection
/// between this data and `MaybeUninitialized
Lval
s` yields the set of
///
l-valu
es that would require a dynamic drop-flag at that statement.
pub
struct
MaybeInitialized
Lval
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
/// between this data and `MaybeUninitialized
Place
s` yields the set of
///
plac
es that would require a dynamic drop-flag at that statement.
pub
struct
MaybeInitialized
Place
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
,
}
impl
<
'a
,
'gcx
:
'tcx
,
'tcx
>
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
:
'tcx
,
'tcx
>
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
)
->
Self
{
MaybeInitialized
Lval
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
MaybeInitialized
Place
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
}
}
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
move_data
(
&
self
)
->
&
MoveData
<
'tcx
>
{
&
self
.mdpe.move_data
}
}
/// `MaybeUninitialized
Lvals` tracks all l-valu
es that might be
/// `MaybeUninitialized
Places` tracks all plac
es that might be
/// uninitialized upon reaching a particular point in the control flow
/// for a function.
///
...
...
@@ -118,42 +118,42 @@ fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
/// }
/// ```
///
/// To determine whether a
n l-valu
e *must* be uninitialized at a
/// To determine whether a
plac
e *must* be uninitialized at a
/// particular control-flow point, one can take the set-difference
/// between this data and the data from `MaybeInitialized
Lval
s` at the
/// between this data and the data from `MaybeInitialized
Place
s` at the
/// corresponding control-flow point.
///
/// Similarly, at a given `drop` statement, the set-intersection
/// between this data and `MaybeInitialized
Lval
s` yields the set of
///
l-valu
es that would require a dynamic drop-flag at that statement.
pub
struct
MaybeUninitialized
Lval
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
/// between this data and `MaybeInitialized
Place
s` yields the set of
///
plac
es that would require a dynamic drop-flag at that statement.
pub
struct
MaybeUninitialized
Place
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
,
}
impl
<
'a
,
'gcx
,
'tcx
>
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
)
->
Self
{
MaybeUninitialized
Lval
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
MaybeUninitialized
Place
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
}
}
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
move_data
(
&
self
)
->
&
MoveData
<
'tcx
>
{
&
self
.mdpe.move_data
}
}
/// `DefinitelyInitialized
Lvals` tracks all l-valu
es that are definitely
/// `DefinitelyInitialized
Places` tracks all plac
es that are definitely
/// initialized upon reaching a particular point in the control flow
/// for a function.
///
/// FIXME: Note that once flow-analysis is complete, this should be
/// the set-complement of MaybeUninitialized
Lval
s; thus we can get rid
/// the set-complement of MaybeUninitialized
Place
s; thus we can get rid
/// of one or the other of these two. I'm inclined to get rid of
/// MaybeUninitialized
Lval
s, simply because the sets will tend to be
/// MaybeUninitialized
Place
s, simply because the sets will tend to be
/// smaller in this analysis and thus easier for humans to process
/// when debugging.
///
...
...
@@ -180,43 +180,43 @@ fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
/// }
/// ```
///
/// To determine whether a
n l-valu
e *may* be uninitialized at a
/// To determine whether a
plac
e *may* be uninitialized at a
/// particular control-flow point, one can take the set-complement
/// of this data.
///
/// Similarly, at a given `drop` statement, the set-difference between
/// this data and `MaybeInitialized
Lvals` yields the set of l-valu
es
/// this data and `MaybeInitialized
Places` yields the set of plac
es
/// that would require a dynamic drop-flag at that statement.
pub
struct
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
pub
struct
DefinitelyInitialized
Place
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
,
}
impl
<
'a
,
'gcx
,
'tcx
:
'a
>
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
:
'a
>
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
)
->
Self
{
DefinitelyInitialized
Lval
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
DefinitelyInitialized
Place
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
}
}
impl
<
'a
,
'gcx
,
'tcx
:
'a
>
HasMoveData
<
'tcx
>
for
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
:
'a
>
HasMoveData
<
'tcx
>
for
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
move_data
(
&
self
)
->
&
MoveData
<
'tcx
>
{
&
self
.mdpe.move_data
}
}
/// `MovingOutStatements` tracks the statements that perform moves out
/// of particular
l-valu
es. More precisely, it tracks whether the
/// of particular
plac
es. More precisely, it tracks whether the
/// *effect* of such moves (namely, the uninitialization of the
///
l-valu
e in question) can reach some point in the control-flow of
///
plac
e in question) can reach some point in the control-flow of
/// the function, or if that effect is "killed" by some intervening
/// operation reinitializing that
l-valu
e.
/// operation reinitializing that
plac
e.
///
/// The resulting dataflow is a more enriched version of
/// `MaybeUninitialized
Lval
s`. Both structures on their own only tell
/// you if a
n l-valu
e *might* be uninitialized at a given point in the
/// `MaybeUninitialized
Place
s`. Both structures on their own only tell
/// you if a
plac
e *might* be uninitialized at a given point in the
/// control flow. But `MovingOutStatements` also includes the added
/// data of *which* particular statement causing the deinitialization
/// 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
}
}
/// `EverInitialized
Lvals` tracks all l-valu
es that might have ever been
/// `EverInitialized
Places` tracks all plac
es that might have ever been
/// initialized upon reaching a particular point in the control flow
/// for a function, without an intervening `Storage Dead`.
///
...
...
@@ -270,28 +270,28 @@ fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
/// c = S; // {a, b, c, d }
/// }
/// ```
pub
struct
EverInitialized
Lval
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
pub
struct
EverInitialized
Place
s
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
,
}
impl
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
EverInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
:
'tcx
,
'tcx
:
'a
>
EverInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
mdpe
:
&
'a
MoveDataParamEnv
<
'gcx
,
'tcx
>
)
->
Self
{
EverInitialized
Lval
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
EverInitialized
Place
s
{
tcx
:
tcx
,
mir
:
mir
,
mdpe
:
mdpe
}
}
}
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
EverInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
HasMoveData
<
'tcx
>
for
EverInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
move_data
(
&
self
)
->
&
MoveData
<
'tcx
>
{
&
self
.mdpe.move_data
}
}
impl
<
'a
,
'gcx
,
'tcx
>
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
update_bits
(
sets
:
&
mut
BlockSets
<
MovePathIndex
>
,
path
:
MovePathIndex
,
state
:
DropFlagState
)
{
...
...
@@ -302,7 +302,7 @@ fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
update_bits
(
sets
:
&
mut
BlockSets
<
MovePathIndex
>
,
path
:
MovePathIndex
,
state
:
DropFlagState
)
{
...
...
@@ -313,7 +313,7 @@ fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
fn
update_bits
(
sets
:
&
mut
BlockSets
<
MovePathIndex
>
,
path
:
MovePathIndex
,
state
:
DropFlagState
)
{
...
...
@@ -324,7 +324,7 @@ fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
type
Idx
=
MovePathIndex
;
fn
name
()
->
&
'static
str
{
"maybe_init"
}
fn
bits_per_block
(
&
self
)
->
usize
{
...
...
@@ -375,7 +375,7 @@ fn propagate_call_return(&self,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
type
Idx
=
MovePathIndex
;
fn
name
()
->
&
'static
str
{
"maybe_uninit"
}
fn
bits_per_block
(
&
self
)
->
usize
{
...
...
@@ -430,7 +430,7 @@ fn propagate_call_return(&self,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
type
Idx
=
MovePathIndex
;
fn
name
()
->
&
'static
str
{
"definite_init"
}
fn
bits_per_block
(
&
self
)
->
usize
{
...
...
@@ -561,7 +561,7 @@ fn propagate_call_return(&self,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
EverInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitDenotation
for
EverInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
type
Idx
=
InitIndex
;
fn
name
()
->
&
'static
str
{
"ever_init"
}
fn
bits_per_block
(
&
self
)
->
usize
{
...
...
@@ -657,21 +657,21 @@ fn propagate_call_return(&self,
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
join
(
&
self
,
pred1
:
usize
,
pred2
:
usize
)
->
usize
{
pred1
|
pred2
// "maybe" means we union effects of both preds
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
join
(
&
self
,
pred1
:
usize
,
pred2
:
usize
)
->
usize
{
pred1
|
pred2
// "maybe" means we union effects of both preds
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
join
(
&
self
,
pred1
:
usize
,
pred2
:
usize
)
->
usize
{
pred1
&
pred2
// "definitely" means we intersect effects of both preds
...
...
@@ -685,7 +685,7 @@ fn join(&self, pred1: usize, pred2: usize) -> usize {
}
}
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
EverInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
BitwiseOperator
for
EverInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
join
(
&
self
,
pred1
:
usize
,
pred2
:
usize
)
->
usize
{
pred1
|
pred2
// inits from both preds are in scope
...
...
@@ -702,21 +702,21 @@ fn join(&self, pred1: usize, pred2: usize) -> usize {
// propagating, or you start at all-ones and then use Intersect as
// your merge when propagating.
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
MaybeInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
MaybeInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
bottom_value
()
->
bool
{
false
// bottom = uninitialized
}
}
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
MaybeUninitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
MaybeUninitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
bottom_value
()
->
bool
{
false
// bottom = initialized (start_block_effect counters this at outset)
}
}
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
DefinitelyInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
DefinitelyInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
bottom_value
()
->
bool
{
true
// bottom = initialized (start_block_effect counters this at outset)
...
...
@@ -730,7 +730,7 @@ fn bottom_value() -> bool {
}
}
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
EverInitialized
Lval
s
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
InitialFlow
for
EverInitialized
Place
s
<
'a
,
'gcx
,
'tcx
>
{
#[inline]
fn
bottom_value
()
->
bool
{
false
// bottom = no initialized variables by default
...
...
src/librustc_mir/dataflow/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -26,9 +26,9 @@
use
std
::
usize
;
pub
use
self
::
impls
::{
MaybeStorageLive
};
pub
use
self
::
impls
::{
MaybeInitialized
Lvals
,
MaybeUninitializedLval
s
};
pub
use
self
::
impls
::{
DefinitelyInitialized
Lval
s
,
MovingOutStatements
};
pub
use
self
::
impls
::
EverInitialized
Lval
s
;
pub
use
self
::
impls
::{
MaybeInitialized
Places
,
MaybeUninitializedPlace
s
};
pub
use
self
::
impls
::{
DefinitelyInitialized
Place
s
,
MovingOutStatements
};
pub
use
self
::
impls
::
EverInitialized
Place
s
;
pub
use
self
::
impls
::
borrows
::{
Borrows
,
BorrowData
};
pub
(
crate
)
use
self
::
impls
::
borrows
::{
ActiveBorrows
,
Reservations
,
ReserveOrActivateIndex
};
pub
use
self
::
at_location
::{
FlowAtLocation
,
FlowsAtLocation
};
...
...
src/librustc_mir/dataflow/move_paths/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -86,7 +86,7 @@ pub fn move_path_index(&self, move_data: &MoveData) -> MovePathIndex {
/// It follows a tree structure.
///
/// Given `struct X { m: M, n: N }` and `x: X`, moves like `drop x.m;`
/// move *out* of the
l-valu
e `x.m`.
/// move *out* of the
plac
e `x.m`.
///
/// 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,
...
...
@@ -222,7 +222,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
/// Tables mapping from a
n l-valu
e to its MovePathIndex.
/// Tables mapping from a
plac
e to its MovePathIndex.
#[derive(Debug)]
pub
struct
MovePathLookup
<
'tcx
>
{
locals
:
IndexVec
<
Local
,
MovePathIndex
>
,
...
...
@@ -247,7 +247,7 @@ pub enum LookupResult {
impl
<
'tcx
>
MovePathLookup
<
'tcx
>
{
// Unlike the builder `fn move_path_for` below, this lookup
// alternative will *not* create a MovePath on the fly for an
// unknown
l-valu
e, but will rather return the nearest available
// unknown
plac
e, but will rather return the nearest available
// parent.
pub
fn
find
(
&
self
,
place
:
&
Place
<
'tcx
>
)
->
LookupResult
{
match
*
place
{
...
...
src/librustc_mir/interpret/place.rs
浏览文件 @
46a9bdda
...
...
@@ -9,9 +9,9 @@
#[derive(Copy,
Clone,
Debug)]
pub
enum
Place
{
/// A
n
place referring to a value allocated in the `Memory` system.
/// A place referring to a value allocated in the `Memory` system.
Ptr
{
/// A
n
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
/// before ever being dereferenced.
ptr
:
Pointer
,
...
...
@@ -19,7 +19,7 @@ pub enum Place {
extra
:
PlaceExtra
,
},
/// A
n
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.
Local
{
frame
:
usize
,
local
:
mir
::
Local
},
}
...
...
@@ -33,7 +33,7 @@ pub enum PlaceExtra {
}
impl
<
'tcx
>
Place
{
/// Produces a
n
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
{
Self
::
from_primval_ptr
(
PrimVal
::
Undef
.into
(),
Align
::
from_bytes
(
1
,
1
)
.unwrap
())
}
...
...
src/librustc_mir/transform/elaborate_drops.rs
浏览文件 @
46a9bdda
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
dataflow
::
move_paths
::{
HasMoveData
,
MoveData
,
MovePathIndex
,
LookupResult
};
use
dataflow
::{
MaybeInitialized
Lvals
,
MaybeUninitializedLval
s
};
use
dataflow
::{
MaybeInitialized
Places
,
MaybeUninitializedPlace
s
};
use
dataflow
::{
DataflowResults
};
use
dataflow
::{
on_all_children_bits
,
on_all_drop_children_bits
};
use
dataflow
::{
drop_flag_effects_for_location
,
on_lookup_result_bits
};
...
...
@@ -60,11 +60,11 @@ fn run_pass<'a, 'tcx>(&self,
let
dead_unwinds
=
find_dead_unwinds
(
tcx
,
mir
,
id
,
&
env
);
let
flow_inits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
[],
&
dead_unwinds
,
MaybeInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
env
),
MaybeInitialized
Place
s
::
new
(
tcx
,
mir
,
&
env
),
|
bd
,
p
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
p
]));
let
flow_uninits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
[],
&
dead_unwinds
,
MaybeUninitialized
Lval
s
::
new
(
tcx
,
mir
,
&
env
),
MaybeUninitialized
Place
s
::
new
(
tcx
,
mir
,
&
env
),
|
bd
,
p
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
p
]));
ElaborateDropsCtxt
{
...
...
@@ -97,7 +97,7 @@ fn find_dead_unwinds<'a, 'tcx>(
let
mut
dead_unwinds
=
IdxSetBuf
::
new_empty
(
mir
.basic_blocks
()
.len
());
let
flow_inits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
[],
&
dead_unwinds
,
MaybeInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
env
),
MaybeInitialized
Place
s
::
new
(
tcx
,
mir
,
&
env
),
|
bd
,
p
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
p
]));
for
(
bb
,
bb_data
)
in
mir
.basic_blocks
()
.iter_enumerated
()
{
let
location
=
match
bb_data
.terminator
()
.kind
{
...
...
@@ -300,8 +300,8 @@ struct ElaborateDropsCtxt<'a, 'tcx: 'a> {
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
mir
:
&
'a
Mir
<
'tcx
>
,
env
:
&
'a
MoveDataParamEnv
<
'tcx
,
'tcx
>
,
flow_inits
:
DataflowResults
<
MaybeInitialized
Lval
s
<
'a
,
'tcx
,
'tcx
>>
,
flow_uninits
:
DataflowResults
<
MaybeUninitialized
Lval
s
<
'a
,
'tcx
,
'tcx
>>
,
flow_inits
:
DataflowResults
<
MaybeInitialized
Place
s
<
'a
,
'tcx
,
'tcx
>>
,
flow_uninits
:
DataflowResults
<
MaybeUninitialized
Place
s
<
'a
,
'tcx
,
'tcx
>>
,
drop_flags
:
FxHashMap
<
MovePathIndex
,
Local
>
,
patch
:
MirPatch
<
'tcx
>
,
}
...
...
src/librustc_mir/transform/rustc_peek.rs
浏览文件 @
46a9bdda
...
...
@@ -22,7 +22,7 @@
use
dataflow
::
MoveDataParamEnv
;
use
dataflow
::
BitDenotation
;
use
dataflow
::
DataflowResults
;
use
dataflow
::{
DefinitelyInitialized
Lvals
,
MaybeInitializedLvals
,
MaybeUninitializedLval
s
};
use
dataflow
::{
DefinitelyInitialized
Places
,
MaybeInitializedPlaces
,
MaybeUninitializedPlace
s
};
use
dataflow
::
move_paths
::{
MovePathIndex
,
LookupResult
};
use
dataflow
::
move_paths
::{
HasMoveData
,
MoveData
};
use
dataflow
;
...
...
@@ -50,15 +50,15 @@ fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
let
dead_unwinds
=
IdxSetBuf
::
new_empty
(
mir
.basic_blocks
()
.len
());
let
flow_inits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
attributes
,
&
dead_unwinds
,
MaybeInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
MaybeInitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
i
]));
let
flow_uninits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
attributes
,
&
dead_unwinds
,
MaybeUninitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
MaybeUninitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
i
]));
let
flow_def_inits
=
do_dataflow
(
tcx
,
mir
,
id
,
&
attributes
,
&
dead_unwinds
,
DefinitelyInitialized
Lval
s
::
new
(
tcx
,
mir
,
&
mdpe
),
DefinitelyInitialized
Place
s
::
new
(
tcx
,
mir
,
&
mdpe
),
|
bd
,
i
|
DebugFormatted
::
new
(
&
bd
.move_data
()
.move_paths
[
i
]));
if
has_rustc_mir_with
(
&
attributes
,
"rustc_peek_maybe_init"
)
.is_some
()
{
...
...
src/librustc_mir/util/elaborate_drops.rs
浏览文件 @
46a9bdda
...
...
@@ -560,7 +560,7 @@ fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind))
/// ptr = cur
/// cur = cur.offset(1)
/// } else {
/// ptr = &mut
LV
[cur]
/// ptr = &mut
P
[cur]
/// cur = cur + 1
/// }
/// drop(ptr)
...
...
@@ -731,7 +731,7 @@ fn drop_loop_pair(&mut self, ety: Ty<'tcx>, ptr_based: bool) -> BasicBlock {
if
ptr_based
{
let
tmp_ty
=
tcx
.mk_mut_ptr
(
self
.place_ty
(
self
.place
));
let
tmp
=
Place
::
Local
(
self
.new_temp
(
tmp_ty
));
// tmp = &
LV
;
// tmp = &
P
;
// cur = tmp as *mut T;
// end = Offset(cur, len);
drop_block_stmts
.push
(
self
.assign
(
&
tmp
,
Rvalue
::
Ref
(
...
...
src/librustc_trans/abi.rs
浏览文件 @
46a9bdda
...
...
@@ -545,7 +545,7 @@ pub fn is_ignore(&self) -> bool {
self
.mode
==
PassMode
::
Ignore
}
/// Get the LLVM type for a
n
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`.
pub
fn
memory_ty
(
&
self
,
cx
:
&
CodegenCx
<
'a
,
'tcx
>
)
->
Type
{
self
.layout
.llvm_type
(
cx
)
...
...
src/librustc_trans/mir/constant.rs
浏览文件 @
46a9bdda
...
...
@@ -209,7 +209,7 @@ enum Base {
Static
(
ValueRef
)
}
/// A
n
place as seen from a constant.
/// A place as seen from a constant.
#[derive(Copy,
Clone)]
struct
ConstPlace
<
'tcx
>
{
base
:
Base
,
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
46a9bdda
...
...
@@ -136,7 +136,7 @@ fn confirm(&mut self,
};
if
let
Some
(
hir
::
MutMutable
)
=
pick
.autoref
{
self
.convert_
lvalu
e_derefs_to_mutable
();
self
.convert_
plac
e_derefs_to_mutable
();
}
ConfirmResult
{
callee
,
illegal_sized_bound
}
...
...
@@ -416,7 +416,7 @@ fn add_obligations(&mut self,
/// 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`
/// respectively.
fn
convert_
lvalu
e_derefs_to_mutable
(
&
self
)
{
fn
convert_
plac
e_derefs_to_mutable
(
&
self
)
{
// Gather up expressions we want to munge.
let
mut
exprs
=
Vec
::
new
();
exprs
.push
(
self
.self_expr
);
...
...
@@ -431,11 +431,11 @@ fn convert_lvalue_derefs_to_mutable(&self) {
}
}
debug!
(
"convert_
lvalu
e_derefs_to_mutable: exprs={:?}"
,
exprs
);
debug!
(
"convert_
plac
e_derefs_to_mutable: exprs={:?}"
,
exprs
);
// Fix up autoderefs and derefs.
for
(
i
,
&
expr
)
in
exprs
.iter
()
.rev
()
.enumerate
()
{
debug!
(
"convert_
lvalu
e_derefs_to_mutable: i={} expr={:?}"
,
i
,
expr
);
debug!
(
"convert_
plac
e_derefs_to_mutable: i={} expr={:?}"
,
i
,
expr
);
// Fix up the autoderefs. Autorefs can only occur immediately preceding
// overloaded place ops, and will be fixed by them in order to get
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -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 `22`.
///
/// - To permit assignment into a local variable or other
lvalu
e
/// - To permit assignment into a local variable or other
plac
e
/// (including the "return slot") of type `!`. This is allowed
/// if **either** the type of value being assigned is `!`, which
/// means the current code is dead, **or** the expression's
...
...
@@ -2275,11 +2275,11 @@ fn is_place_expr(&self, expr: &hir::Expr) -> bool {
}
}
/// For the overloaded
lvalu
e expressions (`*x`, `x[3]`), the trait
/// For the overloaded
plac
e expressions (`*x`, `x[3]`), the trait
/// returns a type of `&T`, but the actual type we assign to the
/// *expression* is `T`. So this function just peels off the return
/// type by one layer to yield `T`.
fn
make_overloaded_
lvalu
e_return_type
(
&
self
,
fn
make_overloaded_
plac
e_return_type
(
&
self
,
method
:
MethodCallee
<
'tcx
>
)
->
ty
::
TypeAndMut
<
'tcx
>
{
...
...
@@ -2373,7 +2373,7 @@ fn try_index_step(&self,
self
.apply_adjustments
(
base_expr
,
adjustments
);
self
.write_method_call
(
expr
.hir_id
,
method
);
(
input_ty
,
self
.make_overloaded_
lvalu
e_return_type
(
method
)
.ty
)
(
input_ty
,
self
.make_overloaded_
plac
e_return_type
(
method
)
.ty
)
});
if
result
.is_some
()
{
return
result
;
...
...
@@ -3650,7 +3650,7 @@ fn check_expr_kind(&self,
target
:
method
.sig
.inputs
()[
0
]
}]);
}
oprnd_t
=
self
.make_overloaded_
lvalu
e_return_type
(
method
)
.ty
;
oprnd_t
=
self
.make_overloaded_
plac
e_return_type
(
method
)
.ty
;
self
.write_method_call
(
expr
.hir_id
,
method
);
}
else
{
type_error_struct!
(
tcx
.sess
,
expr
.span
,
oprnd_t
,
E0614
,
...
...
@@ -3682,7 +3682,7 @@ fn check_expr_kind(&self,
match
ty
.sty
{
ty
::
TyRef
(
_
,
ref
mt
)
|
ty
::
TyRawPtr
(
ref
mt
)
=>
{
if
self
.is_place_expr
(
&
oprnd
)
{
//
Lvalu
es may legitimately have unsized types.
//
Plac
es may legitimately have unsized types.
// For example, dereferences of a fat pointer and
// the last field of a struct can be unsized.
ExpectHasType
(
mt
.ty
)
...
...
@@ -4245,7 +4245,7 @@ pub fn check_decl_initializer(&self,
// ref mut, for soundness (issue #23116). In particular, in
// the latter case, we need to be clear that the type of the
// referent for the reference that results is *equal to* the
// type of the
lvalu
e it is referencing, and not some
// type of the
plac
e it is referencing, and not some
// supertype thereof.
let
init_ty
=
self
.check_expr_with_needs
(
init
,
Needs
::
maybe_mut_place
(
m
));
self
.demand_eqtype
(
init
.span
,
local_ty
,
init_ty
);
...
...
src/librustc_typeck/diagnostics.rs
浏览文件 @
46a9bdda
...
...
@@ -732,8 +732,8 @@ fn main() {
"##
,
E0067
:
r##"
The left-hand side of a compound assignment expression must be a
n lvalu
e
expression. A
n lvalu
e expression represents a memory location and includes
The left-hand side of a compound assignment expression must be a
plac
e
expression. A
plac
e expression represents a memory location and includes
item paths (ie, namespaced variables), dereferences, indexing expressions,
and field references.
...
...
@@ -742,7 +742,7 @@ fn main() {
```compile_fail,E0067
use std::collections::LinkedList;
// Bad: assignment to non-
lvalu
e expression
// Bad: assignment to non-
plac
e expression
LinkedList::new() += 1;
// ...
...
...
@@ -783,14 +783,14 @@ fn foo() -> u8 {
"##
,
E0070
:
r##"
The left-hand side of an assignment operator must be a
n lvalu
e expression. An
lvalu
e expression represents a memory location and can be a variable (with
The left-hand side of an assignment operator must be a
plac
e expression. An
plac
e expression represents a memory location and can be a variable (with
optional namespacing), a dereference, an indexing expression or a field
reference.
More details can be found in the [Expressions] section of the Reference.
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#
lvalu
es-rvalues-and-temporaries
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#
plac
es-rvalues-and-temporaries
Now, we can go further. Here are some erroneous code examples:
...
...
@@ -806,7 +806,7 @@ fn some_other_func() {}
fn some_function() {
SOME_CONST = 14; // error : a constant value cannot be changed!
1 = 3; // error : 1 isn't a valid
lvalu
e!
1 = 3; // error : 1 isn't a valid
plac
e!
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
// like a variable!
...
...
src/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
46a9bdda
...
...
@@ -1439,7 +1439,7 @@ fn build_enum_match_tuple<'b>(&self,
&
catch_all_substructure
);
// Final wrinkle: the self_args are expressions that deref
// down to desired
l-valu
es, but we cannot actually deref
// down to desired
plac
es, but we cannot actually deref
// them when they are fed as r-values into a tuple
// expression; here add a layer of borrowing, turning
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
...
...
@@ -1516,7 +1516,7 @@ fn build_enum_match_tuple<'b>(&self,
}
else
{
// Final wrinkle: the self_args are expressions that deref
// down to desired
l-valu
es, but we cannot actually deref
// down to desired
plac
es, but we cannot actually deref
// them when they are fed as r-values into a tuple
// expression; here add a layer of borrowing, turning
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录