Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
455f8b0d
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,发现更多精彩内容 >>
提交
455f8b0d
编写于
1月 11, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deprecate fn exprs and the fn() type, preferring fn@ and native fn
上级
d2be5b6c
变更
50
显示空白变更内容
内联
并排
Showing
50 changed file
with
177 addition
and
175 deletion
+177
-175
src/comp/back/link.rs
src/comp/back/link.rs
+9
-10
src/comp/front/attr.rs
src/comp/front/attr.rs
+17
-21
src/comp/metadata/encoder.rs
src/comp/metadata/encoder.rs
+3
-3
src/comp/metadata/tyencode.rs
src/comp/metadata/tyencode.rs
+1
-1
src/comp/middle/kind.rs
src/comp/middle/kind.rs
+1
-1
src/comp/middle/resolve.rs
src/comp/middle/resolve.rs
+1
-1
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+5
-5
src/comp/middle/trans_closure.rs
src/comp/middle/trans_closure.rs
+1
-1
src/comp/middle/trans_vec.rs
src/comp/middle/trans_vec.rs
+14
-17
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/auxiliary.rs
+4
-3
src/comp/middle/tstate/bitvectors.rs
src/comp/middle/tstate/bitvectors.rs
+1
-1
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+19
-15
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+3
-3
src/comp/syntax/codemap.rs
src/comp/syntax/codemap.rs
+1
-1
src/comp/syntax/ext/simplext.rs
src/comp/syntax/ext/simplext.rs
+1
-1
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+13
-2
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+6
-6
src/comp/syntax/visit.rs
src/comp/syntax/visit.rs
+15
-15
src/libcore/task.rs
src/libcore/task.rs
+5
-5
src/libstd/io.rs
src/libstd/io.rs
+4
-4
src/libstd/map.rs
src/libstd/map.rs
+2
-2
src/test/compile-fail/bad-var-env-capture-in-block-arg.rs
src/test/compile-fail/bad-var-env-capture-in-block-arg.rs
+1
-1
src/test/run-pass/bind-parameterized-args-2.rs
src/test/run-pass/bind-parameterized-args-2.rs
+1
-1
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-fn-coerce.rs
src/test/run-pass/block-fn-coerce.rs
+1
-1
src/test/run-pass/expr-block-fn.rs
src/test/run-pass/expr-block-fn.rs
+1
-2
src/test/run-pass/fixed-point-bind-box.rs
src/test/run-pass/fixed-point-bind-box.rs
+2
-2
src/test/run-pass/fixed-point-bind-unique.rs
src/test/run-pass/fixed-point-bind-unique.rs
+2
-2
src/test/run-pass/fn-bare-anon-2.rs
src/test/run-pass/fn-bare-anon-2.rs
+0
-7
src/test/run-pass/fn-bare-anon.rs
src/test/run-pass/fn-bare-anon.rs
+0
-6
src/test/run-pass/fn-bare-assign.rs
src/test/run-pass/fn-bare-assign.rs
+1
-1
src/test/run-pass/fn-bare-spawn.rs
src/test/run-pass/fn-bare-spawn.rs
+1
-4
src/test/run-pass/fn-coerce-field.rs
src/test/run-pass/fn-coerce-field.rs
+2
-1
src/test/run-pass/fn-expr.rs
src/test/run-pass/fn-expr.rs
+0
-1
src/test/run-pass/fn-lval.rs
src/test/run-pass/fn-lval.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/fun-indirect-call.rs
src/test/run-pass/fun-indirect-call.rs
+5
-1
src/test/run-pass/generic-temporary.rs
src/test/run-pass/generic-temporary.rs
+6
-3
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hashmap-memory.rs
+1
-1
src/test/run-pass/issue-898.rs
src/test/run-pass/issue-898.rs
+1
-1
src/test/run-pass/morestack6.rs
src/test/run-pass/morestack6.rs
+2
-2
src/test/run-pass/move-nullary-fn.rs
src/test/run-pass/move-nullary-fn.rs
+5
-3
src/test/run-pass/newtype.rs
src/test/run-pass/newtype.rs
+1
-1
src/test/run-pass/resource-generic.rs
src/test/run-pass/resource-generic.rs
+3
-1
src/test/run-pass/sendfn-deep-copy.rs
src/test/run-pass/sendfn-deep-copy.rs
+2
-2
src/test/run-pass/sendfn-generic-fn.rs
src/test/run-pass/sendfn-generic-fn.rs
+3
-3
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
+3
-3
src/test/run-pass/tail-cps.rs
src/test/run-pass/tail-cps.rs
+2
-2
src/test/run-pass/type-param.rs
src/test/run-pass/type-param.rs
+1
-1
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/type-params-in-for-each.rs
+1
-1
未找到文件。
src/comp/back/link.rs
浏览文件 @
455f8b0d
...
...
@@ -564,8 +564,7 @@ fn link_binary(sess: session,
lm
:
link_meta
)
{
// Converts a library file name into a gcc -l argument
fn
unlib
(
config
:
@
session
::
config
,
filename
:
str
)
->
str
{
let
rmlib
=
bind
fn
(
config
:
@
session
::
config
,
filename
:
str
)
->
str
{
let
rmlib
=
fn
@
(
filename
:
str
)
->
str
{
if
config
.os
==
session
::
os_macos
||
(
config
.os
==
session
::
os_linux
||
config
.os
==
session
::
os_freebsd
)
&&
...
...
@@ -573,7 +572,7 @@ fn unlib(config: @session::config, filename: str) -> str {
ret
str
::
slice
(
filename
,
3u
,
str
::
byte_len
(
filename
));
}
else
{
ret
filename
;
}
}(
config
,
_
)
;
}
;
fn
rmext
(
filename
:
str
)
->
str
{
let
parts
=
str
::
split
(
filename
,
'.'
as
u8
);
vec
::
pop
(
parts
);
...
...
src/comp/front/attr.rs
浏览文件 @
455f8b0d
...
...
@@ -43,13 +43,13 @@ fn find_linkage_metas(attrs: [ast::attribute]) -> [@ast::meta_item] {
// Search a list of attributes and return only those with a specific name
fn
find_attrs_by_name
(
attrs
:
[
ast
::
attribute
],
name
:
ast
::
ident
)
->
[
ast
::
attribute
]
{
let
filter
=
bind
fn
(
a
:
ast
::
attribute
,
name
:
ast
::
ident
)
->
option
::
t
<
ast
::
attribute
>
{
let
filter
=
(
fn
@
(
a
:
ast
::
attribute
)
->
option
::
t
<
ast
::
attribute
>
{
if
get_attr_name
(
a
)
==
name
{
option
::
some
(
a
)
}
else
{
option
::
none
}
}(
_
,
name
);
}
);
ret
vec
::
filter_map
(
attrs
,
filter
);
}
...
...
@@ -59,13 +59,11 @@ fn get_attr_name(attr: ast::attribute) -> ast::ident {
fn
find_meta_items_by_name
(
metas
:
[
@
ast
::
meta_item
],
name
:
ast
::
ident
)
->
[
@
ast
::
meta_item
]
{
let
filter
=
bind
fn
(
&&
m
:
@
ast
::
meta_item
,
name
:
ast
::
ident
)
->
option
::
t
<@
ast
::
meta_item
>
{
let
filter
=
fn
@
(
&&
m
:
@
ast
::
meta_item
)
->
option
::
t
<@
ast
::
meta_item
>
{
if
get_meta_item_name
(
m
)
==
name
{
option
::
some
(
m
)
}
else
{
option
::
none
}
}(
_
,
name
)
;
}
;
ret
vec
::
filter_map
(
metas
,
filter
);
}
...
...
@@ -178,13 +176,11 @@ fn key(m: @ast::meta_item) -> ast::ident {
fn
remove_meta_items_by_name
(
items
:
[
@
ast
::
meta_item
],
name
:
str
)
->
[
@
ast
::
meta_item
]
{
let
filter
=
bind
fn
(
&&
item
:
@
ast
::
meta_item
,
name
:
str
)
->
option
::
t
<@
ast
::
meta_item
>
{
let
filter
=
fn
@
(
&&
item
:
@
ast
::
meta_item
)
->
option
::
t
<@
ast
::
meta_item
>
{
if
get_meta_item_name
(
item
)
!=
name
{
option
::
some
(
item
)
}
else
{
option
::
none
}
}(
_
,
name
)
;
}
;
ret
vec
::
filter_map
(
items
,
filter
);
}
...
...
src/comp/metadata/encoder.rs
浏览文件 @
455f8b0d
...
...
@@ -465,7 +465,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
// Path and definition ID indexing
fn
create_index
<
T
:
copy
>
(
index
:
[
entry
<
T
>
],
hash_fn
:
fn
(
T
)
->
uint
)
->
fn
create_index
<
T
:
copy
>
(
index
:
[
entry
<
T
>
],
hash_fn
:
fn
@
(
T
)
->
uint
)
->
[
@
[
entry
<
T
>
]]
{
let
buckets
:
[
@
mutable
[
entry
<
T
>
]]
=
[];
uint
::
range
(
0u
,
256u
)
{|
_
i
|
buckets
+=
[
@
mutable
[]];
};
...
...
@@ -482,8 +482,8 @@ fn create_index<T: copy>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
}
fn
encode_index
<
T
>
(
ebml_w
:
ebml
::
writer
,
buckets
:
[
@
[
entry
<
T
>
]],
write_fn
:
fn
(
io
::
writer
,
T
))
{
let
writer
=
ebml_w
.writer
;
write_fn
:
block
(
io
::
writer
,
T
))
{
let
writer
=
io
::
new_writer
(
ebml_w
.writer
)
;
ebml
::
start_tag
(
ebml_w
,
tag_index
);
let
bucket_locs
:
[
uint
]
=
[];
ebml
::
start_tag
(
ebml_w
,
tag_index_buckets
);
...
...
src/comp/metadata/tyencode.rs
浏览文件 @
455f8b0d
...
...
@@ -18,7 +18,7 @@
type
ctxt
=
// Def -> str Callback:
// The type context.
{
ds
:
fn
(
def_id
)
->
str
,
tcx
:
ty
::
ctxt
,
abbrevs
:
abbrev_ctxt
};
{
ds
:
fn
@
(
def_id
)
->
str
,
tcx
:
ty
::
ctxt
,
abbrevs
:
abbrev_ctxt
};
// Compact string representation for ty.t values. API ty_str & parse_from_str.
// Extra parameters are for converting to/from def_ids in the string rep.
...
...
src/comp/middle/kind.rs
浏览文件 @
455f8b0d
...
...
@@ -58,7 +58,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
// variables. `id` is the node_id for some expression that creates the
// closure.
fn
with_appropriate_checker
(
cx
:
ctx
,
id
:
node_id
,
b
:
block
(
fn
(
ctx
,
ty
::
t
,
sp
:
span
)))
{
b
:
block
(
fn
@
(
ctx
,
ty
::
t
,
sp
:
span
)))
{
let
fty
=
ty
::
node_id_to_monotype
(
cx
.tcx
,
id
);
alt
ty
::
ty_fn_proto
(
cx
.tcx
,
fty
)
{
proto_uniq
.
{
b
(
check_send
);
}
...
...
src/comp/middle/resolve.rs
浏览文件 @
455f8b0d
...
...
@@ -1706,7 +1706,7 @@ fn add_name(ch: checker, sp: span, name: ident) {
fn
ident_id
(
&&
i
:
ident
)
->
ident
{
ret
i
;
}
fn
ensure_unique
<
T
>
(
e
:
env
,
sp
:
span
,
elts
:
[
T
],
id
:
fn
(
T
)
->
ident
,
fn
ensure_unique
<
T
>
(
e
:
env
,
sp
:
span
,
elts
:
[
T
],
id
:
block
(
T
)
->
ident
,
kind
:
str
)
{
let
ch
=
checker
(
e
,
kind
);
for
elt
:
T
in
elts
{
add_name
(
ch
,
sp
,
id
(
elt
));
}
...
...
src/comp/middle/trans.rs
浏览文件 @
455f8b0d
...
...
@@ -1140,7 +1140,7 @@ fn declare_tydesc(cx: @local_ctxt, sp: span, t: ty::t, ty_params: [uint])
ret
info
;
}
type
glue_helper
=
fn
(
@
block_ctxt
,
ValueRef
,
ty
::
t
);
type
glue_helper
=
fn
@
(
@
block_ctxt
,
ValueRef
,
ty
::
t
);
fn
declare_generic_glue
(
cx
:
@
local_ctxt
,
t
:
ty
::
t
,
llfnty
:
TypeRef
,
name
:
str
)
->
ValueRef
{
...
...
@@ -1570,8 +1570,8 @@ fn compare_scalar_values(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
}
}
type
val_pair_fn
=
fn
(
@
block_ctxt
,
ValueRef
,
ValueRef
)
->
@
block_ctxt
;
type
val_and_ty_fn
=
fn
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
@
block_ctxt
;
type
val_pair_fn
=
fn
@
(
@
block_ctxt
,
ValueRef
,
ValueRef
)
->
@
block_ctxt
;
type
val_and_ty_fn
=
fn
@
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
@
block_ctxt
;
fn
load_inbounds
(
cx
:
@
block_ctxt
,
p
:
ValueRef
,
idxs
:
[
int
])
->
ValueRef
{
ret
Load
(
cx
,
GEPi
(
cx
,
p
,
idxs
));
...
...
@@ -3268,7 +3268,7 @@ fn invoke_full(bcx: @block_ctxt, llfn: ValueRef, llargs: [ValueRef],
fn
invoke_
(
bcx
:
@
block_ctxt
,
llfn
:
ValueRef
,
llargs
:
[
ValueRef
],
to_zero
:
[{
v
:
ValueRef
,
t
:
ty
::
t
}],
to_revoke
:
[{
v
:
ValueRef
,
t
:
ty
::
t
}],
invoker
:
fn
(
@
block_ctxt
,
ValueRef
,
[
ValueRef
],
invoker
:
block
(
@
block_ctxt
,
ValueRef
,
[
ValueRef
],
BasicBlockRef
,
BasicBlockRef
))
->
@
block_ctxt
{
// FIXME: May be worth turning this into a plain call when there are no
// cleanups to run
...
...
src/comp/middle/trans_closure.rs
浏览文件 @
455f8b0d
...
...
@@ -647,7 +647,7 @@ fn make_fn_glue(
cx
:
@
block_ctxt
,
v
:
ValueRef
,
t
:
ty
::
t
,
glue_fn
:
fn
(
@
block_ctxt
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
@
block_ctxt
)
glue_fn
:
fn
@
(
@
block_ctxt
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
@
block_ctxt
)
->
@
block_ctxt
{
let
bcx
=
cx
;
let
tcx
=
bcx_tcx
(
cx
);
...
...
src/comp/middle/trans_vec.rs
浏览文件 @
455f8b0d
...
...
@@ -237,14 +237,11 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
let
write_ptr_ptr
=
do_spill_noroot
(
bcx
,
get_dataptr
(
bcx
,
new_vec_ptr
,
llunitty
));
let
copy_fn
=
bind
fn
(
bcx
:
@
block_ctxt
,
addr
:
ValueRef
,
_
ty
:
ty
::
t
,
write_ptr_ptr
:
ValueRef
,
unit_ty
:
ty
::
t
,
llunitsz
:
ValueRef
)
->
@
block_ctxt
{
let
copy_fn
=
fn
@
(
bcx
:
@
block_ctxt
,
addr
:
ValueRef
,
_
ty
:
ty
::
t
)
->
@
block_ctxt
{
let
ccx
=
bcx_ccx
(
bcx
);
let
write_ptr
=
Load
(
bcx
,
write_ptr_ptr
);
let
bcx
=
copy_val
(
bcx
,
INIT
,
write_ptr
,
let
bcx
=
copy_val
(
bcx
,
INIT
,
write_ptr
,
load_if_immediate
(
bcx
,
addr
,
unit_ty
),
unit_ty
);
let
incr
=
ty
::
type_has_dynamic_size
(
bcx_tcx
(
bcx
),
unit_ty
)
?
...
...
@@ -252,14 +249,14 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
Store
(
bcx
,
InBoundsGEP
(
bcx
,
write_ptr
,
[
incr
]),
write_ptr_ptr
);
ret
bcx
;
}(
_
,
_
,
_
,
write_ptr_ptr
,
unit_ty
,
llunitsz
)
;
}
;
let
bcx
=
iter_vec_raw
(
bcx
,
lhs
,
vec_ty
,
lhs_fill
,
copy_fn
);
bcx
=
iter_vec_raw
(
bcx
,
rhs
,
vec_ty
,
rhs_fill
,
copy_fn
);
ret
trans
::
store_in_dest
(
bcx
,
new_vec_ptr
,
dest
);
}
type
val_and_ty_fn
=
fn
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
result
;
type
val_and_ty_fn
=
fn
@
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
result
;
type
iter_vec_block
=
block
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
@
block_ctxt
;
...
...
src/comp/middle/tstate/auxiliary.rs
浏览文件 @
455f8b0d
...
...
@@ -552,7 +552,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
fn
match_args
(
fcx
:
fn_ctxt
,
occs
:
@
mutable
[
pred_args
],
occ
:
[
@
constr_arg_use
])
->
uint
{
#
debug
(
"match_args: looking at %s"
,
constr_args_to_str
(
fn
(
i
:
inst
)
->
str
{
ret
i
.ident
;
},
occ
));
constr_args_to_str
(
fn
@
(
i
:
inst
)
->
str
{
ret
i
.ident
;
},
occ
));
for
pd
:
pred_args
in
*
occs
{
log
(
debug
,
"match_args: candidate "
+
pred_args_to_str
(
pd
));
...
...
@@ -633,7 +633,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
fn
pred_args_to_str
(
p
:
pred_args
)
->
str
{
"<"
+
uint
::
str
(
p
.node.bit_num
)
+
", "
+
constr_args_to_str
(
fn
(
i
:
inst
)
->
str
{
ret
i
.ident
;
},
p
.node.args
)
constr_args_to_str
(
fn
@
(
i
:
inst
)
->
str
{
ret
i
.ident
;
},
p
.node.args
)
+
">"
}
...
...
@@ -973,7 +973,8 @@ fn non_init_constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id)
};
}
fn
args_mention
<
T
>
(
args
:
[
@
constr_arg_use
],
q
:
fn
([
T
],
node_id
)
->
bool
,
fn
args_mention
<
T
>
(
args
:
[
@
constr_arg_use
],
q
:
block
([
T
],
node_id
)
->
bool
,
s
:
[
T
])
->
bool
{
/*
FIXME
...
...
src/comp/middle/tstate/bitvectors.rs
浏览文件 @
455f8b0d
...
...
@@ -151,7 +151,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) {
visit_expr
:
relax_precond_expr
,
visit_stmt
:
relax_precond_stmt
,
visit_item
:
fn
(
_
i
:
@
item
,
_
cx
:
relax_ctxt
,
_
vt
:
visit
::
vt
<
relax_ctxt
>
)
{
},
fn
@
(
_
i
:
@
item
,
_
cx
:
relax_ctxt
,
_
vt
:
visit
::
vt
<
relax_ctxt
>
)
{
},
visit_fn
:
bind
do_nothing
(
_
,
_
,
_
,
_
,
_
,
_
,
_
)
with
*
visitor
};
let
v1
=
visit
::
mk_vt
(
visitor
);
...
...
src/comp/middle/ty.rs
浏览文件 @
455f8b0d
...
...
@@ -1077,7 +1077,7 @@ fn type_is_native(cx: ctxt, ty: t) -> bool {
alt
struct
(
cx
,
ty
)
{
ty_native
(
_
)
{
ret
true
;
}
_
{
ret
false
;
}
}
}
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
fn
(
sty
)
->
bool
)
->
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
block
(
sty
)
->
bool
)
->
bool
{
let
sty
=
struct
(
cx
,
ty
);
if
test
(
sty
)
{
ret
true
;
}
...
...
@@ -1121,20 +1121,20 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
actually checkable. It seems to me like a lot of properties
that the type context tracks about types should be immutable.)
*/
type_structurally_contains
(
cx
,
ty
,
fn
(
sty
:
sty
)
->
bool
{
type_structurally_contains
(
cx
,
ty
)
{|
sty
|
alt
sty
{
ty_param
(
_
,
_
)
{
true
}
_
{
false
}
}
}
)
}
}
// Returns true for noncopyable types and types where a copy of a value can be
// distinguished from the value itself. I.e. types with mutable content that's
// not shared through a pointer.
fn
type_allows_implicit_copy
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
ret
!
type_structurally_contains
(
cx
,
ty
,
fn
(
sty
:
sty
)
->
bool
{
ret
alt
sty
{
ret
!
type_structurally_contains
(
cx
,
ty
,
{|
sty
|
alt
sty
{
ty_param
(
_
,
_
)
{
true
}
ty_vec
(
mt
)
{
mt
.mut
!=
ast
::
imm
...
...
@@ -1149,12 +1149,12 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
false
}
_
{
false
}
}
;
}
})
&&
type_kind
(
cx
,
ty
)
!=
kind_noncopyable
;
}
fn
type_structurally_contains_uniques
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
ret
type_structurally_contains
(
cx
,
ty
,
fn
(
sty
:
sty
)
->
bool
{
ret
type_structurally_contains
(
cx
,
ty
,
{|
sty
|
ret
alt
sty
{
ty_uniq
(
_
)
{
ret
true
;
}
ty_vec
(
_
)
{
true
}
...
...
@@ -1414,7 +1414,9 @@ fn hash_fn(id: uint, args: [arg], rty: t) -> uint {
fn
hash_raw_ty
(
&&
rt
:
@
raw_t
)
->
uint
{
ret
rt
.hash
;
}
fn
arg_eq
<
T
>
(
eq
:
fn
(
T
,
T
)
->
bool
,
a
:
@
sp_constr_arg
<
T
>
,
b
:
@
sp_constr_arg
<
T
>
)
fn
arg_eq
<
T
>
(
eq
:
block
(
T
,
T
)
->
bool
,
a
:
@
sp_constr_arg
<
T
>
,
b
:
@
sp_constr_arg
<
T
>
)
->
bool
{
alt
a
.node
{
ast
::
carg_base
.
{
...
...
@@ -1431,7 +1433,8 @@ fn arg_eq<T>(eq: fn(T, T) -> bool, a: @sp_constr_arg<T>, b: @sp_constr_arg<T>)
}
}
fn
args_eq
<
T
>
(
eq
:
fn
(
T
,
T
)
->
bool
,
a
:
[
@
sp_constr_arg
<
T
>
],
fn
args_eq
<
T
>
(
eq
:
block
(
T
,
T
)
->
bool
,
a
:
[
@
sp_constr_arg
<
T
>
],
b
:
[
@
sp_constr_arg
<
T
>
])
->
bool
{
let
i
:
uint
=
0u
;
for
arg
:
@
sp_constr_arg
<
T
>
in
a
{
...
...
@@ -1752,12 +1755,13 @@ fn union(cx: @ctxt, set_a: uint, set_b: uint,
let
root_a
=
ufind
::
find
(
vb
.sets
,
set_a
);
let
root_b
=
ufind
::
find
(
vb
.sets
,
set_b
);
let
replace_type
=
bind
fn
(
vb
:
@
var_bindings
,
t
:
t
,
set_a
:
uint
,
set_b
:
uin
t
)
{
let
replace_type
=
(
fn
@
(
vb
:
@
var_bindings
,
t
:
t
)
{
ufind
::
union
(
vb
.sets
,
set_a
,
set_b
);
let
root_c
:
uint
=
ufind
::
find
(
vb
.sets
,
set_a
);
smallintmap
::
insert
::
<
t
>
(
vb
.types
,
root_c
,
t
);
}(
_
,
_
,
set_a
,
set_b
);
}
);
alt
smallintmap
::
find
(
vb
.types
,
root_a
)
{
...
...
src/comp/middle/typeck.rs
浏览文件 @
455f8b0d
...
...
@@ -1450,7 +1450,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
}
}
type
unifier
=
fn
(
@
fn_ctxt
,
span
,
ty
::
t
,
ty
::
t
)
->
ty
::
t
;
type
unifier
=
fn
@
(
@
fn_ctxt
,
span
,
ty
::
t
,
ty
::
t
)
->
ty
::
t
;
fn
check_expr
(
fcx
:
@
fn_ctxt
,
expr
:
@
ast
::
expr
)
->
bool
{
fn
dummy_unify
(
_
fcx
:
@
fn_ctxt
,
_
sp
:
span
,
_
expected
:
ty
::
t
,
actual
:
ty
::
t
)
...
...
@@ -2886,7 +2886,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
fn
resolve_in_block
(
fcx
:
@
fn_ctxt
,
bl
:
ast
::
blk
)
{
visit
::
visit_block
(
bl
,
fcx
,
visit
::
mk_vt
(
@
{
visit_expr
:
resolve_expr
,
visit_item
:
fn
(
_
i
:
@
ast
::
item
,
&&
_
e
:
@
fn_ctxt
,
visit_item
:
fn
@
(
_
i
:
@
ast
::
item
,
&&
_
e
:
@
fn_ctxt
,
_
v
:
visit
::
vt
<@
fn_ctxt
>
)
{}
with
*
visit
::
default_visitor
()
}));
...
...
src/comp/syntax/codemap.rs
浏览文件 @
455f8b0d
...
...
@@ -32,7 +32,7 @@ fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
file
.lines
+=
[{
ch
:
chpos
,
byte
:
byte_pos
}];
}
type
lookup_fn
=
fn
(
file_pos
)
->
uint
;
type
lookup_fn
=
fn
@
(
file_pos
)
->
uint
;
fn
lookup_pos
(
map
:
codemap
,
pos
:
uint
,
lookup
:
lookup_fn
)
->
loc
{
let
len
=
vec
::
len
(
map
.files
);
...
...
src/comp/syntax/ext/simplext.rs
浏览文件 @
455f8b0d
...
...
@@ -532,7 +532,7 @@ fn block_to_ident(blk: blk_) -> option::t<ident> {
fn
p_t_s_r_mac
(
cx
:
ext_ctxt
,
mac
:
ast
::
mac
,
s
:
selector
,
b
:
binders
)
{
fn
select_pt_1
(
cx
:
ext_ctxt
,
m
:
matchable
,
fn_m
:
fn
(
ast
::
mac
)
->
match_result
)
->
match_result
{
fn_m
:
block
(
ast
::
mac
)
->
match_result
)
->
match_result
{
ret
alt
m
{
match_expr
(
e
)
{
alt
e
.node
{
expr_mac
(
mac
)
{
fn_m
(
mac
)
}
_
{
none
}
}
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
455f8b0d
...
...
@@ -480,14 +480,21 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
expect
(
p
,
token
::
RBRACKET
);
}
else
if
eat_word
(
p
,
"fn"
)
{
let
proto
=
parse_fn_ty_proto
(
p
);
alt
proto
{
ast
::
proto_bare
.
{
p
.warn
(
"fn is deprecated, use native fn"
);
}
_
{
/* fallthrough */
}
}
t
=
parse_ty_fn
(
proto
,
p
);
}
else
if
eat_word
(
p
,
"block"
)
{
t
=
parse_ty_fn
(
ast
::
proto_block
,
p
);
}
else
if
eat_word
(
p
,
"native"
)
{
expect_word
(
p
,
"fn"
);
t
=
parse_ty_fn
(
ast
::
proto_bare
,
p
);
}
else
if
eat_word
(
p
,
"lambda"
)
{
//(breaks prettyprinting!)
p.warn("lambda is deprecated, use fn@");
p
.warn
(
"lambda is deprecated, use fn@"
);
t
=
parse_ty_fn
(
ast
::
proto_box
,
p
);
}
else
if
eat_word
(
p
,
"sendfn"
)
{
//(breaks prettyprinting!)
p.warn("sendfn is deprecated, use fn~");
p
.warn
(
"sendfn is deprecated, use fn~"
);
t
=
parse_ty_fn
(
ast
::
proto_uniq
,
p
);
}
else
if
p
.token
==
token
::
MOD_SEP
||
is_ident
(
p
.token
)
{
let
path
=
parse_path
(
p
);
...
...
@@ -786,6 +793,10 @@ fn parse_bottom_expr(p: parser) -> pexpr {
ret
pexpr
(
parse_alt_expr
(
p
));
}
else
if
eat_word
(
p
,
"fn"
)
{
let
proto
=
parse_fn_ty_proto
(
p
);
alt
proto
{
ast
::
proto_bare
.
{
p
.warn
(
"fn expr are deprecated, use fn@"
);
}
_
{
/* fallthrough */
}
}
ret
pexpr
(
parse_fn_expr
(
p
,
proto
));
}
else
if
eat_word
(
p
,
"block"
)
{
ret
pexpr
(
parse_fn_expr
(
p
,
ast
::
proto_block
));
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
455f8b0d
...
...
@@ -194,7 +194,7 @@ fn synth_comment(s: ps, text: str) {
word
(
s
.s
,
"*/"
);
}
fn
commasep
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
fn
(
ps
,
IN
))
{
fn
commasep
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
block
(
ps
,
IN
))
{
box
(
s
,
0u
,
b
);
let
first
=
true
;
for
elt
:
IN
in
elts
{
...
...
@@ -205,8 +205,8 @@ fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) {
}
fn
commasep_cmnt
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
fn
(
ps
,
IN
),
get_span
:
fn
(
IN
)
->
codemap
::
span
)
{
fn
commasep_cmnt
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
block
(
ps
,
IN
),
get_span
:
block
(
IN
)
->
codemap
::
span
)
{
box
(
s
,
0u
,
b
);
let
len
=
vec
::
len
::
<
IN
>
(
elts
);
let
i
=
0u
;
...
...
@@ -1246,7 +1246,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
for
elt
:
ast
::
ident
in
*
mod_path
{
word
(
s
.s
,
elt
);
word
(
s
.s
,
"::"
);
}
word
(
s
.s
,
"{"
);
commasep
(
s
,
inconsistent
,
idents
,
fn
(
s
:
ps
,
w
:
ast
::
import_ident
)
{
word
(
s
.s
,
w
.node.name
)
});
fn
@
(
s
:
ps
,
w
:
ast
::
import_ident
)
{
word
(
s
.s
,
w
.node.name
)
});
word
(
s
.s
,
"}"
);
}
ast
::
view_item_import_glob
(
ids
,
_
)
{
...
...
@@ -1261,7 +1261,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
ast
::
view_item_export
(
ids
,
_
)
{
head
(
s
,
"export"
);
commasep
(
s
,
inconsistent
,
ids
,
fn
(
s
:
ps
,
&&
w
:
ast
::
ident
)
{
word
(
s
.s
,
w
)
});
fn
@
(
s
:
ps
,
&&
w
:
ast
::
ident
)
{
word
(
s
.s
,
w
)
});
}
}
word
(
s
.s
,
";"
);
...
...
@@ -1604,7 +1604,7 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
fn
proto_to_str
(
p
:
ast
::
proto
)
->
str
{
ret
alt
p
{
ast
::
proto_bare
.
{
"fn"
}
ast
::
proto_bare
.
{
"
native
fn"
}
ast
::
proto_block
.
{
"block"
}
ast
::
proto_uniq
.
{
"fn~"
}
ast
::
proto_box
.
{
"fn@"
}
...
...
src/comp/syntax/visit.rs
浏览文件 @
455f8b0d
...
...
@@ -391,21 +391,21 @@ fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
fn
simple_ignore_ty
(
_
t
:
@
ty
)
{}
fn
default_simple_visitor
()
->
simple_visitor
{
ret
@
{
visit_mod
:
fn
(
_
m
:
_
mod
,
_
sp
:
span
)
{
},
visit_view_item
:
fn
(
_
vi
:
@
view_item
)
{
},
visit_native_item
:
fn
(
_
ni
:
@
native_item
)
{
},
visit_item
:
fn
(
_
i
:
@
item
)
{
},
visit_local
:
fn
(
_
l
:
@
local
)
{
},
visit_block
:
fn
(
_
b
:
ast
::
blk
)
{
},
visit_stmt
:
fn
(
_
s
:
@
stmt
)
{
},
visit_arm
:
fn
(
_
a
:
arm
)
{
},
visit_pat
:
fn
(
_
p
:
@
pat
)
{
},
visit_decl
:
fn
(
_
d
:
@
decl
)
{
},
visit_expr
:
fn
(
_
e
:
@
expr
)
{
},
ret
@
{
visit_mod
:
fn
@
(
_
m
:
_
mod
,
_
sp
:
span
)
{
},
visit_view_item
:
fn
@
(
_
vi
:
@
view_item
)
{
},
visit_native_item
:
fn
@
(
_
ni
:
@
native_item
)
{
},
visit_item
:
fn
@
(
_
i
:
@
item
)
{
},
visit_local
:
fn
@
(
_
l
:
@
local
)
{
},
visit_block
:
fn
@
(
_
b
:
ast
::
blk
)
{
},
visit_stmt
:
fn
@
(
_
s
:
@
stmt
)
{
},
visit_arm
:
fn
@
(
_
a
:
arm
)
{
},
visit_pat
:
fn
@
(
_
p
:
@
pat
)
{
},
visit_decl
:
fn
@
(
_
d
:
@
decl
)
{
},
visit_expr
:
fn
@
(
_
e
:
@
expr
)
{
},
visit_ty
:
simple_ignore_ty
,
visit_ty_params
:
fn
(
_
ps
:
[
ty_param
])
{},
visit_constr
:
fn
(
_
p
:
@
path
,
_
sp
:
span
,
_
id
:
node_id
)
{
},
visit_fn
:
fn
(
_
fk
:
fn_kind
,
_
d
:
fn_decl
,
_
b
:
blk
,
_
sp
:
span
,
visit_ty_params
:
fn
@
(
_
ps
:
[
ty_param
])
{},
visit_constr
:
fn
@
(
_
p
:
@
path
,
_
sp
:
span
,
_
id
:
node_id
)
{
},
visit_fn
:
fn
@
(
_
fk
:
fn_kind
,
_
d
:
fn_decl
,
_
b
:
blk
,
_
sp
:
span
,
_
id
:
node_id
)
{
}
};
}
...
...
src/libcore/task.rs
浏览文件 @
455f8b0d
...
...
@@ -120,7 +120,7 @@ fn spawn(+f: sendfn()) -> task {
spawn_inner
(
f
,
none
)
}
fn
spawn_inner
(
-
f
:
sendfn
(),
fn
spawn_inner
(
-
f
:
fn
~
(),
notify
:
option
<
comm
::
chan
<
task_notification
>>
)
->
task
unsafe
{
let
closure
:
*
rust_closure
=
unsafe
::
reinterpret_cast
(
ptr
::
addr_of
(
f
));
#
debug
(
"spawn: closure={%x,%x}"
,
(
*
closure
)
.fnptr
,
(
*
closure
)
.envptr
);
...
...
@@ -145,7 +145,7 @@ fn spawn_inner(-f: sendfn(),
*/
type
joinable_task
=
(
task
,
comm
::
port
<
task_notification
>
);
fn
spawn_joinable
(
+
f
:
sendfn
())
->
joinable_task
{
fn
spawn_joinable
(
+
f
:
fn
~
())
->
joinable_task
{
let
notify_port
=
comm
::
port
();
let
notify_chan
=
comm
::
chan
(
notify_port
);
let
task
=
spawn_inner
(
f
,
some
(
notify_chan
));
...
...
@@ -161,7 +161,7 @@ fn spawn_joinable(+f: sendfn()) -> joinable_task {
let notify_port = comm::port();
let notify_chan = comm::chan(notify_port);
let g =
sendfn
[copy notify_chan; move f]() {
let g =
fn~
[copy notify_chan; move f]() {
let this_task = rustrt::get_task_id();
let result = @mutable tr_failure;
let _rsrc = notify_rsrc((notify_chan, this_task, result));
...
...
@@ -203,7 +203,7 @@ fn spawn_joinable(+f: sendfn()) -> joinable_task {
messages from the parent. The type parameter `ToCh` is the type for messages
sent from the parent to the child and `FrCh` is the type for messages sent
from the child to the parent. */
type
connected_fn
<
ToCh
,
FrCh
>
=
sendfn
(
comm
::
port
<
ToCh
>
,
comm
::
chan
<
FrCh
>
);
type
connected_fn
<
ToCh
,
FrCh
>
=
fn
~
(
comm
::
port
<
ToCh
>
,
comm
::
chan
<
FrCh
>
);
/*
Type: connected_fn
...
...
@@ -238,7 +238,7 @@ fn spawn_connected<ToCh:send, FrCh:send>(+f: connected_fn<ToCh, FrCh>)
let
from_child_chan
=
comm
::
chan
(
from_child_port
);
let
get_to_child_port
=
comm
::
port
::
<
comm
::
chan
<
ToCh
>>
();
let
get_to_child_chan
=
comm
::
chan
(
get_to_child_port
);
let
child_task
=
spawn
(
sendfn
[
move
f
]()
{
let
child_task
=
spawn
(
fn
~
[
move
f
]()
{
let
to_child_port
=
comm
::
port
::
<
ToCh
>
();
comm
::
send
(
get_to_child_chan
,
comm
::
chan
(
to_child_port
));
f
(
to_child_port
,
from_child_chan
);
...
...
src/libstd/io.rs
浏览文件 @
455f8b0d
...
...
@@ -523,7 +523,7 @@ mod fsync {
type
arg
<
t
>
=
{
val
:
t
,
opt_level
:
option
::
t
<
level
>
,
fsync_fn
:
fn
(
t
,
level
)
->
int
fsync_fn
:
fn
@
(
t
,
level
)
->
int
};
// fsync file after executing blk
...
...
@@ -532,7 +532,7 @@ fn FILE_res_sync(&&file: FILE_res, opt_level: option::t<level>,
blk
:
block
(
&&
res
<
os
::
libc
::
FILE
>
))
{
blk
(
res
({
val
:
*
file
,
opt_level
:
opt_level
,
fsync_fn
:
fn
(
&&
file
:
os
::
libc
::
FILE
,
l
:
level
)
->
int
{
fsync_fn
:
fn
@
(
&&
file
:
os
::
libc
::
FILE
,
l
:
level
)
->
int
{
ret
os
::
fsync_fd
(
os
::
libc
::
fileno
(
file
),
l
)
as
int
;
}
}));
...
...
@@ -543,7 +543,7 @@ fn fd_res_sync(&&fd: fd_res, opt_level: option::t<level>,
blk
:
block
(
&&
res
<
fd_t
>
))
{
blk
(
res
({
val
:
*
fd
,
opt_level
:
opt_level
,
fsync_fn
:
fn
(
&&
fd
:
fd_t
,
l
:
level
)
->
int
{
fsync_fn
:
fn
@
(
&&
fd
:
fd_t
,
l
:
level
)
->
int
{
ret
os
::
fsync_fd
(
fd
,
l
)
as
int
;
}
}));
...
...
@@ -556,7 +556,7 @@ fn fd_res_sync(&&fd: fd_res, opt_level: option::t<level>,
fn
obj_sync
(
&&
o
:
t
,
opt_level
:
option
::
t
<
level
>
,
blk
:
block
(
&&
res
<
t
>
))
{
blk
(
res
({
val
:
o
,
opt_level
:
opt_level
,
fsync_fn
:
fn
(
&&
o
:
t
,
l
:
level
)
->
int
{
ret
o
.fsync
(
l
);
}
fsync_fn
:
fn
@
(
&&
o
:
t
,
l
:
level
)
->
int
{
ret
o
.fsync
(
l
);
}
}));
}
}
...
...
src/libstd/map.rs
浏览文件 @
455f8b0d
...
...
@@ -13,14 +13,14 @@
The hash should concentrate entropy in the
lower bits.
*/
type
hashfn
<
K
>
=
fn
(
K
)
->
uint
;
type
hashfn
<
K
>
=
fn
@
(
K
)
->
uint
;
/*
Type: eqfn
Equality
*/
type
eqfn
<
K
>
=
fn
(
K
,
K
)
->
bool
;
type
eqfn
<
K
>
=
fn
@
(
K
,
K
)
->
bool
;
/*
Type: hashset
...
...
src/test/compile-fail/bad-var-env-capture-in-block-arg.rs
浏览文件 @
455f8b0d
fn
main
()
{
let
x
=
3
;
fn
blah
(
_
a
:
fn
())
{}
fn
blah
(
_
a
:
native
fn
())
{}
blah
({||
log
(
debug
,
x
);
//! ERROR attempted dynamic environment capture
});
...
...
src/test/run-pass/bind-parameterized-args-2.rs
浏览文件 @
455f8b0d
fn
main
()
{
fn
echo
<
T
>
(
c
:
int
,
x
:
fn
(
T
))
{
#
error
(
"wee"
);
}
fn
echo
<
T
>
(
c
:
int
,
x
:
native
fn
(
T
))
{
#
error
(
"wee"
);
}
let
y
=
bind
echo
(
42
,
_
);
...
...
src/test/run-pass/block-arg-call-as.rs
浏览文件 @
455f8b0d
use
std
;
fn
asSendfn
(
f
:
sendfn
()
->
uint
)
->
uint
{
fn
asSendfn
(
f
:
fn
~
()
->
uint
)
->
uint
{
ret
f
();
}
...
...
src/test/run-pass/block-fn-coerce.rs
浏览文件 @
455f8b0d
fn
force
(
f
:
block
()
->
int
)
->
int
{
ret
f
();
}
fn
main
()
{
let
f
=
fn
()
->
int
{
ret
7
};
fn
f
()
->
int
{
ret
7
;
}
assert
(
force
(
f
)
==
7
);
let
g
=
bind
force
(
f
);
assert
(
g
()
==
7
);
...
...
src/test/run-pass/expr-block-fn.rs
浏览文件 @
455f8b0d
fn
test_fn
()
{
type
t
=
fn
()
->
int
;
type
t
=
native
fn
()
->
int
;
fn
ten
()
->
int
{
ret
10
;
}
let
rs
:
t
=
{
ten
};
assert
(
rs
()
==
10
);
...
...
src/test/run-pass/fixed-point-bind-box.rs
浏览文件 @
455f8b0d
fn
fix_help
<
A
,
B
>
(
f
:
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
fn
fix_help
<
A
,
B
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
ret
f
(
bind
fix_help
(
f
,
_
),
x
);
}
fn
fix
<
A
,
B
>
(
f
:
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
fn
fix
<
A
,
B
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
ret
bind
fix_help
(
f
,
_
);
}
...
...
src/test/run-pass/fixed-point-bind-unique.rs
浏览文件 @
455f8b0d
fn
fix_help
<
A
,
B
:
send
>
(
f
:
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
fn
fix_help
<
A
,
B
:
send
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
ret
f
(
bind
fix_help
(
f
,
_
),
x
);
}
fn
fix
<
A
,
B
:
send
>
(
f
:
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
fn
fix
<
A
,
B
:
send
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
ret
bind
fix_help
(
f
,
_
);
}
...
...
src/test/run-pass/fn-bare-anon-2.rs
已删除
100644 → 0
浏览文件 @
d2be5b6c
fn
main
()
{
let
f
:
fn
()
=
fn
()
{
#
debug
(
"This is a bare function"
)
};
let
g
;
g
=
f
;
}
\ No newline at end of file
src/test/run-pass/fn-bare-anon.rs
已删除
100644 → 0
浏览文件 @
d2be5b6c
fn
main
()
{
let
f
:
fn
()
=
fn
()
{
#
debug
(
"This is a bare function"
)
};
f
();
}
\ No newline at end of file
src/test/run-pass/fn-bare-assign.rs
浏览文件 @
455f8b0d
...
...
@@ -3,7 +3,7 @@ fn f(i: int, &called: bool) {
called
=
true
;
}
fn
g
(
f
:
fn
(
int
,
&
bool
),
&
called
:
bool
)
{
fn
g
(
f
:
native
fn
(
int
,
&
bool
),
&
called
:
bool
)
{
f
(
10
,
called
);
}
...
...
src/test/run-pass/fn-bare-spawn.rs
浏览文件 @
455f8b0d
// This is what the signature to spawn should look like with bare functions
fn
spawn
<
T
:
send
>
(
val
:
T
,
f
:
fn
(
T
))
{
fn
spawn
<
T
:
send
>
(
val
:
T
,
f
:
native
fn
(
T
))
{
f
(
val
);
}
...
...
@@ -10,7 +10,4 @@ fn f(&&i: int) {
fn
main
()
{
spawn
(
100
,
f
);
spawn
(
100
,
fn
(
&&
i
:
int
)
{
assert
i
==
100
;
});
}
\ No newline at end of file
src/test/run-pass/fn-coerce-field.rs
浏览文件 @
455f8b0d
...
...
@@ -3,5 +3,6 @@
};
fn
main
()
{
let
i
:
r
=
{
field
:
fn
()
{
}};
fn
f
()
{}
let
i
:
r
=
{
field
:
f
};
}
\ No newline at end of file
src/test/run-pass/fn-expr.rs
已删除
100644 → 0
浏览文件 @
d2be5b6c
fn
main
()
{
let
x
=
fn
(
a
:
int
)
->
int
{
ret
a
+
1
;
};
assert
(
x
(
4
)
==
5
);
}
src/test/run-pass/fn-lval.rs
浏览文件 @
455f8b0d
...
...
@@ -2,7 +2,7 @@
// -*- rust -*-
fn
foo
(
f
:
fn
(
int
)
->
int
)
{
}
fn
foo
(
f
:
native
fn
(
int
)
->
int
)
{
}
fn
id
(
x
:
int
)
->
int
{
ret
x
;
}
...
...
src/test/run-pass/fn-type-infer.rs
浏览文件 @
455f8b0d
fn
main
()
{
// We should be able to type infer inside of fn@s.
let
f
=
fn
()
{
let
i
=
10
;
};
let
f
=
fn
@
()
{
let
i
=
10
;
};
}
src/test/run-pass/fun-indirect-call.rs
浏览文件 @
455f8b0d
...
...
@@ -4,4 +4,8 @@
// -*- rust -*-
fn
f
()
->
int
{
ret
42
;
}
fn
main
()
{
let
g
:
fn
()
->
int
=
f
;
let
i
:
int
=
g
();
assert
(
i
==
42
);
}
fn
main
()
{
let
g
:
native
fn
()
->
int
=
f
;
let
i
:
int
=
g
();
assert
(
i
==
42
);
}
src/test/run-pass/generic-temporary.rs
浏览文件 @
455f8b0d
...
...
@@ -4,10 +4,13 @@
fn
chk
(
&&
a
:
int
)
{
log
(
debug
,
a
);
assert
(
a
==
1
);
}
fn
apply
<
T
>
(
produce
:
fn
()
->
T
,
consume
:
fn
(
T
))
{
consume
(
produce
());
}
fn
apply
<
T
>
(
produce
:
native
fn
()
->
T
,
consume
:
native
fn
(
T
))
{
consume
(
produce
());
}
fn
main
()
{
let
produce
:
fn
()
->
int
=
mk
;
let
consume
:
fn
(
&&
int
)
=
chk
;
let
produce
:
native
fn
()
->
int
=
mk
;
let
consume
:
native
fn
(
&&
int
)
=
chk
;
apply
::
<
int
>
(
produce
,
consume
);
}
src/test/run-pass/hashmap-memory.rs
浏览文件 @
455f8b0d
...
...
@@ -28,7 +28,7 @@ mod map_reduce {
type
putter
=
fn
@
(
str
,
str
);
type
mapper
=
fn
(
str
,
putter
);
type
mapper
=
native
fn
(
str
,
putter
);
tag
ctrl_proto
{
find_reducer
([
u8
],
chan
<
int
>
);
mapper_done
;
}
...
...
src/test/run-pass/issue-898.rs
浏览文件 @
455f8b0d
...
...
@@ -2,7 +2,7 @@ fn even(&&e: int) -> bool {
e
%
2
==
0
}
fn
log_if
<
T
>
(
c
:
fn
(
T
)
->
bool
,
e
:
T
)
{
fn
log_if
<
T
>
(
c
:
native
fn
(
T
)
->
bool
,
e
:
T
)
{
if
c
(
e
)
{
log
(
debug
,
e
);
}
}
...
...
src/test/run-pass/morestack6.rs
浏览文件 @
455f8b0d
...
...
@@ -32,11 +32,11 @@
fn
calllink09
()
{
rustrt
::
sched_threads
();
}
fn
calllink10
()
{
rustrt
::
rust_get_task
();
}
fn
runtest
(
f
:
sendfn
(),
frame_backoff
:
u32
)
{
fn
runtest
(
f
:
fn
~
(),
frame_backoff
:
u32
)
{
runtest2
(
f
,
frame_backoff
,
0
as
*
u8
);
}
fn
runtest2
(
f
:
sendfn
(),
frame_backoff
:
u32
,
last_stk
:
*
u8
)
->
u32
{
fn
runtest2
(
f
:
fn
~
(),
frame_backoff
:
u32
,
last_stk
:
*
u8
)
->
u32
{
let
curr_stk
=
rustrt
::
debug_get_stk_seg
();
if
(
last_stk
!=
curr_stk
&&
last_stk
!=
0
as
*
u8
)
{
// We switched stacks, go back and try to hit the dynamic linker
...
...
src/test/run-pass/move-nullary-fn.rs
浏览文件 @
455f8b0d
// Issue #922
fn
f2
(
-
thing
:
fn
())
{
}
fn
f2
(
-
thing
:
fn
@
())
{
}
fn
f
(
-
thing
:
fn
())
{
f2
(
thing
);
}
fn
f
(
-
thing
:
fn
@
())
{
f2
(
thing
);
}
fn
main
()
{
f
(
fn
()
{});
f
(
fn
@
()
{});
}
\ No newline at end of file
src/test/run-pass/newtype.rs
浏览文件 @
455f8b0d
tag
mytype
=
{
compute
:
fn
(
mytype
)
->
int
,
val
:
int
};
tag
mytype
=
{
compute
:
native
fn
(
mytype
)
->
int
,
val
:
int
};
fn
compute
(
i
:
mytype
)
->
int
{
ret
i
.val
+
20
;
}
...
...
src/test/run-pass/resource-generic.rs
浏览文件 @
455f8b0d
resource
finish
<
T
>
(
arg
:
{
val
:
T
,
fin
:
fn
(
T
)})
{
arg
.fin
(
arg
.val
);
}
resource
finish
<
T
>
(
arg
:
{
val
:
T
,
fin
:
native
fn
(
T
)})
{
arg
.fin
(
arg
.val
);
}
fn
main
()
{
let
box
=
@
mutable
10
;
...
...
src/test/run-pass/sendfn-deep-copy.rs
浏览文件 @
455f8b0d
...
...
@@ -5,11 +5,11 @@
fn
main
()
{
test05
();
}
fn
mk_counter
<
A
:
copy
>
()
->
sendfn
(
A
)
->
(
A
,
uint
)
{
fn
mk_counter
<
A
:
copy
>
()
->
fn
~
(
A
)
->
(
A
,
uint
)
{
// The only reason that the counter is generic is so that it closes
// over both a type descriptor and some data.
let
v
=
[
mutable
0u
];
ret
sendfn
(
a
:
A
)
->
(
A
,
uint
)
{
ret
fn
~
(
a
:
A
)
->
(
A
,
uint
)
{
let
n
=
v
[
0
];
v
[
0
]
=
n
+
1u
;
(
a
,
n
)
...
...
src/test/run-pass/sendfn-generic-fn.rs
浏览文件 @
455f8b0d
...
...
@@ -11,7 +11,7 @@ fn make_generic_record<A: copy, B: copy>(a: A, b: B) -> pair<A,B> {
ret
{
a
:
a
,
b
:
b
};
}
fn
test05_start
(
&&
f
:
sendfn
(
&&
float
,
&&
str
)
->
pair
<
float
,
str
>
)
{
fn
test05_start
(
&&
f
:
fn
~
(
&&
float
,
&&
str
)
->
pair
<
float
,
str
>
)
{
let
p
=
f
(
22.22
f
,
"Hi"
);
log
(
debug
,
p
);
assert
p
.a
==
22.22
f
;
...
...
@@ -23,8 +23,8 @@ fn test05_start(&&f: sendfn(&&float, &&str) -> pair<float, str>) {
assert
q
.b
==
"Ho"
;
}
fn
spawn
<
A
:
copy
,
B
:
copy
>
(
f
:
fn
(
sendfn
(
A
,
B
)
->
pair
<
A
,
B
>
))
{
let
arg
=
sendfn
(
a
:
A
,
b
:
B
)
->
pair
<
A
,
B
>
{
fn
spawn
<
A
:
copy
,
B
:
copy
>
(
f
:
fn
(
fn
~
(
A
,
B
)
->
pair
<
A
,
B
>
))
{
let
arg
=
fn
~
(
a
:
A
,
b
:
B
)
->
pair
<
A
,
B
>
{
ret
make_generic_record
(
a
,
b
);
};
task
::
spawn
{||
f
(
arg
);
};
...
...
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
浏览文件 @
455f8b0d
...
...
@@ -5,17 +5,17 @@
fn
main
()
{
test05
();
}
fn
test05_start
(
&&
f
:
sendfn
(
int
))
{
fn
test05_start
(
&&
f
:
fn
~
(
int
))
{
f
(
22
);
}
fn
test05
()
{
let
three
=
~
3
;
let
fn_to_send
=
sendfn
(
n
:
int
)
{
let
fn_to_send
=
fn
~
(
n
:
int
)
{
log
(
error
,
*
three
+
n
);
// will copy x into the closure
assert
(
*
three
==
3
);
};
task
::
spawn
(
sendfn
[
move
fn_to_send
]()
{
task
::
spawn
(
fn
~
[
move
fn_to_send
]()
{
test05_start
(
fn_to_send
);
});
}
src/test/run-pass/tail-cps.rs
浏览文件 @
455f8b0d
...
...
@@ -6,13 +6,13 @@
fn
main
()
{
let
k
=
checktrue
;
evenk
(
42
,
k
);
oddk
(
45
,
k
);
}
fn
evenk
(
n
:
int
,
k
:
fn
(
bool
)
->
bool
)
->
bool
{
fn
evenk
(
n
:
int
,
k
:
native
fn
(
bool
)
->
bool
)
->
bool
{
#
debug
(
"evenk"
);
log
(
debug
,
n
);
if
n
==
0
{
be
k
(
true
);
}
else
{
be
oddk
(
n
-
1
,
k
);
}
}
fn
oddk
(
n
:
int
,
k
:
fn
(
bool
)
->
bool
)
->
bool
{
fn
oddk
(
n
:
int
,
k
:
native
fn
(
bool
)
->
bool
)
->
bool
{
#
debug
(
"oddk"
);
log
(
debug
,
n
);
if
n
==
0
{
be
k
(
false
);
}
else
{
be
evenk
(
n
-
1
,
k
);
}
...
...
src/test/run-pass/type-param.rs
浏览文件 @
455f8b0d
type
lteq
<
T
>
=
fn
(
T
)
->
bool
;
type
lteq
<
T
>
=
native
fn
(
T
)
->
bool
;
fn
main
(
args
:
[
str
])
{
}
src/test/run-pass/type-params-in-for-each.rs
浏览文件 @
455f8b0d
...
...
@@ -5,7 +5,7 @@ fn range(lo: uint, hi: uint, it: block(uint)) {
while
lo_
<
hi
{
it
(
lo_
);
lo_
+=
1u
;
}
}
fn
create_index
<
T
>
(
index
:
[{
a
:
T
,
b
:
uint
}],
hash_fn
:
fn
(
T
)
->
uint
)
{
fn
create_index
<
T
>
(
index
:
[{
a
:
T
,
b
:
uint
}],
hash_fn
:
native
fn
(
T
)
->
uint
)
{
range
(
0u
,
256u
)
{|
_
i
|
let
bucket
:
[
T
]
=
[];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录