Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
03f198fc
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
03f198fc
编写于
3月 06, 2018
作者:
B
bobtwinkles
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests after two-phase borrow rewrite
上级
e4e377f6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
33 deletion
+14
-33
src/librustc_mir/dataflow/graphviz.rs
src/librustc_mir/dataflow/graphviz.rs
+2
-2
src/librustc_mir/dataflow/impls/borrows.rs
src/librustc_mir/dataflow/impls/borrows.rs
+10
-17
src/test/compile-fail/nll/region-ends-after-if-condition.rs
src/test/compile-fail/nll/region-ends-after-if-condition.rs
+1
-1
src/test/ui/issue-45157.rs
src/test/ui/issue-45157.rs
+0
-1
src/test/ui/issue-45157.stderr
src/test/ui/issue-45157.stderr
+1
-12
未找到文件。
src/librustc_mir/dataflow/graphviz.rs
浏览文件 @
03f198fc
...
...
@@ -111,7 +111,7 @@ fn node_label(&self, n: &Node) -> dot::LabelText {
// | | | | bb11[0]: active |
// +---------+----------------------------------+------------------+------------------+
// | [00-00] | _7 = const Foo::twiddle(move _8) | [0c-00] | [f3-0f] |
// +---------+----------------------------------+------------------+------------------+
// +---------+----------------------------------+------------------+------------------+
let
mut
v
=
Vec
::
new
();
self
.node_label_internal
(
n
,
&
mut
v
,
*
n
,
self
.mbcx
.mir
())
.unwrap
();
dot
::
LabelText
::
html
(
String
::
from_utf8
(
v
)
.unwrap
())
...
...
@@ -140,7 +140,7 @@ fn node_label_internal<W: io::Write>(&self,
block
:
BasicBlock
,
mir
:
&
Mir
)
->
io
::
Result
<
()
>
{
// Header rows
const
HDRS
:
[
&
'static
str
;
4
]
=
[
"ENTRY"
,
"MIR"
,
"
GEN"
,
"KILL
"
];
const
HDRS
:
[
&
'static
str
;
4
]
=
[
"ENTRY"
,
"MIR"
,
"
BLOCK GENS"
,
"BLOCK KILLS
"
];
const
HDR_FMT
:
&
'static
str
=
"bgcolor=
\"
grey
\"
"
;
write!
(
w
,
"<table><tr><td rowspan=
\"
{}
\"
>"
,
HDRS
.len
())
?
;
write!
(
w
,
"{:?}"
,
block
.index
())
?
;
...
...
src/librustc_mir/dataflow/impls/borrows.rs
浏览文件 @
03f198fc
...
...
@@ -272,17 +272,6 @@ fn visit_statement(&mut self,
}
}
/// Represents what kind of usage we've seen.
enum
PlaceUsageType
{
/// No usage seen
None
,
/// Has been seen as the argument to a StorageDead statement. This is required to
/// gracefully handle cases where user code has an unneeded
StorageKilled
,
/// Has been used in borrow-activating context
BorrowActivateUsage
}
/// A MIR visitor that determines if a specific place is used in a two-phase activating
/// manner in a given chunk of MIR.
struct
ContainsUseOfPlace
<
'b
,
'tcx
:
'b
>
{
...
...
@@ -404,7 +393,8 @@ fn region_terminated_after(&self, region: Region<'tcx>, location: Location) -> b
let
stmt
=
&
block_data
.statements
[
location
.statement_index
];
if
let
mir
::
StatementKind
::
EndRegion
(
region_scope
)
=
stmt
.kind
{
if
&
ReScope
(
region_scope
)
==
region
{
// We encountered an EndRegion statement that terminates the provided region
// We encountered an EndRegion statement that terminates the provided
// region
return
true
;
}
}
...
...
@@ -430,7 +420,7 @@ fn region_terminated_after(&self, region: Region<'tcx>, location: Location) -> b
/// See
/// - https://github.com/rust-lang/rust/issues/48431
/// for detailed design notes.
/// See the
TODO
in the body of the function for notes on extending support to more
/// See the
FIXME
in the body of the function for notes on extending support to more
/// general two-phased borrows.
fn
compute_activation_location
(
&
self
,
start_location
:
Location
,
...
...
@@ -473,7 +463,7 @@ fn compute_activation_location(&self,
}
if
self
.location_contains_use
(
curr_loc
,
assigned_place
)
{
//
TODO
: Handle this case a little more gracefully. Perhaps collect
//
FIXME
: Handle this case a little more gracefully. Perhaps collect
// all uses in a vector, and find the point in the CFG that dominates
// all of them?
// Right now this is sufficient though since there should only be exactly
...
...
@@ -596,7 +586,9 @@ fn start_block_effect(&self, _entry_set: &mut IdxSet<ReserveOrActivateIndex>) {
// `_sets`.
}
fn
before_statement_effect
(
&
self
,
sets
:
&
mut
BlockSets
<
ReserveOrActivateIndex
>
,
location
:
Location
)
{
fn
before_statement_effect
(
&
self
,
sets
:
&
mut
BlockSets
<
ReserveOrActivateIndex
>
,
location
:
Location
)
{
debug!
(
"Borrows::before_statement_effect sets: {:?} location: {:?}"
,
sets
,
location
);
self
.kill_loans_out_of_scope_at_location
(
sets
,
location
);
}
...
...
@@ -662,7 +654,6 @@ fn statement_effect(&self, sets: &mut BlockSets<ReserveOrActivateIndex>, locatio
// Issue #46746: Two-phase borrows handles
// stmts of form `Tmp = &mut Borrow` ...
// XXX bob_twinkles experiment with removing this
match
lhs
{
Place
::
Local
(
..
)
|
Place
::
Static
(
..
)
=>
{}
// okay
Place
::
Projection
(
..
)
=>
{
...
...
@@ -704,7 +695,9 @@ fn statement_effect(&self, sets: &mut BlockSets<ReserveOrActivateIndex>, locatio
}
}
fn
before_terminator_effect
(
&
self
,
sets
:
&
mut
BlockSets
<
ReserveOrActivateIndex
>
,
location
:
Location
)
{
fn
before_terminator_effect
(
&
self
,
sets
:
&
mut
BlockSets
<
ReserveOrActivateIndex
>
,
location
:
Location
)
{
debug!
(
"Borrows::before_terminator_effect sets: {:?} location: {:?}"
,
sets
,
location
);
self
.kill_loans_out_of_scope_at_location
(
sets
,
location
);
}
...
...
src/test/compile-fail/nll/region-ends-after-if-condition.rs
浏览文件 @
03f198fc
...
...
@@ -12,7 +12,7 @@
// in the type of `p` includes the points after `&v[0]` up to (but not
// including) the call to `use_x`. The `else` branch is not included.
// compile-flags:-Zborrowck=compare -Znll
// compile-flags:-Zborrowck=compare -Znll
-Ztwo-phase-borrows
#![allow(warnings)]
#![feature(rustc_attrs)]
...
...
src/test/ui/issue-45157.rs
浏览文件 @
03f198fc
...
...
@@ -37,7 +37,6 @@ fn main() {
let
nref
=
&
u
.z.c
;
//~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502]
println!
(
"{} {}"
,
mref
,
nref
)
//~^ ERROR cannot borrow `u.s.a` as mutable because it is also borrowed as immutable [E0502]
}
}
src/test/ui/issue-45157.stderr
浏览文件 @
03f198fc
...
...
@@ -10,17 +10,6 @@ LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also bo
LL | println!("{} {}", mref, nref)
| ---- borrow later used here
error[E0502]: cannot borrow `u.s.a` as mutable because it is also borrowed as immutable
--> $DIR/issue-45157.rs:39:27
|
LL | let nref = &u.z.c;
| ------ immutable borrow occurs here
LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502]
LL | println!("{} {}", mref, nref)
| ^^^^ ---- borrow later used here
| |
| mutable borrow occurs here
error: aborting due to 2 previous errors
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0502"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录