Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4b833e24
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
4b833e24
编写于
6月 25, 2014
作者:
J
John Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make fold_attribute part of Folder trait
上级
b8c5e465
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
23 deletion
+25
-23
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+25
-23
未找到文件。
src/libsyntax/fold.rs
浏览文件 @
4b833e24
...
...
@@ -86,7 +86,7 @@ fn fold_struct_field(&mut self, sf: &StructField) -> StructField {
kind
:
sf
.node.kind
,
id
:
id
,
ty
:
self
.fold_ty
(
sf
.node.ty
),
attrs
:
sf
.node.attrs
.iter
()
.map
(|
e
|
fold_attribute_
(
*
e
,
self
))
.collect
()
attrs
:
sf
.node.attrs
.iter
()
.map
(|
e
|
self
.fold_attribute
(
*
e
))
.collect
()
},
span
:
self
.new_span
(
sf
.span
)
}
...
...
@@ -118,7 +118,7 @@ fn fold_stmt(&mut self, s: &Stmt) -> SmallVector<Gc<Stmt>> {
fn
fold_arm
(
&
mut
self
,
a
:
&
Arm
)
->
Arm
{
Arm
{
attrs
:
a
.attrs
.iter
()
.map
(|
x
|
fold_attribute_
(
*
x
,
self
))
.collect
(),
attrs
:
a
.attrs
.iter
()
.map
(|
x
|
self
.fold_attribute
(
*
x
))
.collect
(),
pats
:
a
.pats
.iter
()
.map
(|
x
|
self
.fold_pat
(
*
x
))
.collect
(),
guard
:
a
.guard
.map
(|
x
|
self
.fold_expr
(
x
)),
body
:
self
.fold_expr
(
a
.body
),
...
...
@@ -251,7 +251,7 @@ fn fold_variant(&mut self, v: &Variant) -> P<Variant> {
}
}
let
attrs
=
v
.node.attrs
.iter
()
.map
(|
x
|
fold_attribute_
(
*
x
,
self
))
.collect
();
let
attrs
=
v
.node.attrs
.iter
()
.map
(|
x
|
self
.fold_attribute
(
*
x
))
.collect
();
let
de
=
match
v
.node.disr_expr
{
Some
(
e
)
=>
Some
(
self
.fold_expr
(
e
)),
...
...
@@ -344,6 +344,21 @@ fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ {
fn
fold_lifetime
(
&
mut
self
,
l
:
&
Lifetime
)
->
Lifetime
{
noop_fold_lifetime
(
l
,
self
)
}
//used in noop_fold_item and noop_fold_crate
fn
fold_attribute
(
&
mut
self
,
at
:
Attribute
)
->
Attribute
{
Spanned
{
span
:
self
.new_span
(
at
.span
),
node
:
ast
::
Attribute_
{
id
:
at
.node.id
,
style
:
at
.node.style
,
value
:
fold_meta_item_
(
at
.node.value
,
self
),
is_sugared_doc
:
at
.node.is_sugared_doc
}
}
}
}
/* some little folds that probably aren't useful to have in Folder itself*/
...
...
@@ -364,19 +379,6 @@ fn fold_meta_item_<T: Folder>(mi: Gc<MetaItem>, fld: &mut T) -> Gc<MetaItem> {
span
:
fld
.new_span
(
mi
.span
)
}
}
//used in noop_fold_item and noop_fold_crate
fn
fold_attribute_
<
T
:
Folder
>
(
at
:
Attribute
,
fld
:
&
mut
T
)
->
Attribute
{
Spanned
{
span
:
fld
.new_span
(
at
.span
),
node
:
ast
::
Attribute_
{
id
:
at
.node.id
,
style
:
at
.node.style
,
value
:
fold_meta_item_
(
at
.node.value
,
fld
),
is_sugared_doc
:
at
.node.is_sugared_doc
}
}
}
//used in noop_fold_foreign_item and noop_fold_fn_decl
fn
fold_arg_
<
T
:
Folder
>
(
a
:
&
Arg
,
fld
:
&
mut
T
)
->
Arg
{
let
id
=
fld
.new_id
(
a
.id
);
// Needs to be first, for ast_map.
...
...
@@ -526,7 +528,7 @@ fn fold_struct_field<T: Folder>(f: &StructField, fld: &mut T) -> StructField {
kind
:
f
.node.kind
,
id
:
id
,
ty
:
fld
.fold_ty
(
f
.node.ty
),
attrs
:
f
.node.attrs
.iter
()
.map
(|
a
|
f
old_attribute_
(
*
a
,
fld
))
.collect
(),
attrs
:
f
.node.attrs
.iter
()
.map
(|
a
|
f
ld
.fold_attribute
(
*
a
))
.collect
(),
},
span
:
fld
.new_span
(
f
.span
),
}
...
...
@@ -578,7 +580,7 @@ pub fn noop_fold_view_item<T: Folder>(vi: &ViewItem, folder: &mut T)
};
ViewItem
{
node
:
inner_view_item
,
attrs
:
vi
.attrs
.iter
()
.map
(|
a
|
fold
_attribute_
(
*
a
,
folder
))
.collect
(),
attrs
:
vi
.attrs
.iter
()
.map
(|
a
|
fold
er
.fold_attribute
(
*
a
))
.collect
(),
vis
:
vi
.vis
,
span
:
folder
.new_span
(
vi
.span
),
}
...
...
@@ -658,7 +660,7 @@ pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMeth
TypeMethod
{
id
:
id
,
ident
:
fld
.fold_ident
(
m
.ident
),
attrs
:
m
.attrs
.iter
()
.map
(|
a
|
f
old_attribute_
(
*
a
,
fld
))
.collect
(),
attrs
:
m
.attrs
.iter
()
.map
(|
a
|
f
ld
.fold_attribute
(
*
a
))
.collect
(),
fn_style
:
m
.fn_style
,
decl
:
fld
.fold_fn_decl
(
&*
m
.decl
),
generics
:
fold_generics
(
&
m
.generics
,
fld
),
...
...
@@ -681,7 +683,7 @@ pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod {
pub
fn
noop_fold_crate
<
T
:
Folder
>
(
c
:
Crate
,
folder
:
&
mut
T
)
->
Crate
{
Crate
{
module
:
folder
.fold_mod
(
&
c
.module
),
attrs
:
c
.attrs
.iter
()
.map
(|
x
|
fold
_attribute_
(
*
x
,
folder
))
.collect
(),
attrs
:
c
.attrs
.iter
()
.map
(|
x
|
fold
er
.fold_attribute
(
*
x
))
.collect
(),
config
:
c
.config
.iter
()
.map
(|
x
|
fold_meta_item_
(
*
x
,
folder
))
.collect
(),
span
:
folder
.new_span
(
c
.span
),
}
...
...
@@ -702,7 +704,7 @@ pub fn noop_fold_item<T: Folder>(i: &Item,
SmallVector
::
one
(
box
(
GC
)
Item
{
id
:
id
,
ident
:
folder
.fold_ident
(
ident
),
attrs
:
i
.attrs
.iter
()
.map
(|
e
|
fold
_attribute_
(
*
e
,
folder
))
.collect
(),
attrs
:
i
.attrs
.iter
()
.map
(|
e
|
fold
er
.fold_attribute
(
*
e
))
.collect
(),
node
:
node
,
vis
:
i
.vis
,
span
:
folder
.new_span
(
i
.span
)
...
...
@@ -715,7 +717,7 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: &ForeignItem,
box
(
GC
)
ForeignItem
{
id
:
id
,
ident
:
folder
.fold_ident
(
ni
.ident
),
attrs
:
ni
.attrs
.iter
()
.map
(|
x
|
fold
_attribute_
(
*
x
,
folder
))
.collect
(),
attrs
:
ni
.attrs
.iter
()
.map
(|
x
|
fold
er
.fold_attribute
(
*
x
))
.collect
(),
node
:
match
ni
.node
{
ForeignItemFn
(
ref
fdec
,
ref
generics
)
=>
{
ForeignItemFn
(
P
(
FnDecl
{
...
...
@@ -739,7 +741,7 @@ pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> Gc<Method> {
box
(
GC
)
Method
{
id
:
id
,
ident
:
folder
.fold_ident
(
m
.ident
),
attrs
:
m
.attrs
.iter
()
.map
(|
a
|
fold
_attribute_
(
*
a
,
folder
))
.collect
(),
attrs
:
m
.attrs
.iter
()
.map
(|
a
|
fold
er
.fold_attribute
(
*
a
))
.collect
(),
generics
:
fold_generics
(
&
m
.generics
,
folder
),
explicit_self
:
folder
.fold_explicit_self
(
&
m
.explicit_self
),
fn_style
:
m
.fn_style
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录