Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dd610a15
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,发现更多精彩内容 >>
提交
dd610a15
编写于
3月 12, 2012
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Add node IDs to AST types so we can associate them with region environments
上级
d6081314
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
84 addition
and
37 deletion
+84
-37
src/rustc/front/test.rs
src/rustc/front/test.rs
+16
-6
src/rustc/metadata/astencode_gen.rs
src/rustc/metadata/astencode_gen.rs
+12
-6
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+2
-1
src/rustc/syntax/ast.rs
src/rustc/syntax/ast.rs
+1
-1
src/rustc/syntax/fold.rs
src/rustc/syntax/fold.rs
+1
-1
src/rustc/syntax/parse/parser.rs
src/rustc/syntax/parse/parser.rs
+43
-19
src/rustc/syntax/print/pprust.rs
src/rustc/syntax/print/pprust.rs
+9
-3
未找到文件。
src/rustc/front/test.rs
浏览文件 @
dd610a15
...
...
@@ -254,11 +254,15 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
types
:
[]});
let
test_desc_ty
:
ast
::
ty
=
nospan
(
ast
::
ty_path
(
test_desc_ty_path
,
cx
.sess
.next_node_id
()));
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_path
(
test_desc_ty_path
,
cx
.sess
.next_node_id
()),
span
:
dummy_sp
()};
let
vec_mt
:
ast
::
mt
=
{
ty
:
@
test_desc_ty
,
mutbl
:
ast
::
m_imm
};
ret
@
nospan
(
ast
::
ty_vec
(
vec_mt
));
ret
@
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_vec
(
vec_mt
),
span
:
dummy_sp
()};
}
fn
mk_test_desc_vec
(
cx
:
test_ctxt
)
->
@
ast
::
expr
{
...
...
@@ -346,7 +350,7 @@ fn mk_test_wrapper(cx: test_ctxt,
let
wrapper_decl
:
ast
::
fn_decl
=
{
inputs
:
[],
output
:
@
nospan
(
ast
::
ty_nil
)
,
output
:
@
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_nil
,
span
:
span
}
,
purity
:
ast
::
impure_fn
,
cf
:
ast
::
return_val
,
constraints
:
[]
...
...
@@ -377,9 +381,13 @@ fn mk_test_wrapper(cx: test_ctxt,
fn
mk_main
(
cx
:
test_ctxt
)
->
@
ast
::
item
{
let
str_pt
=
@
nospan
({
global
:
false
,
idents
:
[
"str"
],
types
:
[]});
let
str_ty
=
@
nospan
(
ast
::
ty_path
(
str_pt
,
cx
.sess
.next_node_id
()));
let
str_ty
=
@
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_path
(
str_pt
,
cx
.sess
.next_node_id
()),
span
:
dummy_sp
()};
let
args_mt
:
ast
::
mt
=
{
ty
:
str_ty
,
mutbl
:
ast
::
m_imm
};
let
args_ty
:
ast
::
ty
=
nospan
(
ast
::
ty_vec
(
args_mt
));
let
args_ty
:
ast
::
ty
=
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_vec
(
args_mt
),
span
:
dummy_sp
()};
let
args_arg
:
ast
::
arg
=
{
mode
:
ast
::
expl
(
ast
::
by_val
),
...
...
@@ -387,7 +395,9 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
ident
:
"args"
,
id
:
cx
.sess
.next_node_id
()};
let
ret_ty
=
nospan
(
ast
::
ty_nil
);
let
ret_ty
=
{
id
:
cx
.sess
.next_node_id
(),
node
:
ast
::
ty_nil
,
span
:
dummy_sp
()};
let
decl
:
ast
::
fn_decl
=
{
inputs
:
[
args_arg
],
...
...
src/rustc/metadata/astencode_gen.rs
浏览文件 @
dd610a15
...
...
@@ -3463,12 +3463,15 @@ fn serialize_31<S: std::serialization::serializer>(s: S,
/*syntax::ast::ty*/
fn
serialize_30
<
S
:
std
::
serialization
::
serializer
>
(
s
:
S
,
v
:
syntax
::
ast
::
ty
)
{
s
.emit_rec
(
/*syntax::ast::ty_*//*syntax::codemap::span*/
s
.emit_rec
(
/*syntax::ast::node_id*//*syntax::ast::ty_*/
/*syntax::codemap::span*/
{||
{
s
.emit_rec_field
(
"node"
,
0u
,
s
.emit_rec_field
(
"id"
,
0u
,
{||
serialize_27
(
s
,
v
.id
)
});
s
.emit_rec_field
(
"node"
,
1u
,
{||
serialize_31
(
s
,
v
.node
)
});
s
.emit_rec_field
(
"span"
,
1
u
,
s
.emit_rec_field
(
"span"
,
2
u
,
{||
serialize_19
(
s
,
v
.span
)
})
}
});
...
...
@@ -7325,15 +7328,18 @@ fn deserialize_30<S: std::serialization::deserializer>(s: S) ->
s
.read_rec
(
/*syntax::ast::node_id*/
/*syntax::ast::ty_*/
/*syntax::codemap::span*/
{||
{
node
:
s
.read_rec_field
(
"node"
,
0u
,
{||
deserialize_31
(
s
)
}),
{
id
:
s
.read_rec_field
(
"id"
,
0u
,
{||
deserialize_27
(
s
)
}),
node
:
s
.read_rec_field
(
"node"
,
1u
,
{||
deserialize_31
(
s
)
}),
span
:
s
.read_rec_field
(
"span"
,
1
u
,
s
.read_rec_field
(
"span"
,
2
u
,
{||
deserialize_19
(
s
)
}),}
})
...
...
src/rustc/middle/trans/base.rs
浏览文件 @
dd610a15
...
...
@@ -4419,7 +4419,8 @@ fn trans_item(ccx: crate_ctxt, item: ast::item) {
node
:
ast
::
pat_ident
(
rslt_path
,
none
),
span
:
ctor
.node.body.span
};
// Set up obj's type
let
rslt_ast_ty
:
@
ast
::
ty
=
@
{
node
:
ast
::
ty_infer
,
let
rslt_ast_ty
:
@
ast
::
ty
=
@
{
id
:
ccx
.sess
.next_node_id
(),
node
:
ast
::
ty_infer
,
span
:
ctor
.node.body.span
};
// kludgy
let
ty_args
=
[],
i
=
0u
;
...
...
src/rustc/syntax/ast.rs
浏览文件 @
dd610a15
...
...
@@ -334,7 +334,7 @@ enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
enum
float_ty
{
ty_f
,
ty_f32
,
ty_f64
,
}
type
ty
=
spanned
<
ty_
>
;
type
ty
=
{
id
:
node_id
,
node
:
ty_
,
span
:
span
}
;
// Not represented directly in the AST, referred to by name through a ty_path.
enum
prim_ty
{
...
...
src/rustc/syntax/fold.rs
浏览文件 @
dd610a15
...
...
@@ -699,7 +699,7 @@ fn f_expr(afp: ast_fold_precursor, f: ast_fold, &&x: @expr) -> @expr {
}
fn
f_ty
(
afp
:
ast_fold_precursor
,
f
:
ast_fold
,
&&
x
:
@
ty
)
->
@
ty
{
let
(
n
,
s
)
=
afp
.fold_ty
(
x
.node
,
x
.span
,
f
);
ret
@
{
node
:
n
,
span
:
afp
.new_span
(
s
)};
ret
@
{
id
:
x
.id
,
node
:
n
,
span
:
afp
.new_span
(
s
)};
}
fn
f_constr
(
afp
:
ast_fold_precursor
,
f
:
ast_fold
,
&&
x
:
@
ast
::
constr
)
->
@
ast
::
constr
{
...
...
src/rustc/syntax/parse/parser.rs
浏览文件 @
dd610a15
...
...
@@ -385,7 +385,11 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool,
expect
(
p
,
token
::
LT
);
}
else
if
!
colons_before_params
&&
p
.token
==
token
::
LT
{
p
.bump
();
}
else
{
ret
@
spanned
(
lo
,
p
.last_span.hi
,
orig_t
);
}
}
else
{
ret
@
{
id
:
p
.get_id
(),
node
:
orig_t
,
span
:
ast_util
::
mk_sp
(
lo
,
p
.last_span.hi
)};
}
// If we're here, we have explicit type parameter instantiation.
let
seq
=
parse_seq_to_gt
(
some
(
token
::
COMMA
),
{|
p
|
parse_ty
(
p
,
false
)},
...
...
@@ -393,11 +397,12 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool,
alt
orig_t
{
ast
::
ty_path
(
pth
,
ann
)
{
ret
@
spanned
(
lo
,
p
.last_span.hi
,
ast
::
ty_path
(
@
spanned
(
lo
,
p
.last_span.hi
,
{
global
:
pth
.node.global
,
idents
:
pth
.node.idents
,
types
:
seq
}),
ann
));
ret
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_path
(
@
spanned
(
lo
,
p
.last_span.hi
,
{
global
:
pth
.node.global
,
idents
:
pth
.node.idents
,
types
:
seq
}),
ann
),
span
:
ast_util
::
mk_sp
(
lo
,
p
.last_span.hi
)};
}
_
{
p
.fatal
(
"type parameter instantiation only allowed for paths"
);
}
}
...
...
@@ -407,11 +412,17 @@ fn parse_ret_ty(p: parser) -> (ast::ret_style, @ast::ty) {
ret
if
eat
(
p
,
token
::
RARROW
)
{
let
lo
=
p
.span.lo
;
if
eat
(
p
,
token
::
NOT
)
{
(
ast
::
noreturn
,
@
spanned
(
lo
,
p
.last_span.hi
,
ast
::
ty_bot
))
}
else
{
(
ast
::
return_val
,
parse_ty
(
p
,
false
))
}
(
ast
::
noreturn
,
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_bot
,
span
:
ast_util
::
mk_sp
(
lo
,
p
.last_span.hi
)})
}
else
{
(
ast
::
return_val
,
parse_ty
(
p
,
false
))
}
}
else
{
let
pos
=
p
.span.lo
;
(
ast
::
return_val
,
@
spanned
(
pos
,
pos
,
ast
::
ty_nil
))
(
ast
::
return_val
,
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_nil
,
span
:
ast_util
::
mk_sp
(
pos
,
pos
)})
}
}
...
...
@@ -435,8 +446,11 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
let
lo
=
p
.span.lo
;
alt
have_dollar
(
p
)
{
some
(
e
)
{
ret
@
spanned
(
lo
,
p
.span.hi
,
ast
::
ty_mac
(
spanned
(
lo
,
p
.span.hi
,
e
)))}
some
(
e
)
{
ret
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_mac
(
spanned
(
lo
,
p
.span.hi
,
e
)),
span
:
ast_util
::
mk_sp
(
lo
,
p
.span.hi
)};
}
none
{}
}
...
...
@@ -475,7 +489,10 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
let
t
=
ast
::
ty_rec
(
elems
.node
);
if
p
.token
==
token
::
COLON
{
p
.bump
();
ast
::
ty_constr
(
@
spanned
(
lo
,
hi
,
t
),
parse_type_constraints
(
p
))
ast
::
ty_constr
(
@
{
id
:
p
.get_id
(),
node
:
t
,
span
:
ast_util
::
mk_sp
(
lo
,
hi
)},
parse_type_constraints
(
p
))
}
else
{
t
}
}
else
if
p
.token
==
token
::
LBRACKET
{
expect
(
p
,
token
::
LBRACKET
);
...
...
@@ -534,7 +551,9 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
let
t
=
if
eat
(
p
,
token
::
COLON
)
{
parse_ty
(
p
,
false
)
}
else
{
@
spanned
(
p
.span.lo
,
p
.span.hi
,
ast
::
ty_infer
)
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_infer
,
span
:
ast_util
::
mk_sp
(
p
.span.lo
,
p
.span.hi
)}
};
ret
{
mode
:
m
,
ty
:
t
,
ident
:
i
,
id
:
p
.get_id
()};
}
...
...
@@ -1606,7 +1625,9 @@ fn parse_local(p: parser, is_mutbl: bool,
allow_init
:
bool
)
->
@
ast
::
local
{
let
lo
=
p
.span.lo
;
let
pat
=
parse_pat
(
p
);
let
ty
=
@
spanned
(
lo
,
lo
,
ast
::
ty_infer
);
let
ty
=
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_infer
,
span
:
ast_util
::
mk_sp
(
lo
,
lo
)};
if
eat
(
p
,
token
::
COLON
)
{
ty
=
parse_ty
(
p
,
false
);
}
let
init
=
if
allow_init
{
parse_initializer
(
p
)
}
else
{
none
};
ret
@
spanned
(
lo
,
p
.last_span.hi
,
...
...
@@ -1882,7 +1903,7 @@ fn parse_fn_block_decl(p: parser) -> ast::fn_decl {
let
output
=
if
eat
(
p
,
token
::
RARROW
)
{
parse_ty
(
p
,
false
)
}
else
{
@
spanned
(
p
.span.lo
,
p
.span.hi
,
ast
::
ty_infer
)
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_infer
,
span
:
p
.span
}
};
ret
{
inputs
:
inputs
,
output
:
output
,
...
...
@@ -1957,7 +1978,7 @@ fn parse_item_iface(p: parser, attrs: [ast::attribute]) -> @ast::item {
fn
parse_item_impl
(
p
:
parser
,
attrs
:
[
ast
::
attribute
])
->
@
ast
::
item
{
let
lo
=
p
.last_span.lo
;
fn
wrap_path
(
p
:
parser
,
pt
:
@
ast
::
path
)
->
@
ast
::
ty
{
@
{
node
:
ast
::
ty_path
(
pt
,
p
.get_id
()),
span
:
pt
.span
}
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_path
(
pt
,
p
.get_id
()),
span
:
pt
.span
}
}
let
(
ident
,
tps
)
=
if
!
is_word
(
p
,
"of"
)
{
if
p
.token
==
token
::
LT
{
(
none
,
parse_ty_params
(
p
))
}
...
...
@@ -1996,7 +2017,9 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
{
inputs
:
[{
mode
:
ast
::
expl
(
ast
::
by_ref
),
ty
:
t
,
ident
:
arg_ident
,
id
:
p
.get_id
()}],
output
:
@
spanned
(
lo
,
lo
,
ast
::
ty_nil
),
output
:
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_nil
,
span
:
ast_util
::
mk_sp
(
lo
,
lo
)},
purity
:
ast
::
impure_fn
,
cf
:
ast
::
return_val
,
constraints
:
[]};
...
...
@@ -2066,8 +2089,9 @@ fn parse_class_item(p:parser, class_name:@ast::path) -> class_contents {
// Can ctors have attrs?
// result type is always the type of the class
let
decl_
=
parse_fn_decl
(
p
,
ast
::
impure_fn
);
let
decl
=
{
output
:
@
{
node
:
ast
::
ty_path
(
class_name
,
p
.get_id
()),
span
:
decl_
.output.span
}
let
decl
=
{
output
:
@
{
id
:
p
.get_id
(),
node
:
ast
::
ty_path
(
class_name
,
p
.get_id
()),
span
:
decl_
.output.span
}
with
decl_
};
let
body
=
parse_block
(
p
);
ret
ctor_decl
(
decl
,
body
,
ast_util
::
mk_sp
(
lo
,
p
.last_span.hi
));
...
...
src/rustc/syntax/print/pprust.rs
浏览文件 @
dd610a15
...
...
@@ -114,7 +114,9 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
fn
test_fun_to_str
()
{
let
decl
:
ast
::
fn_decl
=
{
inputs
:
[],
output
:
@
ast_util
::
respan
(
ast_util
::
dummy_sp
(),
ast
::
ty_nil
),
output
:
@
{
id
:
0
,
node
:
ast
::
ty_nil
,
span
:
ast_util
::
dummy_sp
()},
purity
:
ast
::
impure_fn
,
cf
:
ast
::
return_val
,
constraints
:
[]
...
...
@@ -138,11 +140,15 @@ fn test_res_to_str() {
let
decl
:
ast
::
fn_decl
=
{
inputs
:
[{
mode
:
ast
::
expl
(
ast
::
by_val
),
ty
:
@
ast_util
::
respan
(
ast_util
::
dummy_sp
(),
ast
::
ty_nil
),
ty
:
@
{
id
:
0
,
node
:
ast
::
ty_nil
,
span
:
ast_util
::
dummy_sp
()},
ident
:
"b"
,
id
:
0
}],
output
:
@
ast_util
::
respan
(
ast_util
::
dummy_sp
(),
ast
::
ty_nil
),
output
:
@
{
id
:
0
,
node
:
ast
::
ty_nil
,
span
:
ast_util
::
dummy_sp
()},
purity
:
ast
::
impure_fn
,
cf
:
ast
::
return_val
,
constraints
:
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录