Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cee5c4ad
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,发现更多精彩内容 >>
提交
cee5c4ad
编写于
7月 18, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #7849 : nikomatsakis/rust/issue-7444-capture-moved-value, r=bblum
This code looks like it was just wrong. r? @bblum
上级
30ef79ca
782853c6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
12 deletion
+26
-12
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/check_loans.rs
+8
-10
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
+0
-1
src/test/compile-fail/borrowck-move-by-capture.rs
src/test/compile-fail/borrowck-move-by-capture.rs
+3
-1
src/test/compile-fail/borrowck-move-moved-value-into-closure.rs
...st/compile-fail/borrowck-move-moved-value-into-closure.rs
+10
-0
src/test/run-pass/borrowck-move-by-capture-ok.rs
src/test/run-pass/borrowck-move-by-capture-ok.rs
+5
-0
未找到文件。
src/librustc/middle/borrowck/check_loans.rs
浏览文件 @
cee5c4ad
...
...
@@ -639,15 +639,14 @@ fn check_captured_variables(this: @mut CheckLoanCtxt,
span
:
span
)
{
let
cap_vars
=
this
.bccx.capture_map
.get
(
&
closure_id
);
for
cap_vars
.iter
()
.advance
|
cap_var
|
{
let
var_id
=
ast_util
::
def_id_of_def
(
cap_var
.def
)
.node
;
let
var_path
=
@
LpVar
(
var_id
);
this
.check_if_path_is_moved
(
closure_id
,
span
,
MovedInCapture
,
var_path
);
match
cap_var
.mode
{
moves
::
CapRef
|
moves
::
CapCopy
=>
{
let
var_id
=
ast_util
::
def_id_of_def
(
cap_var
.def
)
.node
;
let
lp
=
@
LpVar
(
var_id
);
this
.check_if_path_is_moved
(
closure_id
,
span
,
MovedInCapture
,
lp
);
}
moves
::
CapRef
|
moves
::
CapCopy
=>
{}
moves
::
CapMove
=>
{
check_by_move_capture
(
this
,
closure_id
,
cap_var
);
check_by_move_capture
(
this
,
closure_id
,
cap_var
,
var_path
);
}
}
}
...
...
@@ -655,9 +654,8 @@ fn check_captured_variables(this: @mut CheckLoanCtxt,
fn
check_by_move_capture
(
this
:
@
mut
CheckLoanCtxt
,
closure_id
:
ast
::
node_id
,
cap_var
:
&
moves
::
CaptureVar
)
{
let
var_id
=
ast_util
::
def_id_of_def
(
cap_var
.def
)
.node
;
let
move_path
=
@
LpVar
(
var_id
);
cap_var
:
&
moves
::
CaptureVar
,
move_path
:
@
LoanPath
)
{
let
move_err
=
this
.analyze_move_out_from
(
closure_id
,
move_path
);
match
move_err
{
MoveOk
=>
{}
...
...
src/librustc/middle/typeck/infer/region_inference/mod.rs
浏览文件 @
cee5c4ad
...
...
@@ -385,7 +385,6 @@ pub fn vars_created_since_snapshot(&mut self, snapshot: uint)
pub
fn
tainted
(
&
mut
self
,
snapshot
:
uint
,
r0
:
Region
)
->
~
[
Region
]
{
/*!
*
* Computes all regions that have been related to `r0` in any
* way since the snapshot `snapshot` was taken---`r0` itself
* will be the first entry. This is used when checking whether
...
...
src/test/compile-fail/borrowck-move-by-capture.rs
浏览文件 @
cee5c4ad
...
...
@@ -4,8 +4,10 @@ pub fn main() {
let
_
f
:
@
fn
()
->
int
=
||
*
foo
+
5
;
//~^ ERROR cannot move `foo`
// FIXME(#2202) - Due to the way that borrowck treats closures,
// you get two error reports here.
let
bar
=
~
3
;
let
_
g
=
||
{
//~ ERROR capture of moved value
let
_
h
:
@
fn
()
->
int
=
||
*
bar
;
let
_
h
:
@
fn
()
->
int
=
||
*
bar
;
//~ ERROR capture of moved value
};
}
src/test/compile-fail/borrowck-move-moved-value-into-closure.rs
0 → 100644
浏览文件 @
cee5c4ad
fn
call_f
(
f
:
~
fn
:
Send
()
->
int
)
->
int
{
f
()
}
fn
main
()
{
let
t
=
~
3
;
call_f
(||
{
*
t
+
1
});
call_f
(||
{
*
t
+
1
});
//~ ERROR capture of moved value
}
src/test/run-pass/borrowck-move-by-capture-ok.rs
0 → 100644
浏览文件 @
cee5c4ad
pub
fn
main
()
{
let
bar
=
~
3
;
let
h
:
@
fn
()
->
int
=
||
*
bar
;
assert_eq!
(
h
(),
3
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录