Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3f3bfeec
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,发现更多精彩内容 >>
提交
3f3bfeec
编写于
1月 11, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make "native fn" the type for bare functions, remove fn exprs
上级
455f8b0d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
42 addition
and
35 deletion
+42
-35
src/comp/metadata/encoder.rs
src/comp/metadata/encoder.rs
+1
-1
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+11
-4
src/libcore/task.rs
src/libcore/task.rs
+1
-1
src/libstd/test.rs
src/libstd/test.rs
+14
-14
src/test/bench/task-perf-word-count.rs
src/test/bench/task-perf-word-count.rs
+2
-2
src/test/compile-fail/fn-bare-bind.rs
src/test/compile-fail/fn-bare-bind.rs
+2
-3
src/test/compile-fail/fn-compare-mismatch.rs
src/test/compile-fail/fn-compare-mismatch.rs
+1
-2
src/test/compile-fail/main-wrong-type-2.rs
src/test/compile-fail/main-wrong-type-2.rs
+3
-2
src/test/compile-fail/main-wrong-type.rs
src/test/compile-fail/main-wrong-type.rs
+3
-2
src/test/run-fail/unwind-lambda.rs
src/test/run-fail/unwind-lambda.rs
+1
-1
src/test/run-pass/bind-parameterized-args-2.rs
src/test/run-pass/bind-parameterized-args-2.rs
+2
-2
src/test/run-pass/sendfn-generic-fn.rs
src/test/run-pass/sendfn-generic-fn.rs
+1
-1
未找到文件。
src/comp/metadata/encoder.rs
浏览文件 @
3f3bfeec
...
...
@@ -483,7 +483,7 @@ 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
:
block
(
io
::
writer
,
T
))
{
let
writer
=
io
::
new_writer
(
ebml_w
.writer
)
;
let
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/syntax/print/pprust.rs
浏览文件 @
3f3bfeec
...
...
@@ -304,7 +304,7 @@ fn print_field(s: ps, f: ast::ty_field) {
pclose
(
s
);
}
ast
::
ty_fn
(
proto
,
d
)
{
print_ty_fn
(
s
,
proto
,
d
,
none
,
none
);
print_ty_fn
(
s
,
some
(
proto
)
,
d
,
none
,
none
);
}
ast
::
ty_path
(
path
,
_
)
{
print_path
(
s
,
path
,
false
);
}
ast
::
ty_type
.
{
word
(
s
.s
,
"type"
);
}
...
...
@@ -485,7 +485,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) {
hardbreak_if_not_bol
(
s
);
cbox
(
s
,
indent_unit
);
maybe_print_comment
(
s
,
m
.span.lo
);
print_ty_fn
(
s
,
ast
::
proto_bar
e
,
m
.decl
,
some
(
m
.ident
),
some
(
m
.tps
));
print_ty_fn
(
s
,
non
e
,
m
.decl
,
some
(
m
.ident
),
some
(
m
.tps
));
word
(
s
.s
,
";"
);
end
(
s
);
}
...
...
@@ -1320,11 +1320,11 @@ fn print_mt(s: ps, mt: ast::mt) {
print_type
(
s
,
mt
.ty
);
}
fn
print_ty_fn
(
s
:
ps
,
proto
:
ast
::
proto
,
fn
print_ty_fn
(
s
:
ps
,
opt_proto
:
option
<
ast
::
proto
>
,
decl
:
ast
::
fn_decl
,
id
:
option
::
t
<
ast
::
ident
>
,
tps
:
option
::
t
<
[
ast
::
ty_param
]
>
)
{
ibox
(
s
,
indent_unit
);
word
(
s
.s
,
proto_to_str
(
proto
));
word
(
s
.s
,
opt_proto_to_str
(
opt_
proto
));
alt
id
{
some
(
id
)
{
word
(
s
.s
,
" "
);
word
(
s
.s
,
id
);
}
_
{
}
}
alt
tps
{
some
(
tps
)
{
print_type_params
(
s
,
tps
);
}
_
{
}
}
zerobreak
(
s
.s
);
...
...
@@ -1602,6 +1602,13 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
ret
s
;
}
fn
opt_proto_to_str
(
opt_p
:
option
<
ast
::
proto
>
)
->
str
{
alt
opt_p
{
none
.
{
"fn"
}
some
(
p
)
{
proto_to_str
(
p
)
}
}
}
fn
proto_to_str
(
p
:
ast
::
proto
)
->
str
{
ret
alt
p
{
ast
::
proto_bare
.
{
"native fn"
}
...
...
src/libcore/task.rs
浏览文件 @
3f3bfeec
...
...
@@ -116,7 +116,7 @@
A handle to the new task
*/
fn
spawn
(
+
f
:
sendfn
())
->
task
{
fn
spawn
(
+
f
:
fn
~
())
->
task
{
spawn_inner
(
f
,
none
)
}
...
...
src/libstd/test.rs
浏览文件 @
3f3bfeec
...
...
@@ -313,24 +313,24 @@ fn lteq<T>(t1: test_desc<T>, t2: test_desc<T>) -> bool {
fn
run_test
<
T
:
copy
>
(
test
:
test_desc
<
T
>
,
to_task
:
test_to_task
<
T
>
)
->
test_future
<
T
>
{
if
test
.ignore
{
ret
{
test
:
test
,
wait
:
fn
()
->
test_result
{
tr_ignored
}};
ret
{
test
:
test
,
wait
:
fn
@
()
->
test_result
{
tr_ignored
}};
}
let
test_task
=
to_task
(
test
.fn
);
ret
{
test
:
test
,
wait
:
bind
fn
(
test_task
:
joinable
,
should_fail
:
bool
)
->
test_result
{
alt
task
::
join
(
test_task
)
{
task
::
tr_success
.
{
if
should_fail
{
tr_failed
}
else
{
tr_ok
}
}
task
::
tr_failure
.
{
if
should_fail
{
tr_ok
}
else
{
tr_failed
}
}
}
}(
test_task
,
test
.should_fail
)
};
wait
:
fn
@
()
->
test_result
{
alt
task
::
join
(
test_task
)
{
task
::
tr_success
.
{
if
test
.should_fail
{
tr_failed
}
else
{
tr_ok
}
}
task
::
tr_failure
.
{
if
test
.should_fail
{
tr_ok
}
else
{
tr_failed
}
}
}
}
};
}
// We need to run our tests in another task in order to trap test failures.
...
...
src/test/bench/task-perf-word-count.rs
浏览文件 @
3f3bfeec
...
...
@@ -45,11 +45,11 @@ mod map_reduce {
type
putter
=
fn
@
(
str
,
int
);
type
mapper
=
fn
(
str
,
putter
);
type
mapper
=
fn
@
(
str
,
putter
);
type
getter
=
fn
@
()
->
option
<
int
>
;
type
reducer
=
fn
(
str
,
getter
);
type
reducer
=
fn
@
(
str
,
getter
);
tag
ctrl_proto
{
find_reducer
(
str
,
chan
<
chan
<
reduce_proto
>>
);
...
...
src/test/compile-fail/fn-bare-bind.rs
浏览文件 @
3f3bfeec
// error-pattern:mismatched types: expected `fn()` but found `fn@()`
fn
f
()
{
}
fn
main
()
{
// Can't produce a bare function by binding
let
g
:
fn
()
=
bind
f
();
let
g
:
native
fn
()
=
bind
f
();
//!^ ERROR mismatched types: expected `native fn()` but found `fn@()`
}
src/test/compile-fail/fn-compare-mismatch.rs
浏览文件 @
3f3bfeec
// error-pattern:expected `fn()` but found `fn(++int)`
fn
main
()
{
fn
f
()
{
}
fn
g
(
i
:
int
)
{
}
let
x
=
f
==
g
;
//!^ ERROR expected `native fn()` but found `native fn(++int)`
}
src/test/compile-fail/main-wrong-type-2.rs
浏览文件 @
3f3bfeec
// error-pattern:wrong type in main function: found `fn() -> char`
fn
main
()
->
char
{
}
fn
main
()
->
char
{
//!^ ERROR wrong type in main function: found `native fn() -> char`
}
src/test/compile-fail/main-wrong-type.rs
浏览文件 @
3f3bfeec
// error-pattern:wrong type in main function: found `fn(&&{x: int,y: int})`
fn
main
(
foo
:
{
x
:
int
,
y
:
int
})
{
}
fn
main
(
foo
:
{
x
:
int
,
y
:
int
})
{
//!^ ERROR wrong type in main function: found `native fn(&&{x: int,y: int})`
}
src/test/run-fail/unwind-lambda.rs
浏览文件 @
3f3bfeec
...
...
@@ -4,7 +4,7 @@ fn main() {
let
cheese
=
"roquefort"
;
let
carrots
=
@
"crunchy"
;
fn
(
tasties
:
@
str
,
macerate
:
block
(
str
))
{
fn
@
(
tasties
:
@
str
,
macerate
:
block
(
str
))
{
macerate
(
*
tasties
);
}
(
carrots
,
{
|
food
|
let
mush
=
food
+
cheese
;
...
...
src/test/run-pass/bind-parameterized-args-2.rs
浏览文件 @
3f3bfeec
fn
main
()
{
fn
echo
<
T
>
(
c
:
int
,
x
:
native
fn
(
T
))
{
#
error
(
"wee"
);
}
fn
echo
<
T
>
(
c
:
int
,
x
:
fn
@
(
T
))
{
#
error
(
"wee"
);
}
let
y
=
bind
echo
(
42
,
_
);
y
(
fn
(
&&
i
:
str
)
{
});
y
(
fn
@
(
&&
i
:
str
)
{
});
}
src/test/run-pass/sendfn-generic-fn.rs
浏览文件 @
3f3bfeec
...
...
@@ -23,7 +23,7 @@ fn test05_start(&&f: fn~(&&float, &&str) -> pair<float, str>) {
assert
q
.b
==
"Ho"
;
}
fn
spawn
<
A
:
copy
,
B
:
copy
>
(
f
:
fn
(
fn
~
(
A
,
B
)
->
pair
<
A
,
B
>
))
{
fn
spawn
<
A
:
copy
,
B
:
copy
>
(
f
:
native
fn
(
fn
~
(
A
,
B
)
->
pair
<
A
,
B
>
))
{
let
arg
=
fn
~
(
a
:
A
,
b
:
B
)
->
pair
<
A
,
B
>
{
ret
make_generic_record
(
a
,
b
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录