Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4ae91e29
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,发现更多精彩内容 >>
提交
4ae91e29
编写于
2月 26, 2013
作者:
E
Erick Tryzelaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libsyntax: add explicit copies
上级
8d239a25
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
101 addition
and
61 deletion
+101
-61
src/libsyntax/parse/attr.rs
src/libsyntax/parse/attr.rs
+9
-3
src/libsyntax/parse/comments.rs
src/libsyntax/parse/comments.rs
+5
-5
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+13
-8
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+67
-38
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+7
-7
未找到文件。
src/libsyntax/parse/attr.rs
浏览文件 @
4ae91e29
...
...
@@ -46,7 +46,10 @@ fn parse_outer_attributes() -> ~[ast::attribute] {
}
token
::
DOC_COMMENT
(
s
)
=>
{
let
attr
=
::
attr
::
mk_sugared_doc_attr
(
*
self
.id_to_str
(
s
),
self
.span.lo
,
self
.span.hi
);
copy
*
self
.id_to_str
(
s
),
self
.span.lo
,
self
.span.hi
);
if
attr
.node.style
!=
ast
::
attr_outer
{
self
.fatal
(
~
"expected outer comment"
);
}
...
...
@@ -113,7 +116,10 @@ fn parse_inner_attrs_and_next() ->
}
token
::
DOC_COMMENT
(
s
)
=>
{
let
attr
=
::
attr
::
mk_sugared_doc_attr
(
*
self
.id_to_str
(
s
),
self
.span.lo
,
self
.span.hi
);
copy
*
self
.id_to_str
(
s
),
self
.span.lo
,
self
.span.hi
);
self
.bump
();
if
attr
.node.style
==
ast
::
attr_inner
{
inner_attrs
+=
~
[
attr
];
...
...
@@ -151,7 +157,7 @@ fn parse_meta_item() -> @ast::meta_item {
}
fn
parse_meta_seq
()
->
~
[
@
ast
::
meta_item
]
{
self
.parse_seq
(
copy
self
.parse_seq
(
&
token
::
LPAREN
,
&
token
::
RPAREN
,
seq_sep_trailing_disallowed
(
token
::
COMMA
),
...
...
src/libsyntax/parse/comments.rs
浏览文件 @
4ae91e29
...
...
@@ -221,7 +221,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
if
col
<
len
{
s1
=
str
::
slice
(
s
,
col
,
len
);
}
else
{
s1
=
~
""
;
}
}
else
{
s1
=
s
;
}
}
else
{
s1
=
/*bad*/
copy
s
;
}
log
(
debug
,
~
"pushing line: "
+
s1
);
lines
.push
(
s1
);
}
...
...
@@ -321,7 +321,7 @@ pub struct lit {
}
pub
fn
gather_comments_and_literals
(
span_diagnostic
:
diagnostic
::
span_handler
,
path
:
~
str
,
+
path
:
~
str
,
srdr
:
io
::
Reader
)
->
(
~
[
cmnt
],
~
[
lit
])
{
let
src
=
@
str
::
from_bytes
(
srdr
.read_whole_stream
());
let
itr
=
parse
::
token
::
mk_fake_ident_interner
();
...
...
@@ -356,10 +356,10 @@ pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
let
TokenAndSpan
{
tok
:
tok
,
sp
:
sp
}
=
rdr
.peek
();
if
token
::
is_lit
(
&
tok
)
{
let
s
=
get_str_from
(
rdr
,
bstart
);
literals
.push
(
lit
{
lit
:
s
,
pos
:
sp
.lo
});
log
(
debug
,
~
"tok lit: "
+
s
);
literals
.push
(
lit
{
lit
:
/*bad*/
copy
s
,
pos
:
sp
.lo
});
debug!
(
"tok lit: %s"
,
s
);
}
else
{
log
(
debug
,
~
"tok: "
+
token
::
to_str
(
rdr
.interner
,
&
tok
));
debug!
(
"tok: %s"
,
token
::
to_str
(
rdr
.interner
,
&
tok
));
}
first_read
=
false
;
}
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
4ae91e29
...
...
@@ -92,7 +92,7 @@ pub fn parse_crate_from_source_str(name: ~str,
source
:
@~
str
,
cfg
:
ast
::
crate_cfg
,
sess
:
@
mut
ParseSess
)
->
@
ast
::
crate
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
codemap
::
FssNone
,
source
);
let
r
=
p
.parse_crate_mod
(
cfg
);
p
.abort_if_errors
();
...
...
@@ -103,7 +103,7 @@ pub fn parse_expr_from_source_str(name: ~str,
source
:
@~
str
,
cfg
:
ast
::
crate_cfg
,
sess
:
@
mut
ParseSess
)
->
@
ast
::
expr
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
codemap
::
FssNone
,
source
);
let
r
=
p
.parse_expr
();
p
.abort_if_errors
();
...
...
@@ -116,7 +116,7 @@ pub fn parse_item_from_source_str(name: ~str,
+
attrs
:
~
[
ast
::
attribute
],
sess
:
@
mut
ParseSess
)
->
Option
<@
ast
::
item
>
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
codemap
::
FssNone
,
source
);
let
r
=
p
.parse_item
(
attrs
);
p
.abort_if_errors
();
...
...
@@ -128,7 +128,7 @@ pub fn parse_stmt_from_source_str(name: ~str,
cfg
:
ast
::
crate_cfg
,
+
attrs
:
~
[
ast
::
attribute
],
sess
:
@
mut
ParseSess
)
->
@
ast
::
stmt
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
codemap
::
FssNone
,
source
);
let
r
=
p
.parse_stmt
(
attrs
);
p
.abort_if_errors
();
...
...
@@ -139,7 +139,7 @@ pub fn parse_tts_from_source_str(name: ~str,
source
:
@~
str
,
cfg
:
ast
::
crate_cfg
,
sess
:
@
mut
ParseSess
)
->
~
[
ast
::
token_tree
]
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
codemap
::
FssNone
,
source
);
*
p
.quote_depth
+=
1u
;
let
r
=
p
.parse_all_token_trees
();
...
...
@@ -153,8 +153,13 @@ pub fn parse_from_source_str<T>(f: fn (p: Parser) -> T,
sess
:
@
mut
ParseSess
)
->
T
{
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
name
,
ss
,
source
);
let
p
=
new_parser_from_source_str
(
sess
,
cfg
,
/*bad*/
copy
name
,
/*bad*/
copy
ss
,
source
);
let
r
=
f
(
p
);
if
!
p
.reader
.is_eof
()
{
p
.reader
.fatal
(
~
"expected end-of-string"
);
...
...
@@ -226,7 +231,7 @@ pub fn new_sub_parser_from_file(sess: @mut ParseSess, cfg: ast::crate_cfg,
}
pub
fn
new_parser_from_tts
(
sess
:
@
mut
ParseSess
,
cfg
:
ast
::
crate_cfg
,
tts
:
~
[
ast
::
token_tree
])
->
Parser
{
+
tts
:
~
[
ast
::
token_tree
])
->
Parser
{
let
trdr
=
lexer
::
new_tt_reader
(
copy
sess
.span_diagnostic
,
sess
.interner
,
None
,
tts
);
return
Parser
(
sess
,
cfg
,
trdr
as
reader
)
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
4ae91e29
...
...
@@ -147,16 +147,25 @@ enum view_item_parse_mode {
)
macro_rules!
maybe_whole
(
(
$p:expr
,
$constructor:ident
)
=>
(
match
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
x
;
}
(
$p:expr
,
$constructor:ident
)
=>
(
match
copy
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
x
;
}
_
=>
()
})
;
(
deref
$p:expr
,
$constructor:ident
)
=>
(
match
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
*
x
;
}
(
deref
$p:expr
,
$constructor:ident
)
=>
(
match
copy
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
copy
*
x
;
}
_
=>
()
})
;
(
Some
$p:expr
,
$constructor:ident
)
=>
(
match
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
Some
(
x
);
}
(
Some
$p:expr
,
$constructor:ident
)
=>
(
match
copy
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
Some
(
x
);
}
_
=>
()
})
;
(
iovi
$p:expr
,
$constructor:ident
)
=>
(
match
*
$p
.token
{
...
...
@@ -166,9 +175,10 @@ enum view_item_parse_mode {
}
_
=>
()
})
;
(
pair_empty
$p:expr
,
$constructor:ident
)
=>
(
match
*
$p
.token
{
(
pair_empty
$p:expr
,
$constructor:ident
)
=>
(
match
copy
*
$p
.token
{
INTERPOLATED
(
token
::
$constructor
(
x
))
=>
{
$p
.bump
();
return
(
~
[],
x
);
$p
.bump
();
return
(
~
[],
x
);
}
_
=>
()
})
...
...
@@ -612,8 +622,11 @@ fn parse_ty(colons_before_params: bool) -> @Ty {
one_tuple
=
true
;
}
}
let
t
=
if
ts
.len
()
==
1
&&
!
one_tuple
{
ts
[
0
]
.node
}
else
{
ty_tup
(
ts
)
};
let
t
=
if
ts
.len
()
==
1
&&
!
one_tuple
{
copy
ts
[
0
]
.node
}
else
{
ty_tup
(
ts
)
};
self
.expect
(
&
token
::
RPAREN
);
t
}
...
...
@@ -972,7 +985,7 @@ fn parse_path_with_tps(colons: bool) -> @path {
@
ast
::
path
{
span
:
mk_sp
(
lo
,
hi
),
rp
:
rp
,
types
:
tps
,
..
*
path
}
..
copy
*
path
}
}
fn
parse_opt_lifetime
()
->
Option
<
ast
::
Lifetime
>
{
...
...
@@ -1440,7 +1453,12 @@ fn parse_non_delim_tt_tok(p: &Parser) -> token_tree {
|
p
|
p
.parse_token_tree
()
);
let
(
s
,
z
)
=
p
.parse_sep_and_zerok
();
tt_seq
(
mk_sp
(
sp
.lo
,
p
.span.hi
),
seq
.node
,
s
,
z
)
tt_seq
(
mk_sp
(
sp
.lo
,
p
.span.hi
),
/*bad*/
copy
seq
.node
,
s
,
z
)
}
else
{
tt_nonterminal
(
sp
,
p
.parse_ident
())
}
...
...
@@ -1453,7 +1471,7 @@ fn parse_non_delim_tt_tok(p: &Parser) -> token_tree {
// turn the next token into a tt_tok:
fn
parse_any_tt_tok
(
p
:
&
Parser
)
->
token_tree
{
let
res
=
tt_tok
(
*
p
.span
,
*
p
.token
);
let
res
=
tt_tok
(
*
p
.span
,
copy
*
p
.token
);
p
.bump
();
res
}
...
...
@@ -1562,7 +1580,7 @@ fn parse_matcher(name_idx: @mut uint) -> matcher {
m
}
}
else
{
let
m
=
match_tok
(
*
self
.token
);
let
m
=
match_tok
(
copy
*
self
.token
);
self
.bump
();
m
};
...
...
@@ -1665,7 +1683,7 @@ fn parse_binops() -> @expr {
fn
parse_more_binops
(
lhs
:
@
expr
,
min_prec
:
uint
)
->
@
expr
{
if
self
.expr_is_complete
(
lhs
)
{
return
lhs
;
}
let
peeked
=
*
self
.token
;
let
peeked
=
copy
*
self
.token
;
if
peeked
==
token
::
BINOP
(
token
::
OR
)
&&
(
*
self
.restriction
==
RESTRICT_NO_BAR_OP
||
*
self
.restriction
==
RESTRICT_NO_BAR_OR_DOUBLEBAR_OP
)
{
...
...
@@ -1859,7 +1877,7 @@ fn parse_sugary_call_expr(keyword: ~str,
// Turn on the restriction to stop at | or || so we can parse
// them as the lambda arguments
let
e
=
self
.parse_expr_res
(
RESTRICT_NO_BAR_OR_DOUBLEBAR_OP
);
match
e
.node
{
match
/*bad*/
copy
e
.node
{
expr_call
(
f
,
args
,
NoSugar
)
=>
{
let
block
=
self
.parse_lambda_block_expr
();
let
last_arg
=
self
.mk_expr
(
block
.span.lo
,
block
.span.hi
,
...
...
@@ -2441,7 +2459,7 @@ fn parse_instance_var(pr: visibility) -> @struct_field {
fn
parse_stmt
(
+
first_item_attrs
:
~
[
attribute
])
->
@
stmt
{
maybe_whole!
(
self
,
nt_stmt
);
fn
check_expected_item
(
p
:
&
Parser
,
current_attrs
:
~
[
attribute
])
{
fn
check_expected_item
(
p
:
&
Parser
,
current_attrs
:
&
[
attribute
])
{
// If we have attributes then we should have an item
if
!
current_attrs
.is_empty
()
{
p
.fatal
(
~
"expected item after attrs"
);
...
...
@@ -2497,7 +2515,7 @@ fn check_expected_item(p: &Parser, current_attrs: ~[attribute]) {
let
item_attrs
=
vec
::
append
(
first_item_attrs
,
self
.parse_outer_attributes
());
match
self
.parse_item_or_view_item
(
item_attrs
,
match
self
.parse_item_or_view_item
(
/*bad*/
copy
item_attrs
,
true
,
false
,
false
)
{
iovi_item
(
i
)
=>
{
let
mut
hi
=
i
.span.hi
;
...
...
@@ -2614,7 +2632,7 @@ fn parse_block_tail_(lo: BytePos, s: blk_check_mode,
self
.bump
();
stmts
.push
(
@
codemap
::
spanned
{
node
:
stmt_semi
(
e
,
stmt_id
),
..
*
stmt
});
..
copy
*
stmt
});
}
token
::
RBRACE
=>
{
expr
=
Some
(
e
);
...
...
@@ -2640,8 +2658,8 @@ fn parse_block_tail_(lo: BytePos, s: blk_check_mode,
token
::
SEMI
=>
{
self
.bump
();
stmts
.push
(
@
codemap
::
spanned
{
node
:
stmt_mac
(
(
*
m
)
,
true
),
..
*
stmt
});
node
:
stmt_mac
(
copy
*
m
,
true
),
..
copy
*
stmt
});
}
token
::
RBRACE
=>
{
// if a block ends in `m!(arg)` without
...
...
@@ -2649,7 +2667,7 @@ fn parse_block_tail_(lo: BytePos, s: blk_check_mode,
expr
=
Some
(
self
.mk_mac_expr
(
stmt
.span.lo
,
stmt
.span.hi
,
(
*
m
)
.node
));
copy
m
.node
));
}
_
=>
{
stmts
.push
(
stmt
);
}
}
...
...
@@ -2990,6 +3008,7 @@ fn parse_method() -> @method {
let
self_ty
=
if
is_static
{
static_sty
}
else
{
self_ty
};
let
(
inner_attrs
,
body
)
=
self
.parse_inner_attrs_and_block
(
true
);
let
hi
=
body
.span.hi
;
let
attrs
=
vec
::
append
(
attrs
,
inner_attrs
);
@
ast
::
method
{
ident
:
ident
,
...
...
@@ -3000,7 +3019,7 @@ fn parse_method() -> @method {
decl
:
decl
,
body
:
body
,
id
:
self
.get_id
(),
span
:
mk_sp
(
lo
,
body
.span.
hi
),
span
:
mk_sp
(
lo
,
hi
),
self_id
:
self
.get_id
(),
vis
:
visa
,
}
...
...
@@ -3161,7 +3180,7 @@ fn parse_item_struct() -> item_info {
declared here"
);
}
None
=>
{
the_dtor
=
Some
((
(
*
blk
),
(
*
attrs
)
,
s
));
the_dtor
=
Some
((
copy
*
blk
,
copy
*
attrs
,
s
));
}
}
}
...
...
@@ -3205,7 +3224,7 @@ fn parse_item_struct() -> item_info {
}
let
actual_dtor
=
do
the_dtor
.map
|
dtor
|
{
let
(
d_body
,
d_attrs
,
d_s
)
=
*
dtor
;
let
(
d_body
,
d_attrs
,
d_s
)
=
copy
*
dtor
;
codemap
::
spanned
{
node
:
ast
::
struct_dtor_
{
id
:
self
.get_id
(),
attrs
:
d_attrs
,
self_id
:
self
.get_id
(),
...
...
@@ -3257,7 +3276,7 @@ fn parse_single_class_item(vis: visibility) -> @struct_field {
a_var
}
fn
parse_dtor
(
attrs
:
~
[
attribute
])
->
class_contents
{
fn
parse_dtor
(
+
attrs
:
~
[
attribute
])
->
class_contents
{
let
lo
=
self
.last_span.lo
;
let
body
=
self
.parse_block
();
dtor_decl
(
body
,
attrs
,
mk_sp
(
lo
,
self
.last_span.hi
))
...
...
@@ -3323,12 +3342,17 @@ fn parse_mod_items(term: token::Token,
while
*
self
.token
!=
term
{
let
mut
attrs
=
self
.parse_outer_attributes
();
if
first
{
attrs
=
vec
::
append
(
attrs_remaining
,
attrs
);
attrs
=
vec
::
append
(
/*bad*/
copy
attrs_remaining
,
attrs
);
first
=
false
;
}
debug!
(
"parse_mod_items: parse_item_or_view_item(attrs=%?)"
,
attrs
);
match
self
.parse_item_or_view_item
(
attrs
,
true
,
false
,
true
)
{
match
self
.parse_item_or_view_item
(
/*bad*/
copy
attrs
,
true
,
false
,
true
)
{
iovi_item
(
item
)
=>
items
.push
(
item
),
iovi_view_item
(
view_item
)
=>
{
self
.span_fatal
(
view_item
.span
,
~
"view items must be
\
...
...
@@ -3456,7 +3480,7 @@ fn eval_src_mod(id: ast::ident,
outer_attrs
,
id_sp
)
}
fn
eval_src_mod_from_path
(
prefix
:
Path
,
path
:
Path
,
fn
eval_src_mod_from_path
(
prefix
:
Path
,
+
path
:
Path
,
outer_attrs
:
~
[
ast
::
attribute
],
id_sp
:
span
)
->
(
ast
::
item_
,
~
[
ast
::
attribute
])
{
...
...
@@ -3471,12 +3495,15 @@ fn eval_src_mod_from_path(prefix: Path, path: Path,
new_sub_parser_from_file
(
self
.sess
,
self
.cfg
,
&
full_path
,
id_sp
);
let
(
inner
,
next
)
=
p0
.parse_inner_attrs_and_next
();
let
mod_attrs
=
vec
::
append
(
outer_attrs
,
inner
);
let
mod_attrs
=
vec
::
append
(
/*bad*/
copy
outer_attrs
,
inner
);
let
first_item_outer_attrs
=
next
;
let
m0
=
p0
.parse_mod_items
(
token
::
EOF
,
first_item_outer_attrs
);
return
(
ast
::
item_mod
(
m0
),
mod_attrs
);
fn
cdir_path_opt
(
default
:
~
str
,
attrs
:
~
[
ast
::
attribute
])
->
~
str
{
fn
cdir_path_opt
(
+
default
:
~
str
,
attrs
:
~
[
ast
::
attribute
])
->
~
str
{
match
::
attr
::
first_attr_value_str_by_name
(
attrs
,
~
"path"
)
{
Some
(
d
)
=>
copy
*
d
,
None
=>
default
...
...
@@ -3631,8 +3658,9 @@ fn parse_item_foreign_mod(lo: BytePos,
self
.expect
(
&
token
::
RBRACE
);
return
iovi_item
(
self
.mk_item
(
lo
,
self
.last_span.hi
,
ident
,
item_foreign_mod
(
m
),
visibility
,
maybe_append
(
attrs
,
Some
(
inner
))));
item_foreign_mod
(
m
),
visibility
,
maybe_append
(
/*bad*/
copy
attrs
,
Some
(
inner
))));
}
match
abi_opt
{
...
...
@@ -3648,7 +3676,7 @@ fn parse_item_foreign_mod(lo: BytePos,
self
.expect
(
&
token
::
SEMI
);
iovi_view_item
(
@
ast
::
view_item
{
node
:
view_item_extern_mod
(
ident
,
metadata
,
self
.get_id
()),
attrs
:
attrs
,
attrs
:
copy
attrs
,
vis
:
visibility
,
span
:
mk_sp
(
lo
,
self
.last_span.hi
)
})
...
...
@@ -3691,7 +3719,7 @@ fn parse_struct_def() -> @struct_def {
declared here"
);
}
None
=>
{
the_dtor
=
Some
((
(
*
blk
),
(
*
attrs
)
,
s
));
the_dtor
=
Some
((
copy
*
blk
,
copy
*
attrs
,
s
));
}
}
}
...
...
@@ -3704,7 +3732,7 @@ fn parse_struct_def() -> @struct_def {
}
self
.bump
();
let
mut
actual_dtor
=
do
the_dtor
.map
|
dtor
|
{
let
(
d_body
,
d_attrs
,
d_s
)
=
*
dtor
;
let
(
d_body
,
d_attrs
,
d_s
)
=
copy
*
dtor
;
codemap
::
spanned
{
node
:
ast
::
struct_dtor_
{
id
:
self
.get_id
(),
attrs
:
d_attrs
,
self_id
:
self
.get_id
(),
...
...
@@ -4216,7 +4244,8 @@ fn parse_items_and_view_items(+first_item_attrs: ~[attribute],
let
mut
(
view_items
,
items
,
foreign_items
)
=
(
~
[],
~
[],
~
[]);
loop
{
match
self
.parse_item_or_view_item
(
attrs
,
items_allowed
,
match
self
.parse_item_or_view_item
(
/*bad*/
copy
attrs
,
items_allowed
,
foreign_items_allowed
,
macros_allowed
)
{
iovi_none
=>
...
...
@@ -4265,7 +4294,7 @@ fn parse_crate_mod(_cfg: crate_cfg) -> @crate {
@
spanned
(
lo
,
self
.span.lo
,
ast
::
crate_
{
module
:
m
,
attrs
:
inner
,
config
:
self
.cfg
})
config
:
copy
self
.cfg
})
}
fn
parse_str
()
->
@~
str
{
...
...
src/libsyntax/parse/token.rs
浏览文件 @
4ae91e29
...
...
@@ -179,14 +179,14 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
}
LIT_INT_UNSUFFIXED
(
i
)
=>
{
i
.to_str
()
}
LIT_FLOAT
(
s
,
t
)
=>
{
let
mut
body
=
*
in
.get
(
s
);
let
mut
body
=
copy
*
in
.get
(
s
);
if
body
.ends_with
(
~
"."
)
{
body
=
body
+
~
"0"
;
// `10.f` is not a float literal
}
body
+
ast_util
::
float_ty_to_str
(
t
)
}
LIT_FLOAT_UNSUFFIXED
(
s
)
=>
{
let
mut
body
=
*
in
.get
(
s
);
let
mut
body
=
copy
*
in
.get
(
s
);
if
body
.ends_with
(
~
"."
)
{
body
=
body
+
~
"0"
;
// `10.f` is not a float literal
}
...
...
@@ -195,12 +195,12 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
LIT_STR
(
s
)
=>
{
~
"
\"
"
+
str
::
escape_default
(
*
in
.get
(
s
))
+
~
"
\"
"
}
/* Name components */
IDENT
(
s
,
_
)
=>
*
in
.get
(
s
),
IDENT
(
s
,
_
)
=>
copy
*
in
.get
(
s
),
LIFETIME
(
s
)
=>
fmt!
(
"'%s"
,
*
in
.get
(
s
)),
UNDERSCORE
=>
~
"_"
,
/* Other */
DOC_COMMENT
(
s
)
=>
*
in
.get
(
s
),
DOC_COMMENT
(
s
)
=>
copy
*
in
.get
(
s
),
EOF
=>
~
"<eof>"
,
INTERPOLATED
(
ref
nt
)
=>
{
match
nt
{
...
...
@@ -476,7 +476,7 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> {
~
"self"
,
~
"static"
,
];
for
keys
.each
|
word
|
{
words
.insert
(
*
word
,
());
words
.insert
(
copy
*
word
,
());
}
words
}
...
...
@@ -503,7 +503,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
~
"while"
];
for
keys
.each
|
word
|
{
words
.insert
(
*
word
,
());
words
.insert
(
copy
*
word
,
());
}
words
}
...
...
@@ -514,7 +514,7 @@ pub fn reserved_keyword_table() -> HashMap<~str, ()> {
~
"be"
];
for
keys
.each
|
word
|
{
words
.insert
(
*
word
,
());
words
.insert
(
copy
*
word
,
());
}
words
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录