Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fc0b466f
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,发现更多精彩内容 >>
提交
fc0b466f
编写于
12月 22, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: De-`@mut` `all_loans` in the borrow checker
上级
0afae85b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
14 deletion
+20
-14
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
+10
-6
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/borrowck/mod.rs
+10
-8
未找到文件。
src/librustc/middle/borrowck/gather_loans/mod.rs
浏览文件 @
fc0b466f
...
...
@@ -26,6 +26,7 @@
use
util
::
common
::
indenter
;
use
util
::
ppaux
::{
Repr
};
use
std
::
cell
::
RefCell
;
use
syntax
::
ast
;
use
syntax
::
ast_util
::
id_range
;
use
syntax
::
codemap
::
Span
;
...
...
@@ -68,7 +69,7 @@ struct GatherLoanCtxt<'a> {
bccx
:
&
'a
BorrowckCtxt
,
id_range
:
id_range
,
move_data
:
@
move_data
::
MoveData
,
all_loans
:
@
mut
~
[
Loan
]
,
all_loans
:
@
RefCell
<~
[
Loan
]
>
,
item_ub
:
ast
::
NodeId
,
repeating_ids
:
~
[
ast
::
NodeId
]
}
...
...
@@ -103,11 +104,11 @@ fn visit_item(&mut self, _:@ast::item, _:()) { }
pub
fn
gather_loans
(
bccx
:
&
BorrowckCtxt
,
decl
:
&
ast
::
fn_decl
,
body
:
ast
::
P
<
ast
::
Block
>
)
->
(
id_range
,
@
mut
~
[
Loan
]
,
@
move_data
::
MoveData
)
{
->
(
id_range
,
@
RefCell
<~
[
Loan
]
>
,
@
move_data
::
MoveData
)
{
let
mut
glcx
=
GatherLoanCtxt
{
bccx
:
bccx
,
id_range
:
id_range
::
max
(),
all_loans
:
@
mut
~
[]
,
all_loans
:
@
RefCell
::
new
(
~
[])
,
item_ub
:
body
.id
,
repeating_ids
:
~
[
body
.id
],
move_data
:
@
MoveData
::
new
()
...
...
@@ -511,9 +512,9 @@ pub fn guarantee_valid(&mut self,
self
.mark_loan_path_as_mutated
(
loan_path
);
}
let
all_loans
=
&
mut
*
self
.all_loans
;
// FIXME(#5074)
let
all_loans
=
self
.all_loans
.borrow
();
Loan
{
index
:
all_loans
.len
(),
index
:
all_loans
.
get
()
.
len
(),
loan_path
:
loan_path
,
cmt
:
cmt
,
mutbl
:
req_mutbl
,
...
...
@@ -531,7 +532,10 @@ pub fn guarantee_valid(&mut self,
// let loan_path = loan.loan_path;
// let loan_gen_scope = loan.gen_scope;
// let loan_kill_scope = loan.kill_scope;
self
.all_loans
.push
(
loan
);
{
let
mut
all_loans
=
self
.all_loans
.borrow_mut
();
all_loans
.get
()
.push
(
loan
);
}
// if loan_gen_scope != borrow_id {
// FIXME(#6268) Nested method calls
...
...
src/librustc/middle/borrowck/mod.rs
浏览文件 @
fc0b466f
...
...
@@ -133,16 +133,18 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
// Check the body of fn items.
let
(
id_range
,
all_loans
,
move_data
)
=
gather_loans
::
gather_loans
(
this
,
decl
,
body
);
let
mut
loan_dfcx
=
DataFlowContext
::
new
(
this
.tcx
,
this
.method_map
,
LoanDataFlowOperator
,
id_range
,
all_loans
.len
());
for
(
loan_idx
,
loan
)
in
all_loans
.iter
()
.enumerate
()
{
let
all_loans
=
all_loans
.borrow
();
let
mut
loan_dfcx
=
DataFlowContext
::
new
(
this
.tcx
,
this
.method_map
,
LoanDataFlowOperator
,
id_range
,
all_loans
.get
()
.len
());
for
(
loan_idx
,
loan
)
in
all_loans
.get
()
.iter
()
.enumerate
()
{
loan_dfcx
.add_gen
(
loan
.gen_scope
,
loan_idx
);
loan_dfcx
.add_kill
(
loan
.kill_scope
,
loan_idx
);
}
loan_dfcx
.propagate
(
body
);
let
flowed_moves
=
move_data
::
FlowedMoveData
::
new
(
move_data
,
...
...
@@ -152,7 +154,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
body
);
check_loans
::
check_loans
(
this
,
&
loan_dfcx
,
flowed_moves
,
*
all_loans
,
body
);
*
all_loans
.get
()
,
body
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录