Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
df6ec4f8
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,发现更多精彩内容 >>
提交
df6ec4f8
编写于
6月 14, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Pretty-print outer attributes of items
Issue #487
上级
6c6d7c39
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
15 deletion
+47
-15
src/comp/pretty/pprust.rs
src/comp/pretty/pprust.rs
+47
-15
未找到文件。
src/comp/pretty/pprust.rs
浏览文件 @
df6ec4f8
...
...
@@ -257,7 +257,8 @@ fn print_item(&ps s, &@ast::item item) {
hardbreak
(
s
.s
);
maybe_print_comment
(
s
,
item
.span.lo
);
alt
(
item
.node
)
{
case
(
ast
::
item_const
(
?
id
,
?
ty
,
?
expr
,
_
,
_
,
_
))
{
case
(
ast
::
item_const
(
?
id
,
?
ty
,
?
expr
,
?
attrs
,
_
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
head
(
s
,
"const"
);
print_type
(
s
,
*
ty
);
space
(
s
.s
);
...
...
@@ -268,19 +269,22 @@ fn print_item(&ps s, &@ast::item item) {
word
(
s
.s
,
";"
);
end
(
s
);
// end the outer cbox
}
case
(
ast
::
item_fn
(
?
name
,
?
_
fn
,
?
typarams
,
_
,
_
,
_
))
{
case
(
ast
::
item_fn
(
?
name
,
?
_
fn
,
?
typarams
,
?
attrs
,
_
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
print_fn
(
s
,
_
fn
.decl
,
_
fn
.proto
,
name
,
typarams
);
word
(
s
.s
,
" "
);
print_block
(
s
,
_
fn
.body
);
}
case
(
ast
::
item_mod
(
?
id
,
?
_
mod
,
_
,
_
))
{
case
(
ast
::
item_mod
(
?
id
,
?
_
mod
,
?
attrs
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
head
(
s
,
"mod"
);
word_nbsp
(
s
,
id
);
bopen
(
s
);
for
(
@
ast
::
item
itm
in
_
mod
.items
)
{
print_item
(
s
,
itm
);}
bclose
(
s
,
item
.span
);
}
case
(
ast
::
item_native_mod
(
?
id
,
?
nmod
,
_
,
_
))
{
case
(
ast
::
item_native_mod
(
?
id
,
?
nmod
,
?
attrs
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
head
(
s
,
"native"
);
alt
(
nmod
.abi
)
{
case
(
ast
::
native_abi_rust
)
{
word_nbsp
(
s
,
"
\"
rust
\"
"
);}
...
...
@@ -317,7 +321,8 @@ fn print_item(&ps s, &@ast::item item) {
}
bclose
(
s
,
item
.span
);
}
case
(
ast
::
item_ty
(
?
id
,
?
ty
,
?
params
,
_
,
_
,
_
))
{
case
(
ast
::
item_ty
(
?
id
,
?
ty
,
?
params
,
?
attrs
,
_
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
ibox
(
s
,
indent_unit
);
ibox
(
s
,
0u
);
word_nbsp
(
s
,
"type"
);
...
...
@@ -331,7 +336,8 @@ fn print_item(&ps s, &@ast::item item) {
end
(
s
);
// end the outer ibox
break_offset
(
s
.s
,
0u
,
0
);
}
case
(
ast
::
item_tag
(
?
id
,
?
variants
,
?
params
,
_
,
_
,
_
))
{
case
(
ast
::
item_tag
(
?
id
,
?
variants
,
?
params
,
?
attrs
,
_
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
head
(
s
,
"tag"
);
word
(
s
.s
,
id
);
print_type_params
(
s
,
params
);
...
...
@@ -354,7 +360,8 @@ fn print_variant_arg(&ps s, &ast::variant_arg arg) {
}
bclose
(
s
,
item
.span
);
}
case
(
ast
::
item_obj
(
?
id
,
?
_
obj
,
?
params
,
_
,
_
,
_
))
{
case
(
ast
::
item_obj
(
?
id
,
?
_
obj
,
?
params
,
?
attrs
,
_
,
_
))
{
print_outer_attributes
(
s
,
attrs
);
head
(
s
,
"obj"
);
word
(
s
.s
,
id
);
print_type_params
(
s
,
params
);
...
...
@@ -401,6 +408,30 @@ fn print_field(&ps s, &ast::obj_field field) {
}
}
fn
print_outer_attributes
(
&
ps
s
,
vec
[
ast
::
attribute
]
attrs
)
{
auto
count
=
0
;
for
(
ast
::
attribute
attr
in
attrs
)
{
alt
(
attr
.node.style
)
{
case
(
ast
::
attr_outer
)
{
print_attribute
(
s
,
attr
);
count
+=
1
;
}
case
(
_
)
{
/* fallthrough */
}
}
}
if
(
count
>
0
)
{
hardbreak
(
s
.s
);
}
}
fn
print_attribute
(
&
ps
s
,
&
ast
::
attribute
attr
)
{
hardbreak
(
s
.s
);
maybe_print_comment
(
s
,
attr
.span.lo
);
word
(
s
.s
,
"#["
);
print_meta_item
(
s
,
@
attr
.node.value
);
word
(
s
.s
,
"]"
);
}
fn
print_stmt
(
&
ps
s
,
&
ast
::
stmt
st
)
{
maybe_print_comment
(
s
,
st
.span.lo
);
alt
(
st
.node
)
{
...
...
@@ -987,6 +1018,14 @@ fn printParam(&ps s, &ast::ty_param param) {
}
}
fn
print_meta_item
(
&
ps
s
,
&@
ast
::
meta_item
item
)
{
ibox
(
s
,
indent_unit
);
word_space
(
s
,
item
.node.key
);
word_space
(
s
,
"="
);
print_string
(
s
,
item
.node.value
);
end
(
s
);
}
fn
print_view_item
(
&
ps
s
,
&@
ast
::
view_item
item
)
{
hardbreak
(
s
.s
);
maybe_print_comment
(
s
,
item
.span.lo
);
...
...
@@ -996,14 +1035,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
word
(
s
.s
,
id
);
if
(
vec
::
len
(
mta
)
>
0u
)
{
popen
(
s
);
fn
print_meta
(
&
ps
s
,
&@
ast
::
meta_item
item
)
{
ibox
(
s
,
indent_unit
);
word_space
(
s
,
item
.node.key
);
word_space
(
s
,
"="
);
print_string
(
s
,
item
.node.value
);
end
(
s
);
}
commasep
(
s
,
consistent
,
mta
,
print_meta
);
commasep
(
s
,
consistent
,
mta
,
print_meta_item
);
pclose
(
s
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录