Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ca17d081
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
ca17d081
编写于
1月 02, 2015
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix rpass tests
上级
8d0d7521
变更
104
展开全部
隐藏空白更改
内联
并排
Showing
104 changed file
with
212 addition
and
414 deletion
+212
-414
src/test/auxiliary/cci_impl_lib.rs
src/test/auxiliary/cci_impl_lib.rs
+2
-2
src/test/auxiliary/cci_iter_lib.rs
src/test/auxiliary/cci_iter_lib.rs
+1
-1
src/test/auxiliary/cci_no_inline_lib.rs
src/test/auxiliary/cci_no_inline_lib.rs
+1
-1
src/test/auxiliary/iss.rs
src/test/auxiliary/iss.rs
+4
-4
src/test/auxiliary/issue13507.rs
src/test/auxiliary/issue13507.rs
+0
-4
src/test/auxiliary/logging_right_crate.rs
src/test/auxiliary/logging_right_crate.rs
+1
-1
src/test/run-pass/argument-passing.rs
src/test/run-pass/argument-passing.rs
+1
-1
src/test/run-pass/autobind.rs
src/test/run-pass/autobind.rs
+2
-2
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg-call-as.rs
+1
-1
src/test/run-pass/block-explicit-types.rs
src/test/run-pass/block-explicit-types.rs
+1
-1
src/test/run-pass/block-fn-coerce.rs
src/test/run-pass/block-fn-coerce.rs
+3
-2
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-1.rs
+1
-1
src/test/run-pass/block-iter-2.rs
src/test/run-pass/block-iter-2.rs
+1
-1
src/test/run-pass/borrowck-borrow-from-expr-block.rs
src/test/run-pass/borrowck-borrow-from-expr-block.rs
+1
-1
src/test/run-pass/borrowck-closures-two-imm.rs
src/test/run-pass/borrowck-closures-two-imm.rs
+7
-7
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-mut-uniq.rs
+1
-1
src/test/run-pass/call-closure-from-overloaded-op.rs
src/test/run-pass/call-closure-from-overloaded-op.rs
+1
-0
src/test/run-pass/capture-clauses-boxed-closures.rs
src/test/run-pass/capture-clauses-boxed-closures.rs
+1
-1
src/test/run-pass/closure-inference.rs
src/test/run-pass/closure-inference.rs
+2
-2
src/test/run-pass/closure-inference2.rs
src/test/run-pass/closure-inference2.rs
+1
-1
src/test/run-pass/closure-reform.rs
src/test/run-pass/closure-reform.rs
+2
-23
src/test/run-pass/closure-return-bang.rs
src/test/run-pass/closure-return-bang.rs
+0
-20
src/test/run-pass/closure-syntax.rs
src/test/run-pass/closure-syntax.rs
+0
-79
src/test/run-pass/coerce-to-closure-and-proc.rs
src/test/run-pass/coerce-to-closure-and-proc.rs
+0
-37
src/test/run-pass/const-fn-val.rs
src/test/run-pass/const-fn-val.rs
+2
-2
src/test/run-pass/const-vec-of-fns.rs
src/test/run-pass/const-vec-of-fns.rs
+2
-2
src/test/run-pass/empty-tag.rs
src/test/run-pass/empty-tag.rs
+1
-1
src/test/run-pass/enum-null-pointer-opt.rs
src/test/run-pass/enum-null-pointer-opt.rs
+0
-3
src/test/run-pass/expr-block-fn.rs
src/test/run-pass/expr-block-fn.rs
+1
-2
src/test/run-pass/expr-block-generic-unique1.rs
src/test/run-pass/expr-block-generic-unique1.rs
+3
-6
src/test/run-pass/expr-block-generic-unique2.rs
src/test/run-pass/expr-block-generic-unique2.rs
+3
-6
src/test/run-pass/expr-block-generic.rs
src/test/run-pass/expr-block-generic.rs
+4
-9
src/test/run-pass/expr-if-generic.rs
src/test/run-pass/expr-if-generic.rs
+7
-8
src/test/run-pass/expr-match-generic-unique1.rs
src/test/run-pass/expr-match-generic-unique1.rs
+3
-6
src/test/run-pass/expr-match-generic-unique2.rs
src/test/run-pass/expr-match-generic-unique2.rs
+3
-6
src/test/run-pass/fn-bare-coerce-to-block.rs
src/test/run-pass/fn-bare-coerce-to-block.rs
+1
-1
src/test/run-pass/fn-coerce-field.rs
src/test/run-pass/fn-coerce-field.rs
+3
-3
src/test/run-pass/fn-pattern-expected-type.rs
src/test/run-pass/fn-pattern-expected-type.rs
+1
-1
src/test/run-pass/fn-type-infer.rs
src/test/run-pass/fn-type-infer.rs
+1
-1
src/test/run-pass/foreach-nested.rs
src/test/run-pass/foreach-nested.rs
+1
-1
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-put-structured.rs
+1
-1
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/foreach-simple-outer-slot.rs
+1
-1
src/test/run-pass/fun-call-variants.rs
src/test/run-pass/fun-call-variants.rs
+1
-1
src/test/run-pass/generic-static-methods.rs
src/test/run-pass/generic-static-methods.rs
+2
-2
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hashmap-memory.rs
+6
-4
src/test/run-pass/hrtb-debruijn-object-types-in-closures.rs
src/test/run-pass/hrtb-debruijn-object-types-in-closures.rs
+1
-2
src/test/run-pass/hrtb-parse.rs
src/test/run-pass/hrtb-parse.rs
+0
-3
src/test/run-pass/hrtb-trait-object-passed-to-closure.rs
src/test/run-pass/hrtb-trait-object-passed-to-closure.rs
+1
-1
src/test/run-pass/issue-13434.rs
src/test/run-pass/issue-13434.rs
+2
-2
src/test/run-pass/issue-13507-2.rs
src/test/run-pass/issue-13507-2.rs
+0
-1
src/test/run-pass/issue-13808.rs
src/test/run-pass/issue-13808.rs
+3
-3
src/test/run-pass/issue-1460.rs
src/test/run-pass/issue-1460.rs
+1
-1
src/test/run-pass/issue-14919.rs
src/test/run-pass/issue-14919.rs
+4
-4
src/test/run-pass/issue-1516.rs
src/test/run-pass/issue-1516.rs
+0
-13
src/test/run-pass/issue-16256.rs
src/test/run-pass/issue-16256.rs
+1
-1
src/test/run-pass/issue-2074.rs
src/test/run-pass/issue-2074.rs
+2
-2
src/test/run-pass/issue-2487-a.rs
src/test/run-pass/issue-2487-a.rs
+1
-1
src/test/run-pass/issue-3052.rs
src/test/run-pass/issue-3052.rs
+2
-2
src/test/run-pass/issue-3429.rs
src/test/run-pass/issue-3429.rs
+2
-2
src/test/run-pass/issue-3874.rs
src/test/run-pass/issue-3874.rs
+1
-1
src/test/run-pass/issue-3904.rs
src/test/run-pass/issue-3904.rs
+4
-6
src/test/run-pass/issue-5239-2.rs
src/test/run-pass/issue-5239-2.rs
+1
-1
src/test/run-pass/issue-6153.rs
src/test/run-pass/issue-6153.rs
+1
-1
src/test/run-pass/issue-6157.rs
src/test/run-pass/issue-6157.rs
+3
-3
src/test/run-pass/issue-868.rs
src/test/run-pass/issue-868.rs
+2
-2
src/test/run-pass/issue-9129.rs
src/test/run-pass/issue-9129.rs
+1
-1
src/test/run-pass/iter-range.rs
src/test/run-pass/iter-range.rs
+1
-1
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/lambda-infer-unresolved.rs
+1
-1
src/test/run-pass/last-use-in-block.rs
src/test/run-pass/last-use-in-block.rs
+3
-3
src/test/run-pass/last-use-in-cap-clause.rs
src/test/run-pass/last-use-in-cap-clause.rs
+5
-4
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/last-use-is-capture.rs
+1
-1
src/test/run-pass/match-phi.rs
src/test/run-pass/match-phi.rs
+1
-1
src/test/run-pass/monad.rs
src/test/run-pass/monad.rs
+4
-4
src/test/run-pass/move-nullary-fn.rs
src/test/run-pass/move-nullary-fn.rs
+2
-2
src/test/run-pass/mut-function-arguments.rs
src/test/run-pass/mut-function-arguments.rs
+1
-1
src/test/run-pass/mut-in-ident-patterns.rs
src/test/run-pass/mut-in-ident-patterns.rs
+1
-1
src/test/run-pass/newlambdas.rs
src/test/run-pass/newlambdas.rs
+2
-2
src/test/run-pass/non-legacy-modes.rs
src/test/run-pass/non-legacy-modes.rs
+1
-1
src/test/run-pass/pattern-in-closure.rs
src/test/run-pass/pattern-in-closure.rs
+2
-2
src/test/run-pass/purity-infer.rs
src/test/run-pass/purity-infer.rs
+1
-1
src/test/run-pass/regions-copy-closure.rs
src/test/run-pass/regions-copy-closure.rs
+7
-5
src/test/run-pass/regions-dependent-autofn.rs
src/test/run-pass/regions-dependent-autofn.rs
+2
-2
src/test/run-pass/regions-fn-subtyping-2.rs
src/test/run-pass/regions-fn-subtyping-2.rs
+2
-2
src/test/run-pass/regions-fn-subtyping.rs
src/test/run-pass/regions-fn-subtyping.rs
+4
-4
src/test/run-pass/regions-infer-call-2.rs
src/test/run-pass/regions-infer-call-2.rs
+1
-1
src/test/run-pass/regions-lifetime-nonfree-late-bound.rs
src/test/run-pass/regions-lifetime-nonfree-late-bound.rs
+4
-4
src/test/run-pass/regions-link-fn-args.rs
src/test/run-pass/regions-link-fn-args.rs
+1
-1
src/test/run-pass/regions-params.rs
src/test/run-pass/regions-params.rs
+1
-1
src/test/run-pass/regions-static-closure.rs
src/test/run-pass/regions-static-closure.rs
+7
-5
src/test/run-pass/return-from-closure.rs
src/test/run-pass/return-from-closure.rs
+1
-1
src/test/run-pass/sendfn-is-a-block.rs
src/test/run-pass/sendfn-is-a-block.rs
+1
-1
src/test/run-pass/static-impl.rs
src/test/run-pass/static-impl.rs
+7
-7
src/test/run-pass/struct-partial-move-1.rs
src/test/run-pass/struct-partial-move-1.rs
+1
-1
src/test/run-pass/struct-partial-move-2.rs
src/test/run-pass/struct-partial-move-2.rs
+1
-1
src/test/run-pass/tempfile.rs
src/test/run-pass/tempfile.rs
+1
-1
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/trait-bounds-in-arc.rs
+9
-5
src/test/run-pass/trait-generic.rs
src/test/run-pass/trait-generic.rs
+2
-2
src/test/run-pass/type-id-higher-rank.rs
src/test/run-pass/type-id-higher-rank.rs
+0
-18
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/type-params-in-for-each.rs
+1
-1
src/test/run-pass/unnamed_argument_mode.rs
src/test/run-pass/unnamed_argument_mode.rs
+1
-1
src/test/run-pass/unused-move-capture.rs
src/test/run-pass/unused-move-capture.rs
+1
-1
src/test/run-pass/variadic-ffi.rs
src/test/run-pass/variadic-ffi.rs
+1
-1
src/test/run-pass/vec-matching-fold.rs
src/test/run-pass/vec-matching-fold.rs
+14
-8
src/test/run-pass/weird-exprs.rs
src/test/run-pass/weird-exprs.rs
+1
-1
未找到文件。
src/test/auxiliary/cci_impl_lib.rs
浏览文件 @
ca17d081
...
...
@@ -11,12 +11,12 @@
#![crate_name=
"cci_impl_lib"
]
pub
trait
uint_helpers
{
fn
to
(
&
self
,
v
:
uint
,
f
:
|
uint
|
);
fn
to
<
F
>
(
&
self
,
v
:
uint
,
f
:
F
)
where
F
:
FnMut
(
uint
);
}
impl
uint_helpers
for
uint
{
#[inline]
fn
to
(
&
self
,
v
:
uint
,
f
:
|
uint
|
)
{
fn
to
<
F
>
(
&
self
,
v
:
uint
,
mut
f
:
F
)
where
F
:
FnMut
(
uint
)
{
let
mut
i
=
*
self
;
while
i
<
v
{
f
(
i
);
...
...
src/test/auxiliary/cci_iter_lib.rs
浏览文件 @
ca17d081
...
...
@@ -11,7 +11,7 @@
#![crate_name=
"cci_iter_lib"
]
#[inline]
pub
fn
iter
<
T
>
(
v
:
&
[
T
],
f
:
|
&
T
|
)
{
pub
fn
iter
<
T
,
F
>
(
v
:
&
[
T
],
mut
f
:
F
)
where
F
:
FnMut
(
&
T
)
{
let
mut
i
=
0u
;
let
n
=
v
.len
();
while
i
<
n
{
...
...
src/test/auxiliary/cci_no_inline_lib.rs
浏览文件 @
ca17d081
...
...
@@ -12,7 +12,7 @@
// same as cci_iter_lib, more-or-less, but not marked inline
pub
fn
iter
(
v
:
Vec
<
uint
>
,
f
:
|
uint
|
)
{
pub
fn
iter
<
F
>
(
v
:
Vec
<
uint
>
,
mut
f
:
F
)
where
F
:
FnMut
(
uint
)
{
let
mut
i
=
0u
;
let
n
=
v
.len
();
while
i
<
n
{
...
...
src/test/auxiliary/iss.rs
浏览文件 @
ca17d081
...
...
@@ -12,12 +12,12 @@
// part of issue-6919.rs
pub
struct
C
<
'a
>
{
pub
k
:
||:
'a
,
pub
struct
C
<
K
>
where
K
:
FnOnce
()
{
pub
k
:
K
,
}
fn
no_op
()
{
}
pub
const
D
:
C
<
'static
>
=
C
{
k
:
no_op
pub
const
D
:
C
<
fn
()
>
=
C
{
k
:
no_op
as
fn
()
};
src/test/auxiliary/issue13507.rs
浏览文件 @
ca17d081
...
...
@@ -21,7 +21,6 @@ pub fn type_ids() -> Vec<TypeId> {
ids
.push
(
TypeId
::
of
::
<
FooEnum
>
());
ids
.push
(
TypeId
::
of
::
<
FooUniq
>
());
ids
.push
(
TypeId
::
of
::
<
FooPtr
>
());
ids
.push
(
TypeId
::
of
::
<
FooClosure
>
());
ids
.push
(
TypeId
::
of
::
<&
'static
FooTrait
>
());
ids
.push
(
TypeId
::
of
::
<
FooStruct
>
());
ids
.push
(
TypeId
::
of
::
<
FooTuple
>
());
...
...
@@ -68,9 +67,6 @@ pub enum FooEnum {
// Skipping ty_bare_fn (how do you get a bare function type, rather than proc or closure?)
// Tests ty_closure (does not test all types of closures)
pub
type
FooClosure
=
|
arg
:
u8
|:
'static
->
u8
;
// Tests ty_trait
pub
trait
FooTrait
{
fn
foo_method
(
&
self
)
->
uint
;
...
...
src/test/auxiliary/logging_right_crate.rs
浏览文件 @
ca17d081
...
...
@@ -13,5 +13,5 @@
pub
fn
foo
<
T
>
()
{
fn
death
()
->
int
{
panic!
()
}
debug!
(
"{}"
,
(||{
death
()
})());
debug!
(
"{}"
,
(|
&
:
|{
death
()
})());
}
src/test/run-pass/argument-passing.rs
浏览文件 @
ca17d081
...
...
@@ -20,7 +20,7 @@ fn f1(a: &mut X, b: &mut int, c: int) -> int {
return
r
;
}
fn
f2
(
a
:
int
,
f
:
|
int
|)
->
int
{
f
(
1
);
return
a
;
}
fn
f2
<
F
>
(
a
:
int
,
f
:
F
)
->
int
where
F
:
FnOnce
(
int
)
{
f
(
1
);
return
a
;
}
pub
fn
main
()
{
let
mut
a
=
X
{
x
:
1
};
...
...
src/test/run-pass/autobind.rs
浏览文件 @
ca17d081
...
...
@@ -11,11 +11,11 @@
fn
f
<
T
>
(
x
:
Vec
<
T
>
)
->
T
{
return
x
.into_iter
()
.next
()
.unwrap
();
}
fn
g
(
act
:
|
Vec
<
int
>
|
->
int
)
->
int
{
return
act
(
vec!
(
1
,
2
,
3
));
}
fn
g
<
F
>
(
act
:
F
)
->
int
where
F
:
FnOnce
(
Vec
<
int
>
)
->
int
{
return
act
(
vec!
(
1
,
2
,
3
));
}
pub
fn
main
()
{
assert_eq!
(
g
(
f
),
1
);
let
f1
:
|
Vec
<
String
>
|
->
String
=
f
;
let
f1
=
f
;
assert_eq!
(
f1
(
vec!
[
"x"
.to_string
(),
"y"
.to_string
(),
"z"
.to_string
()]),
"x"
.to_string
());
}
src/test/run-pass/block-arg-call-as.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
asBlock
(
f
:
||
->
uint
)
->
uint
{
fn
asBlock
<
F
>
(
f
:
F
)
->
uint
where
F
:
FnOnce
(
)
->
uint
{
return
f
();
}
...
...
src/test/run-pass/block-explicit-types.rs
浏览文件 @
ca17d081
...
...
@@ -9,6 +9,6 @@
// except according to those terms.
pub
fn
main
()
{
fn
as_buf
<
T
>
(
s
:
String
,
f
:
|
String
|
->
T
)
->
T
{
f
(
s
)
}
fn
as_buf
<
T
,
F
>
(
s
:
String
,
f
:
F
)
->
T
where
F
:
FnOnce
(
String
)
->
T
{
f
(
s
)
}
as_buf
(
"foo"
.to_string
(),
|
foo
:
String
|
->
()
println!
(
"{}"
,
foo
)
);
}
src/test/run-pass/block-fn-coerce.rs
浏览文件 @
ca17d081
...
...
@@ -8,10 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
force
(
f
:
||
->
int
)
->
int
{
return
f
();
}
fn
force
<
F
>
(
f
:
F
)
->
int
where
F
:
FnOnce
()
->
int
{
return
f
();
}
pub
fn
main
()
{
fn
f
()
->
int
{
return
7
;
}
assert_eq!
(
force
(
f
),
7
);
let
g
=
{||
force
(
f
)};
let
g
=
{|
&
:
|
force
(
f
)};
assert_eq!
(
g
(),
7
);
}
src/test/run-pass/block-iter-1.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
iter_vec
<
T
>
(
v
:
Vec
<
T
>
,
f
:
|
&
T
|
)
{
for
x
in
v
.iter
()
{
f
(
x
);
}
}
fn
iter_vec
<
T
,
F
>
(
v
:
Vec
<
T
>
,
mut
f
:
F
)
where
F
:
FnMut
(
&
T
)
{
for
x
in
v
.iter
()
{
f
(
x
);
}
}
pub
fn
main
()
{
let
v
=
vec!
(
1
i
,
2
,
3
,
4
,
5
,
6
,
7
);
...
...
src/test/run-pass/block-iter-2.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
iter_vec
<
T
>
(
v
:
Vec
<
T
>
,
f
:
|
&
T
|
)
{
for
x
in
v
.iter
()
{
f
(
x
);
}
}
fn
iter_vec
<
T
,
F
>
(
v
:
Vec
<
T
>
,
mut
f
:
F
)
where
F
:
FnMut
(
&
T
)
{
for
x
in
v
.iter
()
{
f
(
x
);
}
}
pub
fn
main
()
{
let
v
=
vec!
(
1
i
,
2
,
3
,
4
,
5
);
...
...
src/test/run-pass/borrowck-borrow-from-expr-block.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
borrow
(
x
:
&
int
,
f
:
|
x
:
&
int
|
)
{
fn
borrow
<
F
>
(
x
:
&
int
,
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
f
(
x
)
}
...
...
src/test/run-pass/borrowck-closures-two-imm.rs
浏览文件 @
ca17d081
...
...
@@ -15,10 +15,10 @@
// the closures are in scope. Issue #6801.
fn
a
()
->
int
{
let
mut
x
=
3
;
let
mut
x
=
3
i
;
x
+=
1
;
let
c1
=
||
x
*
4
;
let
c2
=
||
x
*
5
;
let
c1
=
|
&
:
|
x
*
4
;
let
c2
=
|
&
:
|
x
*
5
;
c1
()
*
c2
()
*
x
}
...
...
@@ -29,16 +29,16 @@ fn get(x: &int) -> int {
fn
b
()
->
int
{
let
mut
x
=
3
;
x
+=
1
;
let
c1
=
||
get
(
&
x
);
let
c2
=
||
get
(
&
x
);
let
c1
=
|
&
:
|
get
(
&
x
);
let
c2
=
|
&
:
|
get
(
&
x
);
c1
()
*
c2
()
*
x
}
fn
c
()
->
int
{
let
mut
x
=
3
;
x
+=
1
;
let
c1
=
||
x
*
5
;
let
c2
=
||
get
(
&
x
);
let
c1
=
|
&
:
|
x
*
5
;
let
c2
=
|
&
:
|
get
(
&
x
);
c1
()
*
c2
()
*
x
}
...
...
src/test/run-pass/borrowck-mut-uniq.rs
浏览文件 @
ca17d081
...
...
@@ -21,7 +21,7 @@ fn add_int(x: &mut Ints, v: int) {
swap
(
&
mut
values
,
&
mut
x
.values
);
}
fn
iter_ints
(
x
:
&
Ints
,
f
:
|
x
:
&
int
|
->
bool
)
->
bool
{
fn
iter_ints
<
F
>
(
x
:
&
Ints
,
mut
f
:
F
)
->
bool
where
F
:
FnMut
(
&
int
)
->
bool
{
let
l
=
x
.values
.len
();
range
(
0u
,
l
)
.all
(|
i
|
f
(
&
x
.values
[
i
]))
}
...
...
src/test/run-pass/call-closure-from-overloaded-op.rs
浏览文件 @
ca17d081
...
...
@@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test FIXME(japaric) this ICEs
fn
foo
()
->
int
{
22
}
...
...
src/test/run-pass/capture-clauses-boxed-closures.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
each
<
T
>
(
x
:
&
[
T
],
f
:
|
&
T
|
)
{
fn
each
<
T
,
F
>
(
x
:
&
[
T
],
mut
f
:
F
)
where
F
:
FnMut
(
&
T
)
{
for
val
in
x
.iter
()
{
f
(
val
)
}
...
...
src/test/run-pass/closure-inference.rs
浏览文件 @
ca17d081
...
...
@@ -11,9 +11,9 @@
fn
foo
(
i
:
int
)
->
int
{
i
+
1
}
fn
apply
<
A
>
(
f
:
|
A
|
->
A
,
v
:
A
)
->
A
{
f
(
v
)
}
fn
apply
<
A
,
F
>
(
f
:
F
,
v
:
A
)
->
A
where
F
:
FnOnce
(
A
)
->
A
{
f
(
v
)
}
pub
fn
main
()
{
let
f
=
{|
i
|
foo
(
i
)};
let
f
=
{|
:
i
|
foo
(
i
)};
assert_eq!
(
apply
(
f
,
2
),
3
);
}
src/test/run-pass/closure-inference2.rs
浏览文件 @
ca17d081
...
...
@@ -11,7 +11,7 @@
// Test a rather underspecified example:
pub
fn
main
()
{
let
f
=
{|
i
|
i
};
let
f
=
{|
&
:
i
|
i
};
assert_eq!
(
f
(
2
i
),
2
i
);
assert_eq!
(
f
(
5
i
),
5
i
);
}
src/test/run-pass/closure-reform.rs
浏览文件 @
ca17d081
...
...
@@ -22,25 +22,14 @@ fn call_it<F>(f: F)
println!
(
"{}"
,
f
(
"Fred"
.to_string
()))
}
fn
call_a_thunk
(
f
:
||
)
{
fn
call_a_thunk
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
();
}
fn
call_this
(
f
:
|
&
str
|:
Send
)
{
fn
call_this
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
&
str
)
+
Send
{
f
(
"Hello!"
);
}
fn
call_that
(
f
:
<
'a
>
|
&
'a
int
,
&
'a
int
|
->
int
)
{
let
(
ten
,
forty_two
)
=
(
10
,
42
);
println!
(
"Your lucky number is {}"
,
f
(
&
ten
,
&
forty_two
));
}
fn
call_cramped
(
f
:||
->
uint
,
g
:
<
'a
>
||
->
&
'a
uint
)
{
let
number
=
f
();
let
other_number
=
*
g
();
println!
(
"Ticket {} wins an all-expenses-paid trip to Mountain View"
,
number
+
other_number
);
}
fn
call_bare
(
f
:
fn
(
&
str
))
{
f
(
"Hello world!"
)
}
...
...
@@ -71,16 +60,6 @@ pub fn main() {
call_this
(|
s
|
println!
(
"{}"
,
s
));
call_that
(|
x
,
y
|
*
x
+
*
y
);
let
z
=
100
;
call_that
(|
x
,
y
|
*
x
+
*
y
-
z
);
call_cramped
(||
1
,
||
unsafe
{
static
a
:
uint
=
100
;
mem
::
transmute
(
&
a
)
});
// External functions
call_bare
(
println
);
...
...
src/test/run-pass/closure-return-bang.rs
已删除
100644 → 0
浏览文件 @
8d0d7521
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
fn
f
(
x
:
||
->
!
)
->
!
{
x
();
}
fn
main
()
{
let
x
:
||
->
!
=
||
panic!
();
let
_
y
:
||
->
!
=
||
x
();
}
src/test/run-pass/closure-syntax.rs
已删除
100644 → 0
浏览文件 @
8d0d7521
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
#![feature(unboxed_closures)]
// compile-flags:-g
fn
foo
<
T
>
()
{}
trait
Bar3
{}
impl
<
'b
>
Bar3
for
<
'a
>
|
&
'a
int
|:
'b
+
Send
->
&
'a
int
{}
struct
Foo
<
'a
>
{
a
:
||:
'a
,
b
:
||:
'static
,
c
:
<
'b
>
||:
'a
,
d
:
||:
'a
+
Sync
,
e
:
<
'b
>
|
int
|:
'a
+
Sync
->
&
'b
f32
,
}
fn
f
<
'a
>
(
a
:
&
'a
int
,
f
:
<
'b
>
|
&
'b
int
|
->
&
'b
int
)
->
&
'a
int
{
f
(
a
)
}
fn
g
<
'a
>
(
a
:
&
'a
int
)
->
&
'a
int
{
a
}
struct
A
;
impl
A
{
fn
foo
<
T
>
(
&
self
)
{}
}
fn
bar
<
'b
>
()
{
foo
::
<
||
>
();
foo
::
<
||
->
()
>
();
foo
::
<
||:
>
();
foo
::
<
||:
'b
>
();
foo
::
<
||:
'b
+
Sync
>
();
foo
::
<
||:
Sync
>
();
foo
::
<
<
'a
>
|
int
,
f32
,
&
'a
int
|:
'b
+
Sync
->
&
'a
int
>
();
foo
::
<<
'a
>
||
>
();
// issue #11209
let
_
:
||:
'b
;
// for comparison
let
_
:
<
'a
>
||;
let
_
:
Option
<
||:
'b
>
;
let
_
:
Option
<<
'a
>
||
>
;
let
_
:
Option
<
<
'a
>
||
>
;
// issue #11210
let
_
:
||:
'static
;
let
a
=
A
;
a
.foo
::
<<
'a
>
||
>
();
// issue #13490
let
_
=
||
->
!
loop
{};
// issue #17021
let
c
=
box
|
&
:|
{};
}
struct
B
<
T
>
;
impl
<
'b
>
B
<<
'a
>
||:
'b
>
{}
pub
fn
main
()
{
}
src/test/run-pass/coerce-to-closure-and-proc.rs
已删除
100644 → 0
浏览文件 @
8d0d7521
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
#[derive(PartialEq,
Show)]
struct
Foo
<
T
>
(
T
);
#[derive(PartialEq,
Show)]
enum
Bar
<
T
>
{
Baz
(
T
)
}
pub
fn
main
()
{
let
f
:
|
int
|
->
int
=
id
;
assert_eq!
(
f
(
5
),
5
);
let
f
:
|
int
|
->
Foo
<
int
>
=
Foo
;
assert_eq!
(
f
(
5
),
Foo
(
5
));
let
f
:
|
int
|
->
Bar
<
int
>
=
Bar
::
Baz
;
assert_eq!
(
f
(
5
),
Bar
::
Baz
(
5
));
let
f
:
|
int
|
->
Option
<
int
>
=
Some
;
assert_eq!
(
f
(
5
),
Some
(
5
));
}
src/test/run-pass/const-fn-val.rs
浏览文件 @
ca17d081
...
...
@@ -12,9 +12,9 @@ fn foo() -> int {
return
0xca7f000d
;
}
struct
Bar
<
'a
>
{
f
:
||:
'a
->
int
}
struct
Bar
<
F
>
where
F
:
FnMut
()
->
int
{
f
:
F
}
static
mut
b
:
Bar
<
'static
>
=
Bar
{
f
:
foo
};
static
mut
b
:
Bar
<
fn
()
->
int
>
=
Bar
{
f
:
foo
as
fn
()
->
int
};
pub
fn
main
()
{
unsafe
{
assert_eq!
((
b
.f
)(),
0xca7f000d
);
}
...
...
src/test/run-pass/const-vec-of-fns.rs
浏览文件 @
ca17d081
...
...
@@ -17,8 +17,8 @@
fn
f
()
{
}
static
bare_fns
:
&
'static
[
fn
()]
=
&
[
f
,
f
];
struct
S
<
'a
>
(||:
'a
);
static
mut
closures
:
&
'static
mut
[
S
<
'static
>
]
=
&
mut
[
S
(
f
),
S
(
f
)];
struct
S
<
F
:
FnOnce
()
>
(
F
);
static
mut
closures
:
&
'static
mut
[
S
<
fn
()
>
]
=
&
mut
[
S
(
f
as
fn
()),
S
(
f
as
fn
()
)];
pub
fn
main
()
{
unsafe
{
...
...
src/test/run-pass/empty-tag.rs
浏览文件 @
ca17d081
...
...
@@ -25,6 +25,6 @@ fn wrapper3(i: chan) {
}
pub
fn
main
()
{
let
wrapped
=
{||
wrapper3
(
chan
::
chan_t
)};
let
wrapped
=
{|
&
:
|
wrapper3
(
chan
::
chan_t
)};
wrapped
();
}
src/test/run-pass/enum-null-pointer-opt.rs
浏览文件 @
ca17d081
...
...
@@ -19,9 +19,6 @@
trait
Trait
{}
fn
main
()
{
// Closures - ||
assert_eq!
(
size_of
::
<
||
>
(),
size_of
::
<
Option
<
||
>>
());
// Functions
assert_eq!
(
size_of
::
<
fn
(
int
)
>
(),
size_of
::
<
Option
<
fn
(
int
)
>>
());
assert_eq!
(
size_of
::
<
extern
"C"
fn
(
int
)
>
(),
size_of
::
<
Option
<
extern
"C"
fn
(
int
)
>>
());
...
...
src/test/run-pass/expr-block-fn.rs
浏览文件 @
ca17d081
...
...
@@ -11,9 +11,8 @@
fn
test_fn
()
{
type
t
=
||:
'static
->
int
;
fn
ten
()
->
int
{
return
10
;
}
let
rs
:
t
=
ten
;
let
rs
=
ten
;
assert
!
((
rs
()
==
10
));
}
...
...
src/test/run-pass/expr-block-generic-unique1.rs
浏览文件 @
ca17d081
...
...
@@ -8,12 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
compare
<
'a
,
T
>
=
|
Box
<
T
>
,
Box
<
T
>
|:
'a
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
Box
<
T
>
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
,
F
>
(
expected
:
Box
<
T
>
,
eq
:
F
)
where
T
:
Clone
,
F
:
FnOnce
(
Box
<
T
>
,
Box
<
T
>
)
->
bool
{
let
actual
:
Box
<
T
>
=
{
expected
.clone
()
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_box
()
{
...
...
@@ -22,7 +19,7 @@ fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool {
println!
(
"{}"
,
*
b2
);
return
*
b1
==
*
b2
;
}
test_generic
::
<
bool
>
(
box
true
,
compare_box
);
test_generic
::
<
bool
,
_
>
(
box
true
,
compare_box
);
}
pub
fn
main
()
{
test_box
();
}
src/test/run-pass/expr-block-generic-unique2.rs
浏览文件 @
ca17d081
...
...
@@ -8,17 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
compare
<
'a
,
T
>
=
|
T
,
T
|:
'a
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
,
F
>
(
expected
:
T
,
eq
:
F
)
where
T
:
Clone
,
F
:
FnOnce
(
T
,
T
)
->
bool
{
let
actual
:
T
=
{
expected
.clone
()
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_vec
()
{
fn
compare_vec
(
v1
:
Box
<
int
>
,
v2
:
Box
<
int
>
)
->
bool
{
return
v1
==
v2
;
}
test_generic
::
<
Box
<
int
>>
(
box
1
,
compare_vec
);
test_generic
::
<
Box
<
int
>
,
_
>
(
box
1
,
compare_vec
);
}
pub
fn
main
()
{
test_vec
();
}
src/test/run-pass/expr-block-generic.rs
浏览文件 @
ca17d081
...
...
@@ -8,19 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests for standalone blocks as expressions with dynamic type sizes
type
compare
<
'a
,
T
>
=
|
T
,
T
|:
'a
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
,
F
>
(
expected
:
T
,
eq
:
F
)
where
F
:
FnOnce
(
T
,
T
)
->
bool
{
let
actual
:
T
=
{
expected
.clone
()
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_bool
()
{
fn
compare_bool
(
b1
:
bool
,
b2
:
bool
)
->
bool
{
return
b1
==
b2
;
}
test_generic
::
<
bool
>
(
true
,
compare_bool
);
test_generic
::
<
bool
,
_
>
(
true
,
compare_bool
);
}
#[derive(Clone)]
...
...
@@ -33,7 +28,7 @@ fn test_rec() {
fn
compare_rec
(
t1
:
Pair
,
t2
:
Pair
)
->
bool
{
t1
.a
==
t2
.a
&&
t1
.b
==
t2
.b
}
test_generic
::
<
Pair
>
(
Pair
{
a
:
1
,
b
:
2
},
compare_rec
);
test_generic
::
<
Pair
,
_
>
(
Pair
{
a
:
1
,
b
:
2
},
compare_rec
);
}
pub
fn
main
()
{
test_bool
();
test_rec
();
}
src/test/run-pass/expr-if-generic.rs
浏览文件 @
ca17d081
...
...
@@ -8,18 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests for if as expressions with dynamic type sizes
type
compare
<
T
>
=
|
T
,
T
|:
'static
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
T
,
not_expected
:
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
,
F
>
(
expected
:
T
,
not_expected
:
T
,
eq
:
F
)
where
T
:
Clone
,
F
:
FnOnce
(
T
,
T
)
->
bool
,
{
let
actual
:
T
=
if
true
{
expected
.clone
()
}
else
{
not_expected
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_bool
()
{
fn
compare_bool
(
b1
:
bool
,
b2
:
bool
)
->
bool
{
return
b1
==
b2
;
}
test_generic
::
<
bool
>
(
true
,
false
,
compare_bool
);
test_generic
::
<
bool
,
_
>
(
true
,
false
,
compare_bool
);
}
#[derive(Clone)]
...
...
@@ -32,7 +31,7 @@ fn test_rec() {
fn
compare_rec
(
t1
:
Pair
,
t2
:
Pair
)
->
bool
{
t1
.a
==
t2
.a
&&
t1
.b
==
t2
.b
}
test_generic
::
<
Pair
>
(
Pair
{
a
:
1
,
b
:
2
},
Pair
{
a
:
2
,
b
:
3
},
compare_rec
);
test_generic
::
<
Pair
,
_
>
(
Pair
{
a
:
1
,
b
:
2
},
Pair
{
a
:
2
,
b
:
3
},
compare_rec
);
}
pub
fn
main
()
{
test_bool
();
test_rec
();
}
src/test/run-pass/expr-match-generic-unique1.rs
浏览文件 @
ca17d081
...
...
@@ -8,22 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
compare
<
T
>
=
|
Box
<
T
>
,
Box
<
T
>
|:
'static
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
Box
<
T
>
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
,
F
>
(
expected
:
Box
<
T
>
,
eq
:
F
)
where
F
:
FnOnce
(
Box
<
T
>
,
Box
<
T
>
)
->
bool
{
let
actual
:
Box
<
T
>
=
match
true
{
true
=>
{
expected
.clone
()
},
_
=>
panic!
(
"wat"
)
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_box
()
{
fn
compare_box
(
b1
:
Box
<
bool
>
,
b2
:
Box
<
bool
>
)
->
bool
{
return
*
b1
==
*
b2
;
}
test_generic
::
<
bool
>
(
box
true
,
compare_box
);
test_generic
::
<
bool
,
_
>
(
box
true
,
compare_box
);
}
pub
fn
main
()
{
test_box
();
}
src/test/run-pass/expr-match-generic-unique2.rs
浏览文件 @
ca17d081
...
...
@@ -8,20 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
compare
<
'a
,
T
>
=
|
T
,
T
|:
'a
->
bool
;
fn
test_generic
<
T
:
Clone
>
(
expected
:
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
,
F
>
(
expected
:
T
,
eq
:
F
)
where
F
:
FnOnce
(
T
,
T
)
->
bool
{
let
actual
:
T
=
match
true
{
true
=>
expected
.clone
(),
_
=>
panic!
(
"wat"
)
};
assert
!
(
(
eq
(
expected
,
actual
)
));
assert
!
(
eq
(
expected
,
actual
));
}
fn
test_vec
()
{
fn
compare_box
(
v1
:
Box
<
int
>
,
v2
:
Box
<
int
>
)
->
bool
{
return
v1
==
v2
;
}
test_generic
::
<
Box
<
int
>>
(
box
1
,
compare_box
);
test_generic
::
<
Box
<
int
>
,
_
>
(
box
1
,
compare_box
);
}
pub
fn
main
()
{
test_vec
();
}
src/test/run-pass/fn-bare-coerce-to-block.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
fn
bare
()
{}
fn
likes_block
(
f
:
||
)
{
f
()
}
fn
likes_block
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
()
}
pub
fn
main
()
{
likes_block
(
bare
);
...
...
src/test/run-pass/fn-coerce-field.rs
浏览文件 @
ca17d081
...
...
@@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
r
<
'a
>
{
field
:
||:
'a
,
struct
r
<
F
>
where
F
:
FnOnce
()
{
field
:
F
,
}
pub
fn
main
()
{
fn
f
()
{}
let
_
i
:
r
=
r
{
field
:
f
};
let
_
i
:
r
<
fn
()
>
=
r
{
field
:
f
as
fn
()
};
}
src/test/run-pass/fn-pattern-expected-type.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
pub
fn
main
()
{
let
f
:
|(
int
,
int
)|
=
|(
x
,
y
)|
{
let
f
=
|
&
:
(
x
,
y
):
(
int
,
int
)|
{
assert_eq!
(
x
,
1
);
assert_eq!
(
y
,
2
);
};
...
...
src/test/run-pass/fn-type-infer.rs
浏览文件 @
ca17d081
...
...
@@ -12,7 +12,7 @@
pub
fn
main
()
{
// We should be able to type infer inside of ||s.
let
_
f
=
||
{
let
_
f
=
|
&
:
|
{
let
i
=
10
i
;
};
}
src/test/run-pass/foreach-nested.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
two
(
it
:
|
int
|
)
{
it
(
0
);
it
(
1
);
}
fn
two
<
F
>
(
mut
it
:
F
)
where
F
:
FnMut
(
int
)
{
it
(
0
);
it
(
1
);
}
pub
fn
main
()
{
let
mut
a
:
Vec
<
int
>
=
vec!
(
-
1
,
-
1
,
-
1
,
-
1
);
...
...
src/test/run-pass/foreach-put-structured.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
fn
pairs
(
it
:
|(
int
,
int
)|
)
{
fn
pairs
<
F
>
(
mut
it
:
F
)
where
F
:
FnMut
((
int
,
int
)
)
{
let
mut
i
:
int
=
0
;
let
mut
j
:
int
=
0
;
while
i
<
10
{
it
((
i
,
j
));
i
+=
1
;
j
+=
i
;
}
...
...
src/test/run-pass/foreach-simple-outer-slot.rs
浏览文件 @
ca17d081
...
...
@@ -19,7 +19,7 @@ pub fn main() {
assert_eq!
(
sum
,
45
);
}
fn
first_ten
(
it
:
|
int
|
)
{
fn
first_ten
<
F
>
(
mut
it
:
F
)
where
F
:
FnMut
(
int
)
{
let
mut
i
:
int
=
0
;
while
i
<
10
{
println!
(
"first_ten"
);
it
(
i
);
i
=
i
+
1
;
}
}
src/test/run-pass/fun-call-variants.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
ho
(
f
:
|
int
|
->
int
)
->
int
{
let
n
:
int
=
f
(
3
);
return
n
;
}
fn
ho
<
F
>
(
f
:
F
)
->
int
where
F
:
FnOnce
(
int
)
->
int
{
let
n
:
int
=
f
(
3
);
return
n
;
}
fn
direct
(
x
:
int
)
->
int
{
return
x
+
1
;
}
...
...
src/test/run-pass/generic-static-methods.rs
浏览文件 @
ca17d081
...
...
@@ -10,11 +10,11 @@
trait
vec_utils
<
T
>
{
fn
map_
<
U
>
(
x
:
&
Self
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
;
fn
map_
<
U
,
F
>
(
x
:
&
Self
,
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
;
}
impl
<
T
>
vec_utils
<
T
>
for
Vec
<
T
>
{
fn
map_
<
U
>
(
x
:
&
Vec
<
T
>
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
{
fn
map_
<
U
,
F
>
(
x
:
&
Vec
<
T
>
,
mut
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
{
let
mut
r
=
Vec
::
new
();
for
elt
in
x
.iter
()
{
r
.push
(
f
(
elt
));
...
...
src/test/run-pass/hashmap-memory.rs
浏览文件 @
ca17d081
...
...
@@ -9,14 +9,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
/**
A somewhat reduced test case to expose some Valgrind issues.
This originally came from the word-count benchmark.
*/
pub
fn
map
(
filename
:
String
,
emit
:
map_reduce
::
putter
)
{
emit
(
filename
,
"1"
.to_string
(
));
pub
fn
map
(
filename
:
String
,
mut
emit
:
map_reduce
::
putter
)
{
emit
.call_mut
((
filename
,
"1"
.to_string
(),
));
}
mod
map_reduce
{
...
...
@@ -25,7 +27,7 @@ mod map_reduce {
use
std
::
str
;
use
std
::
thread
::
Thread
;
pub
type
putter
<
'a
>
=
|
String
,
String
|:
'a
;
pub
type
putter
<
'a
>
=
Box
<
FnMut
(
String
,
String
)
+
'a
>
;
pub
type
mapper
=
extern
fn
(
String
,
putter
);
...
...
@@ -58,7 +60,7 @@ fn emit(im: &mut HashMap<String, int>,
}
let
ctrl_clone
=
ctrl
.clone
();
::
map
(
input
,
|
a
,
b
|
emit
(
&
mut
intermediates
,
ctrl
.clone
(),
a
,
b
)
);
::
map
(
input
,
box
|
a
,
b
|
emit
(
&
mut
intermediates
,
ctrl
.clone
(),
a
,
b
)
);
ctrl_clone
.send
(
ctrl_proto
::
mapper_done
)
.unwrap
();
}
...
...
src/test/run-pass/hrtb-debruijn-object-types-in-closures.rs
浏览文件 @
ca17d081
...
...
@@ -13,8 +13,7 @@ fn method(&self, data: &'tcx int) -> &'tcx int { data }
fn
dummy
(
&
self
)
{
}
}
fn
g
(
_
:
|
&
Typer
|)
{
}
fn
g
<
F
>
(
_
:
F
)
where
F
:
FnOnce
(
&
Typer
)
{}
fn
h
()
{
g
(|
typer
|
typer
.dummy
())
...
...
src/test/run-pass/hrtb-parse.rs
浏览文件 @
ca17d081
...
...
@@ -40,8 +40,5 @@ fn foo21(t: for<'a> unsafe fn(int) -> int) { }
fn
foo22
(
t
:
for
<
'a
>
extern
"C"
fn
(
int
)
->
int
)
{
}
fn
foo23
(
t
:
for
<
'a
>
unsafe
extern
"C"
fn
(
int
)
->
int
)
{
}
fn
foo30
(
t
:
for
<
'a
>
|
int
|
->
int
)
{
}
fn
foo31
(
t
:
for
<
'a
>
unsafe
|
int
|
->
int
)
{
}
fn
main
()
{
}
src/test/run-pass/hrtb-trait-object-passed-to-closure.rs
浏览文件 @
ca17d081
...
...
@@ -23,7 +23,7 @@ struct NoAnn<'ast> {
impl
<
'ast
>
PrinterSupport
<
'ast
>
for
NoAnn
<
'ast
>
{
}
fn
foo
<
'ast
>
(
f
:
Option
<&
'ast
uint
>
,
g
:
|
&
PrinterSupport
|
)
{
fn
foo
<
'ast
,
G
>
(
f
:
Option
<&
'ast
uint
>
,
g
:
G
)
where
G
:
FnOnce
(
&
PrinterSupport
)
{
let
annotation
=
NoAnn
{
f
:
f
};
g
(
&
annotation
)
}
...
...
src/test/run-pass/issue-13434.rs
浏览文件 @
ca17d081
...
...
@@ -15,7 +15,7 @@ trait Repro {
fn
repro
(
self
,
s
:
MyStruct
)
->
String
;
}
impl
Repro
for
|
MyStruct
|:
'static
->
String
{
impl
<
F
>
Repro
for
F
where
F
:
FnOnce
(
MyStruct
)
->
String
{
fn
repro
(
self
,
s
:
MyStruct
)
->
String
{
self
(
s
)
}
...
...
@@ -26,5 +26,5 @@ fn do_stuff<R: Repro>(r: R) -> String {
}
pub
fn
main
()
{
assert_eq!
(
"MyStruct"
.to_string
(),
do_stuff
(|
s
:
MyStruct
|
format!
(
"{}"
,
s
)));
assert_eq!
(
"MyStruct"
.to_string
(),
do_stuff
(|
:
s
:
MyStruct
|
format!
(
"{}"
,
s
)));
}
src/test/run-pass/issue-13507-2.rs
浏览文件 @
ca17d081
...
...
@@ -24,7 +24,6 @@ pub fn type_ids() -> Vec<TypeId> {
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooEnum
>
());
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooUniq
>
());
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooPtr
>
());
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooClosure
>
());
ids
.push
(
TypeId
::
of
::
<&
'static
testtypes
::
FooTrait
>
());
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooStruct
>
());
ids
.push
(
TypeId
::
of
::
<
testtypes
::
FooTuple
>
());
...
...
src/test/run-pass/issue-13808.rs
浏览文件 @
ca17d081
...
...
@@ -9,12 +9,12 @@
// except according to those terms.
struct
Foo
<
'a
>
{
listener
:
||:
'a
listener
:
Box
<
FnMut
()
+
'a
>
,
}
impl
<
'a
>
Foo
<
'a
>
{
fn
new
(
listener
:
||:
'a
)
->
Foo
<
'a
>
{
Foo
{
listener
:
listener
}
fn
new
<
F
>
(
listener
:
F
)
->
Foo
<
'a
>
where
F
:
FnMut
()
+
'a
{
Foo
{
listener
:
box
listener
}
}
}
...
...
src/test/run-pass/issue-1460.rs
浏览文件 @
ca17d081
...
...
@@ -10,5 +10,5 @@
pub
fn
main
()
{
{|
i
|
if
1
i
==
i
{
}};
{|
&
:
i
|
if
1
i
==
i
{
}};
}
src/test/run-pass/issue-14919.rs
浏览文件 @
ca17d081
...
...
@@ -16,7 +16,7 @@ trait Matcher {
struct
CharPredMatcher
<
'a
,
'b
>
{
str
:
&
'a
str
,
pred
:
|
char
|:
'b
->
bool
pred
:
Box
<
FnMut
(
char
)
->
bool
+
'b
>
,
}
impl
<
'a
,
'b
>
Matcher
for
CharPredMatcher
<
'a
,
'b
>
{
...
...
@@ -29,11 +29,11 @@ trait IntoMatcher<'a, T> {
fn
into_matcher
(
self
,
&
'a
str
)
->
T
;
}
impl
<
'a
,
'b
>
IntoMatcher
<
'a
,
CharPredMatcher
<
'a
,
'b
>>
for
|
char
|:
'b
->
bool
{
impl
<
'a
,
'b
,
F
>
IntoMatcher
<
'a
,
CharPredMatcher
<
'a
,
'b
>>
for
F
where
F
:
FnMut
(
char
)
->
bool
+
'b
{
fn
into_matcher
(
self
,
s
:
&
'a
str
)
->
CharPredMatcher
<
'a
,
'b
>
{
CharPredMatcher
{
str
:
s
,
pred
:
self
pred
:
box
self
,
}
}
}
...
...
@@ -57,6 +57,6 @@ fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndi
fn
main
()
{
let
s
=
"abcbdef"
;
match_indices
(
s
,
|
c
:
char
|
c
==
'b'
)
match_indices
(
s
,
|
&
mut
:
c
:
char
|
c
==
'b'
)
.collect
::
<
Vec
<
(
uint
,
uint
)
>>
();
}
src/test/run-pass/issue-1516.rs
已删除
100644 → 0
浏览文件 @
8d0d7521
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub
fn
main
()
{
let
early_error
:
|
&
str
|:
'static
->
!
=
|
_
msg
|
{
panic!
()
};
}
src/test/run-pass/issue-16256.rs
浏览文件 @
ca17d081
...
...
@@ -10,5 +10,5 @@
fn
main
()
{
let
mut
buf
=
Vec
::
new
();
|
c
:
u8
|
buf
.push
(
c
);
|
&
mut
:
c
:
u8
|
buf
.push
(
c
);
}
src/test/run-pass/issue-2074.rs
浏览文件 @
ca17d081
...
...
@@ -11,11 +11,11 @@
#![allow(non_camel_case_types)]
pub
fn
main
()
{
let
one
:
||
->
uint
=
|
|
{
let
one
=
|
&
:
|
{
enum
r
{
a
};
r
::
a
as
uint
};
let
two
:
||
->
uint
=
|
|
{
let
two
=
|
&
:
|
{
enum
r
{
a
};
r
::
a
as
uint
};
...
...
src/test/run-pass/issue-2487-a.rs
浏览文件 @
ca17d081
...
...
@@ -29,7 +29,7 @@ fn socket() -> socket {
}
}
fn
closure
(
f
:
||
)
{
f
()
}
fn
closure
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
()
}
fn
setsockopt_bytes
(
_
sock
:
int
)
{
}
...
...
src/test/run-pass/issue-3052.rs
浏览文件 @
ca17d081
...
...
@@ -9,10 +9,10 @@
// except according to those terms.
type
Connection
=
|
Vec
<
u8
>
|:
'static
;
type
Connection
=
Box
<
FnMut
(
Vec
<
u8
>
)
+
'static
>
;
fn
f
()
->
Option
<
Connection
>
{
let
mock_connection
:
Connection
=
|
_
|
{};
let
mock_connection
:
Connection
=
box
|
&
mut
:
_
|
{};
Some
(
mock_connection
)
}
...
...
src/test/run-pass/issue-3429.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
pub
fn
main
()
{
let
x
=
1
;
let
y
:
||
->
int
=
|
|
x
;
let
x
=
1
u
;
let
y
=
|
&
:
|
x
;
let
_
z
=
y
();
}
src/test/run-pass/issue-3874.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
enum
PureCounter
{
PureCounterVariant
(
uint
)
}
fn
each
(
thing
:
PureCounter
,
blk
:
|
v
:
&
uint
|
)
{
fn
each
<
F
>
(
thing
:
PureCounter
,
blk
:
F
)
where
F
:
FnOnce
(
&
uint
)
{
let
PureCounter
::
PureCounterVariant
(
ref
x
)
=
thing
;
blk
(
x
);
}
...
...
src/test/run-pass/issue-3904.rs
浏览文件 @
ca17d081
...
...
@@ -8,21 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
ErrPrinter
<
'a
>
=
|
&
str
,
&
str
|:
'a
;
fn
example_err
(
prog
:
&
str
,
arg
:
&
str
)
{
println!
(
"{}: {}"
,
prog
,
arg
)
}
fn
exit
(
print
:
ErrPrinter
,
prog
:
&
str
,
arg
:
&
str
)
{
fn
exit
<
F
>
(
print
:
F
,
prog
:
&
str
,
arg
:
&
str
)
where
F
:
FnOnce
(
&
str
,
&
str
)
{
print
(
prog
,
arg
);
}
struct
X
<
'a
>
{
err
:
ErrPrinter
<
'a
>
struct
X
<
F
>
where
F
:
FnOnce
(
&
str
,
&
str
)
{
err
:
F
,
}
impl
<
'a
>
X
<
'a
>
{
impl
<
F
>
X
<
F
>
where
F
:
FnOnce
(
&
str
,
&
str
)
{
pub
fn
boom
(
self
)
{
exit
(
self
.err
,
"prog"
,
"arg"
);
}
...
...
src/test/run-pass/issue-5239-2.rs
浏览文件 @
ca17d081
...
...
@@ -11,7 +11,7 @@
// Regression test for issue #5239
pub
fn
main
()
{
let
_
f
:
|
int
|
->
int
=
|
ref
x
:
int
|
{
*
x
};
let
_
f
=
|
&
:
ref
x
:
int
|
{
*
x
};
let
foo
=
10
;
assert
!
(
_
f
(
foo
)
==
10
);
}
src/test/run-pass/issue-6153.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
swap
(
f
:
|
Vec
<
int
>
|
->
Vec
<
int
>
)
->
Vec
<
int
>
{
fn
swap
<
F
>
(
f
:
F
)
->
Vec
<
int
>
where
F
:
FnOnce
(
Vec
<
int
>
)
->
Vec
<
int
>
{
let
x
=
vec!
(
1
,
2
,
3
);
f
(
x
)
}
...
...
src/test/run-pass/issue-6157.rs
浏览文件 @
ca17d081
...
...
@@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub
trait
OpInt
<
'a
>
{
fn
call
(
&
mut
self
,
int
,
int
)
->
int
;
}
pub
trait
OpInt
{
fn
call
(
&
mut
self
,
int
,
int
)
->
int
;
}
impl
<
'a
>
OpInt
<
'a
>
for
|
int
,
int
|:
'a
->
int
{
impl
<
F
>
OpInt
for
F
where
F
:
FnMut
(
int
,
int
)
->
int
{
fn
call
(
&
mut
self
,
a
:
int
,
b
:
int
)
->
int
{
(
*
self
)(
a
,
b
)
}
...
...
@@ -21,7 +21,7 @@ fn squarei<'a>(x: int, op: &'a mut OpInt) -> int { op.call(x, x) }
fn
muli
(
x
:
int
,
y
:
int
)
->
int
{
x
*
y
}
pub
fn
main
()
{
let
mut
f
=
|
x
,
y
|
muli
(
x
,
y
);
let
mut
f
=
|
&
mut
:
x
,
y
|
muli
(
x
,
y
);
{
let
g
=
&
mut
f
;
let
h
=
g
as
&
mut
OpInt
;
...
...
src/test/run-pass/issue-868.rs
浏览文件 @
ca17d081
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
f
<
T
>
(
g
:
||
->
T
)
->
T
{
g
()
}
fn
f
<
T
,
F
>
(
g
:
F
)
->
T
where
F
:
FnOnce
(
)
->
T
{
g
()
}
pub
fn
main
()
{
let
_
x
=
f
(
|
|
{
10
i
});
...
...
@@ -20,5 +20,5 @@ pub fn main() {
let
_
:
()
=
f
(|
|
{
});
// empty block with no type info should compile too
let
_
=
f
(||{});
let
_
=
(||{});
let
_
=
(|
&
:
|{});
}
src/test/run-pass/issue-9129.rs
浏览文件 @
ca17d081
...
...
@@ -29,7 +29,7 @@ fn Ident_new() -> Ident {
pub
fn
light_fuse
(
fld
:
Box
<
bomb
>
)
{
int3!
();
let
f
=
||
{
let
f
=
|
&
:
|
{
int3!
();
fld
.boom
(
Ident_new
());
// *** 1
};
...
...
src/test/run-pass/iter-range.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
fn
range_
(
a
:
int
,
b
:
int
,
it
:
|
int
|
)
{
fn
range_
<
F
>
(
a
:
int
,
b
:
int
,
mut
it
:
F
)
where
F
:
FnMut
(
int
)
{
assert
!
((
a
<
b
));
let
mut
i
:
int
=
a
;
while
i
<
b
{
it
(
i
);
i
+=
1
;
}
...
...
src/test/run-pass/lambda-infer-unresolved.rs
浏览文件 @
ca17d081
...
...
@@ -16,7 +16,7 @@ struct Refs { refs: Vec<int> , n: int }
pub
fn
main
()
{
let
mut
e
=
Refs
{
refs
:
vec!
(),
n
:
0
};
let
_
f
:
||
=
|
|
println!
(
"{}"
,
e
.n
);
let
_
f
=
|
&
:
|
println!
(
"{}"
,
e
.n
);
let
x
:
&
[
int
]
=
e
.refs
.as_slice
();
assert_eq!
(
x
.len
(),
0
);
}
src/test/run-pass/last-use-in-block.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
// Issue #1818
fn
lp
<
T
>
(
s
:
String
,
f
:
|
String
|
->
T
)
->
T
{
fn
lp
<
T
,
F
>
(
s
:
String
,
mut
f
:
F
)
->
T
where
F
:
FnMut
(
String
)
->
T
{
while
false
{
let
r
=
f
(
s
);
return
(
r
);
...
...
@@ -18,8 +18,8 @@ fn lp<T>(s: String, f: |String| -> T) -> T {
panic!
();
}
fn
apply
<
T
>
(
s
:
String
,
f
:
|
String
|
->
T
)
->
T
{
fn
g
<
T
>
(
s
:
String
,
f
:
|
String
|
->
T
)
->
T
{
f
(
s
)}
fn
apply
<
T
,
F
>
(
s
:
String
,
mut
f
:
F
)
->
T
where
F
:
FnMut
(
String
)
->
T
{
fn
g
<
T
,
F
>
(
s
:
String
,
mut
f
:
F
)
->
T
where
F
:
FnMut
(
String
)
->
T
{
f
(
s
)}
g
(
s
,
|
v
|
{
let
r
=
f
(
v
);
r
})
}
...
...
src/test/run-pass/last-use-in-cap-clause.rs
浏览文件 @
ca17d081
...
...
@@ -10,16 +10,17 @@
// Make sure #1399 stays fixed
#![feature(unboxed_closures)]
struct
A
{
a
:
Box
<
int
>
}
fn
foo
()
->
||:
'static
->
int
{
fn
foo
()
->
Box
<
FnMut
()
->
int
+
'static
>
{
let
k
=
box
22
i
;
let
_u
=
A
{
a
:
k
.clone
()};
let
result
:
||:
'static
->
int
=
|
|
22
;
result
let
result
=
|
&
mut
:
|
22
;
box
result
}
pub
fn
main
()
{
assert_eq!
(
foo
()
(
),
22
);
assert_eq!
(
foo
()
.call_mut
(()
),
22
);
}
src/test/run-pass/last-use-is-capture.rs
浏览文件 @
ca17d081
...
...
@@ -13,7 +13,7 @@
struct
A
{
a
:
Box
<
int
>
}
pub
fn
main
()
{
fn
invoke
(
f
:
||
)
{
f
();
}
fn
invoke
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
();
}
let
k
=
box
22
i
;
let
_u
=
A
{
a
:
k
.clone
()};
invoke
(||
println!
(
"{}"
,
k
.clone
())
)
...
...
src/test/run-pass/match-phi.rs
浏览文件 @
ca17d081
...
...
@@ -13,7 +13,7 @@
enum
thing
{
a
,
b
,
c
,
}
fn
foo
(
it
:
|
int
|
)
{
it
(
10
);
}
fn
foo
<
F
>
(
it
:
F
)
where
F
:
FnOnce
(
int
)
{
it
(
10
);
}
pub
fn
main
()
{
let
mut
x
=
true
;
...
...
src/test/run-pass/monad.rs
浏览文件 @
ca17d081
...
...
@@ -11,11 +11,11 @@
trait
vec_monad
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
&
A
|
->
Vec
<
B
>
)
->
Vec
<
B
>
;
fn
bind
<
B
,
F
>
(
&
self
,
f
:
F
)
->
Vec
<
B
>
where
F
:
FnMut
(
&
A
)
->
Vec
<
B
>
;
}
impl
<
A
>
vec_monad
<
A
>
for
Vec
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
&
A
|
->
Vec
<
B
>
)
->
Vec
<
B
>
{
fn
bind
<
B
,
F
>
(
&
self
,
mut
f
:
F
)
->
Vec
<
B
>
where
F
:
FnMut
(
&
A
)
->
Vec
<
B
>
{
let
mut
r
=
Vec
::
new
();
for
elt
in
self
.iter
()
{
r
.extend
(
f
(
elt
)
.into_iter
());
...
...
@@ -25,11 +25,11 @@ fn bind<B>(&self, f: |&A| -> Vec<B> ) -> Vec<B> {
}
trait
option_monad
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
&
A
|
->
Option
<
B
>
)
->
Option
<
B
>
;
fn
bind
<
B
,
F
>
(
&
self
,
f
:
F
)
->
Option
<
B
>
where
F
:
FnOnce
(
&
A
)
->
Option
<
B
>
;
}
impl
<
A
>
option_monad
<
A
>
for
Option
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
&
A
|
->
Option
<
B
>
)
->
Option
<
B
>
{
fn
bind
<
B
,
F
>
(
&
self
,
f
:
F
)
->
Option
<
B
>
where
F
:
FnOnce
(
&
A
)
->
Option
<
B
>
{
match
*
self
{
Some
(
ref
a
)
=>
{
f
(
a
)
}
None
=>
{
None
}
...
...
src/test/run-pass/move-nullary-fn.rs
浏览文件 @
ca17d081
...
...
@@ -9,9 +9,9 @@
// except according to those terms.
// Issue #922
fn
f2
(
_
thing
:
||
)
{
}
fn
f2
<
F
>
(
_
thing
:
F
)
where
F
:
FnOnce
(
)
{
}
fn
f
(
thing
:
||
)
{
fn
f
<
F
>
(
thing
:
F
)
where
F
:
FnOnce
(
)
{
f2
(
thing
);
}
...
...
src/test/run-pass/mut-function-arguments.rs
浏览文件 @
ca17d081
...
...
@@ -15,7 +15,7 @@ fn f(mut y: Box<int>) {
}
fn
g
()
{
let
frob
:
|
Box
<
int
>
|
=
|
mut
q
|
{
*
q
=
2
;
assert
!
(
*
q
==
2
);
};
let
frob
=
|
&
:
mut
q
:
Box
<
int
>
|
{
*
q
=
2
;
assert
!
(
*
q
==
2
);
};
let
w
=
box
37
;
frob
(
w
);
...
...
src/test/run-pass/mut-in-ident-patterns.rs
浏览文件 @
ca17d081
...
...
@@ -75,6 +75,6 @@ struct A {
x
=
30
;
assert_eq!
(
x
,
30
);
(|
A
{
x
:
mut
t
}:
A
|
{
t
=
t
+
1
;
t
})(
A
{
x
:
34
});
(|
&
:
A
{
x
:
mut
t
}:
A
|
{
t
=
t
+
1
;
t
})(
A
{
x
:
34
});
}
src/test/run-pass/newlambdas.rs
浏览文件 @
ca17d081
...
...
@@ -10,9 +10,9 @@
// Tests for the new |args| expr lambda syntax
fn
f
(
i
:
int
,
f
:
|
int
|
->
int
)
->
int
{
f
(
i
)
}
fn
f
<
F
>
(
i
:
int
,
f
:
F
)
->
int
where
F
:
FnOnce
(
int
)
->
int
{
f
(
i
)
}
fn
g
(
_
g
:
||
)
{
}
fn
g
<
G
>
(
_
g
:
G
)
where
G
:
FnOnce
(
)
{
}
pub
fn
main
()
{
assert_eq!
(
f
(
10
,
|
a
|
a
),
10
);
...
...
src/test/run-pass/non-legacy-modes.rs
浏览文件 @
ca17d081
...
...
@@ -12,7 +12,7 @@ struct X {
repr
:
int
}
fn
apply
<
T
>
(
x
:
T
,
f
:
|
T
|
)
{
fn
apply
<
T
,
F
>
(
x
:
T
,
f
:
F
)
where
F
:
FnOnce
(
T
)
{
f
(
x
);
}
...
...
src/test/run-pass/pattern-in-closure.rs
浏览文件 @
ca17d081
...
...
@@ -14,8 +14,8 @@ struct Foo {
}
pub
fn
main
()
{
let
f
=
|(
x
,
_
):
(
int
,
int
)|
println!
(
"{}"
,
x
+
1
);
let
g
=
|
Foo
{
x
:
x
,
y
:
_
y
}:
Foo
|
println!
(
"{}"
,
x
+
1
);
let
f
=
|
&
:
(
x
,
_
):
(
int
,
int
)|
println!
(
"{}"
,
x
+
1
);
let
g
=
|
&
:
Foo
{
x
:
x
,
y
:
_
y
}:
Foo
|
println!
(
"{}"
,
x
+
1
);
f
((
2
,
3
));
g
(
Foo
{
x
:
1
,
y
:
2
});
}
src/test/run-pass/purity-infer.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
something
(
f
:
||
)
{
f
();
}
fn
something
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
();
}
pub
fn
main
()
{
something
(||
println!
(
"hi!"
)
);
}
src/test/run-pass/regions-copy-closure.rs
浏览文件 @
ca17d081
...
...
@@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
struct
closure_box
<
'a
>
{
cl
:
||:
'a
,
cl
:
Box
<
FnMut
()
+
'a
>
,
}
fn
box_it
(
x
:
||)
->
closure_box
{
fn
box_it
<
'a
>
(
x
:
Box
<
FnMut
()
+
'a
>
)
->
closure_box
<
'a
>
{
closure_box
{
cl
:
x
}
}
...
...
@@ -20,9 +22,9 @@ pub fn main() {
let
mut
i
=
3
i
;
assert_eq!
(
i
,
3
);
{
let
cl
=
||
i
+=
1
;
let
cl_box
=
box_it
(
cl
);
(
cl_box
.cl
)(
);
let
cl
=
|
&
mut
:
|
i
+=
1
;
let
mut
cl_box
=
box_it
(
box
cl
);
cl_box
.cl
.call_mut
(()
);
}
assert_eq!
(
i
,
4
);
}
src/test/run-pass/regions-dependent-autofn.rs
浏览文件 @
ca17d081
...
...
@@ -11,9 +11,9 @@
// Test lifetimes are linked properly when we autoslice a vector.
// Issue #3148.
fn
subslice
(
v
:
||)
->
||
{
v
}
fn
subslice
<
F
>
(
v
:
F
)
->
F
where
F
:
FnOnce
()
{
v
}
fn
both
(
v
:
||)
->
||
{
fn
both
<
F
>
(
v
:
F
)
->
F
where
F
:
FnOnce
()
{
subslice
(
subslice
(
v
))
}
...
...
src/test/run-pass/regions-fn-subtyping-2.rs
浏览文件 @
ca17d081
...
...
@@ -13,13 +13,13 @@
// Here, `f` is a function that takes a pointer `x` and a function
// `g`, where `g` requires its argument `y` to be in the same region
// that `x` is in.
fn
has_same_region
(
f
:
<
'a
>
|
x
:
&
'a
int
,
g
:
|
y
:
&
'a
int
||
)
{
fn
has_same_region
(
f
:
Box
<
for
<
'a
>
FnMut
(
&
'a
int
,
Box
<
FnMut
(
&
'a
int
)
>
)
>
)
{
// `f` should be the type that `wants_same_region` wants, but
// right now the compiler complains that it isn't.
wants_same_region
(
f
);
}
fn
wants_same_region
(
_
f
:
<
'b
>
|
x
:
&
'b
int
,
g
:
|
y
:
&
'b
int
||
)
{
fn
wants_same_region
(
_
f
:
Box
<
for
<
'b
>
FnMut
(
&
'b
int
,
Box
<
FnMut
(
&
'b
int
)
>
)
>
)
{
}
pub
fn
main
()
{
...
...
src/test/run-pass/regions-fn-subtyping.rs
浏览文件 @
ca17d081
...
...
@@ -14,21 +14,21 @@
#![allow(unused_variable)]
// Should pass region checking.
fn
ok
(
f
:
|
x
:
&
uint
|
)
{
fn
ok
(
f
:
Box
<
FnMut
(
&
uint
)
>
)
{
// Here, g is a function that can accept a uint pointer with
// lifetime r, and f is a function that can accept a uint pointer
// with any lifetime. The assignment g = f should be OK (i.e.,
// f's type should be a subtype of g's type), because f can be
// used in any context that expects g's type. But this currently
// fails.
let
mut
g
:
<
'r
>
|
y
:
&
'r
uint
|
=
|
x
|
{
};
let
mut
g
:
Box
<
for
<
'r
>
FnMut
(
&
'r
uint
)
>
=
box
|
x
|
{
};
g
=
f
;
}
// This version is the same as above, except that here, g's type is
// inferred.
fn
ok_inferred
(
f
:
|
x
:
&
uint
|
)
{
let
mut
g
:
<
'r
>
|
x
:
&
'r
uint
|
=
|
_
|
{};
fn
ok_inferred
(
f
:
Box
<
FnMut
(
&
uint
)
>
)
{
let
mut
g
:
Box
<
for
<
'r
>
FnMut
(
&
'r
uint
)
>
=
box
|
_
|
{};
g
=
f
;
}
...
...
src/test/run-pass/regions-infer-call-2.rs
浏览文件 @
ca17d081
...
...
@@ -10,7 +10,7 @@
fn
takes_two
(
x
:
&
int
,
y
:
&
int
)
->
int
{
*
x
+
*
y
}
fn
with
<
T
>
(
f
:
|
x
:
&
int
|
->
T
)
->
T
{
fn
with
<
T
,
F
>
(
f
:
F
)
->
T
where
F
:
FnOnce
(
&
int
)
->
T
{
f
(
&
20
)
}
...
...
src/test/run-pass/regions-lifetime-nonfree-late-bound.rs
浏览文件 @
ca17d081
...
...
@@ -24,15 +24,15 @@
pub
fn
main
()
{
fn
explicit
()
{
fn
test
(
_
x
:
Option
<
|
f
:
<
'a
>
|
g
:
&
'a
int
||
>
)
{}
test
(
Some
(
|
_
f
:
<
'a
>
|
g
:
&
'a
int
|
|
{}));
fn
test
<
F
>
(
_
x
:
Option
<
Box
<
F
>>
)
where
F
:
FnMut
(
Box
<
for
<
'a
>
FnMut
(
&
'a
int
)
>
)
{}
test
(
Some
(
box
|
&
mut
:
_
f
:
Box
<
for
<
'a
>
FnMut
(
&
'a
int
)
>
|
{}));
}
// The code below is shorthand for the code above (and more likely
// to represent what one encounters in practice).
fn
implicit
()
{
fn
test
(
_
x
:
Option
<
|
f
:
|
g
:
&
int
||
>
)
{}
test
(
Some
(
|
_
f
:
|
g
:
&
int
|
|
{}));
fn
test
<
F
>
(
_
x
:
Option
<
Box
<
F
>>
)
where
F
:
FnMut
(
Box
<
FnMut
(
&
int
)
>
)
{}
test
(
Some
(
box
|
&
mut
:
_
f
:
Box
<
FnMut
(
&
int
)
>
|
{}));
}
explicit
();
...
...
src/test/run-pass/regions-link-fn-args.rs
浏览文件 @
ca17d081
...
...
@@ -13,7 +13,7 @@
#![allow(dead_code)]
fn
with
<
'a
>
(
_
:
|
&
'a
Vec
<
int
>
|
->
&
'a
Vec
<
int
>
)
{
}
fn
with
<
'a
,
F
>
(
_
:
F
)
where
F
:
FnOnce
(
&
'a
Vec
<
int
>
)
->
&
'a
Vec
<
int
>
{
}
fn
foo
()
{
with
(|
&
ref
ints
|
ints
);
...
...
src/test/run-pass/regions-params.rs
浏览文件 @
ca17d081
...
...
@@ -11,7 +11,7 @@
fn
region_identity
(
x
:
&
uint
)
->
&
uint
{
x
}
fn
apply
<
T
>
(
t
:
T
,
f
:
|
T
|
->
T
)
->
T
{
f
(
t
)
}
fn
apply
<
T
,
F
>
(
t
:
T
,
f
:
F
)
->
T
where
F
:
FnOnce
(
T
)
->
T
{
f
(
t
)
}
fn
parameterized
(
x
:
&
uint
)
->
uint
{
let
z
=
apply
(
x
,
({|
y
|
...
...
src/test/run-pass/regions-static-closure.rs
浏览文件 @
ca17d081
...
...
@@ -8,19 +8,21 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
struct
closure_box
<
'a
>
{
cl
:
||:
'a
,
cl
:
Box
<
FnMut
()
+
'a
>
,
}
fn
box_it
(
x
:
||)
->
closure_box
{
fn
box_it
<
'a
>
(
x
:
Box
<
FnMut
()
+
'a
>
)
->
closure_box
<
'a
>
{
closure_box
{
cl
:
x
}
}
fn
call_static_closure
(
cl
:
closure_box
<
'static
>
)
{
(
cl
.cl
)();
fn
call_static_closure
(
mut
cl
:
closure_box
<
'static
>
)
{
cl
.cl
.call_mut
(())
}
pub
fn
main
()
{
let
cl_box
=
box_it
(
|
|
println!
(
"Hello, world!"
));
let
cl_box
=
box_it
(
box
|
&
mut
:
|
println!
(
"Hello, world!"
));
call_static_closure
(
cl_box
);
}
src/test/run-pass/return-from-closure.rs
浏览文件 @
ca17d081
...
...
@@ -13,7 +13,7 @@
static
mut
calls
:
uint
=
0
;
fn
surrounding
()
{
let
return_works
=
|
n
:
int
|
{
let
return_works
=
|
&
:
n
:
int
|
{
unsafe
{
calls
+=
1
}
if
n
>=
0
{
return
;
}
...
...
src/test/run-pass/sendfn-is-a-block.rs
浏览文件 @
ca17d081
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
test
(
f
:
|
uint
|
->
uint
)
->
uint
{
fn
test
<
F
>
(
f
:
F
)
->
uint
where
F
:
FnOnce
(
uint
)
->
uint
{
return
f
(
22u
);
}
...
...
src/test/run-pass/static-impl.rs
浏览文件 @
ca17d081
...
...
@@ -26,14 +26,14 @@ impl plus for String { fn plus(&self) -> int { 200 } }
trait
uint_utils
{
fn
str
(
&
self
)
->
String
;
fn
multi
(
&
self
,
f
:
|
uint
|
);
fn
multi
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnMut
(
uint
);
}
impl
uint_utils
for
uint
{
fn
str
(
&
self
)
->
String
{
self
.to_string
()
}
fn
multi
(
&
self
,
f
:
|
uint
|
)
{
fn
multi
<
F
>
(
&
self
,
mut
f
:
F
)
where
F
:
FnMut
(
uint
)
{
let
mut
c
=
0u
;
while
c
<
*
self
{
f
(
c
);
c
+=
1u
;
}
}
...
...
@@ -41,14 +41,14 @@ fn multi(&self, f: |uint|) {
trait
vec_utils
<
T
>
{
fn
length_
(
&
self
,
)
->
uint
;
fn
iter_
(
&
self
,
f
:
|
&
T
|
);
fn
map_
<
U
>
(
&
self
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
;
fn
iter_
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnMut
(
&
T
);
fn
map_
<
U
,
F
>
(
&
self
,
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
;
}
impl
<
T
>
vec_utils
<
T
>
for
Vec
<
T
>
{
fn
length_
(
&
self
)
->
uint
{
self
.len
()
}
fn
iter_
(
&
self
,
f
:
|
&
T
|
)
{
for
x
in
self
.iter
()
{
f
(
x
);
}
}
fn
map_
<
U
>
(
&
self
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
{
fn
iter_
<
F
>
(
&
self
,
mut
f
:
F
)
where
F
:
FnMut
(
&
T
)
{
for
x
in
self
.iter
()
{
f
(
x
);
}
}
fn
map_
<
U
,
F
>
(
&
self
,
mut
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
{
let
mut
r
=
Vec
::
new
();
for
elt
in
self
.iter
()
{
r
.push
(
f
(
elt
));
...
...
@@ -64,7 +64,7 @@ pub fn main() {
assert_eq!
((
vec!
(
1
i
))
.length_
()
.str
(),
"1"
.to_string
());
let
vect
=
vec!
(
3
i
,
4
)
.map_
(|
a
|
*
a
+
4
);
assert_eq!
(
vect
[
0
],
7
);
let
vect
=
(
vec!
(
3
i
,
4
))
.map_
::
<
uint
>
(|
a
|
*
a
as
uint
+
4u
);
let
vect
=
(
vec!
(
3
i
,
4
))
.map_
::
<
uint
,
_
>
(|
a
|
*
a
as
uint
+
4u
);
assert_eq!
(
vect
[
0
],
7u
);
let
mut
x
=
0u
;
10u
.multi
(|
_
n
|
x
+=
2u
);
...
...
src/test/run-pass/struct-partial-move-1.rs
浏览文件 @
ca17d081
...
...
@@ -16,7 +16,7 @@ struct S { val: int }
impl
S
{
fn
new
(
v
:
int
)
->
S
{
S
{
val
:
v
}
}
}
impl
Drop
for
S
{
fn
drop
(
&
mut
self
)
{
}
}
pub
fn
f
<
T
>
((
b1
,
b2
):
(
T
,
T
),
f
:
|
T
|
->
T
)
->
Partial
<
T
>
{
pub
fn
f
<
T
,
F
>
((
b1
,
b2
):
(
T
,
T
),
mut
f
:
F
)
->
Partial
<
T
>
where
F
:
FnMut
(
T
)
->
T
{
let
p
=
Partial
{
x
:
b1
,
y
:
b2
};
// Move of `p` is legal even though we are also moving `p.y`; the
...
...
src/test/run-pass/struct-partial-move-2.rs
浏览文件 @
ca17d081
...
...
@@ -18,7 +18,7 @@ impl Drop for S { fn drop(&mut self) { } }
pub
type
Two
<
T
>
=
(
Partial
<
T
>
,
Partial
<
T
>
);
pub
fn
f
<
T
>
((
b1
,
b2
):
(
T
,
T
),
(
b3
,
b4
):
(
T
,
T
),
f
:
|
T
|
->
T
)
->
Two
<
T
>
{
pub
fn
f
<
T
,
F
>
((
b1
,
b2
):
(
T
,
T
),
(
b3
,
b4
):
(
T
,
T
),
mut
f
:
F
)
->
Two
<
T
>
where
F
:
FnMut
(
T
)
->
T
{
let
p
=
Partial
{
x
:
b1
,
y
:
b2
};
let
q
=
Partial
{
x
:
b3
,
y
:
b4
};
...
...
src/test/run-pass/tempfile.rs
浏览文件 @
ca17d081
...
...
@@ -189,7 +189,7 @@ pub fn dont_double_panic() {
assert
!
(
r
.is_err
());
}
fn
in_tmpdir
(
f
:
||
)
{
fn
in_tmpdir
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
let
tmpdir
=
TempDir
::
new
(
"test"
)
.ok
()
.expect
(
"can't make tmpdir"
);
assert
!
(
os
::
change_dir
(
tmpdir
.path
())
.is_ok
());
...
...
src/test/run-pass/trait-bounds-in-arc.rs
浏览文件 @
ca17d081
...
...
@@ -11,12 +11,16 @@
// Tests that a heterogeneous list of existential types can be put inside an Arc
// and shared between tasks as long as all types fulfill Send.
// ignore-pretty
#![feature(unboxed_closures)]
use
std
::
sync
::
Arc
;
use
std
::
sync
::
mpsc
::
channel
;
use
std
::
thread
::
Thread
;
trait
Pet
{
fn
name
(
&
self
,
blk
:
|
&
str
|
);
fn
name
(
&
self
,
blk
:
Box
<
FnMut
(
&
str
)
>
);
fn
num_legs
(
&
self
)
->
uint
;
fn
of_good_pedigree
(
&
self
)
->
bool
;
}
...
...
@@ -38,19 +42,19 @@ struct Goldfyshe {
}
impl
Pet
for
Catte
{
fn
name
(
&
self
,
blk
:
|
&
str
|)
{
blk
(
self
.name
.as_slice
(
))
}
fn
name
(
&
self
,
mut
blk
:
Box
<
FnMut
(
&
str
)
>
)
{
blk
.call_mut
((
self
.name
.as_slice
(),
))
}
fn
num_legs
(
&
self
)
->
uint
{
4
}
fn
of_good_pedigree
(
&
self
)
->
bool
{
self
.num_whiskers
>=
4
}
}
impl
Pet
for
Dogge
{
fn
name
(
&
self
,
blk
:
|
&
str
|)
{
blk
(
self
.name
.as_slice
(
))
}
fn
name
(
&
self
,
mut
blk
:
Box
<
FnMut
(
&
str
)
>
)
{
blk
.call_mut
((
self
.name
.as_slice
(),
))
}
fn
num_legs
(
&
self
)
->
uint
{
4
}
fn
of_good_pedigree
(
&
self
)
->
bool
{
self
.bark_decibels
<
70
||
self
.tricks_known
>
20
}
}
impl
Pet
for
Goldfyshe
{
fn
name
(
&
self
,
blk
:
|
&
str
|)
{
blk
(
self
.name
.as_slice
(
))
}
fn
name
(
&
self
,
mut
blk
:
Box
<
FnMut
(
&
str
)
>
)
{
blk
.call_mut
((
self
.name
.as_slice
(),
))
}
fn
num_legs
(
&
self
)
->
uint
{
0
}
fn
of_good_pedigree
(
&
self
)
->
bool
{
self
.swim_speed
>=
500
}
}
...
...
@@ -98,7 +102,7 @@ fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
}
fn
check_names
(
arc
:
Arc
<
Vec
<
Box
<
Pet
+
Sync
+
Send
>>>
)
{
for
pet
in
arc
.iter
()
{
pet
.name
(|
name
|
{
pet
.name
(
box
|
name
|
{
assert
!
(
name
.as_bytes
()[
0
]
==
'a'
as
u8
&&
name
.as_bytes
()[
1
]
==
'l'
as
u8
);
})
}
...
...
src/test/run-pass/trait-generic.rs
浏览文件 @
ca17d081
...
...
@@ -24,10 +24,10 @@ fn to_string_(&self) -> String { "()".to_string() }
}
trait
map
<
T
>
{
fn
map
<
U
>
(
&
self
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
;
fn
map
<
U
,
F
>
(
&
self
,
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
;
}
impl
<
T
>
map
<
T
>
for
Vec
<
T
>
{
fn
map
<
U
>
(
&
self
,
f
:
|
&
T
|
->
U
)
->
Vec
<
U
>
{
fn
map
<
U
,
F
>
(
&
self
,
mut
f
:
F
)
->
Vec
<
U
>
where
F
:
FnMut
(
&
T
)
->
U
{
let
mut
r
=
Vec
::
new
();
for
i
in
self
.iter
()
{
r
.push
(
f
(
i
));
...
...
src/test/run-pass/type-id-higher-rank.rs
浏览文件 @
ca17d081
...
...
@@ -34,24 +34,6 @@ fn main() {
let
f
=
TypeId
::
of
::
<
fn
(
for
<
'a
>
fn
(
&
'a
int
)
->
&
'a
int
)
>
();
assert
!
(
e
!=
f
);
}
// Stack closures
{
let
a
=
TypeId
::
of
::
<
|
&
'static
int
,
&
'static
int
|
>
();
let
b
=
TypeId
::
of
::
<
for
<
'a
>
|
&
'static
int
,
&
'a
int
|
>
();
let
c
=
TypeId
::
of
::
<
for
<
'a
,
'b
>
|
&
'a
int
,
&
'b
int
|
>
();
let
d
=
TypeId
::
of
::
<
for
<
'a
,
'b
>
|
&
'b
int
,
&
'a
int
|
>
();
assert
!
(
a
!=
b
);
assert
!
(
a
!=
c
);
assert
!
(
a
!=
d
);
assert
!
(
b
!=
c
);
assert
!
(
b
!=
d
);
assert_eq!
(
c
,
d
);
// Make sure De Bruijn indices are handled correctly
let
e
=
TypeId
::
of
::
<
for
<
'a
>
|(|
&
'a
int
|
->
&
'a
int
)|
>
();
let
f
=
TypeId
::
of
::
<
|
for
<
'a
>
|
&
'a
int
|
->
&
'a
int
|
>
();
assert
!
(
e
!=
f
);
}
// Boxed unboxed closures
{
let
a
=
TypeId
::
of
::
<
Box
<
Fn
(
&
'static
int
,
&
'static
int
)
>>
();
...
...
src/test/run-pass/type-params-in-for-each.rs
浏览文件 @
ca17d081
...
...
@@ -14,7 +14,7 @@ struct S<T> {
b
:
uint
,
}
fn
range_
(
lo
:
uint
,
hi
:
uint
,
it
:
|
uint
|
)
{
fn
range_
<
F
>
(
lo
:
uint
,
hi
:
uint
,
mut
it
:
F
)
where
F
:
FnMut
(
uint
)
{
let
mut
lo_
=
lo
;
while
lo_
<
hi
{
it
(
lo_
);
lo_
+=
1u
;
}
}
...
...
src/test/run-pass/unnamed_argument_mode.rs
浏览文件 @
ca17d081
...
...
@@ -13,7 +13,7 @@ fn good(_a: &int) {
// unnamed argument &int is now parse x: &int
fn
called
(
_
f
:
|
&
int
|
)
{
fn
called
<
F
>
(
_
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
}
pub
fn
main
()
{
...
...
src/test/run-pass/unused-move-capture.rs
浏览文件 @
ca17d081
此差异已折叠。
点击以展开。
src/test/run-pass/variadic-ffi.rs
浏览文件 @
ca17d081
此差异已折叠。
点击以展开。
src/test/run-pass/vec-matching-fold.rs
浏览文件 @
ca17d081
此差异已折叠。
点击以展开。
src/test/run-pass/weird-exprs.rs
浏览文件 @
ca17d081
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录