Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
882bea5b
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,发现更多精彩内容 >>
提交
882bea5b
编写于
1月 18, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename fn*() to fn() as originally planned.
上级
1f0b3d22
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
30 addition
and
21 deletion
+30
-21
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+9
-7
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+1
-1
src/test/compile-fail/block-coerce-no-2.rs
src/test/compile-fail/block-coerce-no-2.rs
+3
-4
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/block-coerce-no.rs
+8
-8
src/test/pretty/fn-types.rs
src/test/pretty/fn-types.rs
+8
-0
src/test/run-pass/block-arg-used-as-any.rs
src/test/run-pass/block-arg-used-as-any.rs
+1
-1
未找到文件。
src/comp/syntax/parse/parser.rs
浏览文件 @
882bea5b
...
...
@@ -146,8 +146,8 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
for
word
in
[
"mod"
,
"if"
,
"else"
,
"while"
,
"do"
,
"alt"
,
"for"
,
"break"
,
"cont"
,
"ret"
,
"be"
,
"fail"
,
"type"
,
"resource"
,
"check"
,
"assert"
,
"claim"
,
"native"
,
"fn"
,
"pure"
,
"unsafe"
,
"import"
,
"export"
,
"let"
,
"const"
,
"log"
,
"copy"
,
"impl"
,
"iface"
,
"enum"
]
{
"unsafe"
,
"
block"
,
"
import"
,
"export"
,
"let"
,
"const"
,
"log"
,
"copy"
,
"
sendfn"
,
"
impl"
,
"iface"
,
"enum"
]
{
words
.insert
(
word
,
());
}
words
...
...
@@ -493,6 +493,9 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
_
{
/* fallthrough */
}
}
t
=
parse_ty_fn
(
proto
,
p
);
}
else
if
eat_word
(
p
,
"block"
)
{
//p.warn("block is deprecated, use fn& or fn");
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
);
...
...
@@ -799,6 +802,9 @@ fn parse_bottom_expr(p: parser) -> pexpr {
_
{
/* fallthrough */
}
}
ret
pexpr
(
parse_fn_expr
(
p
,
proto
));
}
else
if
eat_word
(
p
,
"block"
)
{
p
.warn
(
"block is deprecated, use fn& or fn"
);
ret
pexpr
(
parse_fn_expr
(
p
,
ast
::
proto_block
));
}
else
if
eat_word
(
p
,
"unchecked"
)
{
ret
pexpr
(
parse_block_expr
(
p
,
lo
,
ast
::
unchecked_blk
));
}
else
if
eat_word
(
p
,
"unsafe"
)
{
...
...
@@ -2109,12 +2115,8 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
p
.bump
();
ast
::
proto_block
}
token
::
BINOP
(
token
::
STAR
)
{
p
.bump
();
// temporary: fn* for any closure
ast
::
proto_any
}
_
{
ast
::
proto_
bare
ast
::
proto_
any
}
}
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
882bea5b
...
...
@@ -1643,7 +1643,7 @@ fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
fn
proto_to_str
(
p
:
ast
::
proto
)
->
str
{
ret
alt
p
{
ast
::
proto_bare
{
"native fn"
}
ast
::
proto_any
{
"fn
*
"
}
ast
::
proto_any
{
"fn"
}
ast
::
proto_block
{
"fn&"
}
ast
::
proto_uniq
{
"fn~"
}
ast
::
proto_box
{
"fn@"
}
...
...
src/test/compile-fail/block-coerce-no-2.rs
浏览文件 @
882bea5b
// error-pattern: mismatched types
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn
main
()
{
fn
f
(
f
:
fn
(
fn
(
fn
())))
{
fn
f
(
f
:
native
fn
(
native
fn
(
native
fn
())))
{
}
fn
g
(
f
:
fn
(
block
()))
{
fn
g
(
f
:
native
fn
(
fn
()))
{
}
f
(
g
);
//!^ ERROR mismatched types: expected `native fn(native fn(native fn()))`
}
src/test/compile-fail/block-coerce-no.rs
浏览文件 @
882bea5b
// error-pattern: mismatched types
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn
coerce
(
b
:
block
())
->
fn
()
{
fn
lol
(
f
:
fn
(
block
())
->
fn
(),
g
:
block
())
->
fn
()
{
ret
f
(
g
);
}
fn
fn_id
(
f
:
fn
())
->
fn
()
{
ret
f
}
fn
coerce
(
b
:
fn
())
->
native
fn
()
{
fn
lol
(
f
:
native
fn
(
block
())
->
native
fn
(),
g
:
fn
())
->
native
fn
()
{
ret
f
(
g
);
}
fn
fn_id
(
f
:
native
fn
())
->
native
fn
()
{
ret
f
}
ret
lol
(
fn_id
,
b
);
//!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()`
}
fn
main
()
{
let
i
=
8
;
let
f
=
coerce
(
block
()
{
log
(
error
,
i
);
});
f
();
}
let
f
=
coerce
({||
log
(
error
,
i
);
});
f
();
}
src/test/pretty/fn-types.rs
0 → 100644
浏览文件 @
882bea5b
// pp-exact
fn
from_native_fn
(
x
:
native
fn
())
{
}
fn
from_closure
(
x
:
fn
())
{
}
fn
from_stack_closure
(
x
:
fn
&
())
{
}
fn
from_box_closure
(
x
:
fn
@
())
{
}
fn
from_unique_closure
(
x
:
fn
~
())
{
}
fn
main
()
{
}
src/test/run-pass/block-arg-used-as-any.rs
浏览文件 @
882bea5b
fn
call_any
(
f
:
fn
*
()
->
uint
)
->
uint
{
fn
call_any
(
f
:
fn
()
->
uint
)
->
uint
{
ret
f
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录