Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
959d9d60
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,发现更多精彩内容 >>
提交
959d9d60
编写于
9月 10, 2013
作者:
F
Felix S. Klock II
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check_loans.rs Visitor refactoring (#7081): unify CheckLoan{Ctxt,Visitor}.
上级
485446b9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
37 deletion
+30
-37
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/check_loans.rs
+30
-37
未找到文件。
src/librustc/middle/borrowck/check_loans.rs
浏览文件 @
959d9d60
...
...
@@ -40,24 +40,23 @@ struct CheckLoanCtxt<'self> {
reported
:
@
mut
HashSet
<
ast
::
NodeId
>
,
}
struct
CheckLoanVisitor
;
impl
<
'self
>
Visitor
<
()
>
for
CheckLoanCtxt
<
'self
>
{
impl
<
'self
>
Visitor
<
CheckLoanCtxt
<
'self
>>
for
CheckLoanVisitor
{
fn
visit_expr
<
'a
>
(
&
mut
self
,
ex
:
@
ast
::
Expr
,
e
:
CheckLoanCtxt
<
'a
>
)
{
check_loans_in_expr
(
self
,
ex
,
e
);
fn
visit_expr
(
&
mut
self
,
ex
:
@
ast
::
Expr
,
_
:())
{
check_loans_in_expr
(
self
,
ex
);
}
fn
visit_local
(
&
mut
self
,
l
:
@
ast
::
Local
,
e
:
CheckLoanCtxt
)
{
check_loans_in_local
(
self
,
l
,
e
);
fn
visit_local
(
&
mut
self
,
l
:
@
ast
::
Local
,
_
:()
)
{
check_loans_in_local
(
self
,
l
);
}
fn
visit_block
(
&
mut
self
,
b
:
&
ast
::
Block
,
e
:
CheckLoanCtxt
)
{
check_loans_in_block
(
self
,
b
,
e
);
fn
visit_block
(
&
mut
self
,
b
:
&
ast
::
Block
,
_
:()
)
{
check_loans_in_block
(
self
,
b
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
e
:
CheckLoanCtxt
)
{
check_loans_in_pat
(
self
,
p
,
e
);
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
_
:()
)
{
check_loans_in_pat
(
self
,
p
);
}
fn
visit_fn
(
&
mut
self
,
fk
:
&
visit
::
fn_kind
,
fd
:
&
ast
::
fn_decl
,
b
:
&
ast
::
Block
,
s
:
Span
,
n
:
ast
::
NodeId
,
e
:
CheckLoanCtxt
)
{
check_loans_in_fn
(
self
,
fk
,
fd
,
b
,
s
,
n
,
e
);
b
:
&
ast
::
Block
,
s
:
Span
,
n
:
ast
::
NodeId
,
_
:()
)
{
check_loans_in_fn
(
self
,
fk
,
fd
,
b
,
s
,
n
);
}
}
...
...
@@ -68,7 +67,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
body
:
&
ast
::
Block
)
{
debug!
(
"check_loans(body id=%?)"
,
body
.id
);
let
clcx
=
CheckLoanCtxt
{
let
mut
clcx
=
CheckLoanCtxt
{
bccx
:
bccx
,
dfcx_loans
:
dfcx_loans
,
move_data
:
@
move_data
,
...
...
@@ -76,8 +75,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
reported
:
@
mut
HashSet
::
new
(),
};
let
mut
vt
=
CheckLoanVisitor
;
vt
.visit_block
(
body
,
clcx
);
clcx
.visit_block
(
body
,
());
}
enum
MoveError
{
...
...
@@ -725,13 +723,12 @@ pub fn check_call(&self,
}
}
fn
check_loans_in_fn
<
'a
>
(
visitor
:
&
mut
CheckLoanVisitor
,
fn
check_loans_in_fn
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
fk
:
&
visit
::
fn_kind
,
decl
:
&
ast
::
fn_decl
,
body
:
&
ast
::
Block
,
sp
:
Span
,
id
:
ast
::
NodeId
,
this
:
CheckLoanCtxt
<
'a
>
)
{
id
:
ast
::
NodeId
)
{
match
*
fk
{
visit
::
fk_item_fn
(
*
)
|
visit
::
fk_method
(
*
)
=>
{
...
...
@@ -745,9 +742,9 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
}
}
visit
::
walk_fn
(
visitor
,
fk
,
decl
,
body
,
sp
,
id
,
this
);
visit
::
walk_fn
(
this
,
fk
,
decl
,
body
,
sp
,
id
,
()
);
fn
check_captured_variables
(
this
:
CheckLoanCtxt
,
fn
check_captured_variables
(
this
:
&
CheckLoanCtxt
,
closure_id
:
ast
::
NodeId
,
span
:
Span
)
{
let
cap_vars
=
this
.bccx.capture_map
.get
(
&
closure_id
);
...
...
@@ -765,7 +762,7 @@ fn check_captured_variables(this: CheckLoanCtxt,
}
return
;
fn
check_by_move_capture
(
this
:
CheckLoanCtxt
,
fn
check_by_move_capture
(
this
:
&
CheckLoanCtxt
,
closure_id
:
ast
::
NodeId
,
cap_var
:
&
moves
::
CaptureVar
,
move_path
:
@
LoanPath
)
{
...
...
@@ -788,16 +785,14 @@ fn check_by_move_capture(this: CheckLoanCtxt,
}
}
fn
check_loans_in_local
<
'a
>
(
vt
:
&
mut
CheckLoanVisitor
,
local
:
@
ast
::
Local
,
this
:
CheckLoanCtxt
<
'a
>
)
{
visit
::
walk_local
(
vt
,
local
,
this
);
fn
check_loans_in_local
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
local
:
@
ast
::
Local
)
{
visit
::
walk_local
(
this
,
local
,
());
}
fn
check_loans_in_expr
<
'a
>
(
vt
:
&
mut
CheckLoanVisitor
,
expr
:
@
ast
::
Expr
,
this
:
CheckLoanCtxt
<
'a
>
)
{
visit
::
walk_expr
(
vt
,
expr
,
this
);
fn
check_loans_in_expr
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
expr
:
@
ast
::
Expr
)
{
visit
::
walk_expr
(
this
,
expr
,
());
debug!
(
"check_loans_in_expr(expr=%s)"
,
expr
.repr
(
this
.tcx
()));
...
...
@@ -848,20 +843,18 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor,
}
}
fn
check_loans_in_pat
<
'a
>
(
vt
:
&
mut
CheckLoanVisitor
,
pat
:
@
ast
::
Pat
,
this
:
CheckLoanCtxt
<
'a
>
)
fn
check_loans_in_pat
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
pat
:
@
ast
::
Pat
)
{
this
.check_for_conflicting_loans
(
pat
.id
);
this
.check_move_out_from_id
(
pat
.id
,
pat
.span
);
visit
::
walk_pat
(
vt
,
pat
,
this
);
visit
::
walk_pat
(
this
,
pat
,
()
);
}
fn
check_loans_in_block
<
'a
>
(
vt
:
&
mut
CheckLoanVisitor
,
blk
:
&
ast
::
Block
,
this
:
CheckLoanCtxt
<
'a
>
)
fn
check_loans_in_block
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
blk
:
&
ast
::
Block
)
{
visit
::
walk_block
(
vt
,
blk
,
this
);
visit
::
walk_block
(
this
,
blk
,
()
);
this
.check_for_conflicting_loans
(
blk
.id
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录