Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
982e1166
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
982e1166
编写于
6月 17, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #2633: remove last_use entries that are subject to a loan
上级
3e2006a5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
4 deletion
+38
-4
src/rustc/driver/driver.rs
src/rustc/driver/driver.rs
+2
-1
src/rustc/middle/borrowck.rs
src/rustc/middle/borrowck.rs
+3
-0
src/rustc/middle/borrowck/check_loans.rs
src/rustc/middle/borrowck/check_loans.rs
+21
-0
src/rustc/middle/liveness.rs
src/rustc/middle/liveness.rs
+3
-0
src/test/run-pass/issue-2633-2.rs
src/test/run-pass/issue-2633-2.rs
+8
-0
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2633.rs
+1
-3
未找到文件。
src/rustc/driver/driver.rs
浏览文件 @
982e1166
...
...
@@ -203,7 +203,8 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
bind
middle
::
tstate
::
ck
::
check_crate
(
ty_cx
,
crate
));
let
(
root_map
,
mutbl_map
)
=
time
(
time_passes
,
"borrow checking"
,
bind
middle
::
borrowck
::
check_crate
(
ty_cx
,
method_map
,
crate
));
bind
middle
::
borrowck
::
check_crate
(
ty_cx
,
method_map
,
last_use_map
,
crate
));
time
(
time_passes
,
"kind checking"
,
bind
kind
::
check_crate
(
ty_cx
,
method_map
,
last_use_map
,
crate
));
time
(
time_passes
,
"lint checking"
,
...
...
src/rustc/middle/borrowck.rs
浏览文件 @
982e1166
...
...
@@ -170,9 +170,11 @@
fn
check_crate
(
tcx
:
ty
::
ctxt
,
method_map
:
typeck
::
method_map
,
last_use_map
:
liveness
::
last_use_map
,
crate
:
@
ast
::
crate
)
->
(
root_map
,
mutbl_map
)
{
let
bccx
=
@
{
tcx
:
tcx
,
method_map
:
method_map
,
last_use_map
:
last_use_map
,
root_map
:
root_map
(),
mutbl_map
:
int_hash
()};
...
...
@@ -186,6 +188,7 @@ fn check_crate(tcx: ty::ctxt,
type
borrowck_ctxt
=
@
{
tcx
:
ty
::
ctxt
,
method_map
:
typeck
::
method_map
,
last_use_map
:
liveness
::
last_use_map
,
root_map
:
root_map
,
mutbl_map
:
mutbl_map
};
...
...
src/rustc/middle/borrowck/check_loans.rs
浏览文件 @
982e1166
...
...
@@ -448,6 +448,23 @@ fn check_move_out_from_cmt(cmt: cmt) {
}
}
// Very subtle (#2633): liveness can mark options as last_use even
// when there is an outstanding loan. In that case, it is not
// safe to consider the use a last_use.
fn
check_last_use
(
expr
:
@
ast
::
expr
)
{
let
cmt
=
self
.bccx
.cat_expr
(
expr
);
let
lp
=
alt
cmt
.lp
{
none
{
ret
;
}
some
(
lp
)
{
lp
}
};
for
self
.walk_loans_of
(
cmt
.id
,
lp
)
{
|
_
loan
|
#
debug
[
"Removing last use entry %? due to outstanding loan"
,
expr
.id
];
self
.bccx.last_use_map
.remove
(
expr
.id
);
ret
;
}
}
fn
check_call
(
expr
:
@
ast
::
expr
,
callee
:
option
<@
ast
::
expr
>
,
callee_id
:
ast
::
node_id
,
...
...
@@ -531,6 +548,10 @@ fn check_loans_in_expr(expr: @ast::expr,
self
.check_for_conflicting_loans
(
expr
.id
);
alt
expr
.node
{
ast
::
expr_path
(
*
)
if
self
.bccx.last_use_map
.contains_key
(
expr
.id
)
{
self
.check_last_use
(
expr
);
}
ast
::
expr_swap
(
l
,
r
)
{
self
.check_assignment
(
at_swap
,
l
);
self
.check_assignment
(
at_swap
,
r
);
...
...
src/rustc/middle/liveness.rs
浏览文件 @
982e1166
...
...
@@ -63,6 +63,9 @@
// the local/argument/etc that the path refers to. However, it also
// possible for the expr to be a closure, in which case the list is a
// list of closed over variables that can be moved into the closure.
//
// Very subtle (#2633): borrowck will remove entries from this table
// if it detects an outstanding loan (that is, the addr is taken).
type
last_use_map
=
hashmap
<
node_id
,
@
dvec
<
node_id
>>
;
enum
variable
=
uint
;
...
...
src/test/run-pass/issue-2633-2.rs
0 → 100644
浏览文件 @
982e1166
fn
a_val
(
&&
x
:
~
int
,
+
y
:
~
int
)
->
int
{
*
x
+
*
y
}
fn
main
()
{
let
z
=
~
22
;
a_val
(
z
,
z
);
}
src/test/run-pass/issue-2633.rs
浏览文件 @
982e1166
// Currently segfaults
// xfail-test
class
cat
{
let
mut
meow
:
fn
@
();
new
()
{
self
.meow
=
fn
@
()
{
#
error
(
"meow"
);
};}
...
...
@@ -15,4 +13,4 @@ fn nyan(kitty: cat, _kitty_info: kitty_info) {
fn
main
()
{
let
mut
kitty
=
cat
();
nyan
(
kitty
,
{
kitty
:
kitty
});
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录