Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fa2b4d3a
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,发现更多精彩内容 >>
提交
fa2b4d3a
编写于
6月 14, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove a bunch of primitive-compiler-workarounds from pprust.rs
上级
471436a2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
41 deletion
+23
-41
src/comp/pretty/pprust.rs
src/comp/pretty/pprust.rs
+23
-41
未找到文件。
src/comp/pretty/pprust.rs
浏览文件 @
fa2b4d3a
...
...
@@ -164,9 +164,7 @@ fn commasep_cmnt[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN) op,
fn
commasep_exprs
(
&
ps
s
,
breaks
b
,
vec
[
@
ast
::
expr
]
exprs
)
{
fn
expr_span
(
&@
ast
::
expr
expr
)
->
common
::
span
{
ret
expr
.span
;}
auto
f
=
print_expr
;
auto
gs
=
expr_span
;
commasep_cmnt
[
@
ast
::
expr
](
s
,
b
,
exprs
,
f
,
gs
);
commasep_cmnt
(
s
,
b
,
exprs
,
print_expr
,
expr_span
);
}
fn
print_mod
(
&
ps
s
,
ast
::
_
mod
_
mod
)
{
...
...
@@ -210,8 +208,7 @@ fn print_type(&ps s, &ast::ty ty) {
case
(
ast
::
ty_tup
(
?
elts
))
{
word
(
s
.s
,
"tup"
);
popen
(
s
);
auto
f
=
print_mt
;
commasep
[
ast
::
mt
](
s
,
inconsistent
,
elts
,
f
);
commasep
(
s
,
inconsistent
,
elts
,
print_mt
);
pclose
(
s
);
}
case
(
ast
::
ty_rec
(
?
fields
))
{
...
...
@@ -227,9 +224,7 @@ fn print_field(&ps s, &ast::ty_field f) {
fn
get_span
(
&
ast
::
ty_field
f
)
->
common
::
span
{
ret
f
.span
;
}
auto
f
=
print_field
;
auto
gs
=
get_span
;
commasep_cmnt
[
ast
::
ty_field
](
s
,
consistent
,
fields
,
f
,
gs
);
commasep_cmnt
(
s
,
consistent
,
fields
,
print_field
,
get_span
);
pclose
(
s
);
}
case
(
ast
::
ty_obj
(
?
methods
))
{
...
...
@@ -346,13 +341,12 @@ fn print_item(&ps s, &@ast::item item) {
space
(
s
.s
);
maybe_print_comment
(
s
,
v
.span.lo
);
word
(
s
.s
,
v
.node.name
);
if
(
vec
::
len
[
ast
::
variant_arg
]
(
v
.node.args
)
>
0u
)
{
if
(
vec
::
len
(
v
.node.args
)
>
0u
)
{
popen
(
s
);
fn
print_variant_arg
(
&
ps
s
,
&
ast
::
variant_arg
arg
)
{
print_type
(
s
,
*
arg
.ty
);
}
auto
f
=
print_variant_arg
;
commasep
[
ast
::
variant_arg
](
s
,
consistent
,
v
.node.args
,
f
);
commasep
(
s
,
consistent
,
v
.node.args
,
print_variant_arg
);
pclose
(
s
);
}
word
(
s
.s
,
";"
);
...
...
@@ -373,9 +367,7 @@ fn print_field(&ps s, &ast::obj_field field) {
end
(
s
);
}
fn
get_span
(
&
ast
::
obj_field
f
)
->
common
::
span
{
ret
f
.ty.span
;}
auto
f
=
print_field
;
auto
gs
=
get_span
;
commasep_cmnt
[
ast
::
obj_field
](
s
,
consistent
,
_
obj
.fields
,
f
,
gs
);
commasep_cmnt
(
s
,
consistent
,
_
obj
.fields
,
print_field
,
get_span
);
pclose
(
s
);
space
(
s
.s
);
bopen
(
s
);
...
...
@@ -488,9 +480,7 @@ fn printElt(&ps s, &ast::elt elt) {
fn
get_span
(
&
ast
::
elt
elt
)
->
common
::
span
{
ret
elt
.expr.span
;}
word
(
s
.s
,
"tup"
);
popen
(
s
);
auto
f
=
printElt
;
auto
gs
=
get_span
;
commasep_cmnt
[
ast
::
elt
](
s
,
inconsistent
,
exprs
,
f
,
gs
);
commasep_cmnt
(
s
,
inconsistent
,
exprs
,
printElt
,
get_span
);
pclose
(
s
);
}
case
(
ast
::
expr_rec
(
?
fields
,
?
wth
,
_
))
{
...
...
@@ -507,12 +497,10 @@ fn get_span(&ast::field field) -> common::span {
}
word
(
s
.s
,
"rec"
);
popen
(
s
);
auto
f
=
print_field
;
auto
gs
=
get_span
;
commasep_cmnt
[
ast
::
field
](
s
,
consistent
,
fields
,
f
,
gs
);
commasep_cmnt
(
s
,
consistent
,
fields
,
print_field
,
get_span
);
alt
(
wth
)
{
case
(
some
(
?
expr
))
{
if
(
vec
::
len
[
ast
::
field
]
(
fields
)
>
0u
)
{
space
(
s
.s
);}
if
(
vec
::
len
(
fields
)
>
0u
)
{
space
(
s
.s
);}
ibox
(
s
,
indent_unit
);
word_space
(
s
,
"with"
);
print_expr
(
s
,
expr
);
...
...
@@ -544,8 +532,7 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
word_nbsp
(
s
,
"bind"
);
print_expr
(
s
,
func
);
popen
(
s
);
auto
f
=
print_opt
;
commasep
[
option
::
t
[
@
ast
::
expr
]](
s
,
inconsistent
,
args
,
f
);
commasep
(
s
,
inconsistent
,
args
,
print_opt
);
pclose
(
s
);
}
case
(
ast
::
expr_spawn
(
_
,
_
,
?
e
,
?
es
,
_
))
{
...
...
@@ -792,7 +779,7 @@ fn do_else(&ps s, option::t[@ast::expr] els) {
case
(
ast
::
expr_ext
(
?
path
,
?
args
,
?
body
,
_
,
_
))
{
word
(
s
.s
,
"#"
);
print_path
(
s
,
path
);
if
(
vec
::
len
[
@
ast
::
expr
]
(
args
)
>
0u
)
{
if
(
vec
::
len
(
args
)
>
0u
)
{
popen
(
s
);
commasep_exprs
(
s
,
inconsistent
,
args
);
pclose
(
s
);
...
...
@@ -896,7 +883,7 @@ fn print_ident(&ps s, &ast::ident ident) {
}
fn
print_for_decl
(
&
ps
s
,
@
ast
::
local
loc
)
{
print_type
(
s
,
*
option
::
get
[
@
ast
::
ty
]
(
loc
.node.ty
));
print_type
(
s
,
*
option
::
get
(
loc
.node.ty
));
space
(
s
.s
);
word
(
s
.s
,
loc
.node.ident
);
}
...
...
@@ -909,10 +896,9 @@ fn print_path(&ps s, &ast::path path) {
else
{
word
(
s
.s
,
"::"
);}
word
(
s
.s
,
id
);
}
if
(
vec
::
len
[
@
ast
::
ty
]
(
path
.node.types
)
>
0u
)
{
if
(
vec
::
len
(
path
.node.types
)
>
0u
)
{
word
(
s
.s
,
"["
);
auto
f
=
print_boxed_type
;
commasep
[
@
ast
::
ty
](
s
,
inconsistent
,
path
.node.types
,
f
);
commasep
(
s
,
inconsistent
,
path
.node.types
,
print_boxed_type
);
word
(
s
.s
,
"]"
);
}
}
...
...
@@ -925,10 +911,9 @@ fn print_pat(&ps s, &@ast::pat pat) {
case
(
ast
::
pat_lit
(
?
lit
,
_
))
{
print_literal
(
s
,
lit
);}
case
(
ast
::
pat_tag
(
?
path
,
?
args
,
_
))
{
print_path
(
s
,
path
);
if
(
vec
::
len
[
@
ast
::
pat
]
(
args
)
>
0u
)
{
if
(
vec
::
len
(
args
)
>
0u
)
{
popen
(
s
);
auto
f
=
print_pat
;
commasep
[
@
ast
::
pat
](
s
,
inconsistent
,
args
,
f
);
commasep
(
s
,
inconsistent
,
args
,
print_pat
);
pclose
(
s
);
}
}
...
...
@@ -973,7 +958,7 @@ fn print_arg(&ps s, &ast::arg x) {
word
(
s
.s
,
x
.ident
);
end
(
s
);
}
commasep
[
ast
::
arg
]
(
s
,
inconsistent
,
decl
.inputs
,
print_arg
);
commasep
(
s
,
inconsistent
,
decl
.inputs
,
print_arg
);
pclose
(
s
);
maybe_print_comment
(
s
,
decl
.output.span.lo
);
if
(
decl
.output.node
!=
ast
::
ty_nil
)
{
...
...
@@ -992,13 +977,12 @@ fn print_alias(&ps s, ast::mode m) {
}
fn
print_type_params
(
&
ps
s
,
&
vec
[
ast
::
ty_param
]
params
)
{
if
(
vec
::
len
[
ast
::
ty_param
]
(
params
)
>
0u
)
{
if
(
vec
::
len
(
params
)
>
0u
)
{
word
(
s
.s
,
"["
);
fn
printParam
(
&
ps
s
,
&
ast
::
ty_param
param
)
{
word
(
s
.s
,
param
);
}
auto
f
=
printParam
;
commasep
[
ast
::
ty_param
](
s
,
inconsistent
,
params
,
f
);
commasep
(
s
,
inconsistent
,
params
,
printParam
);
word
(
s
.s
,
"]"
);
}
}
...
...
@@ -1010,7 +994,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
case
(
ast
::
view_item_use
(
?
id
,
?
mta
,
_
,
_
))
{
head
(
s
,
"use"
);
word
(
s
.s
,
id
);
if
(
vec
::
len
[
@
ast
::
meta_item
]
(
mta
)
>
0u
)
{
if
(
vec
::
len
(
mta
)
>
0u
)
{
popen
(
s
);
fn
print_meta
(
&
ps
s
,
&@
ast
::
meta_item
item
)
{
ibox
(
s
,
indent_unit
);
...
...
@@ -1019,14 +1003,13 @@ fn print_meta(&ps s, &@ast::meta_item item) {
print_string
(
s
,
item
.node.value
);
end
(
s
);
}
auto
f
=
print_meta
;
commasep
[
@
ast
::
meta_item
](
s
,
consistent
,
mta
,
f
);
commasep
(
s
,
consistent
,
mta
,
print_meta
);
pclose
(
s
);
}
}
case
(
ast
::
view_item_import
(
?
id
,
?
ids
,
_
))
{
head
(
s
,
"import"
);
if
(
!
str
::
eq
(
id
,
ids
.
(
vec
::
len
[
str
]
(
ids
)
-
1u
)))
{
if
(
!
str
::
eq
(
id
,
ids
.
(
vec
::
len
(
ids
)
-
1u
)))
{
word_space
(
s
,
id
);
word_space
(
s
,
"="
);
}
...
...
@@ -1112,8 +1095,7 @@ fn print_arg(&ps s, &ast::ty_arg input) {
print_alias
(
s
,
input
.node.mode
);
print_type
(
s
,
*
input
.node.ty
);
}
auto
f
=
print_arg
;
commasep
[
ast
::
ty_arg
](
s
,
inconsistent
,
inputs
,
f
);
commasep
(
s
,
inconsistent
,
inputs
,
print_arg
);
pclose
(
s
);
maybe_print_comment
(
s
,
output
.span.lo
);
if
(
output
.node
!=
ast
::
ty_nil
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录