Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
05d4cefd
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,发现更多精彩内容 >>
提交
05d4cefd
编写于
2月 08, 2016
作者:
O
Oliver Schneider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[breaking-change] don't pub export ast::Ty_ variants
上级
ec61e632
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
126 addition
and
128 deletion
+126
-128
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+14
-13
src/librustc_trans/save/dump_csv.rs
src/librustc_trans/save/dump_csv.rs
+1
-1
src/librustc_trans/save/mod.rs
src/librustc_trans/save/mod.rs
+1
-1
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+17
-18
src/libsyntax/diagnostics/plugin.rs
src/libsyntax/diagnostics/plugin.rs
+2
-2
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+1
-1
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+7
-7
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+2
-2
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+21
-21
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-1
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+24
-26
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+15
-15
src/libsyntax/test.rs
src/libsyntax/test.rs
+4
-4
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+12
-12
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+2
-2
src/libsyntax_ext/deriving/generic/ty.rs
src/libsyntax_ext/deriving/generic/ty.rs
+1
-1
src/libsyntax_ext/format.rs
src/libsyntax_ext/format.rs
+1
-1
未找到文件。
src/librustc_front/lowering.rs
浏览文件 @
05d4cefd
...
@@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin
...
@@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin
}
}
pub
fn
lower_ty
(
lctx
:
&
LoweringContext
,
t
:
&
Ty
)
->
P
<
hir
::
Ty
>
{
pub
fn
lower_ty
(
lctx
:
&
LoweringContext
,
t
:
&
Ty
)
->
P
<
hir
::
Ty
>
{
use
syntax
::
ast
::
TyKind
::
*
;
P
(
hir
::
Ty
{
P
(
hir
::
Ty
{
id
:
t
.id
,
id
:
t
.id
,
node
:
match
t
.node
{
node
:
match
t
.node
{
Ty
Infer
=>
hir
::
TyInfer
,
Infer
=>
hir
::
TyInfer
,
Ty
Vec
(
ref
ty
)
=>
hir
::
TyVec
(
lower_ty
(
lctx
,
ty
)),
Vec
(
ref
ty
)
=>
hir
::
TyVec
(
lower_ty
(
lctx
,
ty
)),
Ty
Ptr
(
ref
mt
)
=>
hir
::
TyPtr
(
lower_mt
(
lctx
,
mt
)),
Ptr
(
ref
mt
)
=>
hir
::
TyPtr
(
lower_mt
(
lctx
,
mt
)),
Ty
Rptr
(
ref
region
,
ref
mt
)
=>
{
Rptr
(
ref
region
,
ref
mt
)
=>
{
hir
::
TyRptr
(
lower_opt_lifetime
(
lctx
,
region
),
lower_mt
(
lctx
,
mt
))
hir
::
TyRptr
(
lower_opt_lifetime
(
lctx
,
region
),
lower_mt
(
lctx
,
mt
))
}
}
Ty
BareFn
(
ref
f
)
=>
{
BareFn
(
ref
f
)
=>
{
hir
::
TyBareFn
(
P
(
hir
::
BareFnTy
{
hir
::
TyBareFn
(
P
(
hir
::
BareFnTy
{
lifetimes
:
lower_lifetime_defs
(
lctx
,
&
f
.lifetimes
),
lifetimes
:
lower_lifetime_defs
(
lctx
,
&
f
.lifetimes
),
unsafety
:
lower_unsafety
(
lctx
,
f
.unsafety
),
unsafety
:
lower_unsafety
(
lctx
,
f
.unsafety
),
...
@@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
...
@@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
decl
:
lower_fn_decl
(
lctx
,
&
f
.decl
),
decl
:
lower_fn_decl
(
lctx
,
&
f
.decl
),
}))
}))
}
}
T
yT
up
(
ref
tys
)
=>
hir
::
TyTup
(
tys
.iter
()
.map
(|
ty
|
lower_ty
(
lctx
,
ty
))
.collect
()),
Tup
(
ref
tys
)
=>
hir
::
TyTup
(
tys
.iter
()
.map
(|
ty
|
lower_ty
(
lctx
,
ty
))
.collect
()),
Ty
Paren
(
ref
ty
)
=>
{
Paren
(
ref
ty
)
=>
{
return
lower_ty
(
lctx
,
ty
);
return
lower_ty
(
lctx
,
ty
);
}
}
Ty
Path
(
ref
qself
,
ref
path
)
=>
{
Path
(
ref
qself
,
ref
path
)
=>
{
let
qself
=
qself
.as_ref
()
.map
(|
&
QSelf
{
ref
ty
,
position
}|
{
let
qself
=
qself
.as_ref
()
.map
(|
&
QSelf
{
ref
ty
,
position
}|
{
hir
::
QSelf
{
hir
::
QSelf
{
ty
:
lower_ty
(
lctx
,
ty
),
ty
:
lower_ty
(
lctx
,
ty
),
...
@@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
...
@@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
});
});
hir
::
TyPath
(
qself
,
lower_path
(
lctx
,
path
))
hir
::
TyPath
(
qself
,
lower_path
(
lctx
,
path
))
}
}
Ty
ObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
ObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
hir
::
TyObjectSum
(
lower_ty
(
lctx
,
ty
),
lower_bounds
(
lctx
,
bounds
))
hir
::
TyObjectSum
(
lower_ty
(
lctx
,
ty
),
lower_bounds
(
lctx
,
bounds
))
}
}
Ty
FixedLengthVec
(
ref
ty
,
ref
e
)
=>
{
FixedLengthVec
(
ref
ty
,
ref
e
)
=>
{
hir
::
TyFixedLengthVec
(
lower_ty
(
lctx
,
ty
),
lower_expr
(
lctx
,
e
))
hir
::
TyFixedLengthVec
(
lower_ty
(
lctx
,
ty
),
lower_expr
(
lctx
,
e
))
}
}
Ty
Ty
peof
(
ref
expr
)
=>
{
Typeof
(
ref
expr
)
=>
{
hir
::
TyTypeof
(
lower_expr
(
lctx
,
expr
))
hir
::
TyTypeof
(
lower_expr
(
lctx
,
expr
))
}
}
Ty
PolyTraitRef
(
ref
bounds
)
=>
{
PolyTraitRef
(
ref
bounds
)
=>
{
hir
::
TyPolyTraitRef
(
bounds
.iter
()
.map
(|
b
|
lower_ty_param_bound
(
lctx
,
b
))
.collect
())
hir
::
TyPolyTraitRef
(
bounds
.iter
()
.map
(|
b
|
lower_ty_param_bound
(
lctx
,
b
))
.collect
())
}
}
Ty
Mac
(
_
)
=>
panic!
(
"TyMac should have been expanded by now."
),
Mac
(
_
)
=>
panic!
(
"TyMac should have been expanded by now."
),
},
},
span
:
t
.span
,
span
:
t
.span
,
})
})
...
...
src/librustc_trans/save/dump_csv.rs
浏览文件 @
05d4cefd
...
@@ -1063,7 +1063,7 @@ fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
...
@@ -1063,7 +1063,7 @@ fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
fn
visit_ty
(
&
mut
self
,
t
:
&
ast
::
Ty
)
{
fn
visit_ty
(
&
mut
self
,
t
:
&
ast
::
Ty
)
{
self
.process_macro_use
(
t
.span
,
t
.id
);
self
.process_macro_use
(
t
.span
,
t
.id
);
match
t
.node
{
match
t
.node
{
ast
::
TyPath
(
_
,
ref
path
)
=>
{
ast
::
Ty
Kind
::
Path
(
_
,
ref
path
)
=>
{
match
self
.lookup_type_ref
(
t
.id
)
{
match
self
.lookup_type_ref
(
t
.id
)
{
Some
(
id
)
=>
{
Some
(
id
)
=>
{
let
sub_span
=
self
.span
.sub_span_for_type_name
(
t
.span
);
let
sub_span
=
self
.span
.sub_span_for_type_name
(
t
.span
);
...
...
src/librustc_trans/save/mod.rs
浏览文件 @
05d4cefd
...
@@ -316,7 +316,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
...
@@ -316,7 +316,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
match
typ
.node
{
match
typ
.node
{
// Common case impl for a struct or something basic.
// Common case impl for a struct or something basic.
ast
::
TyPath
(
None
,
ref
path
)
=>
{
ast
::
Ty
Kind
::
Path
(
None
,
ref
path
)
=>
{
sub_span
=
self
.span_utils
.sub_span_for_type_name
(
path
.span
);
sub_span
=
self
.span_utils
.sub_span_for_type_name
(
path
.span
);
filter!
(
self
.span_utils
,
sub_span
,
path
.span
,
None
);
filter!
(
self
.span_utils
,
sub_span
,
path
.span
,
None
);
type_data
=
self
.lookup_ref_id
(
typ
.id
)
.map
(|
id
|
{
type_data
=
self
.lookup_ref_id
(
typ
.id
)
.map
(|
id
|
{
...
...
src/libsyntax/ast.rs
浏览文件 @
05d4cefd
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
pub
use
self
::
StrStyle
::
*
;
pub
use
self
::
StrStyle
::
*
;
pub
use
self
::
StructFieldKind
::
*
;
pub
use
self
::
StructFieldKind
::
*
;
pub
use
self
::
TraitItem_
::
*
;
pub
use
self
::
TraitItem_
::
*
;
pub
use
self
::
Ty_
::
*
;
pub
use
self
::
TyParamBound
::
*
;
pub
use
self
::
TyParamBound
::
*
;
pub
use
self
::
UnsafeSource
::
*
;
pub
use
self
::
UnsafeSource
::
*
;
pub
use
self
::
ViewPath_
::
*
;
pub
use
self
::
ViewPath_
::
*
;
...
@@ -1523,7 +1522,7 @@ pub struct TypeBinding {
...
@@ -1523,7 +1522,7 @@ pub struct TypeBinding {
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash)]
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash)]
pub
struct
Ty
{
pub
struct
Ty
{
pub
id
:
NodeId
,
pub
id
:
NodeId
,
pub
node
:
Ty
_
,
pub
node
:
Ty
Kind
,
pub
span
:
Span
,
pub
span
:
Span
,
}
}
...
@@ -1543,36 +1542,36 @@ pub struct BareFnTy {
...
@@ -1543,36 +1542,36 @@ pub struct BareFnTy {
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
/// The different kinds of types recognized by the compiler
/// The different kinds of types recognized by the compiler
pub
enum
Ty
_
{
pub
enum
Ty
Kind
{
Ty
Vec
(
P
<
Ty
>
),
Vec
(
P
<
Ty
>
),
/// A fixed length array (`[T; n]`)
/// A fixed length array (`[T; n]`)
Ty
FixedLengthVec
(
P
<
Ty
>
,
P
<
Expr
>
),
FixedLengthVec
(
P
<
Ty
>
,
P
<
Expr
>
),
/// A raw pointer (`*const T` or `*mut T`)
/// A raw pointer (`*const T` or `*mut T`)
Ty
Ptr
(
MutTy
),
Ptr
(
MutTy
),
/// A reference (`&'a T` or `&'a mut T`)
/// A reference (`&'a T` or `&'a mut T`)
Ty
Rptr
(
Option
<
Lifetime
>
,
MutTy
),
Rptr
(
Option
<
Lifetime
>
,
MutTy
),
/// A bare function (e.g. `fn(usize) -> bool`)
/// A bare function (e.g. `fn(usize) -> bool`)
Ty
BareFn
(
P
<
BareFnTy
>
),
BareFn
(
P
<
BareFnTy
>
),
/// A tuple (`(A, B, C, D,...)`)
/// A tuple (`(A, B, C, D,...)`)
T
yT
up
(
Vec
<
P
<
Ty
>>
),
Tup
(
Vec
<
P
<
Ty
>>
),
/// A path (`module::module::...::Type`), optionally
/// A path (`module::module::...::Type`), optionally
/// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
/// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
///
///
/// Type parameters are stored in the Path itself
/// Type parameters are stored in the Path itself
Ty
Path
(
Option
<
QSelf
>
,
Path
),
Path
(
Option
<
QSelf
>
,
Path
),
/// Something like `A+B`. Note that `B` must always be a path.
/// Something like `A+B`. Note that `B` must always be a path.
Ty
ObjectSum
(
P
<
Ty
>
,
TyParamBounds
),
ObjectSum
(
P
<
Ty
>
,
TyParamBounds
),
/// A type like `for<'a> Foo<&'a Bar>`
/// A type like `for<'a> Foo<&'a Bar>`
Ty
PolyTraitRef
(
TyParamBounds
),
PolyTraitRef
(
TyParamBounds
),
/// No-op; kept solely so that we can pretty-print faithfully
/// No-op; kept solely so that we can pretty-print faithfully
Ty
Paren
(
P
<
Ty
>
),
Paren
(
P
<
Ty
>
),
/// Unused for now
/// Unused for now
Ty
Ty
peof
(
P
<
Expr
>
),
Typeof
(
P
<
Expr
>
),
/// TyInfer means the type should be inferred instead of it having been
/// Ty
Kind::
Infer means the type should be inferred instead of it having been
/// specified. This can appear anywhere in a type.
/// specified. This can appear anywhere in a type.
Ty
Infer
,
Infer
,
// A macro in the type position.
// A macro in the type position.
TyMac
(
Mac
)
Mac
(
Mac
),
}
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug,
Copy)]
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug,
Copy)]
...
@@ -1617,7 +1616,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
...
@@ -1617,7 +1616,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
// HACK(eddyb) fake type for the self argument.
// HACK(eddyb) fake type for the self argument.
ty
:
P
(
Ty
{
ty
:
P
(
Ty
{
id
:
DUMMY_NODE_ID
,
id
:
DUMMY_NODE_ID
,
node
:
TyInfer
,
node
:
Ty
Kind
::
Infer
,
span
:
DUMMY_SP
,
span
:
DUMMY_SP
,
}),
}),
pat
:
P
(
Pat
{
pat
:
P
(
Pat
{
...
...
src/libsyntax/diagnostics/plugin.rs
浏览文件 @
05d4cefd
...
@@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
...
@@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
let
ty
=
ecx
.ty
(
let
ty
=
ecx
.ty
(
span
,
span
,
ast
::
TyFixedLengthVec
(
ast
::
Ty
Kind
::
FixedLengthVec
(
ecx
.ty
(
ecx
.ty
(
span
,
span
,
ast
::
TyTup
(
vec!
[
ty_str
.clone
(),
ty_str
])
ast
::
Ty
Kind
::
Tup
(
vec!
[
ty_str
.clone
(),
ty_str
])
),
),
ecx
.expr_usize
(
span
,
count
),
ecx
.expr_usize
(
span
,
count
),
),
),
...
...
src/libsyntax/ext/base.rs
浏览文件 @
05d4cefd
...
@@ -367,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
...
@@ -367,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
pub
fn
raw_ty
(
sp
:
Span
)
->
P
<
ast
::
Ty
>
{
pub
fn
raw_ty
(
sp
:
Span
)
->
P
<
ast
::
Ty
>
{
P
(
ast
::
Ty
{
P
(
ast
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
id
:
ast
::
DUMMY_NODE_ID
,
node
:
ast
::
TyInfer
,
node
:
ast
::
Ty
Kind
::
Infer
,
span
:
sp
span
:
sp
})
})
}
}
...
...
src/libsyntax/ext/build.rs
浏览文件 @
05d4cefd
...
@@ -52,7 +52,7 @@ fn qpath_all(&self, self_type: P<ast::Ty>,
...
@@ -52,7 +52,7 @@ fn qpath_all(&self, self_type: P<ast::Ty>,
// types
// types
fn
ty_mt
(
&
self
,
ty
:
P
<
ast
::
Ty
>
,
mutbl
:
ast
::
Mutability
)
->
ast
::
MutTy
;
fn
ty_mt
(
&
self
,
ty
:
P
<
ast
::
Ty
>
,
mutbl
:
ast
::
Mutability
)
->
ast
::
MutTy
;
fn
ty
(
&
self
,
span
:
Span
,
ty
:
ast
::
Ty
_
)
->
P
<
ast
::
Ty
>
;
fn
ty
(
&
self
,
span
:
Span
,
ty
:
ast
::
Ty
Kind
)
->
P
<
ast
::
Ty
>
;
fn
ty_path
(
&
self
,
ast
::
Path
)
->
P
<
ast
::
Ty
>
;
fn
ty_path
(
&
self
,
ast
::
Path
)
->
P
<
ast
::
Ty
>
;
fn
ty_sum
(
&
self
,
ast
::
Path
,
ast
::
TyParamBounds
)
->
P
<
ast
::
Ty
>
;
fn
ty_sum
(
&
self
,
ast
::
Path
,
ast
::
TyParamBounds
)
->
P
<
ast
::
Ty
>
;
fn
ty_ident
(
&
self
,
span
:
Span
,
idents
:
ast
::
Ident
)
->
P
<
ast
::
Ty
>
;
fn
ty_ident
(
&
self
,
span
:
Span
,
idents
:
ast
::
Ident
)
->
P
<
ast
::
Ty
>
;
...
@@ -385,7 +385,7 @@ fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy {
...
@@ -385,7 +385,7 @@ fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy {
}
}
}
}
fn
ty
(
&
self
,
span
:
Span
,
ty
:
ast
::
Ty
_
)
->
P
<
ast
::
Ty
>
{
fn
ty
(
&
self
,
span
:
Span
,
ty
:
ast
::
Ty
Kind
)
->
P
<
ast
::
Ty
>
{
P
(
ast
::
Ty
{
P
(
ast
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
id
:
ast
::
DUMMY_NODE_ID
,
span
:
span
,
span
:
span
,
...
@@ -394,12 +394,12 @@ fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> {
...
@@ -394,12 +394,12 @@ fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> {
}
}
fn
ty_path
(
&
self
,
path
:
ast
::
Path
)
->
P
<
ast
::
Ty
>
{
fn
ty_path
(
&
self
,
path
:
ast
::
Path
)
->
P
<
ast
::
Ty
>
{
self
.ty
(
path
.span
,
ast
::
TyPath
(
None
,
path
))
self
.ty
(
path
.span
,
ast
::
Ty
Kind
::
Path
(
None
,
path
))
}
}
fn
ty_sum
(
&
self
,
path
:
ast
::
Path
,
bounds
:
ast
::
TyParamBounds
)
->
P
<
ast
::
Ty
>
{
fn
ty_sum
(
&
self
,
path
:
ast
::
Path
,
bounds
:
ast
::
TyParamBounds
)
->
P
<
ast
::
Ty
>
{
self
.ty
(
path
.span
,
self
.ty
(
path
.span
,
ast
::
TyObjectSum
(
self
.ty_path
(
path
),
ast
::
Ty
Kind
::
ObjectSum
(
self
.ty_path
(
path
),
bounds
))
bounds
))
}
}
...
@@ -417,7 +417,7 @@ fn ty_rptr(&self,
...
@@ -417,7 +417,7 @@ fn ty_rptr(&self,
mutbl
:
ast
::
Mutability
)
mutbl
:
ast
::
Mutability
)
->
P
<
ast
::
Ty
>
{
->
P
<
ast
::
Ty
>
{
self
.ty
(
span
,
self
.ty
(
span
,
ast
::
TyRptr
(
lifetime
,
self
.ty_mt
(
ty
,
mutbl
)))
ast
::
Ty
Kind
::
Rptr
(
lifetime
,
self
.ty_mt
(
ty
,
mutbl
)))
}
}
fn
ty_ptr
(
&
self
,
fn
ty_ptr
(
&
self
,
...
@@ -426,7 +426,7 @@ fn ty_ptr(&self,
...
@@ -426,7 +426,7 @@ fn ty_ptr(&self,
mutbl
:
ast
::
Mutability
)
mutbl
:
ast
::
Mutability
)
->
P
<
ast
::
Ty
>
{
->
P
<
ast
::
Ty
>
{
self
.ty
(
span
,
self
.ty
(
span
,
ast
::
TyPtr
(
self
.ty_mt
(
ty
,
mutbl
)))
ast
::
Ty
Kind
::
Ptr
(
self
.ty_mt
(
ty
,
mutbl
)))
}
}
fn
ty_option
(
&
self
,
ty
:
P
<
ast
::
Ty
>
)
->
P
<
ast
::
Ty
>
{
fn
ty_option
(
&
self
,
ty
:
P
<
ast
::
Ty
>
)
->
P
<
ast
::
Ty
>
{
...
@@ -440,7 +440,7 @@ fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
...
@@ -440,7 +440,7 @@ fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
}
}
fn
ty_infer
(
&
self
,
span
:
Span
)
->
P
<
ast
::
Ty
>
{
fn
ty_infer
(
&
self
,
span
:
Span
)
->
P
<
ast
::
Ty
>
{
self
.ty
(
span
,
ast
::
TyInfer
)
self
.ty
(
span
,
ast
::
Ty
Kind
::
Infer
)
}
}
fn
typaram
(
&
self
,
fn
typaram
(
&
self
,
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
05d4cefd
...
@@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
...
@@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
DeclKind
::
Local
(
local
)
=>
{
DeclKind
::
Local
(
local
)
=>
{
// take it apart:
// take it apart:
let
rewritten_local
=
local
.map
(|
Local
{
id
,
pat
,
ty
,
init
,
span
,
attrs
}|
{
let
rewritten_local
=
local
.map
(|
Local
{
id
,
pat
,
ty
,
init
,
span
,
attrs
}|
{
// expand the ty since TyFixedLengthVec contains an Expr
// expand the ty since Ty
Kind::
FixedLengthVec contains an Expr
// and thus may have a macro use
// and thus may have a macro use
let
expanded_ty
=
ty
.map
(|
t
|
fld
.fold_ty
(
t
));
let
expanded_ty
=
ty
.map
(|
t
|
fld
.fold_ty
(
t
));
// expand the pat (it might contain macro uses):
// expand the pat (it might contain macro uses):
...
@@ -1133,7 +1133,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,
...
@@ -1133,7 +1133,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,
pub
fn
expand_type
(
t
:
P
<
ast
::
Ty
>
,
fld
:
&
mut
MacroExpander
)
->
P
<
ast
::
Ty
>
{
pub
fn
expand_type
(
t
:
P
<
ast
::
Ty
>
,
fld
:
&
mut
MacroExpander
)
->
P
<
ast
::
Ty
>
{
let
t
=
match
t
.node
.clone
()
{
let
t
=
match
t
.node
.clone
()
{
ast
::
Ty
_
::
Ty
Mac
(
mac
)
=>
{
ast
::
Ty
Kind
::
Mac
(
mac
)
=>
{
if
fld
.cx.ecfg.features
.unwrap
()
.type_macros
{
if
fld
.cx.ecfg.features
.unwrap
()
.type_macros
{
let
expanded_ty
=
match
expand_mac_invoc
(
mac
,
t
.span
,
let
expanded_ty
=
match
expand_mac_invoc
(
mac
,
t
.span
,
|
r
|
r
.make_ty
(),
|
r
|
r
.make_ty
(),
...
...
src/libsyntax/fold.rs
浏览文件 @
05d4cefd
...
@@ -380,46 +380,46 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
...
@@ -380,46 +380,46 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
t
.map
(|
Ty
{
id
,
node
,
span
}|
Ty
{
t
.map
(|
Ty
{
id
,
node
,
span
}|
Ty
{
id
:
fld
.new_id
(
id
),
id
:
fld
.new_id
(
id
),
node
:
match
node
{
node
:
match
node
{
TyInfer
=>
node
,
Ty
Kind
::
Infer
=>
node
,
Ty
Vec
(
ty
)
=>
Ty
Vec
(
fld
.fold_ty
(
ty
)),
Ty
Kind
::
Vec
(
ty
)
=>
TyKind
::
Vec
(
fld
.fold_ty
(
ty
)),
Ty
Ptr
(
mt
)
=>
Ty
Ptr
(
fld
.fold_mt
(
mt
)),
Ty
Kind
::
Ptr
(
mt
)
=>
TyKind
::
Ptr
(
fld
.fold_mt
(
mt
)),
TyRptr
(
region
,
mt
)
=>
{
Ty
Kind
::
Rptr
(
region
,
mt
)
=>
{
TyRptr
(
fld
.fold_opt_lifetime
(
region
),
fld
.fold_mt
(
mt
))
Ty
Kind
::
Rptr
(
fld
.fold_opt_lifetime
(
region
),
fld
.fold_mt
(
mt
))
}
}
TyBareFn
(
f
)
=>
{
Ty
Kind
::
BareFn
(
f
)
=>
{
TyBareFn
(
f
.map
(|
BareFnTy
{
lifetimes
,
unsafety
,
abi
,
decl
}|
BareFnTy
{
Ty
Kind
::
BareFn
(
f
.map
(|
BareFnTy
{
lifetimes
,
unsafety
,
abi
,
decl
}|
BareFnTy
{
lifetimes
:
fld
.fold_lifetime_defs
(
lifetimes
),
lifetimes
:
fld
.fold_lifetime_defs
(
lifetimes
),
unsafety
:
unsafety
,
unsafety
:
unsafety
,
abi
:
abi
,
abi
:
abi
,
decl
:
fld
.fold_fn_decl
(
decl
)
decl
:
fld
.fold_fn_decl
(
decl
)
}))
}))
}
}
Ty
Tup
(
tys
)
=>
Ty
Tup
(
tys
.move_map
(|
ty
|
fld
.fold_ty
(
ty
))),
Ty
Kind
::
Tup
(
tys
)
=>
TyKind
::
Tup
(
tys
.move_map
(|
ty
|
fld
.fold_ty
(
ty
))),
Ty
Paren
(
ty
)
=>
Ty
Paren
(
fld
.fold_ty
(
ty
)),
Ty
Kind
::
Paren
(
ty
)
=>
TyKind
::
Paren
(
fld
.fold_ty
(
ty
)),
TyPath
(
qself
,
path
)
=>
{
Ty
Kind
::
Path
(
qself
,
path
)
=>
{
let
qself
=
qself
.map
(|
QSelf
{
ty
,
position
}|
{
let
qself
=
qself
.map
(|
QSelf
{
ty
,
position
}|
{
QSelf
{
QSelf
{
ty
:
fld
.fold_ty
(
ty
),
ty
:
fld
.fold_ty
(
ty
),
position
:
position
position
:
position
}
}
});
});
TyPath
(
qself
,
fld
.fold_path
(
path
))
Ty
Kind
::
Path
(
qself
,
fld
.fold_path
(
path
))
}
}
TyObjectSum
(
ty
,
bounds
)
=>
{
Ty
Kind
::
ObjectSum
(
ty
,
bounds
)
=>
{
TyObjectSum
(
fld
.fold_ty
(
ty
),
Ty
Kind
::
ObjectSum
(
fld
.fold_ty
(
ty
),
fld
.fold_bounds
(
bounds
))
fld
.fold_bounds
(
bounds
))
}
}
TyFixedLengthVec
(
ty
,
e
)
=>
{
Ty
Kind
::
FixedLengthVec
(
ty
,
e
)
=>
{
TyFixedLengthVec
(
fld
.fold_ty
(
ty
),
fld
.fold_expr
(
e
))
Ty
Kind
::
FixedLengthVec
(
fld
.fold_ty
(
ty
),
fld
.fold_expr
(
e
))
}
}
TyTypeof
(
expr
)
=>
{
Ty
Kind
::
Typeof
(
expr
)
=>
{
TyTypeof
(
fld
.fold_expr
(
expr
))
Ty
Kind
::
Typeof
(
fld
.fold_expr
(
expr
))
}
}
TyPolyTraitRef
(
bounds
)
=>
{
Ty
Kind
::
PolyTraitRef
(
bounds
)
=>
{
TyPolyTraitRef
(
bounds
.move_map
(|
b
|
fld
.fold_ty_param_bound
(
b
)))
Ty
Kind
::
PolyTraitRef
(
bounds
.move_map
(|
b
|
fld
.fold_ty_param_bound
(
b
)))
}
}
TyMac
(
mac
)
=>
{
Ty
Kind
::
Mac
(
mac
)
=>
{
TyMac
(
fld
.fold_mac
(
mac
))
Ty
Kind
::
Mac
(
fld
.fold_mac
(
mac
))
}
}
},
},
span
:
fld
.new_span
(
span
)
span
:
fld
.new_span
(
span
)
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
05d4cefd
...
@@ -916,7 +916,7 @@ fn parser_done(p: Parser){
...
@@ -916,7 +916,7 @@ fn parser_done(p: Parser){
node
:
ast
::
ItemFn
(
P
(
ast
::
FnDecl
{
node
:
ast
::
ItemFn
(
P
(
ast
::
FnDecl
{
inputs
:
vec!
(
ast
::
Arg
{
inputs
:
vec!
(
ast
::
Arg
{
ty
:
P
(
ast
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
ty
:
P
(
ast
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
ast
::
TyPath
(
None
,
ast
::
Path
{
node
:
ast
::
Ty
Kind
::
Path
(
None
,
ast
::
Path
{
span
:
sp
(
10
,
13
),
span
:
sp
(
10
,
13
),
global
:
false
,
global
:
false
,
segments
:
vec!
(
segments
:
vec!
(
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
05d4cefd
...
@@ -42,10 +42,7 @@
...
@@ -42,10 +42,7 @@
use
ast
::
StrStyle
;
use
ast
::
StrStyle
;
use
ast
::
SelfKind
;
use
ast
::
SelfKind
;
use
ast
::{
Delimited
,
SequenceRepetition
,
TokenTree
,
TraitItem
,
TraitRef
};
use
ast
::{
Delimited
,
SequenceRepetition
,
TokenTree
,
TraitItem
,
TraitRef
};
use
ast
::{
Ty
,
Ty_
,
TypeBinding
,
TyMac
};
use
ast
::{
Ty
,
TyKind
,
TypeBinding
,
TyParam
,
TyParamBounds
};
use
ast
::{
TyFixedLengthVec
,
TyBareFn
,
TyTypeof
,
TyInfer
};
use
ast
::{
TyParam
,
TyParamBounds
,
TyParen
,
TyPath
,
TyPtr
};
use
ast
::{
TyRptr
,
TyTup
,
TyVec
};
use
ast
::
TypeTraitItem
;
use
ast
::
TypeTraitItem
;
use
ast
::
UnnamedField
;
use
ast
::
UnnamedField
;
use
ast
::{
ViewPath
,
ViewPathGlob
,
ViewPathList
,
ViewPathSimple
};
use
ast
::{
ViewPath
,
ViewPathGlob
,
ViewPathList
,
ViewPathSimple
};
...
@@ -1058,7 +1055,7 @@ pub fn get_lifetime(&mut self) -> ast::Ident {
...
@@ -1058,7 +1055,7 @@ pub fn get_lifetime(&mut self) -> ast::Ident {
}
}
}
}
pub
fn
parse_for_in_type
(
&
mut
self
)
->
PResult
<
'a
,
Ty
_
>
{
pub
fn
parse_for_in_type
(
&
mut
self
)
->
PResult
<
'a
,
Ty
Kind
>
{
/*
/*
Parses whatever can come after a `for` keyword in a type.
Parses whatever can come after a `for` keyword in a type.
The `for` has already been consumed.
The `for` has already been consumed.
...
@@ -1097,16 +1094,17 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> {
...
@@ -1097,16 +1094,17 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> {
Some
(
TraitTyParamBound
(
poly_trait_ref
,
TraitBoundModifier
::
None
))
.into_iter
()
Some
(
TraitTyParamBound
(
poly_trait_ref
,
TraitBoundModifier
::
None
))
.into_iter
()
.chain
(
other_bounds
.into_vec
())
.chain
(
other_bounds
.into_vec
())
.collect
();
.collect
();
Ok
(
ast
::
TyPolyTraitRef
(
all_bounds
))
Ok
(
ast
::
Ty
Kind
::
PolyTraitRef
(
all_bounds
))
}
}
}
}
pub
fn
parse_ty_path
(
&
mut
self
)
->
PResult
<
'a
,
Ty
_
>
{
pub
fn
parse_ty_path
(
&
mut
self
)
->
PResult
<
'a
,
Ty
Kind
>
{
Ok
(
TyPath
(
None
,
try!
(
self
.parse_path
(
LifetimeAndTypesWithoutColons
))))
Ok
(
Ty
Kind
::
Path
(
None
,
try!
(
self
.parse_path
(
LifetimeAndTypesWithoutColons
))))
}
}
/// parse a TyBareFn type:
/// parse a TyKind::BareFn type:
pub
fn
parse_ty_bare_fn
(
&
mut
self
,
lifetime_defs
:
Vec
<
ast
::
LifetimeDef
>
)
->
PResult
<
'a
,
Ty_
>
{
pub
fn
parse_ty_bare_fn
(
&
mut
self
,
lifetime_defs
:
Vec
<
ast
::
LifetimeDef
>
)
->
PResult
<
'a
,
TyKind
>
{
/*
/*
[unsafe] [extern "ABI"] fn <'lt> (S) -> T
[unsafe] [extern "ABI"] fn <'lt> (S) -> T
...
@@ -1134,7 +1132,7 @@ pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PRes
...
@@ -1134,7 +1132,7 @@ pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PRes
output
:
ret_ty
,
output
:
ret_ty
,
variadic
:
variadic
variadic
:
variadic
});
});
Ok
(
TyBareFn
(
P
(
BareFnTy
{
Ok
(
Ty
Kind
::
BareFn
(
P
(
BareFnTy
{
abi
:
abi
,
abi
:
abi
,
unsafety
:
unsafety
,
unsafety
:
unsafety
,
lifetimes
:
lifetime_defs
,
lifetimes
:
lifetime_defs
,
...
@@ -1308,7 +1306,7 @@ pub fn parse_ty_sum(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1308,7 +1306,7 @@ pub fn parse_ty_sum(&mut self) -> PResult<'a, P<Ty>> {
}
}
let
sp
=
mk_sp
(
lo
,
self
.last_span.hi
);
let
sp
=
mk_sp
(
lo
,
self
.last_span.hi
);
let
sum
=
ast
::
TyObjectSum
(
lhs
,
bounds
);
let
sum
=
ast
::
Ty
Kind
::
ObjectSum
(
lhs
,
bounds
);
Ok
(
P
(
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
sum
,
span
:
sp
}))
Ok
(
P
(
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
sum
,
span
:
sp
}))
}
}
...
@@ -1339,14 +1337,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1339,14 +1337,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Paren
)));
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Paren
)));
if
ts
.len
()
==
1
&&
!
last_comma
{
if
ts
.len
()
==
1
&&
!
last_comma
{
TyParen
(
ts
.into_iter
()
.nth
(
0
)
.unwrap
())
Ty
Kind
::
Paren
(
ts
.into_iter
()
.nth
(
0
)
.unwrap
())
}
else
{
}
else
{
TyTup
(
ts
)
Ty
Kind
::
Tup
(
ts
)
}
}
}
else
if
self
.check
(
&
token
::
BinOp
(
token
::
Star
))
{
}
else
if
self
.check
(
&
token
::
BinOp
(
token
::
Star
))
{
// STAR POINTER (bare pointer?)
// STAR POINTER (bare pointer?)
self
.bump
();
self
.bump
();
TyPtr
(
try!
(
self
.parse_ptr
()))
Ty
Kind
::
Ptr
(
try!
(
self
.parse_ptr
()))
}
else
if
self
.check
(
&
token
::
OpenDelim
(
token
::
Bracket
))
{
}
else
if
self
.check
(
&
token
::
OpenDelim
(
token
::
Bracket
))
{
// VECTOR
// VECTOR
try!
(
self
.expect
(
&
token
::
OpenDelim
(
token
::
Bracket
)));
try!
(
self
.expect
(
&
token
::
OpenDelim
(
token
::
Bracket
)));
...
@@ -1355,8 +1353,8 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1355,8 +1353,8 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
// Parse the `; e` in `[ i32; e ]`
// Parse the `; e` in `[ i32; e ]`
// where `e` is a const expression
// where `e` is a const expression
let
t
=
match
try!
(
self
.maybe_parse_fixed_length_of_vec
())
{
let
t
=
match
try!
(
self
.maybe_parse_fixed_length_of_vec
())
{
None
=>
TyVec
(
t
),
None
=>
Ty
Kind
::
Vec
(
t
),
Some
(
suffix
)
=>
TyFixedLengthVec
(
t
,
suffix
)
Some
(
suffix
)
=>
Ty
Kind
::
FixedLengthVec
(
t
,
suffix
)
};
};
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Bracket
)));
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Bracket
)));
t
t
...
@@ -1376,13 +1374,13 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1376,13 +1374,13 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
try!
(
self
.expect
(
&
token
::
OpenDelim
(
token
::
Paren
)));
try!
(
self
.expect
(
&
token
::
OpenDelim
(
token
::
Paren
)));
let
e
=
try!
(
self
.parse_expr
());
let
e
=
try!
(
self
.parse_expr
());
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Paren
)));
try!
(
self
.expect
(
&
token
::
CloseDelim
(
token
::
Paren
)));
TyTypeof
(
e
)
Ty
Kind
::
Typeof
(
e
)
}
else
if
self
.eat_lt
()
{
}
else
if
self
.eat_lt
()
{
let
(
qself
,
path
)
=
let
(
qself
,
path
)
=
try!
(
self
.parse_qualified_path
(
NoTypesAllowed
));
try!
(
self
.parse_qualified_path
(
NoTypesAllowed
));
TyPath
(
Some
(
qself
),
path
)
Ty
Kind
::
Path
(
Some
(
qself
),
path
)
}
else
if
self
.check
(
&
token
::
ModSep
)
||
}
else
if
self
.check
(
&
token
::
ModSep
)
||
self
.token
.is_ident
()
||
self
.token
.is_ident
()
||
self
.token
.is_path
()
{
self
.token
.is_path
()
{
...
@@ -1395,14 +1393,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1395,14 +1393,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
seq_sep_none
(),
seq_sep_none
(),
|
p
|
p
.parse_token_tree
()));
|
p
|
p
.parse_token_tree
()));
let
hi
=
self
.span.hi
;
let
hi
=
self
.span.hi
;
TyMac
(
spanned
(
lo
,
hi
,
Mac_
{
path
:
path
,
tts
:
tts
,
ctxt
:
EMPTY_CTXT
}))
Ty
Kind
::
Mac
(
spanned
(
lo
,
hi
,
Mac_
{
path
:
path
,
tts
:
tts
,
ctxt
:
EMPTY_CTXT
}))
}
else
{
}
else
{
// NAMED TYPE
// NAMED TYPE
TyPath
(
None
,
path
)
Ty
Kind
::
Path
(
None
,
path
)
}
}
}
else
if
self
.eat
(
&
token
::
Underscore
)
{
}
else
if
self
.eat
(
&
token
::
Underscore
)
{
// TYPE TO BE INFERRED
// TYPE TO BE INFERRED
TyInfer
Ty
Kind
::
Infer
}
else
{
}
else
{
let
this_token_str
=
self
.this_token_to_string
();
let
this_token_str
=
self
.this_token_to_string
();
let
msg
=
format!
(
"expected type, found `{}`"
,
this_token_str
);
let
msg
=
format!
(
"expected type, found `{}`"
,
this_token_str
);
...
@@ -1413,12 +1411,12 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
...
@@ -1413,12 +1411,12 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
Ok
(
P
(
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
t
,
span
:
sp
}))
Ok
(
P
(
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
t
,
span
:
sp
}))
}
}
pub
fn
parse_borrowed_pointee
(
&
mut
self
)
->
PResult
<
'a
,
Ty
_
>
{
pub
fn
parse_borrowed_pointee
(
&
mut
self
)
->
PResult
<
'a
,
Ty
Kind
>
{
// look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
// look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
let
opt_lifetime
=
try!
(
self
.parse_opt_lifetime
());
let
opt_lifetime
=
try!
(
self
.parse_opt_lifetime
());
let
mt
=
try!
(
self
.parse_mt
());
let
mt
=
try!
(
self
.parse_mt
());
return
Ok
(
TyRptr
(
opt_lifetime
,
mt
));
return
Ok
(
Ty
Kind
::
Rptr
(
opt_lifetime
,
mt
));
}
}
pub
fn
parse_ptr
(
&
mut
self
)
->
PResult
<
'a
,
MutTy
>
{
pub
fn
parse_ptr
(
&
mut
self
)
->
PResult
<
'a
,
MutTy
>
{
...
@@ -1498,7 +1496,7 @@ pub fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> {
...
@@ -1498,7 +1496,7 @@ pub fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> {
}
else
{
}
else
{
P
(
Ty
{
P
(
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
id
:
ast
::
DUMMY_NODE_ID
,
node
:
TyInfer
,
node
:
Ty
Kind
::
Infer
,
span
:
mk_sp
(
self
.span.lo
,
self
.span.hi
),
span
:
mk_sp
(
self
.span.lo
,
self
.span.hi
),
})
})
};
};
...
@@ -4809,7 +4807,7 @@ fn parse_item_impl(&mut self, unsafety: ast::Unsafety) -> PResult<'a, ItemInfo>
...
@@ -4809,7 +4807,7 @@ fn parse_item_impl(&mut self, unsafety: ast::Unsafety) -> PResult<'a, ItemInfo>
let
opt_trait
=
if
could_be_trait
&&
self
.eat_keyword
(
keywords
::
For
)
{
let
opt_trait
=
if
could_be_trait
&&
self
.eat_keyword
(
keywords
::
For
)
{
// New-style trait. Reinterpret the type as a trait.
// New-style trait. Reinterpret the type as a trait.
match
ty
.node
{
match
ty
.node
{
TyPath
(
None
,
ref
path
)
=>
{
Ty
Kind
::
Path
(
None
,
ref
path
)
=>
{
Some
(
TraitRef
{
Some
(
TraitRef
{
path
:
(
*
path
)
.clone
(),
path
:
(
*
path
)
.clone
(),
ref_id
:
ty
.id
,
ref_id
:
ty
.id
,
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
05d4cefd
...
@@ -957,12 +957,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
...
@@ -957,12 +957,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
try!
(
self
.maybe_print_comment
(
ty
.span.lo
));
try!
(
self
.maybe_print_comment
(
ty
.span.lo
));
try!
(
self
.ibox
(
0
));
try!
(
self
.ibox
(
0
));
match
ty
.node
{
match
ty
.node
{
ast
::
TyVec
(
ref
ty
)
=>
{
ast
::
Ty
Kind
::
Vec
(
ref
ty
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"["
));
try!
(
word
(
&
mut
self
.s
,
"["
));
try!
(
self
.print_type
(
&**
ty
));
try!
(
self
.print_type
(
&**
ty
));
try!
(
word
(
&
mut
self
.s
,
"]"
));
try!
(
word
(
&
mut
self
.s
,
"]"
));
}
}
ast
::
TyPtr
(
ref
mt
)
=>
{
ast
::
Ty
Kind
::
Ptr
(
ref
mt
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"*"
));
try!
(
word
(
&
mut
self
.s
,
"*"
));
match
mt
.mutbl
{
match
mt
.mutbl
{
ast
::
MutMutable
=>
try!
(
self
.word_nbsp
(
"mut"
)),
ast
::
MutMutable
=>
try!
(
self
.word_nbsp
(
"mut"
)),
...
@@ -970,12 +970,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
...
@@ -970,12 +970,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
}
}
try!
(
self
.print_type
(
&*
mt
.ty
));
try!
(
self
.print_type
(
&*
mt
.ty
));
}
}
ast
::
TyRptr
(
ref
lifetime
,
ref
mt
)
=>
{
ast
::
Ty
Kind
::
Rptr
(
ref
lifetime
,
ref
mt
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"&"
));
try!
(
word
(
&
mut
self
.s
,
"&"
));
try!
(
self
.print_opt_lifetime
(
lifetime
));
try!
(
self
.print_opt_lifetime
(
lifetime
));
try!
(
self
.print_mt
(
mt
));
try!
(
self
.print_mt
(
mt
));
}
}
ast
::
TyTup
(
ref
elts
)
=>
{
ast
::
Ty
Kind
::
Tup
(
ref
elts
)
=>
{
try!
(
self
.popen
());
try!
(
self
.popen
());
try!
(
self
.commasep
(
Inconsistent
,
&
elts
[
..
],
try!
(
self
.commasep
(
Inconsistent
,
&
elts
[
..
],
|
s
,
ty
|
s
.print_type
(
&**
ty
)));
|
s
,
ty
|
s
.print_type
(
&**
ty
)));
...
@@ -984,12 +984,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
...
@@ -984,12 +984,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
}
}
try!
(
self
.pclose
());
try!
(
self
.pclose
());
}
}
ast
::
TyParen
(
ref
typ
)
=>
{
ast
::
Ty
Kind
::
Paren
(
ref
typ
)
=>
{
try!
(
self
.popen
());
try!
(
self
.popen
());
try!
(
self
.print_type
(
&**
typ
));
try!
(
self
.print_type
(
&**
typ
));
try!
(
self
.pclose
());
try!
(
self
.pclose
());
}
}
ast
::
TyBareFn
(
ref
f
)
=>
{
ast
::
Ty
Kind
::
BareFn
(
ref
f
)
=>
{
let
generics
=
ast
::
Generics
{
let
generics
=
ast
::
Generics
{
lifetimes
:
f
.lifetimes
.clone
(),
lifetimes
:
f
.lifetimes
.clone
(),
ty_params
:
P
::
empty
(),
ty_params
:
P
::
empty
(),
...
@@ -1005,35 +1005,35 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
...
@@ -1005,35 +1005,35 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
&
generics
,
&
generics
,
None
));
None
));
}
}
ast
::
TyPath
(
None
,
ref
path
)
=>
{
ast
::
Ty
Kind
::
Path
(
None
,
ref
path
)
=>
{
try!
(
self
.print_path
(
path
,
false
,
0
));
try!
(
self
.print_path
(
path
,
false
,
0
));
}
}
ast
::
TyPath
(
Some
(
ref
qself
),
ref
path
)
=>
{
ast
::
Ty
Kind
::
Path
(
Some
(
ref
qself
),
ref
path
)
=>
{
try!
(
self
.print_qpath
(
path
,
qself
,
false
))
try!
(
self
.print_qpath
(
path
,
qself
,
false
))
}
}
ast
::
TyObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
ast
::
Ty
Kind
::
ObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
try!
(
self
.print_type
(
&**
ty
));
try!
(
self
.print_type
(
&**
ty
));
try!
(
self
.print_bounds
(
"+"
,
&
bounds
[
..
]));
try!
(
self
.print_bounds
(
"+"
,
&
bounds
[
..
]));
}
}
ast
::
TyPolyTraitRef
(
ref
bounds
)
=>
{
ast
::
Ty
Kind
::
PolyTraitRef
(
ref
bounds
)
=>
{
try!
(
self
.print_bounds
(
""
,
&
bounds
[
..
]));
try!
(
self
.print_bounds
(
""
,
&
bounds
[
..
]));
}
}
ast
::
TyFixedLengthVec
(
ref
ty
,
ref
v
)
=>
{
ast
::
Ty
Kind
::
FixedLengthVec
(
ref
ty
,
ref
v
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"["
));
try!
(
word
(
&
mut
self
.s
,
"["
));
try!
(
self
.print_type
(
&**
ty
));
try!
(
self
.print_type
(
&**
ty
));
try!
(
word
(
&
mut
self
.s
,
"; "
));
try!
(
word
(
&
mut
self
.s
,
"; "
));
try!
(
self
.print_expr
(
&**
v
));
try!
(
self
.print_expr
(
&**
v
));
try!
(
word
(
&
mut
self
.s
,
"]"
));
try!
(
word
(
&
mut
self
.s
,
"]"
));
}
}
ast
::
TyTypeof
(
ref
e
)
=>
{
ast
::
Ty
Kind
::
Typeof
(
ref
e
)
=>
{
try!
(
word
(
&
mut
self
.s
,
"typeof("
));
try!
(
word
(
&
mut
self
.s
,
"typeof("
));
try!
(
self
.print_expr
(
&**
e
));
try!
(
self
.print_expr
(
&**
e
));
try!
(
word
(
&
mut
self
.s
,
")"
));
try!
(
word
(
&
mut
self
.s
,
")"
));
}
}
ast
::
TyInfer
=>
{
ast
::
Ty
Kind
::
Infer
=>
{
try!
(
word
(
&
mut
self
.s
,
"_"
));
try!
(
word
(
&
mut
self
.s
,
"_"
));
}
}
ast
::
TyMac
(
ref
m
)
=>
{
ast
::
Ty
Kind
::
Mac
(
ref
m
)
=>
{
try!
(
self
.print_mac
(
m
,
token
::
Paren
));
try!
(
self
.print_mac
(
m
,
token
::
Paren
));
}
}
}
}
...
@@ -2959,7 +2959,7 @@ pub fn print_mt(&mut self, mt: &ast::MutTy) -> io::Result<()> {
...
@@ -2959,7 +2959,7 @@ pub fn print_mt(&mut self, mt: &ast::MutTy) -> io::Result<()> {
pub
fn
print_arg
(
&
mut
self
,
input
:
&
ast
::
Arg
,
is_closure
:
bool
)
->
io
::
Result
<
()
>
{
pub
fn
print_arg
(
&
mut
self
,
input
:
&
ast
::
Arg
,
is_closure
:
bool
)
->
io
::
Result
<
()
>
{
try!
(
self
.ibox
(
INDENT_UNIT
));
try!
(
self
.ibox
(
INDENT_UNIT
));
match
input
.ty.node
{
match
input
.ty.node
{
ast
::
TyInfer
if
is_closure
=>
try!
(
self
.print_pat
(
&*
input
.pat
)),
ast
::
Ty
Kind
::
Infer
if
is_closure
=>
try!
(
self
.print_pat
(
&*
input
.pat
)),
_
=>
{
_
=>
{
match
input
.pat.node
{
match
input
.pat.node
{
ast
::
PatIdent
(
_
,
ref
path1
,
_
)
if
ast
::
PatIdent
(
_
,
ref
path1
,
_
)
if
...
...
src/libsyntax/test.rs
浏览文件 @
05d4cefd
...
@@ -358,7 +358,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature {
...
@@ -358,7 +358,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature {
ast
::
ItemFn
(
ref
decl
,
_
,
_
,
_
,
ref
generics
,
_
)
=>
{
ast
::
ItemFn
(
ref
decl
,
_
,
_
,
_
,
ref
generics
,
_
)
=>
{
let
no_output
=
match
decl
.output
{
let
no_output
=
match
decl
.output
{
ast
::
FunctionRetTy
::
Default
(
..
)
=>
true
,
ast
::
FunctionRetTy
::
Default
(
..
)
=>
true
,
ast
::
FunctionRetTy
::
Ty
(
ref
t
)
if
t
.node
==
ast
::
TyTup
(
vec!
[])
=>
true
,
ast
::
FunctionRetTy
::
Ty
(
ref
t
)
if
t
.node
==
ast
::
Ty
Kind
::
Tup
(
vec!
[])
=>
true
,
_
=>
false
_
=>
false
};
};
if
decl
.inputs
.is_empty
()
if
decl
.inputs
.is_empty
()
...
@@ -395,7 +395,7 @@ fn has_test_signature(i: &ast::Item) -> bool {
...
@@ -395,7 +395,7 @@ fn has_test_signature(i: &ast::Item) -> bool {
let
input_cnt
=
decl
.inputs
.len
();
let
input_cnt
=
decl
.inputs
.len
();
let
no_output
=
match
decl
.output
{
let
no_output
=
match
decl
.output
{
ast
::
FunctionRetTy
::
Default
(
..
)
=>
true
,
ast
::
FunctionRetTy
::
Default
(
..
)
=>
true
,
ast
::
FunctionRetTy
::
Ty
(
ref
t
)
if
t
.node
==
ast
::
TyTup
(
vec!
[])
=>
true
,
ast
::
FunctionRetTy
::
Ty
(
ref
t
)
if
t
.node
==
ast
::
Ty
Kind
::
Tup
(
vec!
[])
=>
true
,
_
=>
false
_
=>
false
};
};
let
tparm_cnt
=
generics
.ty_params
.len
();
let
tparm_cnt
=
generics
.ty_params
.len
();
...
@@ -494,7 +494,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
...
@@ -494,7 +494,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
let
main_meta
=
ecx
.meta_word
(
sp
,
token
::
intern_and_get_ident
(
"main"
));
let
main_meta
=
ecx
.meta_word
(
sp
,
token
::
intern_and_get_ident
(
"main"
));
let
main_attr
=
ecx
.attribute
(
sp
,
main_meta
);
let
main_attr
=
ecx
.attribute
(
sp
,
main_meta
);
// pub fn main() { ... }
// pub fn main() { ... }
let
main_ret_ty
=
ecx
.ty
(
sp
,
ast
::
TyTup
(
vec!
[]));
let
main_ret_ty
=
ecx
.ty
(
sp
,
ast
::
Ty
Kind
::
Tup
(
vec!
[]));
let
main_body
=
ecx
.block_all
(
sp
,
vec!
[
call_test_main
],
None
);
let
main_body
=
ecx
.block_all
(
sp
,
vec!
[
call_test_main
],
None
);
let
main
=
ast
::
ItemFn
(
ecx
.fn_decl
(
vec!
[],
main_ret_ty
),
let
main
=
ast
::
ItemFn
(
ecx
.fn_decl
(
vec!
[],
main_ret_ty
),
ast
::
Unsafety
::
Normal
,
ast
::
Unsafety
::
Normal
,
...
@@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
...
@@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
let
static_lt
=
ecx
.lifetime
(
sp
,
token
::
special_idents
::
static_lifetime
.name
);
let
static_lt
=
ecx
.lifetime
(
sp
,
token
::
special_idents
::
static_lifetime
.name
);
// &'static [self::test::TestDescAndFn]
// &'static [self::test::TestDescAndFn]
let
static_type
=
ecx
.ty_rptr
(
sp
,
let
static_type
=
ecx
.ty_rptr
(
sp
,
ecx
.ty
(
sp
,
ast
::
TyVec
(
struct_type
)),
ecx
.ty
(
sp
,
ast
::
Ty
Kind
::
Vec
(
struct_type
)),
Some
(
static_lt
),
Some
(
static_lt
),
ast
::
MutImmutable
);
ast
::
MutImmutable
);
// static TESTS: $static_type = &[...];
// static TESTS: $static_type = &[...];
...
...
src/libsyntax/visit.rs
浏览文件 @
05d4cefd
...
@@ -328,45 +328,45 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -328,45 +328,45 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_ty
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
typ
:
&
'v
Ty
)
{
pub
fn
walk_ty
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
typ
:
&
'v
Ty
)
{
match
typ
.node
{
match
typ
.node
{
Ty
Vec
(
ref
ty
)
|
Ty
Paren
(
ref
ty
)
=>
{
Ty
Kind
::
Vec
(
ref
ty
)
|
TyKind
::
Paren
(
ref
ty
)
=>
{
visitor
.visit_ty
(
ty
)
visitor
.visit_ty
(
ty
)
}
}
TyPtr
(
ref
mutable_type
)
=>
{
Ty
Kind
::
Ptr
(
ref
mutable_type
)
=>
{
visitor
.visit_ty
(
&
mutable_type
.ty
)
visitor
.visit_ty
(
&
mutable_type
.ty
)
}
}
TyRptr
(
ref
opt_lifetime
,
ref
mutable_type
)
=>
{
Ty
Kind
::
Rptr
(
ref
opt_lifetime
,
ref
mutable_type
)
=>
{
walk_list!
(
visitor
,
visit_lifetime
,
opt_lifetime
);
walk_list!
(
visitor
,
visit_lifetime
,
opt_lifetime
);
visitor
.visit_ty
(
&
mutable_type
.ty
)
visitor
.visit_ty
(
&
mutable_type
.ty
)
}
}
TyTup
(
ref
tuple_element_types
)
=>
{
Ty
Kind
::
Tup
(
ref
tuple_element_types
)
=>
{
walk_list!
(
visitor
,
visit_ty
,
tuple_element_types
);
walk_list!
(
visitor
,
visit_ty
,
tuple_element_types
);
}
}
TyBareFn
(
ref
function_declaration
)
=>
{
Ty
Kind
::
BareFn
(
ref
function_declaration
)
=>
{
walk_fn_decl
(
visitor
,
&
function_declaration
.decl
);
walk_fn_decl
(
visitor
,
&
function_declaration
.decl
);
walk_list!
(
visitor
,
visit_lifetime_def
,
&
function_declaration
.lifetimes
);
walk_list!
(
visitor
,
visit_lifetime_def
,
&
function_declaration
.lifetimes
);
}
}
TyPath
(
ref
maybe_qself
,
ref
path
)
=>
{
Ty
Kind
::
Path
(
ref
maybe_qself
,
ref
path
)
=>
{
if
let
Some
(
ref
qself
)
=
*
maybe_qself
{
if
let
Some
(
ref
qself
)
=
*
maybe_qself
{
visitor
.visit_ty
(
&
qself
.ty
);
visitor
.visit_ty
(
&
qself
.ty
);
}
}
visitor
.visit_path
(
path
,
typ
.id
);
visitor
.visit_path
(
path
,
typ
.id
);
}
}
TyObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
Ty
Kind
::
ObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
visitor
.visit_ty
(
ty
);
visitor
.visit_ty
(
ty
);
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
}
}
TyFixedLengthVec
(
ref
ty
,
ref
expression
)
=>
{
Ty
Kind
::
FixedLengthVec
(
ref
ty
,
ref
expression
)
=>
{
visitor
.visit_ty
(
ty
);
visitor
.visit_ty
(
ty
);
visitor
.visit_expr
(
expression
)
visitor
.visit_expr
(
expression
)
}
}
TyPolyTraitRef
(
ref
bounds
)
=>
{
Ty
Kind
::
PolyTraitRef
(
ref
bounds
)
=>
{
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
}
}
TyTypeof
(
ref
expression
)
=>
{
Ty
Kind
::
Typeof
(
ref
expression
)
=>
{
visitor
.visit_expr
(
expression
)
visitor
.visit_expr
(
expression
)
}
}
TyInfer
=>
{}
Ty
Kind
::
Infer
=>
{}
TyMac
(
ref
mac
)
=>
{
Ty
Kind
::
Mac
(
ref
mac
)
=>
{
visitor
.visit_mac
(
mac
)
visitor
.visit_mac
(
mac
)
}
}
}
}
...
...
src/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
05d4cefd
...
@@ -354,7 +354,7 @@ struct Visitor<'a> {
...
@@ -354,7 +354,7 @@ struct Visitor<'a> {
impl
<
'a
>
visit
::
Visitor
<
'a
>
for
Visitor
<
'a
>
{
impl
<
'a
>
visit
::
Visitor
<
'a
>
for
Visitor
<
'a
>
{
fn
visit_ty
(
&
mut
self
,
ty
:
&
'a
ast
::
Ty
)
{
fn
visit_ty
(
&
mut
self
,
ty
:
&
'a
ast
::
Ty
)
{
match
ty
.node
{
match
ty
.node
{
ast
::
TyPath
(
_
,
ref
path
)
if
!
path
.global
=>
{
ast
::
Ty
Kind
::
Path
(
_
,
ref
path
)
if
!
path
.global
=>
{
match
path
.segments
.first
()
{
match
path
.segments
.first
()
{
Some
(
segment
)
=>
{
Some
(
segment
)
=>
{
if
self
.ty_param_names
.contains
(
&
segment
.identifier.name
)
{
if
self
.ty_param_names
.contains
(
&
segment
.identifier.name
)
{
...
@@ -557,7 +557,7 @@ fn create_derived_impl(&self,
...
@@ -557,7 +557,7 @@ fn create_derived_impl(&self,
for
ty
in
tys
{
for
ty
in
tys
{
// if we have already handled this type, skip it
// if we have already handled this type, skip it
if
let
ast
::
TyPath
(
_
,
ref
p
)
=
ty
.node
{
if
let
ast
::
Ty
Kind
::
Path
(
_
,
ref
p
)
=
ty
.node
{
if
p
.segments
.len
()
==
1
if
p
.segments
.len
()
==
1
&&
ty_param_names
.contains
(
&
p
.segments
[
0
]
.identifier.name
)
&&
ty_param_names
.contains
(
&
p
.segments
[
0
]
.identifier.name
)
||
processed_field_types
.contains
(
&
p
.segments
)
{
||
processed_field_types
.contains
(
&
p
.segments
)
{
...
...
src/libsyntax_ext/deriving/generic/ty.rs
浏览文件 @
05d4cefd
...
@@ -153,7 +153,7 @@ pub fn to_ty(&self,
...
@@ -153,7 +153,7 @@ pub fn to_ty(&self,
cx
.ty_path
(
self
.to_path
(
cx
,
span
,
self_ty
,
self_generics
))
cx
.ty_path
(
self
.to_path
(
cx
,
span
,
self_ty
,
self_generics
))
}
}
Tuple
(
ref
fields
)
=>
{
Tuple
(
ref
fields
)
=>
{
let
ty
=
ast
::
TyTup
(
fields
.iter
()
let
ty
=
ast
::
Ty
Kind
::
Tup
(
fields
.iter
()
.map
(|
f
|
f
.to_ty
(
cx
,
span
,
self_ty
,
self_generics
))
.map
(|
f
|
f
.to_ty
(
cx
,
span
,
self_ty
,
self_generics
))
.collect
());
.collect
());
cx
.ty
(
span
,
ty
)
cx
.ty
(
span
,
ty
)
...
...
src/libsyntax_ext/format.rs
浏览文件 @
05d4cefd
...
@@ -448,7 +448,7 @@ fn static_array(ecx: &mut ExtCtxt,
...
@@ -448,7 +448,7 @@ fn static_array(ecx: &mut ExtCtxt,
->
P
<
ast
::
Expr
>
{
->
P
<
ast
::
Expr
>
{
let
sp
=
piece_ty
.span
;
let
sp
=
piece_ty
.span
;
let
ty
=
ecx
.ty_rptr
(
sp
,
let
ty
=
ecx
.ty_rptr
(
sp
,
ecx
.ty
(
sp
,
ast
::
TyVec
(
piece_ty
)),
ecx
.ty
(
sp
,
ast
::
Ty
Kind
::
Vec
(
piece_ty
)),
Some
(
ecx
.lifetime
(
sp
,
special_idents
::
static_lifetime
.name
)),
Some
(
ecx
.lifetime
(
sp
,
special_idents
::
static_lifetime
.name
)),
ast
::
MutImmutable
);
ast
::
MutImmutable
);
let
slice
=
ecx
.expr_vec_slice
(
sp
,
pieces
);
let
slice
=
ecx
.expr_vec_slice
(
sp
,
pieces
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录