Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
401b6362
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,发现更多精彩内容 >>
提交
401b6362
编写于
7月 05, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Make meta items into interior vectors
上级
479ce4d7
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
90 addition
and
66 deletion
+90
-66
src/comp/driver/rustc.rs
src/comp/driver/rustc.rs
+10
-11
src/comp/front/attr.rs
src/comp/front/attr.rs
+16
-18
src/comp/front/config.rs
src/comp/front/config.rs
+4
-6
src/comp/metadata/creader.rs
src/comp/metadata/creader.rs
+6
-5
src/comp/metadata/decoder.rs
src/comp/metadata/decoder.rs
+7
-6
src/comp/metadata/encoder.rs
src/comp/metadata/encoder.rs
+4
-5
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+3
-3
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+2
-2
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+35
-7
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+3
-3
未找到文件。
src/comp/driver/rustc.rs
浏览文件 @
401b6362
...
...
@@ -50,13 +50,13 @@ fn default_configuration(session::session sess, str argv0, str input) ->
auto
mk
=
attr
::
mk_name_value_item_str
;
ret
[
// Target bindings.
mk
(
"target_os"
,
std
::
os
::
target_os
()),
mk
(
"target_arch"
,
"x86"
),
mk
(
"target_libc"
,
libc
),
// Build bindings.
mk
(
"build_compiler"
,
argv0
),
mk
(
"build_input"
,
input
)];
ret
~
[
// Target bindings.
mk
(
"target_os"
,
std
::
os
::
target_os
()),
mk
(
"target_arch"
,
"x86"
),
mk
(
"target_libc"
,
libc
),
// Build bindings.
mk
(
"build_compiler"
,
argv0
),
mk
(
"build_input"
,
input
)];
}
fn
build_configuration
(
session
::
session
sess
,
str
argv0
,
...
...
@@ -70,10 +70,9 @@ fn build_configuration(session::session sess, str argv0,
fn
parse_cfgspecs
(
&
vec
[
str
]
cfgspecs
)
->
ast
::
crate_cfg
{
// FIXME: It would be nice to use the parser to parse all varieties of
// meta_item here. At the moment we just support the meta_word variant.
fn
to_meta_word
(
&
str
cfgspec
)
->
@
ast
::
meta_item
{
attr
::
mk_word_item
(
cfgspec
)
}
ret
vec
::
map
(
to_meta_word
,
cfgspecs
);
auto
words
=
~
[];
for
(
str
s
in
cfgspecs
)
{
words
+=
~
[
attr
::
mk_word_item
(
s
)];
}
ret
words
;
}
fn
parse_input
(
session
::
session
sess
,
&
ast
::
crate_cfg
cfg
,
str
input
)
...
...
src/comp/front/attr.rs
浏览文件 @
401b6362
...
...
@@ -29,13 +29,11 @@
// From a list of crate attributes get only the meta_items that impact crate
// linkage
fn
find_linkage_metas
(
&
ast
::
attribute
[]
attrs
)
->
vec
[
@
ast
::
meta_item
]
{
let
vec
[
@
ast
::
meta_item
]
metas
=
[];
fn
find_linkage_metas
(
&
ast
::
attribute
[]
attrs
)
->
(
@
ast
::
meta_item
)[
]
{
let
(
@
ast
::
meta_item
)[]
metas
=
~
[];
for
(
ast
::
attribute
attr
in
find_attrs_by_name
(
attrs
,
"link"
))
{
alt
(
attr
.node.value.node
)
{
case
(
ast
::
meta_list
(
_
,
?
items
))
{
metas
+=
items
;
}
case
(
ast
::
meta_list
(
_
,
?
items
))
{
metas
+=
items
;
}
case
(
_
)
{
log
"ignoring link attribute that has incorrect type"
;
}
...
...
@@ -62,8 +60,8 @@ fn get_attr_name(&ast::attribute attr) -> ast::ident {
get_meta_item_name
(
@
attr
.node.value
)
}
fn
find_meta_items_by_name
(
vec
[
@
ast
::
meta_item
]
metas
,
ast
::
ident
name
)
->
vec
[
@
ast
::
meta_item
]
{
fn
find_meta_items_by_name
(
&
(
@
ast
::
meta_item
)[
]
metas
,
ast
::
ident
name
)
->
(
@
ast
::
meta_item
)[
]
{
auto
filter
=
bind
fn
(
&@
ast
::
meta_item
m
,
ast
::
ident
name
)
->
option
::
t
[
@
ast
::
meta_item
]
{
if
(
get_meta_item_name
(
m
)
==
name
)
{
...
...
@@ -72,7 +70,7 @@ fn find_meta_items_by_name(vec[@ast::meta_item] metas,
option
::
none
}
}
(
_
,
name
);
ret
vec
::
filter_map
(
filter
,
metas
);
ret
i
vec
::
filter_map
(
filter
,
metas
);
}
fn
get_meta_item_name
(
&@
ast
::
meta_item
meta
)
->
ast
::
ident
{
...
...
@@ -102,9 +100,9 @@ fn get_meta_item_value_str(&@ast::meta_item meta) -> option::t[str] {
fn
attr_meta
(
&
ast
::
attribute
attr
)
->
@
ast
::
meta_item
{
@
attr
.node.value
}
// Get the meta_items from inside a vector of attributes
fn
attr_metas
(
&
ast
::
attribute
[]
attrs
)
->
vec
[
@
ast
::
meta_item
]
{
auto
mitems
=
[];
for
(
ast
::
attribute
a
in
attrs
)
{
mitems
+=
[
attr_meta
(
a
)];
}
fn
attr_metas
(
&
ast
::
attribute
[]
attrs
)
->
(
@
ast
::
meta_item
)[
]
{
auto
mitems
=
~
[];
for
(
ast
::
attribute
a
in
attrs
)
{
mitems
+=
~
[
attr_meta
(
a
)];
}
ret
mitems
;
}
...
...
@@ -133,7 +131,7 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool {
}
}
fn
contains
(
&
vec
[
@
ast
::
meta_item
]
haystack
,
@
ast
::
meta_item
needle
)
->
bool
{
fn
contains
(
&
(
@
ast
::
meta_item
)[
]
haystack
,
@
ast
::
meta_item
needle
)
->
bool
{
log
#
fmt
(
"looking for %s"
,
syntax
::
print
::
pprust
::
meta_item_to_str
(
*
needle
));
for
(
@
ast
::
meta_item
item
in
haystack
)
{
...
...
@@ -182,8 +180,8 @@ fn key(&@ast::meta_item m) -> ast::ident {
ret
v2
;
}
fn
remove_meta_items_by_name
(
&
vec
[
@
ast
::
meta_item
]
items
,
str
name
)
->
vec
[
@
ast
::
meta_item
]
{
fn
remove_meta_items_by_name
(
&
(
@
ast
::
meta_item
)[
]
items
,
str
name
)
->
(
@
ast
::
meta_item
)[
]
{
auto
filter
=
bind
fn
(
&@
ast
::
meta_item
item
,
str
name
)
->
option
::
t
[
@
ast
::
meta_item
]
{
...
...
@@ -194,10 +192,10 @@ fn remove_meta_items_by_name(&vec[@ast::meta_item] items,
}
}
(
_
,
name
);
ret
vec
::
filter_map
(
filter
,
items
);
ret
i
vec
::
filter_map
(
filter
,
items
);
}
fn
require_unique_names
(
&
session
::
session
sess
,
&
vec
[
@
ast
::
meta_item
]
metas
)
{
fn
require_unique_names
(
&
session
::
session
sess
,
&
(
@
ast
::
meta_item
)[
]
metas
)
{
auto
map
=
map
::
mk_hashmap
[
str
,
()](
str
::
hash
,
str
::
eq
);
for
(
@
ast
::
meta_item
meta
in
metas
)
{
auto
name
=
get_meta_item_name
(
meta
);
...
...
@@ -222,8 +220,8 @@ fn mk_name_value_item(ast::ident name, ast::lit value) -> @ast::meta_item {
ret
@
span
(
ast
::
meta_name_value
(
name
,
value
));
}
fn
mk_list_item
(
ast
::
ident
name
,
&
vec
[
@
ast
::
meta_item
]
items
)
->
@
ast
::
meta_item
{
fn
mk_list_item
(
ast
::
ident
name
,
&
(
@
ast
::
meta_item
)[]
items
)
->
@
ast
::
meta_item
{
ret
@
span
(
ast
::
meta_list
(
name
,
items
));
}
...
...
src/comp/front/config.rs
浏览文件 @
401b6362
...
...
@@ -109,9 +109,9 @@ fn in_cfg(&ast::crate_cfg cfg, &ast::attribute[] attrs) -> bool {
// so we can match against them. This is the list of configurations for
// which the item is valid
auto
item_cfg_metas
=
{
fn
extract_metas
(
&
vec
[
@
ast
::
meta_item
]
inner_items
,
fn
extract_metas
(
&
(
@
ast
::
meta_item
)[
]
inner_items
,
&@
ast
::
meta_item
cfg_item
)
->
vec
[
@
ast
::
meta_item
]
{
->
(
@
ast
::
meta_item
)[
]
{
alt
(
cfg_item
.node
)
{
case
(
ast
::
meta_list
(
?
name
,
?
items
))
{
...
...
@@ -122,13 +122,11 @@ fn extract_metas(&vec[@ast::meta_item] inner_items,
}
}
auto
cfg_metas
=
attr
::
attr_metas
(
item_cfg_attrs
);
vec
::
foldl
(
extract_metas
,
[],
cfg_metas
)
ivec
::
foldl
(
extract_metas
,
~
[],
cfg_metas
)
};
for
(
@
ast
::
meta_item
cfg_mi
in
item_cfg_metas
)
{
if
(
attr
::
contains
(
cfg
,
cfg_mi
))
{
ret
true
;
}
if
(
attr
::
contains
(
cfg
,
cfg_mi
))
{
ret
true
;
}
}
ret
false
;
...
...
src/comp/metadata/creader.rs
浏览文件 @
401b6362
...
...
@@ -12,6 +12,7 @@
import
syntax
::
codemap
::
span
;
import
back
::
x86
;
import
util
::
common
;
import
std
::
ivec
;
import
std
::
str
;
import
std
::
vec
;
import
std
::
ebml
;
...
...
@@ -28,12 +29,12 @@
export
list_file_metadata
;
fn
metadata_matches
(
&
vec
[
u8
]
crate_data
,
&
vec
[
@
ast
::
meta_item
]
metas
)
->
bool
{
&
(
@
ast
::
meta_item
)[
]
metas
)
->
bool
{
auto
attrs
=
decoder
::
get_crate_attributes
(
crate_data
);
auto
linkage_metas
=
attr
::
find_linkage_metas
(
attrs
);
log
#
fmt
(
"matching %u metadata requirements against %u items"
,
vec
::
len
(
metas
),
vec
::
len
(
linkage_metas
));
ivec
::
len
(
metas
),
i
vec
::
len
(
linkage_metas
));
for
(
@
ast
::
meta_item
needed
in
metas
)
{
if
(
!
attr
::
contains
(
linkage_metas
,
needed
))
{
...
...
@@ -54,7 +55,7 @@ fn default_native_lib_naming(session::session sess) ->
}
fn
find_library_crate
(
&
session
::
session
sess
,
&
ast
::
ident
ident
,
&
vec
[
@
ast
::
meta_item
]
metas
,
&
(
@
ast
::
meta_item
)[
]
metas
,
&
vec
[
str
]
library_search_paths
)
->
option
::
t
[
tup
(
str
,
vec
[
u8
])]
{
...
...
@@ -62,7 +63,7 @@ fn find_library_crate(&session::session sess, &ast::ident ident,
auto
crate_name
=
{
auto
name_items
=
attr
::
find_meta_items_by_name
(
metas
,
"name"
);
alt
(
vec
::
last
(
name_items
))
{
alt
(
i
vec
::
last
(
name_items
))
{
case
(
some
(
?
i
))
{
alt
(
attr
::
get_meta_item_value_str
(
i
))
{
case
(
some
(
?
n
))
{
n
}
...
...
@@ -133,7 +134,7 @@ fn get_metadata_section(str filename) -> option::t[vec[u8]] {
}
fn
load_library_crate
(
&
session
::
session
sess
,
span
span
,
int
cnum
,
&
ast
::
ident
ident
,
vec
[
@
ast
::
meta_item
]
metas
,
&
ast
::
ident
ident
,
&
(
@
ast
::
meta_item
)[
]
metas
,
&
vec
[
str
]
library_search_paths
)
{
alt
(
find_library_crate
(
sess
,
ident
,
metas
,
library_search_paths
))
{
case
(
some
(
?
t
))
{
...
...
src/comp/metadata/decoder.rs
浏览文件 @
401b6362
// Metadata decoding
import
std
::
ebml
;
import
std
::
ivec
;
import
std
::
option
;
import
std
::
vec
;
import
std
::
str
;
...
...
@@ -262,13 +263,13 @@ fn item_kind_to_str(u8 kind) -> str {
}
}
fn
get_meta_items
(
&
ebml
::
doc
md
)
->
vec
[
@
ast
::
meta_item
]
{
let
vec
[
@
ast
::
meta_item
]
items
=
[];
fn
get_meta_items
(
&
ebml
::
doc
md
)
->
(
@
ast
::
meta_item
)[
]
{
let
(
@
ast
::
meta_item
)[]
items
=
~
[];
for
each
(
ebml
::
doc
meta_item_doc
in
ebml
::
tagged_docs
(
md
,
tag_meta_item_word
))
{
auto
nd
=
ebml
::
get_doc
(
meta_item_doc
,
tag_meta_item_name
);
auto
n
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
nd
));
items
+=
[
attr
::
mk_word_item
(
n
)];
items
+=
~
[
attr
::
mk_word_item
(
n
)];
}
for
each
(
ebml
::
doc
meta_item_doc
in
ebml
::
tagged_docs
(
md
,
tag_meta_item_name_value
))
{
...
...
@@ -278,14 +279,14 @@ fn get_meta_items(&ebml::doc md) -> vec[@ast::meta_item] {
auto
v
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
vd
));
// FIXME (#611): Should be able to decode meta_name_value variants,
// but currently they can't be encoded
items
+=
[
attr
::
mk_name_value_item_str
(
n
,
v
)];
items
+=
~
[
attr
::
mk_name_value_item_str
(
n
,
v
)];
}
for
each
(
ebml
::
doc
meta_item_doc
in
ebml
::
tagged_docs
(
md
,
tag_meta_item_list
))
{
auto
nd
=
ebml
::
get_doc
(
meta_item_doc
,
tag_meta_item_name
);
auto
n
=
str
::
unsafe_from_bytes
(
ebml
::
doc_data
(
nd
));
auto
subitems
=
get_meta_items
(
meta_item_doc
);
items
+=
[
attr
::
mk_list_item
(
n
,
subitems
)];
items
+=
~
[
attr
::
mk_list_item
(
n
,
subitems
)];
}
ret
items
;
}
...
...
@@ -299,7 +300,7 @@ fn get_attributes(&ebml::doc md) -> ast::attribute[] {
auto
meta_items
=
get_meta_items
(
attr_doc
);
// Currently it's only possible to have a single meta item on
// an attribute
assert
(
vec
::
len
(
meta_items
)
==
1u
);
assert
(
i
vec
::
len
(
meta_items
)
==
1u
);
auto
meta_item
=
meta_items
.
(
0
);
attrs
+=
~
[
rec
(
node
=
rec
(
style
=
ast
::
attr_outer
,
value
=*
meta_item
),
...
...
src/comp/metadata/encoder.rs
浏览文件 @
401b6362
...
...
@@ -473,9 +473,8 @@ fn encode_attributes(&ebml::writer ebml_w, &vec[attribute] attrs) {
fn
synthesize_crate_attrs
(
&@
crate_ctxt
cx
,
&@
crate
crate
)
->
vec
[
attribute
]
{
fn
synthesize_link_attr
(
&@
crate_ctxt
cx
,
&
vec
[
@
meta_item
]
items
)
->
attribute
{
fn
synthesize_link_attr
(
&@
crate_ctxt
cx
,
&
(
@
meta_item
)[]
items
)
->
attribute
{
assert
cx
.link_meta.name
!=
""
;
assert
cx
.link_meta.vers
!=
""
;
...
...
@@ -490,7 +489,7 @@ fn synthesize_link_attr(&@crate_ctxt cx,
attr
::
remove_meta_items_by_name
(
tmp
,
"vers"
)
};
auto
meta_items
=
[
name_item
]
+
[
vers_item
]
+
other_items
;
auto
meta_items
=
~
[
name_item
,
vers_item
]
+
other_items
;
auto
link_item
=
attr
::
mk_list_item
(
"link"
,
meta_items
);
ret
attr
::
mk_attr
(
link_item
);
...
...
@@ -513,7 +512,7 @@ fn synthesize_link_attr(&@crate_ctxt cx,
}
if
(
!
found_link_attr
)
{
attrs
+=
[
synthesize_link_attr
(
cx
,
[])];
attrs
+=
[
synthesize_link_attr
(
cx
,
~
[])];
}
ret
attrs
;
...
...
src/comp/syntax/ast.rs
浏览文件 @
401b6362
...
...
@@ -81,7 +81,7 @@ fn def_id_of_def(def d) -> def_id {
// The set of meta_items that define the compilation environment of the crate,
// used to drive conditional compilation
type
crate_cfg
=
vec
[
@
meta_item
];
type
crate_cfg
=
(
@
meta_item
)[
];
type
crate
=
spanned
[
crate_
];
...
...
@@ -105,7 +105,7 @@ fn def_id_of_def(def d) -> def_id {
tag
meta_item_
{
meta_word
(
ident
);
meta_list
(
ident
,
vec
[
@
meta_item
]);
meta_list
(
ident
,
(
@
meta_item
)[
]);
meta_name_value
(
ident
,
lit
);
}
...
...
@@ -505,7 +505,7 @@ fn ty_mach_to_str(ty_mach tm) -> str {
type
view_item
=
spanned
[
view_item_
];
tag
view_item_
{
view_item_use
(
ident
,
vec
[
@
meta_item
],
node_id
);
view_item_use
(
ident
,
(
@
meta_item
)[
],
node_id
);
view_item_import
(
ident
,
vec
[
ident
],
node_id
);
view_item_import_glob
(
vec
[
ident
],
node_id
);
view_item_export
(
ident
,
node_id
);
...
...
src/comp/syntax/fold.rs
浏览文件 @
401b6362
...
...
@@ -104,7 +104,7 @@ fn fold_meta_item_(&@meta_item mi, ast_fold fld) -> @meta_item {
case
(
meta_word
(
?
id
))
{
meta_word
(
fld
.fold_ident
(
id
))
}
case
(
meta_list
(
?
id
,
?
mis
))
{
auto
fold_meta_item
=
bind
fold_meta_item_
(
_
,
fld
);
meta_list
(
id
,
map
(
fold_meta_item
,
mis
))
meta_list
(
id
,
ivec
::
map
(
fold_meta_item
,
mis
))
}
case
(
meta_name_value
(
?
id
,
?
s
))
{
meta_name_value
(
fld
.fold_ident
(
id
),
s
)
...
...
@@ -135,7 +135,7 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
ret
rec
(
directives
=
ivec
::
map
(
fld
.fold_crate_directive
,
c
.directives
),
module
=
fld
.fold_mod
(
c
.module
),
attrs
=
ivec
::
map
(
fold_attribute
,
c
.attrs
),
config
=
vec
::
map
(
fold_meta_item
,
c
.config
));
config
=
i
vec
::
map
(
fold_meta_item
,
c
.config
));
}
fn
noop_fold_crate_directive
(
&
crate_directive_
cd
,
ast_fold
fld
)
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
401b6362
...
...
@@ -591,6 +591,24 @@ fn parse_seq_to_end[T](token::token ket, option::t[token::token] sep,
ret
v
;
}
fn
parse_seq_to_end_ivec
[
T
](
token
::
token
ket
,
option
::
t
[
token
::
token
]
sep
,
fn
(
&
parser
)
->
T
f
,
&
parser
p
)
->
T
[]
{
let
bool
first
=
true
;
let
T
[]
v
=
~
[];
while
(
p
.peek
()
!=
ket
)
{
alt
(
sep
)
{
case
(
some
(
?
t
))
{
if
(
first
)
{
first
=
false
;
}
else
{
expect
(
p
,
t
);
}
}
case
(
_
)
{
}
}
v
+=
~
[
f
(
p
)];
}
expect
(
p
,
ket
);
ret
v
;
}
fn
parse_seq
[
T
](
token
::
token
bra
,
token
::
token
ket
,
option
::
t
[
token
::
token
]
sep
,
fn
(
&
parser
)
->
T
f
,
&
parser
p
)
->
ast
::
spanned
[
vec
[
T
]]
{
...
...
@@ -601,6 +619,17 @@ fn parse_seq[T](token::token bra, token::token ket,
ret
spanned
(
lo
,
hi
,
result
);
}
fn
parse_seq_ivec
[
T
](
token
::
token
bra
,
token
::
token
ket
,
option
::
t
[
token
::
token
]
sep
,
fn
(
&
parser
)
->
T
f
,
&
parser
p
)
->
ast
::
spanned
[
T
[]]
{
auto
lo
=
p
.get_lo_pos
();
expect
(
p
,
bra
);
auto
result
=
parse_seq_to_end_ivec
[
T
](
ket
,
sep
,
f
,
p
);
auto
hi
=
p
.get_hi_pos
();
ret
spanned
(
lo
,
hi
,
result
);
}
fn
parse_lit
(
&
parser
p
)
->
ast
::
lit
{
auto
sp
=
p
.get_span
();
let
ast
::
lit_
lit
=
ast
::
lit_nil
;
...
...
@@ -2185,15 +2214,15 @@ fn parse_meta_item(&parser p) -> @ast::meta_item {
}
}
fn
parse_meta_seq
(
&
parser
p
)
->
vec
[
@
ast
::
meta_item
]
{
ret
parse_seq
(
token
::
LPAREN
,
token
::
RPAREN
,
some
(
token
::
COMMA
),
parse_meta_item
,
p
)
.node
;
fn
parse_meta_seq
(
&
parser
p
)
->
(
@
ast
::
meta_item
)[
]
{
ret
parse_seq
_ivec
(
token
::
LPAREN
,
token
::
RPAREN
,
some
(
token
::
COMMA
),
parse_meta_item
,
p
)
.node
;
}
fn
parse_optional_meta
(
&
parser
p
)
->
vec
[
@
ast
::
meta_item
]
{
fn
parse_optional_meta
(
&
parser
p
)
->
(
@
ast
::
meta_item
)[
]
{
alt
(
p
.peek
())
{
case
(
token
::
LPAREN
)
{
ret
parse_meta_seq
(
p
);
}
case
(
_
)
{
let
vec
[
@
ast
::
meta_item
]
v
=
[];
ret
v
;
}
case
(
_
)
{
ret
~
[]
;
}
}
}
...
...
@@ -2203,8 +2232,7 @@ fn parse_use(&parser p) -> @ast::view_item {
auto
metadata
=
parse_optional_meta
(
p
);
auto
hi
=
p
.get_hi_pos
();
expect
(
p
,
token
::
SEMI
);
auto
use_decl
=
ast
::
view_item_use
(
ident
,
metadata
,
p
.get_id
());
auto
use_decl
=
ast
::
view_item_use
(
ident
,
metadata
,
p
.get_id
());
ret
@
spanned
(
lo
,
hi
,
use_decl
);
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
401b6362
...
...
@@ -1118,7 +1118,7 @@ fn print_meta_item(&ps s, &@ast::meta_item item) {
case
(
ast
::
meta_list
(
?
name
,
?
items
))
{
word
(
s
.s
,
name
);
popen
(
s
);
commasep
(
s
,
consistent
,
items
,
print_meta_item
);
commasep
_ivec
(
s
,
consistent
,
items
,
print_meta_item
);
pclose
(
s
);
}
}
...
...
@@ -1132,9 +1132,9 @@ fn print_view_item(&ps s, &@ast::view_item item) {
case
(
ast
::
view_item_use
(
?
id
,
?
mta
,
_
))
{
head
(
s
,
"use"
);
word
(
s
.s
,
id
);
if
(
vec
::
len
(
mta
)
>
0u
)
{
if
(
i
vec
::
len
(
mta
)
>
0u
)
{
popen
(
s
);
commasep
(
s
,
consistent
,
mta
,
print_meta_item
);
commasep
_ivec
(
s
,
consistent
,
mta
,
print_meta_item
);
pclose
(
s
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录