Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ade7df43
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,发现更多精彩内容 >>
提交
ade7df43
编写于
9月 09, 2013
作者:
L
Lindsey Kuper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor libsyntax Visitor impls to use default methods.
上级
150b4ffc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
3 addition
and
275 deletion
+3
-275
src/libsyntax/ast_map.rs
src/libsyntax/ast_map.rs
+1
-77
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+2
-198
未找到文件。
src/libsyntax/ast_map.rs
浏览文件 @
ade7df43
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012
-2013
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -362,85 +362,9 @@ fn visit_block(&mut self, block: &Block, _: ()) {
self
.map_block
(
block
)
}
// XXX: Methods below can become default methods.
fn
visit_mod
(
&
mut
self
,
module
:
&
_
mod
,
_
:
Span
,
_
:
NodeId
,
_
:
())
{
visit
::
walk_mod
(
self
,
module
,
())
}
fn
visit_view_item
(
&
mut
self
,
view_item
:
&
view_item
,
_
:
())
{
visit
::
walk_view_item
(
self
,
view_item
,
())
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
@
foreign_item
,
_
:
())
{
visit
::
walk_foreign_item
(
self
,
foreign_item
,
())
}
fn
visit_local
(
&
mut
self
,
local
:
@
Local
,
_
:
())
{
visit
::
walk_local
(
self
,
local
,
())
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
Arm
,
_
:
())
{
visit
::
walk_arm
(
self
,
arm
,
())
}
fn
visit_decl
(
&
mut
self
,
decl
:
@
Decl
,
_
:
())
{
visit
::
walk_decl
(
self
,
decl
,
())
}
fn
visit_expr_post
(
&
mut
self
,
_
:
@
Expr
,
_
:
())
{
// Empty!
}
fn
visit_ty
(
&
mut
self
,
typ
:
&
Ty
,
_
:
())
{
visit
::
walk_ty
(
self
,
typ
,
())
}
fn
visit_generics
(
&
mut
self
,
generics
:
&
Generics
,
_
:
())
{
visit
::
walk_generics
(
self
,
generics
,
())
}
fn
visit_fn
(
&
mut
self
,
function_kind
:
&
fn_kind
,
function_declaration
:
&
fn_decl
,
block
:
&
Block
,
span
:
Span
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_fn
(
self
,
function_kind
,
function_declaration
,
block
,
span
,
node_id
,
())
}
fn
visit_ty_method
(
&
mut
self
,
ty_method
:
&
TypeMethod
,
_
:
())
{
visit
::
walk_ty_method
(
self
,
ty_method
,
())
}
fn
visit_trait_method
(
&
mut
self
,
trait_method
:
&
trait_method
,
_
:
())
{
visit
::
walk_trait_method
(
self
,
trait_method
,
())
}
fn
visit_struct_def
(
&
mut
self
,
struct_def
:
@
struct_def
,
ident
:
Ident
,
generics
:
&
Generics
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_struct_def
(
self
,
struct_def
,
ident
,
generics
,
node_id
,
())
}
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
@
struct_field
,
_
:
())
{
visit
::
walk_struct_field
(
self
,
struct_field
,
())
}
}
pub
fn
map_crate
(
diag
:
@
mut
span_handler
,
c
:
&
Crate
)
->
map
{
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
ade7df43
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012
-2013
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
ast
::{
Block
,
Crate
,
NodeId
,
DeclLocal
,
Expr_
,
ExprMac
,
SyntaxContext
};
use
ast
::{
Block
,
Crate
,
DeclLocal
,
Expr_
,
ExprMac
,
SyntaxContext
};
use
ast
::{
Local
,
Ident
,
mac_invoc_tt
};
use
ast
::{
item_mac
,
Mrk
,
Stmt_
,
StmtDecl
,
StmtMac
,
StmtExpr
,
StmtSemi
};
use
ast
::{
token_tree
};
...
...
@@ -553,107 +553,10 @@ fn visit_pat(&mut self, pattern: @ast::Pat, _: ()) {
}
}
// XXX: Methods below can become default methods.
fn
visit_mod
(
&
mut
self
,
module
:
&
ast
::
_
mod
,
_
:
Span
,
_
:
NodeId
,
_
:
())
{
visit
::
walk_mod
(
self
,
module
,
())
}
fn
visit_view_item
(
&
mut
self
,
view_item
:
&
ast
::
view_item
,
_
:
())
{
visit
::
walk_view_item
(
self
,
view_item
,
())
}
fn
visit_item
(
&
mut
self
,
item
:
@
ast
::
item
,
_
:
())
{
visit
::
walk_item
(
self
,
item
,
())
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
@
ast
::
foreign_item
,
_
:
())
{
visit
::
walk_foreign_item
(
self
,
foreign_item
,
())
}
fn
visit_local
(
&
mut
self
,
local
:
@
ast
::
Local
,
_
:
())
{
visit
::
walk_local
(
self
,
local
,
())
}
fn
visit_block
(
&
mut
self
,
block
:
&
ast
::
Block
,
_
:
())
{
visit
::
walk_block
(
self
,
block
,
())
}
fn
visit_stmt
(
&
mut
self
,
stmt
:
@
ast
::
Stmt
,
_
:
())
{
visit
::
walk_stmt
(
self
,
stmt
,
())
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
ast
::
Arm
,
_
:
())
{
visit
::
walk_arm
(
self
,
arm
,
())
}
fn
visit_decl
(
&
mut
self
,
decl
:
@
ast
::
Decl
,
_
:
())
{
visit
::
walk_decl
(
self
,
decl
,
())
}
fn
visit_expr
(
&
mut
self
,
expr
:
@
ast
::
Expr
,
_
:
())
{
visit
::
walk_expr
(
self
,
expr
,
())
}
fn
visit_expr_post
(
&
mut
self
,
_
:
@
ast
::
Expr
,
_
:
())
{
// Empty!
}
fn
visit_ty
(
&
mut
self
,
typ
:
&
ast
::
Ty
,
_
:
())
{
visit
::
walk_ty
(
self
,
typ
,
())
}
fn
visit_generics
(
&
mut
self
,
generics
:
&
ast
::
Generics
,
_
:
())
{
visit
::
walk_generics
(
self
,
generics
,
())
}
fn
visit_fn
(
&
mut
self
,
function_kind
:
&
visit
::
fn_kind
,
function_declaration
:
&
ast
::
fn_decl
,
block
:
&
ast
::
Block
,
span
:
Span
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_fn
(
self
,
function_kind
,
function_declaration
,
block
,
span
,
node_id
,
())
}
fn
visit_ty_method
(
&
mut
self
,
ty_method
:
&
ast
::
TypeMethod
,
_
:
())
{
visit
::
walk_ty_method
(
self
,
ty_method
,
())
}
fn
visit_trait_method
(
&
mut
self
,
trait_method
:
&
ast
::
trait_method
,
_
:
())
{
visit
::
walk_trait_method
(
self
,
trait_method
,
())
}
fn
visit_struct_def
(
&
mut
self
,
struct_def
:
@
ast
::
struct_def
,
ident
:
Ident
,
generics
:
&
ast
::
Generics
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_struct_def
(
self
,
struct_def
,
ident
,
generics
,
node_id
,
())
}
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
@
ast
::
struct_field
,
_
:
())
{
visit
::
walk_struct_field
(
self
,
struct_field
,
())
}
}
// a visitor that extracts the paths
...
...
@@ -664,7 +567,6 @@ struct NewPathExprFinderContext {
path_accumulator
:
@
mut
~
[
ast
::
Path
],
}
// XXX : YIKES a lot of boilerplate again....
impl
Visitor
<
()
>
for
NewPathExprFinderContext
{
fn
visit_expr
(
&
mut
self
,
expr
:
@
ast
::
Expr
,
_
:
())
{
...
...
@@ -677,108 +579,10 @@ fn visit_expr(&mut self, expr: @ast::Expr, _: ()) {
}
}
// XXX: Methods below can become default methods.
fn
visit_pat
(
&
mut
self
,
pattern
:
@
ast
::
Pat
,
_
:
())
{
visit
::
walk_pat
(
self
,
pattern
,())
}
fn
visit_mod
(
&
mut
self
,
module
:
&
ast
::
_
mod
,
_
:
Span
,
_
:
NodeId
,
_
:
())
{
visit
::
walk_mod
(
self
,
module
,
())
}
fn
visit_view_item
(
&
mut
self
,
view_item
:
&
ast
::
view_item
,
_
:
())
{
visit
::
walk_view_item
(
self
,
view_item
,
())
}
fn
visit_item
(
&
mut
self
,
item
:
@
ast
::
item
,
_
:
())
{
visit
::
walk_item
(
self
,
item
,
())
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
@
ast
::
foreign_item
,
_
:
())
{
visit
::
walk_foreign_item
(
self
,
foreign_item
,
())
}
fn
visit_local
(
&
mut
self
,
local
:
@
ast
::
Local
,
_
:
())
{
visit
::
walk_local
(
self
,
local
,
())
}
fn
visit_block
(
&
mut
self
,
block
:
&
ast
::
Block
,
_
:
())
{
visit
::
walk_block
(
self
,
block
,
())
}
fn
visit_stmt
(
&
mut
self
,
stmt
:
@
ast
::
Stmt
,
_
:
())
{
visit
::
walk_stmt
(
self
,
stmt
,
())
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
ast
::
Arm
,
_
:
())
{
visit
::
walk_arm
(
self
,
arm
,
())
}
fn
visit_decl
(
&
mut
self
,
decl
:
@
ast
::
Decl
,
_
:
())
{
visit
::
walk_decl
(
self
,
decl
,
())
}
fn
visit_expr_post
(
&
mut
self
,
_
:
@
ast
::
Expr
,
_
:
())
{
// Empty!
}
fn
visit_ty
(
&
mut
self
,
typ
:
&
ast
::
Ty
,
_
:
())
{
visit
::
walk_ty
(
self
,
typ
,
())
}
fn
visit_generics
(
&
mut
self
,
generics
:
&
ast
::
Generics
,
_
:
())
{
visit
::
walk_generics
(
self
,
generics
,
())
}
fn
visit_fn
(
&
mut
self
,
function_kind
:
&
visit
::
fn_kind
,
function_declaration
:
&
ast
::
fn_decl
,
block
:
&
ast
::
Block
,
span
:
Span
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_fn
(
self
,
function_kind
,
function_declaration
,
block
,
span
,
node_id
,
())
}
fn
visit_ty_method
(
&
mut
self
,
ty_method
:
&
ast
::
TypeMethod
,
_
:
())
{
visit
::
walk_ty_method
(
self
,
ty_method
,
())
}
fn
visit_trait_method
(
&
mut
self
,
trait_method
:
&
ast
::
trait_method
,
_
:
())
{
visit
::
walk_trait_method
(
self
,
trait_method
,
())
}
fn
visit_struct_def
(
&
mut
self
,
struct_def
:
@
ast
::
struct_def
,
ident
:
Ident
,
generics
:
&
ast
::
Generics
,
node_id
:
NodeId
,
_
:
())
{
visit
::
walk_struct_def
(
self
,
struct_def
,
ident
,
generics
,
node_id
,
())
}
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
@
ast
::
struct_field
,
_
:
())
{
visit
::
walk_struct_field
(
self
,
struct_field
,
())
}
}
// return a visitor that extracts the pat_ident paths
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录