Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
47eca211
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,发现更多精彩内容 >>
提交
47eca211
编写于
7月 06, 2013
作者:
J
James Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
De-share ast::Ty
上级
46a1f546
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
256 addition
and
255 deletion
+256
-255
src/librustc/front/config.rs
src/librustc/front/config.rs
+2
-2
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+1
-1
src/librustc/middle/kind.rs
src/librustc/middle/kind.rs
+2
-2
src/librustc/middle/lint.rs
src/librustc/middle/lint.rs
+3
-3
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+9
-9
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+17
-17
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+3
-3
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/debuginfo.rs
+11
-9
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+8
-8
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+9
-9
src/librustc/middle/typeck/coherence.rs
src/librustc/middle/typeck/coherence.rs
+2
-2
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/collect.rs
+8
-8
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+15
-15
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+51
-52
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/generic.rs
+3
-3
src/libsyntax/ext/deriving/ty.rs
src/libsyntax/ext/deriving/ty.rs
+2
-2
src/libsyntax/ext/pipes/ast_builder.rs
src/libsyntax/ext/pipes/ast_builder.rs
+4
-4
src/libsyntax/ext/pipes/check.rs
src/libsyntax/ext/pipes/check.rs
+1
-1
src/libsyntax/ext/pipes/pipec.rs
src/libsyntax/ext/pipes/pipec.rs
+6
-6
src/libsyntax/ext/pipes/proto.rs
src/libsyntax/ext/pipes/proto.rs
+5
-5
src/libsyntax/ext/quote.rs
src/libsyntax/ext/quote.rs
+5
-5
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+24
-24
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+17
-17
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+1
-1
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+20
-20
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+27
-27
未找到文件。
src/librustc/front/config.rs
浏览文件 @
47eca211
...
...
@@ -98,10 +98,10 @@ fn fold_foreign_mod(
fn
fold_item_underscore
(
cx
:
@
Context
,
item
:
&
ast
::
item_
,
fld
:
@
fold
::
ast_fold
)
->
ast
::
item_
{
let
item
=
match
*
item
{
ast
::
item_impl
(
ref
a
,
ref
b
,
c
,
ref
methods
)
=>
{
ast
::
item_impl
(
ref
a
,
ref
b
,
ref
c
,
ref
methods
)
=>
{
let
methods
=
methods
.iter
()
.filter
(|
m
|
method_in_cfg
(
cx
,
**
m
))
.transform
(|
x
|
*
x
)
.collect
();
ast
::
item_impl
(
/*bad*/
copy
*
a
,
/*bad*/
copy
*
b
,
c
,
methods
)
ast
::
item_impl
(
/*bad*/
copy
*
a
,
/*bad*/
copy
*
b
,
/*bad*/
copy
*
c
,
methods
)
}
ast
::
item_trait
(
ref
a
,
ref
b
,
ref
methods
)
=>
{
let
methods
=
methods
.iter
()
.filter
(|
m
|
trait_method_in_cfg
(
cx
,
*
m
)
)
...
...
src/librustc/metadata/encoder.rs
浏览文件 @
47eca211
...
...
@@ -1003,7 +1003,7 @@ fn add_to_index_(item: @item, ebml_w: &writer::Encoder,
index
);
}
}
item_impl
(
ref
generics
,
ref
opt_trait
,
ty
,
ref
methods
)
=>
{
item_impl
(
ref
generics
,
ref
opt_trait
,
ref
ty
,
ref
methods
)
=>
{
add_to_index
();
ebml_w
.start_tag
(
tag_items_data_item
);
encode_def_id
(
ebml_w
,
local_def
(
item
.id
));
...
...
src/librustc/middle/kind.rs
浏览文件 @
47eca211
...
...
@@ -117,7 +117,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
// If this is a destructor, check kinds.
if
!
attrs_contains_name
(
item
.attrs
,
"unsafe_destructor"
)
{
match
item
.node
{
item_impl
(
_
,
Some
(
ref
trait_ref
),
self_type
,
_
)
=>
{
item_impl
(
_
,
Some
(
ref
trait_ref
),
ref
self_type
,
_
)
=>
{
match
cx
.tcx.def_map
.find
(
&
trait_ref
.ref_id
)
{
None
=>
cx
.tcx.sess
.bug
(
"trait ref not in def map!"
),
Some
(
&
trait_def
)
=>
{
...
...
@@ -321,7 +321,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
visit
::
visit_expr
(
e
,
(
cx
,
v
));
}
fn
check_ty
(
aty
:
@
Ty
,
(
cx
,
v
):
(
Context
,
visit
::
vt
<
Context
>
))
{
fn
check_ty
(
aty
:
&
Ty
,
(
cx
,
v
):
(
Context
,
visit
::
vt
<
Context
>
))
{
match
aty
.node
{
ty_path
(
_
,
_
,
id
)
=>
{
let
r
=
cx
.tcx.node_type_substs
.find
(
&
id
);
...
...
src/librustc/middle/lint.rs
浏览文件 @
47eca211
...
...
@@ -747,9 +747,9 @@ fn check_ty(cx: &Context, ty: &ast::Ty) {
fn
check_foreign_fn
(
cx
:
&
Context
,
decl
:
&
ast
::
fn_decl
)
{
for
decl
.inputs
.iter
()
.advance
|
in
|
{
check_ty
(
cx
,
in
.ty
);
check_ty
(
cx
,
&
in
.ty
);
}
check_ty
(
cx
,
decl
.output
)
check_ty
(
cx
,
&
decl
.output
)
}
match
it
.node
{
...
...
@@ -759,7 +759,7 @@ fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
ast
::
foreign_item_fn
(
ref
decl
,
_
,
_
)
=>
{
check_foreign_fn
(
cx
,
decl
);
}
ast
::
foreign_item_static
(
t
,
_
)
=>
{
check_ty
(
cx
,
t
);
}
ast
::
foreign_item_static
(
ref
t
,
_
)
=>
{
check_ty
(
cx
,
t
);
}
}
}
}
...
...
src/librustc/middle/region.rs
浏览文件 @
47eca211
...
...
@@ -713,10 +713,10 @@ fn determine_rp_in_fn(fk: &visit::fn_kind,
do
cx
.with
(
cx
.item_id
,
false
)
{
do
cx
.with_ambient_variance
(
rv_contravariant
)
{
for
decl
.inputs
.iter
()
.advance
|
a
|
{
(
visitor
.visit_ty
)(
a
.ty
,
(
cx
,
visitor
));
(
visitor
.visit_ty
)(
&
a
.ty
,
(
cx
,
visitor
));
}
}
(
visitor
.visit_ty
)(
decl
.output
,
(
cx
,
visitor
));
(
visitor
.visit_ty
)(
&
decl
.output
,
(
cx
,
visitor
));
let
generics
=
visit
::
generics_of_fn
(
fk
);
(
visitor
.visit_generics
)(
&
generics
,
(
cx
,
visitor
));
(
visitor
.visit_block
)(
body
,
(
cx
,
visitor
));
...
...
@@ -731,7 +731,7 @@ fn determine_rp_in_ty_method(ty_m: &ast::ty_method,
}
}
fn
determine_rp_in_ty
(
ty
:
@
ast
::
Ty
,
fn
determine_rp_in_ty
(
ty
:
&
ast
::
Ty
,
(
cx
,
visitor
):
(
@
mut
DetermineRpCtxt
,
visit
::
vt
<@
mut
DetermineRpCtxt
>
))
{
// we are only interested in types that will require an item to
...
...
@@ -815,8 +815,8 @@ fn determine_rp_in_ty(ty: @ast::Ty,
}
match
ty
.node
{
ast
::
ty_box
(
mt
)
|
ast
::
ty_uniq
(
mt
)
|
ast
::
ty_vec
(
mt
)
|
ast
::
ty_rptr
(
_
,
mt
)
|
ast
::
ty_ptr
(
mt
)
=>
{
ast
::
ty_box
(
ref
mt
)
|
ast
::
ty_uniq
(
ref
mt
)
|
ast
::
ty_vec
(
ref
mt
)
|
ast
::
ty_rptr
(
_
,
ref
mt
)
|
ast
::
ty_ptr
(
ref
mt
)
=>
{
visit_mt
(
mt
,
(
cx
,
visitor
));
}
...
...
@@ -824,7 +824,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// type parameters are---for now, anyway---always invariant
do
cx
.with_ambient_variance
(
rv_invariant
)
{
for
path
.types
.iter
()
.advance
|
tp
|
{
(
visitor
.visit_ty
)(
*
tp
,
(
cx
,
visitor
));
(
visitor
.visit_ty
)(
tp
,
(
cx
,
visitor
));
}
}
}
...
...
@@ -837,10 +837,10 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// parameters are contravariant
do
cx
.with_ambient_variance
(
rv_contravariant
)
{
for
decl
.inputs
.iter
()
.advance
|
a
|
{
(
visitor
.visit_ty
)(
a
.ty
,
(
cx
,
visitor
));
(
visitor
.visit_ty
)(
&
a
.ty
,
(
cx
,
visitor
));
}
}
(
visitor
.visit_ty
)(
decl
.output
,
(
cx
,
visitor
));
(
visitor
.visit_ty
)(
&
decl
.output
,
(
cx
,
visitor
));
}
}
...
...
@@ -849,7 +849,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
}
}
fn
visit_mt
(
mt
:
ast
::
mt
,
fn
visit_mt
(
mt
:
&
ast
::
mt
,
(
cx
,
visitor
):
(
@
mut
DetermineRpCtxt
,
visit
::
vt
<@
mut
DetermineRpCtxt
>
))
{
// mutability is invariant
...
...
src/librustc/middle/resolve.rs
浏览文件 @
47eca211
...
...
@@ -1233,7 +1233,7 @@ pub fn build_reduced_graph_for_item(@mut self,
visit_item
(
item
,
(
new_parent
,
visitor
));
}
item_impl
(
_
,
None
,
ty
,
ref
methods
)
=>
{
item_impl
(
_
,
None
,
ref
ty
,
ref
methods
)
=>
{
// If this implements an anonymous trait, then add all the
// methods within to a new module, if the type was defined
// within this module.
...
...
@@ -1243,8 +1243,8 @@ pub fn build_reduced_graph_for_item(@mut self,
// the same module that declared the type.
// Create the module and add all methods.
match
*
ty
{
Ty
{
match
ty
{
&
Ty
{
node
:
ty_path
(
ref
path
,
_
,
_
),
_
}
if
path
.idents
.len
()
==
1
=>
{
...
...
@@ -1313,7 +1313,7 @@ pub fn build_reduced_graph_for_item(@mut self,
visit_item
(
item
,
(
parent
,
visitor
));
}
item_impl
(
_
,
Some
(
_
),
_
ty
,
ref
_
methods
)
=>
{
item_impl
(
_
,
Some
(
_
),
_
,
_
)
=>
{
visit_item
(
item
,
(
parent
,
visitor
));
}
...
...
@@ -3534,7 +3534,7 @@ pub fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
item_impl
(
ref
generics
,
ref
implemented_traits
,
self_type
,
ref
self_type
,
ref
methods
)
=>
{
self
.resolve_implementation
(
item
.id
,
generics
,
...
...
@@ -3585,10 +3585,10 @@ pub fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
visitor
);
for
ty_m
.decl.inputs
.iter
()
.advance
|
argument
|
{
self
.resolve_type
(
argument
.ty
,
visitor
);
self
.resolve_type
(
&
argument
.ty
,
visitor
);
}
self
.resolve_type
(
ty_m
.decl.output
,
visitor
);
self
.resolve_type
(
&
ty_m
.decl.output
,
visitor
);
}
}
provided
(
m
)
=>
{
...
...
@@ -3778,12 +3778,12 @@ pub fn resolve_function(@mut self,
None
,
visitor
);
self
.resolve_type
(
argument
.ty
,
visitor
);
self
.resolve_type
(
&
argument
.ty
,
visitor
);
debug!
(
"(resolving function) recorded argument"
);
}
self
.resolve_type
(
declaration
.output
,
visitor
);
self
.resolve_type
(
&
declaration
.output
,
visitor
);
}
}
...
...
@@ -3878,7 +3878,7 @@ pub fn resolve_struct(@mut self,
// Resolve fields.
for
fields
.iter
()
.advance
|
field
|
{
self
.resolve_type
(
field
.node.ty
,
visitor
);
self
.resolve_type
(
&
field
.node.ty
,
visitor
);
}
}
}
...
...
@@ -3914,7 +3914,7 @@ pub fn resolve_implementation(@mut self,
id
:
node_id
,
generics
:
&
Generics
,
opt_trait_reference
:
&
Option
<
trait_ref
>
,
self_type
:
@
Ty
,
self_type
:
&
Ty
,
methods
:
&
[
@
method
],
visitor
:
ResolveVisitor
)
{
// If applicable, create a rib for the type parameters.
...
...
@@ -4001,7 +4001,7 @@ pub fn resolve_local(@mut self, local: @local, visitor: ResolveVisitor) {
let
mutability
=
if
local
.node.is_mutbl
{
Mutable
}
else
{
Immutable
};
// Resolve the type.
self
.resolve_type
(
local
.node.ty
,
visitor
);
self
.resolve_type
(
&
local
.node.ty
,
visitor
);
// Resolve the initializer, if necessary.
match
local
.node.init
{
...
...
@@ -4112,7 +4112,7 @@ pub fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
debug!
(
"(resolving block) leaving block"
);
}
pub
fn
resolve_type
(
@
mut
self
,
ty
:
@
Ty
,
visitor
:
ResolveVisitor
)
{
pub
fn
resolve_type
(
@
mut
self
,
ty
:
&
Ty
,
visitor
:
ResolveVisitor
)
{
match
ty
.node
{
// Like path expressions, the interpretation of path types depends
// on whether the path has multiple elements in it or not.
...
...
@@ -4334,7 +4334,7 @@ struct in scope",
// Check the types in the path pattern.
for
path
.types
.iter
()
.advance
|
ty
|
{
self
.resolve_type
(
*
ty
,
visitor
);
self
.resolve_type
(
ty
,
visitor
);
}
}
...
...
@@ -4367,7 +4367,7 @@ struct in scope",
// Check the types in the path pattern.
for
path
.types
.iter
()
.advance
|
ty
|
{
self
.resolve_type
(
*
ty
,
visitor
);
self
.resolve_type
(
ty
,
visitor
);
}
}
...
...
@@ -4396,7 +4396,7 @@ struct in scope",
// Check the types in the path pattern.
for
path
.types
.iter
()
.advance
|
ty
|
{
self
.resolve_type
(
*
ty
,
visitor
);
self
.resolve_type
(
ty
,
visitor
);
}
}
...
...
@@ -4491,7 +4491,7 @@ pub fn resolve_path(@mut self,
->
Option
<
def
>
{
// First, resolve the types.
for
path
.types
.iter
()
.advance
|
ty
|
{
self
.resolve_type
(
*
ty
,
visitor
);
self
.resolve_type
(
ty
,
visitor
);
}
if
path
.global
{
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
47eca211
...
...
@@ -1737,7 +1737,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
fcx
.llargs
.insert
(
arg_id
,
llarg
);
if
fcx
.ccx.sess.opts.extra_debuginfo
&&
fcx_has_nonzero_span
(
fcx
)
{
debuginfo
::
create_arg
(
bcx
,
args
[
arg_n
],
args
[
arg_n
]
.ty.span
);
debuginfo
::
create_arg
(
bcx
,
&
args
[
arg_n
],
args
[
arg_n
]
.ty.span
);
}
}
...
...
@@ -1911,7 +1911,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
let
fn_args
=
do
args
.map
|
varg
|
{
ast
::
arg
{
is_mutbl
:
false
,
ty
:
varg
.ty
,
ty
:
copy
varg
.ty
,
pat
:
ast_util
::
ident_to_pat
(
ccx
.tcx.sess
.next_node_id
(),
codemap
::
dummy_sp
(),
...
...
@@ -1985,7 +1985,7 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext,
let
fn_args
=
do
fields
.map
|
field
|
{
ast
::
arg
{
is_mutbl
:
false
,
ty
:
field
.node.ty
,
ty
:
copy
field
.node.ty
,
pat
:
ast_util
::
ident_to_pat
(
ccx
.tcx.sess
.next_node_id
(),
codemap
::
dummy_sp
(),
special_idents
::
arg
),
...
...
src/librustc/middle/trans/debuginfo.rs
浏览文件 @
47eca211
...
...
@@ -182,7 +182,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
///
/// Adds the created metadata nodes directly to the crate's IR.
/// The return value should be ignored if called from outside of the debuginfo module.
pub
fn
create_arg
(
bcx
:
block
,
arg
:
ast
::
arg
,
span
:
span
)
->
Option
<
DIVariable
>
{
pub
fn
create_arg
(
bcx
:
block
,
arg
:
&
ast
::
arg
,
span
:
span
)
->
Option
<
DIVariable
>
{
debug!
(
"create_arg"
);
if
true
{
// XXX create_arg disabled for now because "node_id_type(bcx, arg.id)" below blows
...
...
@@ -259,23 +259,25 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
let
fcx
=
&
mut
*
fcx
;
let
span
=
fcx
.span
.get
();
let
(
ident
,
ret_ty
,
id
)
=
match
cx
.tcx.items
.get_copy
(
&
fcx
.id
)
{
ast_map
::
node_item
(
item
,
_
)
=>
{
let
fnitem
=
cx
.tcx.items
.get_copy
(
&
fcx
.id
);
let
(
ident
,
ret_ty
,
id
)
=
match
fnitem
{
ast_map
::
node_item
(
ref
item
,
_
)
=>
{
match
item
.node
{
ast
::
item_fn
(
ref
decl
,
_
,
_
,
_
,
_
)
=>
{
(
item
.ident
,
decl
.output
,
item
.id
)
ast
::
item_fn
(
ast
::
fn_decl
{
output
:
ref
ty
,
_
}
,
_
,
_
,
_
,
_
)
=>
{
(
item
.ident
,
ty
,
item
.id
)
}
_
=>
fcx
.ccx.sess
.span_bug
(
item
.span
,
"create_function: item bound to non-function"
)
}
}
ast_map
::
node_method
(
method
,
_
,
_
)
=>
{
(
method
.ident
,
method
.decl.output
,
method
.id
)
ast_map
::
node_method
(
@
ast
::
method
{
decl
:
ast
::
fn_decl
{
output
:
ref
ty
,
_
},
id
:
id
,
ident
:
ident
,
_
},
_
,
_
)
=>
{
(
ident
,
ty
,
id
)
}
ast_map
::
node_expr
(
expr
)
=>
{
ast_map
::
node_expr
(
ref
expr
)
=>
{
match
expr
.node
{
ast
::
expr_fn_block
(
ref
decl
,
_
)
=>
{
let
name
=
gensym_name
(
"fn"
);
(
name
,
decl
.output
,
expr
.id
)
(
name
,
&
decl
.output
,
expr
.id
)
}
_
=>
fcx
.ccx.sess
.span_bug
(
expr
.span
,
"create_function: expected an expr_fn_block here"
)
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
47eca211
...
...
@@ -179,7 +179,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + 'static>(
fmt!
(
"wrong number of type arguments: expected %u but found %u"
,
decl_generics
.type_param_defs
.len
(),
path
.types
.len
()));
}
let
tps
=
path
.types
.map
(|
a_t
|
ast_ty_to_ty
(
this
,
rscope
,
*
a_t
));
let
tps
=
path
.types
.map
(|
a_t
|
ast_ty_to_ty
(
this
,
rscope
,
a_t
));
substs
{
self_r
:
self_r
,
self_ty
:
self_ty
,
tps
:
tps
}
}
...
...
@@ -377,7 +377,7 @@ fn check_path_args(tcx: ty::ctxt,
|
tmt
|
ty
::
mk_rptr
(
tcx
,
r
,
tmt
))
}
ast
::
ty_tup
(
ref
fields
)
=>
{
let
flds
=
fields
.map
(|
t
|
ast_ty_to_ty
(
this
,
rscope
,
*
t
));
let
flds
=
fields
.map
(|
t
|
ast_ty_to_ty
(
this
,
rscope
,
t
));
ty
::
mk_tup
(
tcx
,
flds
)
}
ast
::
ty_bare_fn
(
ref
bf
)
=>
{
...
...
@@ -525,13 +525,13 @@ pub fn ty_of_arg<AC:AstConv,
RS
:
region_scope
+
Copy
+
'static
>
(
this
:
&
AC
,
rscope
:
&
RS
,
a
:
ast
::
arg
,
a
:
&
ast
::
arg
,
expected_ty
:
Option
<
ty
::
t
>
)
->
ty
::
t
{
match
a
.ty.node
{
ast
::
ty_infer
if
expected_ty
.is_some
()
=>
expected_ty
.get
(),
ast
::
ty_infer
=>
this
.ty_infer
(
a
.ty.span
),
_
=>
ast_ty_to_ty
(
this
,
rscope
,
a
.ty
),
_
=>
ast_ty_to_ty
(
this
,
rscope
,
&
a
.ty
),
}
}
...
...
@@ -621,11 +621,11 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
transform_self_ty
(
this
,
&
rb
,
self_info
)
});
let
input_tys
=
decl
.inputs
.map
(|
a
|
ty_of_arg
(
this
,
&
rb
,
*
a
,
None
));
let
input_tys
=
decl
.inputs
.map
(|
a
|
ty_of_arg
(
this
,
&
rb
,
a
,
None
));
let
output_ty
=
match
decl
.output.node
{
ast
::
ty_infer
=>
this
.ty_infer
(
decl
.output.span
),
_
=>
ast_ty_to_ty
(
this
,
&
rb
,
decl
.output
)
_
=>
ast_ty_to_ty
(
this
,
&
rb
,
&
decl
.output
)
};
return
(
opt_transformed_self_ty
,
...
...
@@ -724,14 +724,14 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + 'static>(
// were supplied
if
i
<
e
.inputs
.len
()
{
Some
(
e
.inputs
[
i
])}
else
{
None
}
};
ty_of_arg
(
this
,
&
rb
,
*
a
,
expected_arg_ty
)
ty_of_arg
(
this
,
&
rb
,
a
,
expected_arg_ty
)
}
.collect
();
let
expected_ret_ty
=
expected_sig
.map
(|
e
|
e
.output
);
let
output_ty
=
match
decl
.output.node
{
ast
::
ty_infer
if
expected_ret_ty
.is_some
()
=>
expected_ret_ty
.get
(),
ast
::
ty_infer
=>
this
.ty_infer
(
decl
.output.span
),
_
=>
ast_ty_to_ty
(
this
,
&
rb
,
decl
.output
)
_
=>
ast_ty_to_ty
(
this
,
&
rb
,
&
decl
.output
)
};
ty
::
ClosureTy
{
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
47eca211
...
...
@@ -476,7 +476,7 @@ fn gather_locals(fcx: @mut FnCtxt,
|
local
,
(
e
,
v
)|
{
let
o_ty
=
match
local
.node.ty.node
{
ast
::
ty_infer
=>
None
,
_
=>
Some
(
fcx
.to_ty
(
local
.node.ty
))
_
=>
Some
(
fcx
.to_ty
(
&
local
.node.ty
))
};
assign
(
local
.node.id
,
o_ty
);
debug!
(
"Local variable %s is assigned type %s"
,
...
...
@@ -624,7 +624,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
ast
::
item_struct
(
*
)
=>
{
check_struct
(
ccx
,
it
.id
,
it
.span
);
}
ast
::
item_ty
(
t
,
ref
generics
)
=>
{
ast
::
item_ty
(
ref
t
,
ref
generics
)
=>
{
let
tpt_ty
=
ty
::
node_id_to_type
(
ccx
.tcx
,
it
.id
);
check_bounds_are_used
(
ccx
,
t
.span
,
&
generics
.ty_params
,
tpt_ty
);
}
...
...
@@ -790,7 +790,7 @@ pub fn write_error(@mut self, node_id: ast::node_id) {
self
.write_ty
(
node_id
,
ty
::
mk_err
());
}
pub
fn
to_ty
(
&
self
,
ast_t
:
@
ast
::
Ty
)
->
ty
::
t
{
pub
fn
to_ty
(
&
self
,
ast_t
:
&
ast
::
Ty
)
->
ty
::
t
{
ast_ty_to_ty
(
self
,
self
,
ast_t
)
}
...
...
@@ -1381,7 +1381,7 @@ fn check_method_call(fcx: @mut FnCtxt,
rcvr
:
@
ast
::
expr
,
method_name
:
ast
::
ident
,
args
:
&
[
@
ast
::
expr
],
tps
:
&
[
@
ast
::
Ty
],
tps
:
&
[
ast
::
Ty
],
sugar
:
ast
::
CallSugar
)
{
check_expr
(
fcx
,
rcvr
);
...
...
@@ -1390,7 +1390,7 @@ fn check_method_call(fcx: @mut FnCtxt,
expr
.span
,
fcx
.expr_ty
(
rcvr
));
let
tps
=
tps
.map
(|
ast_ty
|
fcx
.to_ty
(
*
ast_ty
));
let
tps
=
tps
.map
(|
ast_ty
|
fcx
.to_ty
(
ast_ty
));
match
method
::
lookup
(
fcx
,
expr
,
rcvr
,
...
...
@@ -1779,7 +1779,7 @@ fn check_field(fcx: @mut FnCtxt,
expr
:
@
ast
::
expr
,
base
:
@
ast
::
expr
,
field
:
ast
::
ident
,
tys
:
&
[
@
ast
::
Ty
])
{
tys
:
&
[
ast
::
Ty
])
{
let
tcx
=
fcx
.ccx.tcx
;
let
bot
=
check_expr
(
fcx
,
base
);
let
expr_t
=
structurally_resolved_type
(
fcx
,
expr
.span
,
...
...
@@ -1809,7 +1809,7 @@ fn check_field(fcx: @mut FnCtxt,
_
=>
()
}
let
tps
=
tys
.iter
()
.transform
(|
ty
|
fcx
.to_ty
(
*
ty
))
.collect
::
<~
[
ty
::
t
]
>
();
let
tps
:
~
[
ty
::
t
]
=
tys
.iter
()
.transform
(|
ty
|
fcx
.to_ty
(
ty
))
.collect
();
match
method
::
lookup
(
fcx
,
expr
,
base
,
...
...
@@ -2622,7 +2622,7 @@ fn check_loop_body(fcx: @mut FnCtxt,
fcx
.write_bot
(
id
);
}
}
ast
::
expr_cast
(
e
,
t
)
=>
{
ast
::
expr_cast
(
e
,
ref
t
)
=>
{
check_expr
(
fcx
,
e
);
let
t_1
=
fcx
.to_ty
(
t
);
let
t_e
=
fcx
.expr_ty
(
e
);
...
...
@@ -3336,7 +3336,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
(
span
,
"not enough type parameters provided for this item"
);
fcx
.infcx
()
.next_ty_vars
(
ty_param_count
)
}
else
{
pth
.types
.map
(|
aty
|
fcx
.to_ty
(
*
aty
))
pth
.types
.map
(|
aty
|
fcx
.to_ty
(
aty
))
};
let
substs
=
substs
{
self_r
:
self_r
,
self_ty
:
None
,
tps
:
tps
};
...
...
src/librustc/middle/typeck/coherence.rs
浏览文件 @
47eca211
...
...
@@ -638,7 +638,7 @@ pub fn check_privileged_scopes(self, crate: &crate) {
// Then visit the module items.
visit_mod
(
module_
,
item
.span
,
item
.id
,
((),
visitor
));
}
item_impl
(
_
,
None
,
ast_ty
,
_
)
=>
{
item_impl
(
_
,
None
,
ref
ast_ty
,
_
)
=>
{
if
!
self
.ast_type_is_defined_in_local_crate
(
ast_ty
)
{
// This is an error.
let
session
=
self
.crate_context.tcx.sess
;
...
...
@@ -725,7 +725,7 @@ pub fn please_check_that_trait_methods_are_implemented(&self,
/// For coherence, when we have `impl Type`, we need to guarantee that
/// `Type` is "local" to the crate. For our purposes, this means that it
/// must precisely name some nominal type defined in this crate.
pub
fn
ast_type_is_defined_in_local_crate
(
&
self
,
original_type
:
@
ast
::
Ty
)
pub
fn
ast_type_is_defined_in_local_crate
(
&
self
,
original_type
:
&
ast
::
Ty
)
->
bool
{
match
original_type
.node
{
ty_path
(
_
,
_
,
path_id
)
=>
{
...
...
src/librustc/middle/typeck/collect.rs
浏览文件 @
47eca211
...
...
@@ -148,7 +148,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt,
match
variant
.node.kind
{
ast
::
tuple_variant_kind
(
ref
args
)
if
args
.len
()
>
0
=>
{
let
rs
=
type_rscope
(
region_parameterization
);
let
input_tys
=
args
.map
(|
va
|
ccx
.to_ty
(
&
rs
,
va
.ty
));
let
input_tys
=
args
.map
(|
va
|
ccx
.to_ty
(
&
rs
,
&
va
.ty
));
result_ty
=
Some
(
ty
::
mk_ctor_fn
(
tcx
,
input_tys
,
enum_ty
));
}
...
...
@@ -684,7 +684,7 @@ pub fn convert_field(ccx: &CrateCtxt,
generics
:
&
ast
::
Generics
)
{
let
region_parameterization
=
RegionParameterization
::
from_variance_and_generics
(
rp
,
generics
);
let
tt
=
ccx
.to_ty
(
&
type_rscope
(
region_parameterization
),
v
.node.ty
);
let
tt
=
ccx
.to_ty
(
&
type_rscope
(
region_parameterization
),
&
v
.node.ty
);
write_ty_to_tcx
(
ccx
.tcx
,
v
.node.id
,
tt
);
/* add the field to the tcache */
ccx
.tcx.tcache
.insert
(
local_def
(
v
.node.id
),
...
...
@@ -813,7 +813,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
generics
,
rp
);
}
ast
::
item_impl
(
ref
generics
,
ref
opt_trait_ref
,
selfty
,
ref
ms
)
=>
{
ast
::
item_impl
(
ref
generics
,
ref
opt_trait_ref
,
ref
selfty
,
ref
ms
)
=>
{
let
i_ty_generics
=
ty_generics
(
ccx
,
rp
,
generics
,
0
);
let
region_parameterization
=
RegionParameterization
::
from_variance_and_generics
(
rp
,
generics
);
...
...
@@ -1031,7 +1031,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item)
}
let
rp
=
tcx
.region_paramd_items
.find
(
&
it
.id
)
.map_consume
(|
x
|
*
x
);
match
it
.node
{
ast
::
item_static
(
t
,
_
,
_
)
=>
{
ast
::
item_static
(
ref
t
,
_
,
_
)
=>
{
let
typ
=
ccx
.to_ty
(
&
empty_rscope
,
t
);
let
tpt
=
no_params
(
typ
);
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
...
...
@@ -1060,7 +1060,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item)
ccx
.tcx.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
return
tpt
;
}
ast
::
item_ty
(
t
,
ref
generics
)
=>
{
ast
::
item_ty
(
ref
t
,
ref
generics
)
=>
{
match
tcx
.tcache
.find
(
&
local_def
(
it
.id
))
{
Some
(
&
tpt
)
=>
return
tpt
,
None
=>
{
}
...
...
@@ -1124,7 +1124,7 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt,
generics
,
abis
)
}
ast
::
foreign_item_static
(
t
,
_
)
=>
{
ast
::
foreign_item_static
(
ref
t
,
_
)
=>
{
ty
::
ty_param_bounds_and_ty
{
generics
:
ty
::
Generics
{
type_param_defs
:
@~
[],
...
...
@@ -1215,8 +1215,8 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
let
ty_generics
=
ty_generics
(
ccx
,
None
,
ast_generics
,
0
);
let
region_param_names
=
RegionParamNames
::
from_generics
(
ast_generics
);
let
rb
=
in_binding_rscope
(
&
empty_rscope
,
region_param_names
);
let
input_tys
=
decl
.inputs
.map
(|
a
|
ty_of_arg
(
ccx
,
&
rb
,
*
a
,
None
)
);
let
output_ty
=
ast_ty_to_ty
(
ccx
,
&
rb
,
decl
.output
);
let
input_tys
=
decl
.inputs
.map
(|
a
|
ty_of_arg
(
ccx
,
&
rb
,
a
,
None
)
);
let
output_ty
=
ast_ty_to_ty
(
ccx
,
&
rb
,
&
decl
.output
);
let
t_fn
=
ty
::
mk_bare_fn
(
ccx
.tcx
,
...
...
src/libsyntax/ast.rs
浏览文件 @
47eca211
...
...
@@ -110,7 +110,7 @@ pub struct Path {
global
:
bool
,
idents
:
~
[
ident
],
rp
:
Option
<
Lifetime
>
,
types
:
~
[
@
Ty
],
types
:
~
[
Ty
],
}
pub
type
crate_num
=
int
;
...
...
@@ -361,7 +361,7 @@ pub enum stmt_ {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
struct
local_
{
is_mutbl
:
bool
,
ty
:
@
Ty
,
ty
:
Ty
,
pat
:
@
pat
,
init
:
Option
<@
expr
>
,
id
:
node_id
,
...
...
@@ -429,12 +429,12 @@ pub enum expr_ {
expr_vstore
(
@
expr
,
expr_vstore
),
expr_vec
(
~
[
@
expr
],
mutability
),
expr_call
(
@
expr
,
~
[
@
expr
],
CallSugar
),
expr_method_call
(
node_id
,
@
expr
,
ident
,
~
[
@
Ty
],
~
[
@
expr
],
CallSugar
),
expr_method_call
(
node_id
,
@
expr
,
ident
,
~
[
Ty
],
~
[
@
expr
],
CallSugar
),
expr_tup
(
~
[
@
expr
]),
expr_binary
(
node_id
,
binop
,
@
expr
,
@
expr
),
expr_unary
(
node_id
,
unop
,
@
expr
),
expr_lit
(
@
lit
),
expr_cast
(
@
expr
,
@
Ty
),
expr_cast
(
@
expr
,
Ty
),
expr_if
(
@
expr
,
blk
,
Option
<@
expr
>
),
expr_while
(
@
expr
,
blk
),
/* Conditionless loop (can be exited with break, cont, or ret)
...
...
@@ -454,7 +454,7 @@ pub enum expr_ {
expr_copy
(
@
expr
),
expr_assign
(
@
expr
,
@
expr
),
expr_assign_op
(
node_id
,
binop
,
@
expr
,
@
expr
),
expr_field
(
@
expr
,
ident
,
~
[
@
Ty
]),
expr_field
(
@
expr
,
ident
,
~
[
Ty
]),
expr_index
(
node_id
,
@
expr
,
@
expr
),
expr_path
(
Path
),
...
...
@@ -604,7 +604,7 @@ pub enum lit_ {
// type structure in middle/ty.rs as well.
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
struct
mt
{
ty
:
@
Ty
,
ty
:
~
Ty
,
mutbl
:
mutability
,
}
...
...
@@ -733,7 +733,7 @@ pub enum ty_ {
ty_rptr
(
Option
<
Lifetime
>
,
mt
),
ty_closure
(
@
TyClosure
),
ty_bare_fn
(
@
TyBareFn
),
ty_tup
(
~
[
@
Ty
]),
ty_tup
(
~
[
Ty
]),
ty_path
(
Path
,
Option
<
OptVec
<
TyParamBound
>>
,
node_id
),
// for #7264; see above
ty_mac
(
mac
),
// ty_infer means the type should be inferred instead of it having been
...
...
@@ -762,7 +762,7 @@ pub struct inline_asm {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
struct
arg
{
is_mutbl
:
bool
,
ty
:
@
Ty
,
ty
:
Ty
,
pat
:
@
pat
,
id
:
node_id
,
}
...
...
@@ -770,7 +770,7 @@ pub struct arg {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
struct
fn_decl
{
inputs
:
~
[
arg
],
output
:
@
Ty
,
output
:
Ty
,
cf
:
ret_style
,
}
...
...
@@ -845,7 +845,7 @@ pub struct foreign_mod {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
struct
variant_arg
{
ty
:
@
Ty
,
ty
:
Ty
,
id
:
node_id
,
}
...
...
@@ -959,7 +959,7 @@ pub fn inherit_from(&self, parent_visibility: visibility) -> visibility {
pub
struct
struct_field_
{
kind
:
struct_field_kind
,
id
:
node_id
,
ty
:
@
Ty
,
ty
:
Ty
,
attrs
:
~
[
attribute
],
}
...
...
@@ -995,17 +995,17 @@ pub struct item {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
enum
item_
{
item_static
(
@
Ty
,
mutability
,
@
expr
),
item_static
(
Ty
,
mutability
,
@
expr
),
item_fn
(
fn_decl
,
purity
,
AbiSet
,
Generics
,
blk
),
item_mod
(
_
mod
),
item_foreign_mod
(
foreign_mod
),
item_ty
(
@
Ty
,
Generics
),
item_ty
(
Ty
,
Generics
),
item_enum
(
enum_def
,
Generics
),
item_struct
(
@
struct_def
,
Generics
),
item_trait
(
Generics
,
~
[
trait_ref
],
~
[
trait_method
]),
item_impl
(
Generics
,
Option
<
trait_ref
>
,
// (optional) trait this impl implements
@
Ty
,
// self
Ty
,
// self
~
[
@
method
]),
// a macro invocation (which includes macro definition)
item_mac
(
mac
),
...
...
@@ -1024,7 +1024,7 @@ pub struct foreign_item {
#[deriving(Eq,
Encodable,
Decodable,IterBytes)]
pub
enum
foreign_item_
{
foreign_item_fn
(
fn_decl
,
purity
,
Generics
),
foreign_item_static
(
@
Ty
,
/* is_mutbl */
bool
),
foreign_item_static
(
Ty
,
/* is_mutbl */
bool
),
}
// The data we save and restore about an inlined item or method. This is not
...
...
src/libsyntax/ext/build.rs
浏览文件 @
47eca211
...
...
@@ -39,31 +39,30 @@ fn path_all(&self, sp: span,
global
:
bool
,
idents
:
~
[
ast
::
ident
],
rp
:
Option
<
ast
::
Lifetime
>
,
types
:
~
[
@
ast
::
Ty
])
types
:
~
[
ast
::
Ty
])
->
ast
::
Path
;
// types
fn
ty_mt
(
&
self
,
ty
:
@
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
mt
;
fn
ty_mt
(
&
self
,
ty
:
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
mt
;
fn
ty
(
&
self
,
span
:
span
,
ty
:
ast
::
ty_
)
->
@
ast
::
Ty
;
fn
ty_path
(
&
self
,
ast
::
Path
,
Option
<
OptVec
<
ast
::
TyParamBound
>>
)
->
@
ast
::
Ty
;
fn
ty_ident
(
&
self
,
span
:
span
,
idents
:
ast
::
ident
)
->
@
ast
::
Ty
;
fn
ty
(
&
self
,
span
:
span
,
ty
:
ast
::
ty_
)
->
ast
::
Ty
;
fn
ty_path
(
&
self
,
ast
::
Path
,
Option
<
OptVec
<
ast
::
TyParamBound
>>
)
->
ast
::
Ty
;
fn
ty_ident
(
&
self
,
span
:
span
,
idents
:
ast
::
ident
)
->
ast
::
Ty
;
fn
ty_rptr
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
,
ty
:
ast
::
Ty
,
lifetime
:
Option
<
ast
::
Lifetime
>
,
mutbl
:
ast
::
mutability
)
->
@
ast
::
Ty
;
fn
ty_uniq
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
Ty
;
fn
ty_box
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
@
ast
::
Ty
;
mutbl
:
ast
::
mutability
)
->
ast
::
Ty
;
fn
ty_uniq
(
&
self
,
span
:
span
,
ty
:
ast
::
Ty
)
->
ast
::
Ty
;
fn
ty_box
(
&
self
,
span
:
span
,
ty
:
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
Ty
;
fn
ty_option
(
&
self
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
Ty
;
fn
ty_infer
(
&
self
,
sp
:
span
)
->
@
ast
::
Ty
;
fn
ty_nil
(
&
self
)
->
@
ast
::
Ty
;
fn
ty_option
(
&
self
,
ty
:
ast
::
Ty
)
->
ast
::
Ty
;
fn
ty_infer
(
&
self
,
sp
:
span
)
->
ast
::
Ty
;
fn
ty_nil
(
&
self
)
->
ast
::
Ty
;
fn
ty_vars
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
@
ast
::
Ty
];
fn
ty_vars_global
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
@
ast
::
Ty
];
fn
ty_field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
)
->
ast
::
ty_field
;
fn
ty_vars
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
ast
::
Ty
];
fn
ty_vars_global
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
ast
::
Ty
];
fn
ty_field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
)
->
ast
::
ty_field
;
fn
strip_bounds
(
&
self
,
bounds
:
&
Generics
)
->
Generics
;
fn
typaram
(
&
self
,
id
:
ast
::
ident
,
bounds
:
OptVec
<
ast
::
TyParamBound
>
)
->
ast
::
TyParam
;
...
...
@@ -167,25 +166,25 @@ fn expr_if(&self, span: span,
fn
item
(
&
self
,
span
:
span
,
name
:
ident
,
attrs
:
~
[
ast
::
attribute
],
node
:
ast
::
item_
)
->
@
ast
::
item
;
fn
arg
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
)
->
ast
::
arg
;
fn
arg
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
)
->
ast
::
arg
;
// XXX unused self
fn
fn_decl
(
&
self
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
)
->
ast
::
fn_decl
;
fn
fn_decl
(
&
self
,
inputs
:
~
[
ast
::
arg
],
output
:
ast
::
Ty
)
->
ast
::
fn_decl
;
fn
item_fn_poly
(
&
self
,
span
:
span
,
name
:
ident
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
,
output
:
ast
::
Ty
,
generics
:
Generics
,
body
:
ast
::
blk
)
->
@
ast
::
item
;
fn
item_fn
(
&
self
,
span
:
span
,
name
:
ident
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
,
output
:
ast
::
Ty
,
body
:
ast
::
blk
)
->
@
ast
::
item
;
fn
variant
(
&
self
,
span
:
span
,
name
:
ident
,
tys
:
~
[
@
ast
::
Ty
])
->
ast
::
variant
;
fn
variant
(
&
self
,
span
:
span
,
name
:
ident
,
tys
:
~
[
ast
::
Ty
])
->
ast
::
variant
;
fn
item_enum_poly
(
&
self
,
span
:
span
,
name
:
ident
,
...
...
@@ -207,9 +206,9 @@ fn item_mod(&self, span: span,
fn
item_ty_poly
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
,
ty
:
ast
::
Ty
,
generics
:
Generics
)
->
@
ast
::
item
;
fn
item_ty
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
item
;
fn
item_ty
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
)
->
@
ast
::
item
;
fn
attribute
(
&
self
,
sp
:
span
,
mi
:
@
ast
::
meta_item
)
->
ast
::
attribute
;
...
...
@@ -239,7 +238,7 @@ fn path_all(&self, sp: span,
global
:
bool
,
idents
:
~
[
ast
::
ident
],
rp
:
Option
<
ast
::
Lifetime
>
,
types
:
~
[
@
ast
::
Ty
])
types
:
~
[
ast
::
Ty
])
->
ast
::
Path
{
ast
::
Path
{
span
:
sp
,
...
...
@@ -250,15 +249,15 @@ fn path_all(&self, sp: span,
}
}
fn
ty_mt
(
&
self
,
ty
:
@
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
mt
{
fn
ty_mt
(
&
self
,
ty
:
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
mt
{
ast
::
mt
{
ty
:
ty
,
ty
:
~
ty
,
mutbl
:
mutbl
}
}
fn
ty
(
&
self
,
span
:
span
,
ty
:
ast
::
ty_
)
->
@
ast
::
Ty
{
@
ast
::
Ty
{
fn
ty
(
&
self
,
span
:
span
,
ty
:
ast
::
ty_
)
->
ast
::
Ty
{
ast
::
Ty
{
id
:
self
.next_id
(),
span
:
span
,
node
:
ty
...
...
@@ -266,7 +265,7 @@ fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty {
}
fn
ty_path
(
&
self
,
path
:
ast
::
Path
,
bounds
:
Option
<
OptVec
<
ast
::
TyParamBound
>>
)
->
@
ast
::
Ty
{
->
ast
::
Ty
{
self
.ty
(
path
.span
,
ast
::
ty_path
(
path
,
bounds
,
self
.next_id
()))
}
...
...
@@ -274,28 +273,28 @@ fn ty_path(&self, path: ast::Path, bounds: Option<OptVec<ast::TyParamBound>>)
// Might need to take bounds as an argument in the future, if you ever want
// to generate a bounded existential trait type.
fn
ty_ident
(
&
self
,
span
:
span
,
ident
:
ast
::
ident
)
->
@
ast
::
Ty
{
->
ast
::
Ty
{
self
.ty_path
(
self
.path_ident
(
span
,
ident
),
None
)
}
fn
ty_rptr
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
,
ty
:
ast
::
Ty
,
lifetime
:
Option
<
ast
::
Lifetime
>
,
mutbl
:
ast
::
mutability
)
->
@
ast
::
Ty
{
->
ast
::
Ty
{
self
.ty
(
span
,
ast
::
ty_rptr
(
lifetime
,
self
.ty_mt
(
ty
,
mutbl
)))
}
fn
ty_uniq
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
Ty
{
fn
ty_uniq
(
&
self
,
span
:
span
,
ty
:
ast
::
Ty
)
->
ast
::
Ty
{
self
.ty
(
span
,
ast
::
ty_uniq
(
self
.ty_mt
(
ty
,
ast
::
m_imm
)))
}
fn
ty_box
(
&
self
,
span
:
span
,
ty
:
@
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
@
ast
::
Ty
{
ty
:
ast
::
Ty
,
mutbl
:
ast
::
mutability
)
->
ast
::
Ty
{
self
.ty
(
span
,
ast
::
ty_box
(
self
.ty_mt
(
ty
,
mutbl
)))
}
fn
ty_option
(
&
self
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
Ty
{
fn
ty_option
(
&
self
,
ty
:
ast
::
Ty
)
->
ast
::
Ty
{
self
.ty_path
(
self
.path_all
(
dummy_sp
(),
true
,
...
...
@@ -308,20 +307,20 @@ fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty {
~
[
ty
]),
None
)
}
fn
ty_field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
)
->
ast
::
ty_field
{
fn
ty_field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
)
->
ast
::
ty_field
{
respan
(
span
,
ast
::
ty_field_
{
ident
:
name
,
mt
:
ast
::
mt
{
ty
:
ty
,
mutbl
:
ast
::
m_imm
},
mt
:
ast
::
mt
{
ty
:
~
ty
,
mutbl
:
ast
::
m_imm
},
})
}
fn
ty_infer
(
&
self
,
span
:
span
)
->
@
ast
::
Ty
{
fn
ty_infer
(
&
self
,
span
:
span
)
->
ast
::
Ty
{
self
.ty
(
span
,
ast
::
ty_infer
)
}
fn
ty_nil
(
&
self
)
->
@
ast
::
Ty
{
@
ast
::
Ty
{
fn
ty_nil
(
&
self
)
->
ast
::
Ty
{
ast
::
Ty
{
id
:
self
.next_id
(),
node
:
ast
::
ty_nil
,
span
:
dummy_sp
(),
...
...
@@ -335,12 +334,12 @@ fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyP
// these are strange, and probably shouldn't be used outside of
// pipes. Specifically, the global version possible generates
// incorrect code.
fn
ty_vars
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
@
ast
::
Ty
]
{
fn
ty_vars
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
ast
::
Ty
]
{
opt_vec
::
take_vec
(
ty_params
.map
(|
p
|
self
.ty_ident
(
dummy_sp
(),
p
.ident
)))
}
fn
ty_vars_global
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
@
ast
::
Ty
]
{
fn
ty_vars_global
(
&
self
,
ty_params
:
&
OptVec
<
ast
::
TyParam
>
)
->
~
[
ast
::
Ty
]
{
opt_vec
::
take_vec
(
ty_params
.map
(|
p
|
self
.ty_path
(
self
.path_global
(
dummy_sp
(),
~
[
p
.ident
]),
None
)))
...
...
@@ -642,7 +641,7 @@ fn lambda_stmts_1(&self, span: span, stmts: ~[@ast::stmt], ident: ast::ident) ->
self
.lambda1
(
span
,
self
.blk
(
span
,
stmts
,
None
),
ident
)
}
fn
arg
(
&
self
,
span
:
span
,
ident
:
ast
::
ident
,
ty
:
@
ast
::
Ty
)
->
ast
::
arg
{
fn
arg
(
&
self
,
span
:
span
,
ident
:
ast
::
ident
,
ty
:
ast
::
Ty
)
->
ast
::
arg
{
let
arg_pat
=
self
.pat_ident
(
span
,
ident
);
ast
::
arg
{
is_mutbl
:
false
,
...
...
@@ -653,7 +652,7 @@ fn arg(&self, span: span, ident: ast::ident, ty: @ast::Ty) -> ast::arg {
}
// XXX unused self
fn
fn_decl
(
&
self
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
)
->
ast
::
fn_decl
{
fn
fn_decl
(
&
self
,
inputs
:
~
[
ast
::
arg
],
output
:
ast
::
Ty
)
->
ast
::
fn_decl
{
ast
::
fn_decl
{
inputs
:
inputs
,
output
:
output
,
...
...
@@ -677,7 +676,7 @@ fn item_fn_poly(&self,
span
:
span
,
name
:
ident
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
,
output
:
ast
::
Ty
,
generics
:
Generics
,
body
:
ast
::
blk
)
->
@
ast
::
item
{
self
.item
(
span
,
...
...
@@ -694,7 +693,7 @@ fn item_fn(&self,
span
:
span
,
name
:
ident
,
inputs
:
~
[
ast
::
arg
],
output
:
@
ast
::
Ty
,
output
:
ast
::
Ty
,
body
:
ast
::
blk
)
->
@
ast
::
item
{
self
.item_fn_poly
(
...
...
@@ -706,10 +705,10 @@ fn item_fn(&self,
body
)
}
fn
variant
(
&
self
,
span
:
span
,
name
:
ident
,
tys
:
~
[
@
ast
::
Ty
])
->
ast
::
variant
{
let
args
=
do
tys
.map
|
ty
|
{
ast
::
variant_arg
{
ty
:
*
ty
,
id
:
self
.next_id
()
}
};
fn
variant
(
&
self
,
span
:
span
,
name
:
ident
,
tys
:
~
[
ast
::
Ty
])
->
ast
::
variant
{
let
args
=
tys
.consume_iter
()
.transform
(
|
ty
|
{
ast
::
variant_arg
{
ty
:
ty
,
id
:
self
.next_id
()
}
}
)
.collect
()
;
respan
(
span
,
ast
::
variant_
{
...
...
@@ -773,12 +772,12 @@ fn item_mod(&self, span: span, name: ident,
)
}
fn
item_ty_poly
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
,
fn
item_ty_poly
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
,
generics
:
Generics
)
->
@
ast
::
item
{
self
.item
(
span
,
name
,
~
[],
ast
::
item_ty
(
ty
,
generics
))
}
fn
item_ty
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
@
ast
::
Ty
)
->
@
ast
::
item
{
fn
item_ty
(
&
self
,
span
:
span
,
name
:
ident
,
ty
:
ast
::
Ty
)
->
@
ast
::
item
{
self
.item_ty_poly
(
span
,
name
,
ty
,
ast_util
::
empty_generics
())
}
...
...
src/libsyntax/ext/deriving/generic.rs
浏览文件 @
47eca211
...
...
@@ -456,7 +456,7 @@ fn call_substructure_method(&self,
}
fn
get_ret_ty
(
&
self
,
cx
:
@
ExtCtxt
,
span
:
span
,
generics
:
&
Generics
,
type_ident
:
ident
)
->
@
ast
::
Ty
{
generics
:
&
Generics
,
type_ident
:
ident
)
->
ast
::
Ty
{
self
.ret_ty
.to_ty
(
cx
,
span
,
type_ident
,
generics
)
}
...
...
@@ -466,7 +466,7 @@ fn is_static(&self) -> bool {
fn
split_self_nonself_args
(
&
self
,
cx
:
@
ExtCtxt
,
span
:
span
,
type_ident
:
ident
,
generics
:
&
Generics
)
->
(
ast
::
explicit_self
,
~
[
@
expr
],
~
[
@
expr
],
~
[(
ident
,
@
ast
::
Ty
)])
{
->
(
ast
::
explicit_self
,
~
[
@
expr
],
~
[
@
expr
],
~
[(
ident
,
ast
::
Ty
)])
{
let
mut
self_args
=
~
[];
let
mut
nonself_args
=
~
[];
...
...
@@ -514,7 +514,7 @@ fn create_method(&self, cx: @ExtCtxt, span: span,
type_ident
:
ident
,
generics
:
&
Generics
,
explicit_self
:
ast
::
explicit_self
,
arg_types
:
~
[(
ident
,
@
ast
::
Ty
)],
arg_types
:
~
[(
ident
,
ast
::
Ty
)],
body
:
@
expr
)
->
@
ast
::
method
{
// create the generics that aren't for Self
let
fn_generics
=
self
.generics
.to_generics
(
cx
,
span
,
type_ident
,
generics
);
...
...
src/libsyntax/ext/deriving/ty.rs
浏览文件 @
47eca211
...
...
@@ -61,7 +61,7 @@ pub fn to_ty(&self,
span
:
span
,
self_ty
:
ident
,
self_generics
:
&
Generics
)
->
@
ast
::
Ty
{
->
ast
::
Ty
{
cx
.ty_path
(
self
.to_path
(
cx
,
span
,
self_ty
,
self_generics
),
None
)
}
pub
fn
to_path
(
&
self
,
...
...
@@ -122,7 +122,7 @@ pub fn to_ty(&self,
span
:
span
,
self_ty
:
ident
,
self_generics
:
&
Generics
)
->
@
ast
::
Ty
{
->
ast
::
Ty
{
match
*
self
{
Ptr
(
ref
ty
,
ref
ptr
)
=>
{
let
raw_ty
=
ty
.to_ty
(
cx
,
span
,
self_ty
,
self_generics
);
...
...
src/libsyntax/ext/pipes/ast_builder.rs
浏览文件 @
47eca211
...
...
@@ -42,19 +42,19 @@ pub fn path_global(ids: ~[ident], span: span) -> ast::Path {
}
pub
trait
append_types
{
fn
add_ty
(
&
self
,
ty
:
@
ast
::
Ty
)
->
ast
::
Path
;
fn
add_tys
(
&
self
,
tys
:
~
[
@
ast
::
Ty
])
->
ast
::
Path
;
fn
add_ty
(
&
self
,
ty
:
ast
::
Ty
)
->
ast
::
Path
;
fn
add_tys
(
&
self
,
tys
:
~
[
ast
::
Ty
])
->
ast
::
Path
;
}
impl
append_types
for
ast
::
Path
{
fn
add_ty
(
&
self
,
ty
:
@
ast
::
Ty
)
->
ast
::
Path
{
fn
add_ty
(
&
self
,
ty
:
ast
::
Ty
)
->
ast
::
Path
{
ast
::
Path
{
types
:
vec
::
append_one
(
copy
self
.types
,
ty
),
..
copy
*
self
}
}
fn
add_tys
(
&
self
,
tys
:
~
[
@
ast
::
Ty
])
->
ast
::
Path
{
fn
add_tys
(
&
self
,
tys
:
~
[
ast
::
Ty
])
->
ast
::
Path
{
ast
::
Path
{
types
:
vec
::
append
(
copy
self
.types
,
tys
),
..
copy
*
self
...
...
src/libsyntax/ext/pipes/check.rs
浏览文件 @
47eca211
...
...
@@ -49,7 +49,7 @@ fn visit_state(&self, state: state, _m: &[()]) {
}
}
fn
visit_message
(
&
self
,
name
:
@
str
,
_
span
:
span
,
_
tys
:
&
[
@
ast
::
Ty
],
fn
visit_message
(
&
self
,
name
:
@
str
,
_
span
:
span
,
_
tys
:
&
[
ast
::
Ty
],
this
:
state
,
next
:
Option
<
next_state
>
)
{
match
next
{
Some
(
ref
next_state
)
=>
{
...
...
src/libsyntax/ext/pipes/pipec.rs
浏览文件 @
47eca211
...
...
@@ -25,7 +25,7 @@
pub
trait
gen_send
{
fn
gen_send
(
&
mut
self
,
cx
:
@
ExtCtxt
,
try
:
bool
)
->
@
ast
::
item
;
fn
to_ty
(
&
mut
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
Ty
;
fn
to_ty
(
&
mut
self
,
cx
:
@
ExtCtxt
)
->
ast
::
Ty
;
}
pub
trait
to_type_decls
{
...
...
@@ -37,7 +37,7 @@ fn to_endpoint_decls(&self, cx: @ExtCtxt,
pub
trait
gen_init
{
fn
gen_init
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
item
;
fn
compile
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
item
;
fn
buffer_ty_path
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
Ty
;
fn
buffer_ty_path
(
&
self
,
cx
:
@
ExtCtxt
)
->
ast
::
Ty
;
fn
gen_buffer_type
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
item
;
fn
gen_buffer_init
(
&
self
,
ext_cx
:
@
ExtCtxt
)
->
@
ast
::
expr
;
fn
gen_init_bounded
(
&
self
,
ext_cx
:
@
ExtCtxt
)
->
@
ast
::
expr
;
...
...
@@ -56,7 +56,7 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
next
.generics.ty_params
.len
());
let
arg_names
=
vec
::
from_fn
(
tys
.len
(),
|
i
|
cx
.ident_of
(
"x_"
+
i
.to_str
()));
let
args_ast
:
~
[
ast
::
arg
]
=
arg_names
.iter
()
.zip
(
tys
.iter
())
.transform
(|(
n
,
t
)|
cx
.arg
(
span
,
*
n
,
*
t
))
.collect
();
.transform
(|(
n
,
t
)|
cx
.arg
(
span
,
copy
*
n
,
copy
*
t
))
.collect
();
let
pipe_ty
=
cx
.ty_path
(
path
(
~
[
this
.data_name
()],
span
)
...
...
@@ -137,7 +137,7 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
let
arg_names
=
vec
::
from_fn
(
tys
.len
(),
|
i
|
"x_"
+
i
.to_str
());
let
args_ast
:
~
[
ast
::
arg
]
=
arg_names
.iter
()
.zip
(
tys
.iter
())
.transform
(|(
n
,
t
)|
cx
.arg
(
span
,
cx
.ident_of
(
*
n
),
*
t
))
.collect
();
.transform
(|(
&
n
,
t
)|
cx
.arg
(
span
,
cx
.ident_of
(
n
),
copy
*
t
))
.collect
();
let
args_ast
=
vec
::
append
(
~
[
cx
.arg
(
span
,
...
...
@@ -189,7 +189,7 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
}
}
fn
to_ty
(
&
mut
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
Ty
{
fn
to_ty
(
&
mut
self
,
cx
:
@
ExtCtxt
)
->
ast
::
Ty
{
cx
.ty_path
(
path
(
~
[
cx
.ident_of
(
self
.name
())],
self
.span
())
.add_tys
(
cx
.ty_vars
(
&
self
.get_generics
()
.ty_params
)),
None
)
}
...
...
@@ -369,7 +369,7 @@ fn gen_init_bounded(&self, ext_cx: @ExtCtxt) -> @ast::expr {
})
}
fn
buffer_ty_path
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
Ty
{
fn
buffer_ty_path
(
&
self
,
cx
:
@
ExtCtxt
)
->
ast
::
Ty
{
let
mut
params
:
OptVec
<
ast
::
TyParam
>
=
opt_vec
::
Empty
;
for
self
.states
.iter
()
.advance
|
s
|
{
for
s
.generics.ty_params
.iter
()
.advance
|
tp
|
{
...
...
src/libsyntax/ext/pipes/proto.rs
浏览文件 @
47eca211
...
...
@@ -37,11 +37,11 @@ pub fn reverse(&self) -> direction {
pub
struct
next_state
{
state
:
@
str
,
tys
:
~
[
@
ast
::
Ty
],
tys
:
~
[
ast
::
Ty
],
}
// name, span, data, current state, next state
pub
struct
message
(
@
str
,
span
,
~
[
@
ast
::
Ty
],
state
,
Option
<
next_state
>
);
pub
struct
message
(
@
str
,
span
,
~
[
ast
::
Ty
],
state
,
Option
<
next_state
>
);
impl
message
{
pub
fn
name
(
&
mut
self
)
->
@
str
{
...
...
@@ -81,7 +81,7 @@ impl state_ {
pub
fn
add_message
(
@
self
,
name
:
@
str
,
span
:
span
,
data
:
~
[
@
ast
::
Ty
],
data
:
~
[
ast
::
Ty
],
next
:
Option
<
next_state
>
)
{
self
.messages
.push
(
message
(
name
,
span
,
data
,
self
,
next
));
...
...
@@ -96,7 +96,7 @@ pub fn data_name(&self) -> ast::ident {
}
/// Returns the type that is used for the messages.
pub
fn
to_ty
(
&
self
,
cx
:
@
ExtCtxt
)
->
@
ast
::
Ty
{
pub
fn
to_ty
(
&
self
,
cx
:
@
ExtCtxt
)
->
ast
::
Ty
{
cx
.ty_path
(
path
(
~
[
cx
.ident_of
(
self
.name
)],
self
.span
)
.add_tys
(
cx
.ty_vars
(
&
self
.generics.ty_params
)),
None
)
...
...
@@ -206,7 +206,7 @@ pub fn add_state_poly(@mut self,
pub
trait
visitor
<
Tproto
,
Tstate
,
Tmessage
>
{
fn
visit_proto
(
&
self
,
proto
:
protocol
,
st
:
&
[
Tstate
])
->
Tproto
;
fn
visit_state
(
&
self
,
state
:
state
,
m
:
&
[
Tmessage
])
->
Tstate
;
fn
visit_message
(
&
self
,
name
:
@
str
,
spane
:
span
,
tys
:
&
[
@
ast
::
Ty
],
fn
visit_message
(
&
self
,
name
:
@
str
,
spane
:
span
,
tys
:
&
[
ast
::
Ty
],
this
:
state
,
next
:
Option
<
next_state
>
)
->
Tmessage
;
}
...
...
src/libsyntax/ext/quote.rs
浏览文件 @
47eca211
...
...
@@ -88,13 +88,13 @@ fn to_source(&self) -> @str {
}
}
impl
ToSource
for
@
ast
::
Ty
{
impl
ToSource
for
ast
::
Ty
{
fn
to_source
(
&
self
)
->
@
str
{
pprust
::
ty_to_str
(
*
self
,
get_ident_interner
())
.to_managed
()
pprust
::
ty_to_str
(
self
,
get_ident_interner
())
.to_managed
()
}
}
impl
<
'self
>
ToSource
for
&
'self
[
@
ast
::
Ty
]
{
impl
<
'self
>
ToSource
for
&
'self
[
ast
::
Ty
]
{
fn
to_source
(
&
self
)
->
@
str
{
self
.map
(|
i
|
i
.to_source
())
.connect
(
", "
)
.to_managed
()
}
...
...
@@ -216,13 +216,13 @@ fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
}
}
impl
ToTokens
for
@
ast
::
Ty
{
impl
ToTokens
for
ast
::
Ty
{
fn
to_tokens
(
&
self
,
cx
:
@
ExtCtxt
)
->
~
[
token_tree
]
{
cx
.parse_tts
(
self
.to_source
())
}
}
impl
<
'self
>
ToTokens
for
&
'self
[
@
ast
::
Ty
]
{
impl
<
'self
>
ToTokens
for
&
'self
[
ast
::
Ty
]
{
fn
to_tokens
(
&
self
,
cx
:
@
ExtCtxt
)
->
~
[
token_tree
]
{
cx
.parse_tts
(
self
.to_source
())
}
...
...
src/libsyntax/fold.rs
浏览文件 @
47eca211
...
...
@@ -28,7 +28,7 @@ pub trait ast_fold {
fn
fold_pat
(
@
self
,
@
pat
)
->
@
pat
;
fn
fold_decl
(
@
self
,
@
decl
)
->
Option
<@
decl
>
;
fn
fold_expr
(
@
self
,
@
expr
)
->
@
expr
;
fn
fold_ty
(
@
self
,
@
Ty
)
->
@
Ty
;
fn
fold_ty
(
@
self
,
&
Ty
)
->
Ty
;
fn
fold_mod
(
@
self
,
&
_
mod
)
->
_
mod
;
fn
fold_foreign_mod
(
@
self
,
&
foreign_mod
)
->
foreign_mod
;
fn
fold_variant
(
@
self
,
&
variant
)
->
variant
;
...
...
@@ -107,7 +107,7 @@ fn fold_attribute_(at: attribute, fld: @ast_fold) -> attribute {
fn
fold_arg_
(
a
:
arg
,
fld
:
@
ast_fold
)
->
arg
{
ast
::
arg
{
is_mutbl
:
a
.is_mutbl
,
ty
:
fld
.fold_ty
(
a
.ty
),
ty
:
fld
.fold_ty
(
&
a
.ty
),
pat
:
fld
.fold_pat
(
a
.pat
),
id
:
fld
.new_id
(
a
.id
),
}
...
...
@@ -154,8 +154,8 @@ fn maybe_fold_ident(t : &token::Token, fld: @ast_fold) -> token::Token {
pub
fn
fold_fn_decl
(
decl
:
&
ast
::
fn_decl
,
fld
:
@
ast_fold
)
->
ast
::
fn_decl
{
ast
::
fn_decl
{
inputs
:
decl
.inputs
.map
(|
x
|
fold_arg_
(
*
x
,
fld
)),
output
:
fld
.fold_ty
(
decl
.output
),
inputs
:
decl
.inputs
.map
(|
x
|
fold_arg_
(
/*bad*/
copy
*
x
,
fld
)),
output
:
fld
.fold_ty
(
&
decl
.output
),
cf
:
decl
.cf
,
}
}
...
...
@@ -226,14 +226,14 @@ fn noop_fold_foreign_item(ni: @foreign_item, fld: @ast_fold)
foreign_item_fn
(
ref
fdec
,
purity
,
ref
generics
)
=>
{
foreign_item_fn
(
ast
::
fn_decl
{
inputs
:
fdec
.inputs
.map
(|
a
|
fold_arg
(
*
a
)),
output
:
fld
.fold_ty
(
fdec
.output
),
inputs
:
fdec
.inputs
.map
(|
a
|
fold_arg
(
/*bad*/
copy
*
a
)),
output
:
fld
.fold_ty
(
&
fdec
.output
),
cf
:
fdec
.cf
,
},
purity
,
fold_generics
(
generics
,
fld
))
}
foreign_item_static
(
t
,
m
)
=>
{
foreign_item_static
(
ref
t
,
m
)
=>
{
foreign_item_static
(
fld
.fold_ty
(
t
),
m
)
}
},
...
...
@@ -260,14 +260,14 @@ fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold)
@
spanned
{
node
:
ast
::
struct_field_
{
kind
:
copy
sf
.node.kind
,
id
:
sf
.node.id
,
ty
:
fld
.fold_ty
(
sf
.node.ty
),
ty
:
fld
.fold_ty
(
&
sf
.node.ty
),
attrs
:
sf
.node.attrs
.map
(|
e
|
fold_attribute
(
*
e
))
},
span
:
sf
.span
}
}
pub
fn
noop_fold_item_underscore
(
i
:
&
item_
,
fld
:
@
ast_fold
)
->
item_
{
match
*
i
{
item_static
(
t
,
m
,
e
)
=>
item_static
(
fld
.fold_ty
(
t
),
m
,
fld
.fold_expr
(
e
)),
item_static
(
ref
t
,
m
,
e
)
=>
item_static
(
fld
.fold_ty
(
t
),
m
,
fld
.fold_expr
(
e
)),
item_fn
(
ref
decl
,
purity
,
abi
,
ref
generics
,
ref
body
)
=>
{
item_fn
(
fold_fn_decl
(
decl
,
fld
),
...
...
@@ -281,7 +281,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
item_foreign_mod
(
ref
nm
)
=>
{
item_foreign_mod
(
fld
.fold_foreign_mod
(
nm
))
}
item_ty
(
t
,
ref
generics
)
=>
{
item_ty
(
ref
t
,
ref
generics
)
=>
{
item_ty
(
fld
.fold_ty
(
t
),
fold_generics
(
generics
,
fld
))
}
item_enum
(
ref
enum_definition
,
ref
generics
)
=>
{
...
...
@@ -297,7 +297,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
let
struct_def
=
fold_struct_def
(
*
struct_def
,
fld
);
item_struct
(
struct_def
,
/* FIXME (#2543) */
copy
*
generics
)
}
item_impl
(
ref
generics
,
ref
ifce
,
ty
,
ref
methods
)
=>
{
item_impl
(
ref
generics
,
ref
ifce
,
ref
ty
,
ref
methods
)
=>
{
item_impl
(
fold_generics
(
generics
,
fld
),
ifce
.map
(|
p
|
fold_trait_ref
(
p
,
fld
)),
...
...
@@ -348,7 +348,7 @@ fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field {
node
:
ast
::
struct_field_
{
kind
:
copy
f
.node.kind
,
id
:
fld
.new_id
(
f
.node.id
),
ty
:
fld
.fold_ty
(
f
.node.ty
),
ty
:
fld
.fold_ty
(
&
f
.node.ty
),
attrs
:
/* FIXME (#2543) */
copy
f
.node.attrs
,
},
span
:
fld
.new_span
(
f
.span
),
...
...
@@ -518,7 +518,7 @@ fn fold_field_(field: field, fld: @ast_fold) -> field {
fld
.new_id
(
callee_id
),
fld
.fold_expr
(
f
),
fld
.fold_ident
(
i
),
tps
.map
(|
x
|
fld
.fold_ty
(
*
x
)),
tps
.map
(|
x
|
fld
.fold_ty
(
x
)),
fld
.map_exprs
(|
x
|
fld
.fold_expr
(
x
),
*
args
),
blk
)
...
...
@@ -541,7 +541,7 @@ fn fold_field_(field: field, fld: @ast_fold) -> field {
expr_loop_body
(
f
)
=>
expr_loop_body
(
fld
.fold_expr
(
f
)),
expr_do_body
(
f
)
=>
expr_do_body
(
fld
.fold_expr
(
f
)),
expr_lit
(
_
)
=>
copy
*
e
,
expr_cast
(
expr
,
ty
)
=>
expr_cast
(
fld
.fold_expr
(
expr
),
ty
),
expr_cast
(
expr
,
ref
ty
)
=>
expr_cast
(
fld
.fold_expr
(
expr
),
copy
*
ty
),
expr_addr_of
(
m
,
ohs
)
=>
expr_addr_of
(
m
,
fld
.fold_expr
(
ohs
)),
expr_if
(
cond
,
ref
tr
,
fl
)
=>
{
expr_if
(
...
...
@@ -587,7 +587,7 @@ fn fold_field_(field: field, fld: @ast_fold) -> field {
expr_field
(
el
,
id
,
ref
tys
)
=>
{
expr_field
(
fld
.fold_expr
(
el
),
fld
.fold_ident
(
id
),
tys
.map
(|
x
|
fld
.fold_ty
(
*
x
))
tys
.map
(|
x
|
fld
.fold_ty
(
x
))
)
}
expr_index
(
callee_id
,
el
,
er
)
=>
{
...
...
@@ -637,7 +637,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
let
fold_mac
=
|
x
|
fold_mac_
(
x
,
fld
);
fn
fold_mt
(
mt
:
&
mt
,
fld
:
@
ast_fold
)
->
mt
{
mt
{
ty
:
fld
.fold_ty
(
mt
.ty
),
ty
:
~
fld
.fold_ty
(
mt
.ty
),
mutbl
:
mt
.mutbl
,
}
}
...
...
@@ -682,7 +682,7 @@ fn fold_opt_bounds(b: &Option<OptVec<TyParamBound>>, fld: @ast_fold)
decl
:
fold_fn_decl
(
&
f
.decl
,
fld
)
})
}
ty_tup
(
ref
tys
)
=>
ty_tup
(
tys
.map
(|
ty
|
fld
.fold_ty
(
*
ty
))),
ty_tup
(
ref
tys
)
=>
ty_tup
(
tys
.map
(|
ty
|
fld
.fold_ty
(
ty
))),
ty_path
(
ref
path
,
ref
bounds
,
id
)
=>
ty_path
(
fld
.fold_path
(
path
),
fold_opt_bounds
(
bounds
,
fld
),
fld
.new_id
(
id
)),
ty_fixed_length_vec
(
ref
mt
,
e
)
=>
{
...
...
@@ -714,7 +714,7 @@ fn noop_fold_foreign_mod(nm: &foreign_mod, fld: @ast_fold) -> foreign_mod {
fn
noop_fold_variant
(
v
:
&
variant_
,
fld
:
@
ast_fold
)
->
variant_
{
fn
fold_variant_arg_
(
va
:
variant_arg
,
fld
:
@
ast_fold
)
->
variant_arg
{
ast
::
variant_arg
{
ty
:
fld
.fold_ty
(
va
.ty
),
id
:
fld
.new_id
(
va
.id
)
}
ast
::
variant_arg
{
ty
:
fld
.fold_ty
(
&
va
.ty
),
id
:
fld
.new_id
(
va
.id
)
}
}
let
fold_variant_arg
=
|
x
|
fold_variant_arg_
(
x
,
fld
);
...
...
@@ -722,7 +722,7 @@ fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg {
match
v
.kind
{
tuple_variant_kind
(
ref
variant_args
)
=>
{
kind
=
tuple_variant_kind
(
do
variant_args
.map
|
x
|
{
fold_variant_arg
(
*
x
)
fold_variant_arg
(
/*bad*/
copy
*
x
)
})
}
struct_variant_kind
(
struct_def
)
=>
{
...
...
@@ -761,14 +761,14 @@ fn noop_fold_path(p: &Path, fld: @ast_fold) -> Path {
global
:
p
.global
,
idents
:
p
.idents
.map
(|
x
|
fld
.fold_ident
(
*
x
)),
rp
:
p
.rp
,
types
:
p
.types
.map
(|
x
|
fld
.fold_ty
(
*
x
)),
types
:
p
.types
.map
(|
x
|
fld
.fold_ty
(
x
)),
}
}
fn
noop_fold_local
(
l
:
&
local_
,
fld
:
@
ast_fold
)
->
local_
{
local_
{
is_mutbl
:
l
.is_mutbl
,
ty
:
fld
.fold_ty
(
l
.ty
),
ty
:
fld
.fold_ty
(
&
l
.ty
),
pat
:
fld
.fold_pat
(
l
.pat
),
init
:
l
.init
.map
(|
e
|
fld
.fold_expr
(
*
e
)),
id
:
fld
.new_id
(
l
.id
),
...
...
@@ -838,7 +838,7 @@ fn fold_struct_field(@self, sf: @struct_field) -> @struct_field {
node
:
ast
::
struct_field_
{
kind
:
copy
sf
.node.kind
,
id
:
sf
.node.id
,
ty
:
(
self
as
@
ast_fold
)
.fold_ty
(
sf
.node.ty
),
ty
:
self
.fold_ty
(
&
sf
.node.ty
),
attrs
:
copy
sf
.node.attrs
,
},
span
:
(
self
.new_span
)(
sf
.span
),
...
...
@@ -887,9 +887,9 @@ fn fold_expr(@self, x: @expr) -> @expr {
span
:
(
self
.new_span
)(
s
),
}
}
fn
fold_ty
(
@
self
,
x
:
@
Ty
)
->
@
Ty
{
fn
fold_ty
(
@
self
,
x
:
&
Ty
)
->
Ty
{
let
(
n
,
s
)
=
(
self
.fold_ty
)(
&
x
.node
,
x
.span
,
self
as
@
ast_fold
);
@
Ty
{
Ty
{
id
:
(
self
.new_id
)(
x
.id
),
node
:
n
,
span
:
(
self
.new_span
)(
s
),
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
47eca211
...
...
@@ -824,7 +824,7 @@ pub fn parse_trait_methods(&self) -> ~[trait_method] {
// parse a possibly mutable type
pub
fn
parse_mt
(
&
self
)
->
mt
{
let
mutbl
=
self
.parse_mutability
();
let
t
=
self
.parse_ty
(
false
);
let
t
=
~
self
.parse_ty
(
false
);
mt
{
ty
:
t
,
mutbl
:
mutbl
}
}
...
...
@@ -835,7 +835,7 @@ pub fn parse_ty_field(&self) -> ty_field {
let
mutbl
=
self
.parse_mutability
();
let
id
=
self
.parse_ident
();
self
.expect
(
&
token
::
COLON
);
let
ty
=
self
.parse_ty
(
false
);
let
ty
=
~
self
.parse_ty
(
false
);
spanned
(
lo
,
ty
.span.hi
,
...
...
@@ -847,13 +847,13 @@ pub fn parse_ty_field(&self) -> ty_field {
}
// parse optional return type [ -> TY ] in function decl
pub
fn
parse_ret_ty
(
&
self
)
->
(
ret_style
,
@
Ty
)
{
pub
fn
parse_ret_ty
(
&
self
)
->
(
ret_style
,
Ty
)
{
return
if
self
.eat
(
&
token
::
RARROW
)
{
let
lo
=
self
.span.lo
;
if
self
.eat
(
&
token
::
NOT
)
{
(
noreturn
,
@
Ty
{
Ty
{
id
:
self
.get_id
(),
node
:
ty_bot
,
span
:
mk_sp
(
lo
,
self
.last_span.hi
)
...
...
@@ -866,7 +866,7 @@ pub fn parse_ret_ty(&self) -> (ret_style, @Ty) {
let
pos
=
self
.span.lo
;
(
return_val
,
@
Ty
{
Ty
{
id
:
self
.get_id
(),
node
:
ty_nil
,
span
:
mk_sp
(
pos
,
pos
),
...
...
@@ -878,7 +878,7 @@ pub fn parse_ret_ty(&self) -> (ret_style, @Ty) {
// parse a type.
// Useless second parameter for compatibility with quasiquote macros.
// Bleh!
pub
fn
parse_ty
(
&
self
,
_
:
bool
)
->
@
Ty
{
pub
fn
parse_ty
(
&
self
,
_
:
bool
)
->
Ty
{
maybe_whole!
(
self
,
nt_ty
);
let
lo
=
self
.span.lo
;
...
...
@@ -975,7 +975,7 @@ pub fn parse_ty(&self, _: bool) -> @Ty {
};
let
sp
=
mk_sp
(
lo
,
self
.last_span.hi
);
@
Ty
{
id
:
self
.get_id
(),
node
:
t
,
span
:
sp
}
Ty
{
id
:
self
.get_id
(),
node
:
t
,
span
:
sp
}
}
// parse the type following a @ or a ~
...
...
@@ -1116,7 +1116,7 @@ pub fn parse_fn_block_arg(&self) -> arg_or_capture_item {
let
t
=
if
self
.eat
(
&
token
::
COLON
)
{
self
.parse_ty
(
false
)
}
else
{
@
Ty
{
Ty
{
id
:
self
.get_id
(),
node
:
ty_infer
,
span
:
mk_sp
(
self
.span.lo
,
self
.span.hi
),
...
...
@@ -1463,7 +1463,7 @@ pub fn mk_call(&self, f: @expr, args: ~[@expr], sugar: CallSugar) -> ast::expr_
pub
fn
mk_method_call
(
&
self
,
rcvr
:
@
expr
,
ident
:
ident
,
tps
:
~
[
@
Ty
],
tps
:
~
[
Ty
],
args
:
~
[
@
expr
],
sugar
:
CallSugar
)
->
ast
::
expr_
{
expr_method_call
(
self
.get_id
(),
rcvr
,
ident
,
tps
,
args
,
sugar
)
...
...
@@ -1473,7 +1473,7 @@ pub fn mk_index(&self, expr: @expr, idx: @expr) -> ast::expr_ {
expr_index
(
self
.get_id
(),
expr
,
idx
)
}
pub
fn
mk_field
(
&
self
,
expr
:
@
expr
,
ident
:
ident
,
tys
:
~
[
@
Ty
])
->
ast
::
expr_
{
pub
fn
mk_field
(
&
self
,
expr
:
@
expr
,
ident
:
ident
,
tys
:
~
[
Ty
])
->
ast
::
expr_
{
expr_field
(
expr
,
ident
,
tys
)
}
...
...
@@ -2215,7 +2215,7 @@ pub fn parse_lambda_block_expr(&self) -> @expr {
// No argument list - `do foo {`
ast
::
fn_decl
{
inputs
:
~
[],
output
:
@
Ty
{
output
:
Ty
{
id
:
self
.get_id
(),
node
:
ty_infer
,
span
:
*
self
.span
...
...
@@ -2826,7 +2826,7 @@ fn parse_local(&self, is_mutbl: bool) -> @local {
self
.obsolete
(
*
self
.span
,
ObsoleteMutWithMultipleBindings
)
}
let
mut
ty
=
@
Ty
{
let
mut
ty
=
Ty
{
id
:
self
.get_id
(),
node
:
ty_infer
,
span
:
mk_sp
(
lo
,
lo
),
...
...
@@ -3235,7 +3235,7 @@ pub fn parse_generics(&self) -> ast::Generics {
// parse a generic use site
fn
parse_generic_values
(
&
self
)
->
(
OptVec
<
ast
::
Lifetime
>
,
~
[
@
Ty
])
&
self
)
->
(
OptVec
<
ast
::
Lifetime
>
,
~
[
Ty
])
{
if
!
self
.eat
(
&
token
::
LT
)
{
(
opt_vec
::
Empty
,
~
[])
...
...
@@ -3245,7 +3245,7 @@ fn parse_generic_values(
}
fn
parse_generic_values_after_lt
(
&
self
)
->
(
OptVec
<
ast
::
Lifetime
>
,
~
[
@
Ty
])
&
self
)
->
(
OptVec
<
ast
::
Lifetime
>
,
~
[
Ty
])
{
let
lifetimes
=
self
.parse_lifetimes
();
let
result
=
self
.parse_seq_to_gt
(
...
...
@@ -3455,7 +3455,7 @@ fn parse_fn_block_decl(&self) -> fn_decl {
let
output
=
if
self
.eat
(
&
token
::
RARROW
)
{
self
.parse_ty
(
false
)
}
else
{
@
Ty
{
id
:
self
.get_id
(),
node
:
ty_infer
,
span
:
*
self
.span
}
Ty
{
id
:
self
.get_id
(),
node
:
ty_infer
,
span
:
*
self
.span
}
};
ast
::
fn_decl
{
...
...
@@ -4155,9 +4155,9 @@ fn parse_enum_def(&self, _generics: &ast::Generics) -> enum_def {
seq_sep_trailing_disallowed
(
token
::
COMMA
),
|
p
|
p
.parse_ty
(
false
)
);
for
arg_tys
.iter
()
.advance
|
ty
|
{
for
arg_tys
.
consume_
iter
()
.advance
|
ty
|
{
args
.push
(
ast
::
variant_arg
{
ty
:
*
ty
,
ty
:
ty
,
id
:
self
.get_id
(),
});
}
...
...
src/libsyntax/parse/token.rs
浏览文件 @
47eca211
...
...
@@ -104,7 +104,7 @@ pub enum nonterminal {
nt_stmt
(
@
ast
::
stmt
),
nt_pat
(
@
ast
::
pat
),
nt_expr
(
@
ast
::
expr
),
nt_ty
(
@
ast
::
Ty
),
nt_ty
(
ast
::
Ty
),
nt_ident
(
ast
::
ident
,
bool
),
nt_path
(
ast
::
Path
),
nt_tt
(
@
ast
::
token_tree
),
//needs @ed to break a circularity
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
47eca211
...
...
@@ -398,7 +398,7 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
}
ast
::
ty_tup
(
ref
elts
)
=>
{
popen
(
s
);
commasep
(
s
,
inconsistent
,
*
elts
,
|
p
,
&
t
|
print_type
(
p
,
t
)
);
commasep
(
s
,
inconsistent
,
*
elts
,
print_type
);
if
elts
.len
()
==
1
{
word
(
s
.s
,
","
);
}
...
...
@@ -454,7 +454,7 @@ pub fn print_foreign_item(s: @ps, item: &ast::foreign_item) {
word
(
s
.s
,
";"
);
end
(
s
);
// end the outer fn box
}
ast
::
foreign_item_static
(
t
,
m
)
=>
{
ast
::
foreign_item_static
(
ref
t
,
m
)
=>
{
head
(
s
,
"static"
);
if
m
{
word_space
(
s
,
"mut"
);
...
...
@@ -476,7 +476,7 @@ pub fn print_item(s: @ps, item: &ast::item) {
let
ann_node
=
node_item
(
s
,
item
);
(
s
.ann.pre
)(
ann_node
);
match
item
.node
{
ast
::
item_static
(
ty
,
m
,
expr
)
=>
{
ast
::
item_static
(
ref
ty
,
m
,
expr
)
=>
{
head
(
s
,
visibility_qualified
(
item
.vis
,
"static"
));
if
m
==
ast
::
m_mutbl
{
word_space
(
s
,
"mut"
);
...
...
@@ -530,7 +530,7 @@ pub fn print_item(s: @ps, item: &ast::item) {
print_foreign_mod
(
s
,
nmod
,
item
.attrs
);
bclose
(
s
,
item
.span
);
}
ast
::
item_ty
(
ty
,
ref
params
)
=>
{
ast
::
item_ty
(
ref
ty
,
ref
params
)
=>
{
ibox
(
s
,
indent_unit
);
ibox
(
s
,
0u
);
word_nbsp
(
s
,
visibility_qualified
(
item
.vis
,
"type"
));
...
...
@@ -559,7 +559,7 @@ pub fn print_item(s: @ps, item: &ast::item) {
print_struct
(
s
,
struct_def
,
generics
,
item
.ident
,
item
.span
);
}
ast
::
item_impl
(
ref
generics
,
ref
opt_trait
,
ty
,
ref
methods
)
=>
{
ast
::
item_impl
(
ref
generics
,
ref
opt_trait
,
ref
ty
,
ref
methods
)
=>
{
head
(
s
,
visibility_qualified
(
item
.vis
,
"impl"
));
if
generics
.is_parameterized
()
{
print_generics
(
s
,
generics
);
...
...
@@ -694,7 +694,7 @@ pub fn print_struct(s: @ps,
ast
::
named_field
(
*
)
=>
fail
!
(
"unexpected named field"
),
ast
::
unnamed_field
=>
{
maybe_print_comment
(
s
,
field
.span.lo
);
print_type
(
s
,
field
.node.ty
);
print_type
(
s
,
&
field
.node.ty
);
}
}
}
...
...
@@ -718,7 +718,7 @@ pub fn print_struct(s: @ps,
print_visibility
(
s
,
visibility
);
print_ident
(
s
,
ident
);
word_nbsp
(
s
,
":"
);
print_type
(
s
,
field
.node.ty
);
print_type
(
s
,
&
field
.node.ty
);
word
(
s
.s
,
","
);
}
}
...
...
@@ -777,7 +777,7 @@ pub fn print_variant(s: @ps, v: &ast::variant) {
if
!
args
.is_empty
()
{
popen
(
s
);
fn
print_variant_arg
(
s
:
@
ps
,
arg
:
&
ast
::
variant_arg
)
{
print_type
(
s
,
arg
.ty
);
print_type
(
s
,
&
arg
.ty
);
}
commasep
(
s
,
consistent
,
*
args
,
print_variant_arg
);
pclose
(
s
);
...
...
@@ -1172,7 +1172,7 @@ fn print_field(s: @ps, field: &ast::field) {
print_ident
(
s
,
ident
);
if
tys
.len
()
>
0u
{
word
(
s
.s
,
"::<"
);
commasep
(
s
,
inconsistent
,
*
tys
,
|
p
,
&
e
|
print_type
(
p
,
e
)
);
commasep
(
s
,
inconsistent
,
*
tys
,
print_type
);
word
(
s
.s
,
">"
);
}
print_call_post
(
s
,
sugar
,
&
blk
,
&
mut
base_args
);
...
...
@@ -1198,7 +1198,7 @@ fn print_field(s: @ps, field: &ast::field) {
print_expr
(
s
,
expr
);
}
ast
::
expr_lit
(
lit
)
=>
print_literal
(
s
,
lit
),
ast
::
expr_cast
(
expr
,
ty
)
=>
{
ast
::
expr_cast
(
expr
,
ref
ty
)
=>
{
print_expr
(
s
,
expr
);
space
(
s
.s
);
word_space
(
s
,
"as"
);
...
...
@@ -1348,7 +1348,7 @@ fn print_field(s: @ps, field: &ast::field) {
print_ident
(
s
,
id
);
if
tys
.len
()
>
0u
{
word
(
s
.s
,
"::<"
);
commasep
(
s
,
inconsistent
,
*
tys
,
|
p
,
&
e
|
print_type
(
p
,
e
)
);
commasep
(
s
,
inconsistent
,
*
tys
,
print_type
);
word
(
s
.s
,
">"
);
}
}
...
...
@@ -1437,7 +1437,7 @@ pub fn print_local_decl(s: @ps, loc: &ast::local) {
print_irrefutable_pat
(
s
,
loc
.node.pat
);
match
loc
.node.ty.node
{
ast
::
ty_infer
=>
(),
_
=>
{
word_space
(
s
,
":"
);
print_type
(
s
,
loc
.node.ty
);
}
_
=>
{
word_space
(
s
,
":"
);
print_type
(
s
,
&
loc
.node.ty
);
}
}
}
...
...
@@ -1510,7 +1510,7 @@ fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool,
}
}
commasep
(
s
,
inconsistent
,
path
.types
,
|
p
,
&
e
|
print_type
(
p
,
e
)
);
commasep
(
s
,
inconsistent
,
path
.types
,
print_type
);
word
(
s
.s
,
">"
);
}
...
...
@@ -1693,7 +1693,7 @@ pub fn print_fn_args(s: @ps, decl: &ast::fn_decl,
for
decl
.inputs
.iter
()
.advance
|
arg
|
{
if
first
{
first
=
false
;
}
else
{
word_space
(
s
,
","
);
}
print_arg
(
s
,
*
arg
);
print_arg
(
s
,
arg
);
}
end
(
s
);
...
...
@@ -1711,7 +1711,7 @@ pub fn print_fn_args_and_ret(s: @ps, decl: &ast::fn_decl,
_
=>
{
space_if_not_bol
(
s
);
word_space
(
s
,
"->"
);
print_type
(
s
,
decl
.output
);
print_type
(
s
,
&
decl
.output
);
}
}
}
...
...
@@ -1726,7 +1726,7 @@ pub fn print_fn_block_args(s: @ps, decl: &ast::fn_decl) {
_
=>
{
space_if_not_bol
(
s
);
word_space
(
s
,
"->"
);
print_type
(
s
,
decl
.output
);
print_type
(
s
,
&
decl
.output
);
}
}
...
...
@@ -1882,7 +1882,7 @@ pub fn print_mt(s: @ps, mt: &ast::mt) {
print_type
(
s
,
mt
.ty
);
}
pub
fn
print_arg
(
s
:
@
ps
,
input
:
ast
::
arg
)
{
pub
fn
print_arg
(
s
:
@
ps
,
input
:
&
ast
::
arg
)
{
ibox
(
s
,
indent_unit
);
if
input
.is_mutbl
{
word_space
(
s
,
"mut"
);
...
...
@@ -1902,7 +1902,7 @@ pub fn print_arg(s: @ps, input: ast::arg) {
space
(
s
.s
);
}
}
print_type
(
s
,
input
.ty
);
print_type
(
s
,
&
input
.ty
);
}
}
end
(
s
);
...
...
@@ -1944,7 +1944,7 @@ pub fn print_ty_fn(s: @ps,
}
for
decl
.inputs
.iter
()
.advance
|
arg
|
{
if
first
{
first
=
false
;
}
else
{
word_space
(
s
,
","
);
}
print_arg
(
s
,
*
arg
);
print_arg
(
s
,
arg
);
}
end
(
s
);
pclose
(
s
);
...
...
@@ -1958,7 +1958,7 @@ pub fn print_ty_fn(s: @ps,
ibox
(
s
,
indent_unit
);
word_space
(
s
,
"->"
);
if
decl
.cf
==
ast
::
noreturn
{
word_nbsp
(
s
,
"!"
);
}
else
{
print_type
(
s
,
decl
.output
);
}
else
{
print_type
(
s
,
&
decl
.output
);
}
end
(
s
);
}
}
...
...
src/libsyntax/visit.rs
浏览文件 @
47eca211
...
...
@@ -83,7 +83,7 @@ pub struct Visitor<E> {
visit_decl
:
@
fn
(
@
decl
,
(
E
,
vt
<
E
>
)),
visit_expr
:
@
fn
(
@
expr
,
(
E
,
vt
<
E
>
)),
visit_expr_post
:
@
fn
(
@
expr
,
(
E
,
vt
<
E
>
)),
visit_ty
:
@
fn
(
@
Ty
,
(
E
,
vt
<
E
>
)),
visit_ty
:
@
fn
(
&
Ty
,
(
E
,
vt
<
E
>
)),
visit_generics
:
@
fn
(
&
Generics
,
(
E
,
vt
<
E
>
)),
visit_fn
:
@
fn
(
&
fn_kind
,
&
fn_decl
,
&
blk
,
span
,
node_id
,
(
E
,
vt
<
E
>
)),
visit_ty_method
:
@
fn
(
&
ty_method
,
(
E
,
vt
<
E
>
)),
...
...
@@ -131,7 +131,7 @@ pub fn visit_view_item<E>(_vi: &view_item, (_e, _v): (E, vt<E>)) { }
pub
fn
visit_local
<
E
:
Copy
>
(
loc
:
&
local
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
(
v
.visit_pat
)(
loc
.node.pat
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
loc
.node.ty
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
&
loc
.node.ty
,
(
copy
e
,
v
));
match
loc
.node.init
{
None
=>
(),
Some
(
ex
)
=>
(
v
.visit_expr
)(
ex
,
(
e
,
v
))
...
...
@@ -144,7 +144,7 @@ fn visit_trait_ref<E: Copy>(tref: &ast::trait_ref, (e, v): (E, vt<E>)) {
pub
fn
visit_item
<
E
:
Copy
>
(
i
:
&
item
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
match
i
.node
{
item_static
(
t
,
_
,
ex
)
=>
{
item_static
(
ref
t
,
_
,
ex
)
=>
{
(
v
.visit_ty
)(
t
,
(
copy
e
,
v
));
(
v
.visit_expr
)(
ex
,
(
copy
e
,
v
));
}
...
...
@@ -169,7 +169,7 @@ pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) {
for
nm
.view_items
.iter
()
.advance
|
vi
|
{
(
v
.visit_view_item
)(
vi
,
(
copy
e
,
v
));
}
for
nm
.items
.iter
()
.advance
|
ni
|
{
(
v
.visit_foreign_item
)(
*
ni
,
(
copy
e
,
v
));
}
}
item_ty
(
t
,
ref
tps
)
=>
{
item_ty
(
ref
t
,
ref
tps
)
=>
{
(
v
.visit_ty
)(
t
,
(
copy
e
,
v
));
(
v
.visit_generics
)(
tps
,
(
e
,
v
));
}
...
...
@@ -181,7 +181,7 @@ pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) {
(
e
,
v
)
);
}
item_impl
(
ref
tps
,
ref
traits
,
ty
,
ref
methods
)
=>
{
item_impl
(
ref
tps
,
ref
traits
,
ref
ty
,
ref
methods
)
=>
{
(
v
.visit_generics
)(
tps
,
(
copy
e
,
v
));
for
traits
.iter
()
.advance
|
p
|
{
visit_trait_ref
(
p
,
(
copy
e
,
v
));
...
...
@@ -213,7 +213,7 @@ pub fn visit_enum_def<E: Copy>(enum_definition: &ast::enum_def,
match
vr
.node.kind
{
tuple_variant_kind
(
ref
variant_args
)
=>
{
for
variant_args
.iter
()
.advance
|
va
|
{
(
v
.visit_ty
)(
va
.ty
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
&
va
.ty
,
(
copy
e
,
v
));
}
}
struct_variant_kind
(
struct_def
)
=>
{
...
...
@@ -232,25 +232,25 @@ pub fn skip_ty<E>(_t: &Ty, (_e,_v): (E, vt<E>)) {}
pub
fn
visit_ty
<
E
:
Copy
>
(
t
:
&
Ty
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
match
t
.node
{
ty_box
(
mt
)
|
ty_uniq
(
mt
)
|
ty_vec
(
mt
)
|
ty_ptr
(
mt
)
|
ty_rptr
(
_
,
mt
)
=>
{
ty_box
(
ref
mt
)
|
ty_uniq
(
ref
mt
)
|
ty_vec
(
ref
mt
)
|
ty_ptr
(
ref
mt
)
|
ty_rptr
(
_
,
ref
mt
)
=>
{
(
v
.visit_ty
)(
mt
.ty
,
(
e
,
v
));
},
ty_tup
(
ref
ts
)
=>
{
for
ts
.iter
()
.advance
|
tt
|
{
(
v
.visit_ty
)(
*
tt
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
tt
,
(
copy
e
,
v
));
}
},
ty_closure
(
ref
f
)
=>
{
for
f
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_ty
)(
f
.decl.output
,
(
copy
e
,
v
));
for
f
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
&
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_ty
)(
&
f
.decl.output
,
(
copy
e
,
v
));
do
f
.bounds.map
|
bounds
|
{
visit_ty_param_bounds
(
bounds
,
(
copy
e
,
v
));
};
},
ty_bare_fn
(
ref
f
)
=>
{
for
f
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_ty
)(
f
.decl.output
,
(
e
,
v
));
for
f
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
&
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_ty
)(
&
f
.decl.output
,
(
e
,
v
));
},
ty_path
(
ref
p
,
ref
bounds
,
_
)
=>
{
visit_path
(
p
,
(
copy
e
,
v
));
...
...
@@ -267,7 +267,7 @@ pub fn visit_ty<E: Copy>(t: &Ty, (e, v): (E, vt<E>)) {
}
pub
fn
visit_path
<
E
:
Copy
>
(
p
:
&
Path
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
for
p
.types
.iter
()
.advance
|
tp
|
{
(
v
.visit_ty
)(
*
tp
,
(
copy
e
,
v
));
}
for
p
.types
.iter
()
.advance
|
tp
|
{
(
v
.visit_ty
)(
tp
,
(
copy
e
,
v
));
}
}
pub
fn
visit_pat
<
E
:
Copy
>
(
p
:
&
pat
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
...
...
@@ -326,7 +326,7 @@ pub fn visit_foreign_item<E: Copy>(ni: &foreign_item, (e, v): (E, vt<E>)) {
visit_fn_decl
(
fd
,
(
copy
e
,
v
));
(
v
.visit_generics
)(
generics
,
(
e
,
v
));
}
foreign_item_static
(
t
,
_
)
=>
{
foreign_item_static
(
ref
t
,
_
)
=>
{
(
v
.visit_ty
)(
t
,
(
e
,
v
));
}
}
...
...
@@ -351,9 +351,9 @@ pub fn visit_generics<E: Copy>(generics: &Generics, (e, v): (E, vt<E>)) {
pub
fn
visit_fn_decl
<
E
:
Copy
>
(
fd
:
&
fn_decl
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
for
fd
.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_pat
)(
a
.pat
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
a
.ty
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
&
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_ty
)(
fd
.output
,
(
e
,
v
));
(
v
.visit_ty
)(
&
fd
.output
,
(
e
,
v
));
}
// Note: there is no visit_method() method in the visitor, instead override
...
...
@@ -384,9 +384,9 @@ pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
}
pub
fn
visit_ty_method
<
E
:
Copy
>
(
m
:
&
ty_method
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
for
m
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
a
.ty
,
(
copy
e
,
v
));
}
for
m
.decl.inputs
.iter
()
.advance
|
a
|
{
(
v
.visit_ty
)(
&
a
.ty
,
(
copy
e
,
v
));
}
(
v
.visit_generics
)(
&
m
.generics
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
m
.decl.output
,
(
e
,
v
));
(
v
.visit_ty
)(
&
m
.decl.output
,
(
e
,
v
));
}
pub
fn
visit_trait_method
<
E
:
Copy
>
(
m
:
&
trait_method
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
...
...
@@ -409,7 +409,7 @@ pub fn visit_struct_def<E: Copy>(
}
pub
fn
visit_struct_field
<
E
:
Copy
>
(
sf
:
&
struct_field
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
(
v
.visit_ty
)(
sf
.node.ty
,
(
e
,
v
));
(
v
.visit_ty
)(
&
sf
.node.ty
,
(
e
,
v
));
}
pub
fn
visit_block
<
E
:
Copy
>
(
b
:
&
blk
,
(
e
,
v
):
(
E
,
vt
<
E
>
))
{
...
...
@@ -475,7 +475,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
expr_method_call
(
_
,
callee
,
_
,
ref
tys
,
ref
args
,
_
)
=>
{
visit_exprs
(
*
args
,
(
copy
e
,
v
));
for
tys
.iter
()
.advance
|
tp
|
{
(
v
.visit_ty
)(
*
tp
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
tp
,
(
copy
e
,
v
));
}
(
v
.visit_expr
)(
callee
,
(
copy
e
,
v
));
}
...
...
@@ -486,7 +486,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
expr_addr_of
(
_
,
x
)
|
expr_unary
(
_
,
_
,
x
)
|
expr_loop_body
(
x
)
|
expr_do_body
(
x
)
=>
(
v
.visit_expr
)(
x
,
(
copy
e
,
v
)),
expr_lit
(
_
)
=>
(),
expr_cast
(
x
,
t
)
=>
{
expr_cast
(
x
,
ref
t
)
=>
{
(
v
.visit_expr
)(
x
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
t
,
(
copy
e
,
v
));
}
...
...
@@ -527,7 +527,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
expr_field
(
x
,
_
,
ref
tys
)
=>
{
(
v
.visit_expr
)(
x
,
(
copy
e
,
v
));
for
tys
.iter
()
.advance
|
tp
|
{
(
v
.visit_ty
)(
*
tp
,
(
copy
e
,
v
));
(
v
.visit_ty
)(
tp
,
(
copy
e
,
v
));
}
}
expr_index
(
_
,
a
,
b
)
=>
{
...
...
@@ -579,7 +579,7 @@ pub struct SimpleVisitor {
visit_decl
:
@
fn
(
@
decl
),
visit_expr
:
@
fn
(
@
expr
),
visit_expr_post
:
@
fn
(
@
expr
),
visit_ty
:
@
fn
(
@
Ty
),
visit_ty
:
@
fn
(
&
Ty
),
visit_generics
:
@
fn
(
&
Generics
),
visit_fn
:
@
fn
(
&
fn_kind
,
&
fn_decl
,
&
blk
,
span
,
node_id
),
visit_ty_method
:
@
fn
(
&
ty_method
),
...
...
@@ -591,7 +591,7 @@ pub struct SimpleVisitor {
pub
type
simple_visitor
=
@
SimpleVisitor
;
pub
fn
simple_ignore_ty
(
_
t
:
@
Ty
)
{}
pub
fn
simple_ignore_ty
(
_
t
:
&
Ty
)
{}
pub
fn
default_simple_visitor
()
->
@
SimpleVisitor
{
@
SimpleVisitor
{
...
...
@@ -672,7 +672,7 @@ fn v_expr(f: @fn(@expr), ex: @expr, (e, v): ((), vt<()>)) {
fn
v_expr_post
(
f
:
@
fn
(
@
expr
),
ex
:
@
expr
,
(
_
e
,
_
v
):
((),
vt
<
()
>
))
{
f
(
ex
);
}
fn
v_ty
(
f
:
@
fn
(
@
Ty
),
ty
:
@
Ty
,
(
e
,
v
):
((),
vt
<
()
>
))
{
fn
v_ty
(
f
:
@
fn
(
&
Ty
),
ty
:
&
Ty
,
(
e
,
v
):
((),
vt
<
()
>
))
{
f
(
ty
);
visit_ty
(
ty
,
(
e
,
v
));
}
...
...
@@ -717,7 +717,7 @@ fn v_fn(
f
(
fk
,
decl
,
body
,
sp
,
id
);
visit_fn
(
fk
,
decl
,
body
,
sp
,
id
,
(
e
,
v
));
}
let
visit_ty
:
@
fn
(
@
Ty
,
((),
vt
<
()
>
))
=
let
visit_ty
:
@
fn
(
&
Ty
,
((),
vt
<
()
>
))
=
|
a
,
b
|
v_ty
(
v
.visit_ty
,
a
,
b
);
fn
v_struct_field
(
f
:
@
fn
(
@
struct_field
),
sf
:
@
struct_field
,
(
e
,
v
):
((),
vt
<
()
>
))
{
f
(
sf
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录