libsyntax: add explicit copies
This commit is contained in:
parent
8d239a256d
commit
4ae91e2961
5 changed files with 101 additions and 61 deletions
|
@ -46,7 +46,10 @@ impl parser_attr for Parser {
|
||||||
}
|
}
|
||||||
token::DOC_COMMENT(s) => {
|
token::DOC_COMMENT(s) => {
|
||||||
let attr = ::attr::mk_sugared_doc_attr(
|
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 {
|
if attr.node.style != ast::attr_outer {
|
||||||
self.fatal(~"expected outer comment");
|
self.fatal(~"expected outer comment");
|
||||||
}
|
}
|
||||||
|
@ -113,7 +116,10 @@ impl parser_attr for Parser {
|
||||||
}
|
}
|
||||||
token::DOC_COMMENT(s) => {
|
token::DOC_COMMENT(s) => {
|
||||||
let attr = ::attr::mk_sugared_doc_attr(
|
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();
|
self.bump();
|
||||||
if attr.node.style == ast::attr_inner {
|
if attr.node.style == ast::attr_inner {
|
||||||
inner_attrs += ~[attr];
|
inner_attrs += ~[attr];
|
||||||
|
@ -151,7 +157,7 @@ impl parser_attr for Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_meta_seq() -> ~[@ast::meta_item] {
|
fn parse_meta_seq() -> ~[@ast::meta_item] {
|
||||||
self.parse_seq(
|
copy self.parse_seq(
|
||||||
&token::LPAREN,
|
&token::LPAREN,
|
||||||
&token::RPAREN,
|
&token::RPAREN,
|
||||||
seq_sep_trailing_disallowed(token::COMMA),
|
seq_sep_trailing_disallowed(token::COMMA),
|
||||||
|
|
|
@ -221,7 +221,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
|
||||||
if col < len {
|
if col < len {
|
||||||
s1 = str::slice(s, col, len);
|
s1 = str::slice(s, col, len);
|
||||||
} else { s1 = ~""; }
|
} else { s1 = ~""; }
|
||||||
} else { s1 = s; }
|
} else { s1 = /*bad*/ copy s; }
|
||||||
log(debug, ~"pushing line: " + s1);
|
log(debug, ~"pushing line: " + s1);
|
||||||
lines.push(s1);
|
lines.push(s1);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ pub struct lit {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
|
pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
|
||||||
path: ~str,
|
+path: ~str,
|
||||||
srdr: io::Reader) -> (~[cmnt], ~[lit]) {
|
srdr: io::Reader) -> (~[cmnt], ~[lit]) {
|
||||||
let src = @str::from_bytes(srdr.read_whole_stream());
|
let src = @str::from_bytes(srdr.read_whole_stream());
|
||||||
let itr = parse::token::mk_fake_ident_interner();
|
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();
|
let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
|
||||||
if token::is_lit(&tok) {
|
if token::is_lit(&tok) {
|
||||||
let s = get_str_from(rdr, bstart);
|
let s = get_str_from(rdr, bstart);
|
||||||
literals.push(lit {lit: s, pos: sp.lo});
|
literals.push(lit {lit: /*bad*/ copy s, pos: sp.lo});
|
||||||
log(debug, ~"tok lit: " + s);
|
debug!("tok lit: %s", s);
|
||||||
} else {
|
} else {
|
||||||
log(debug, ~"tok: " + token::to_str(rdr.interner, &tok));
|
debug!("tok: %s", token::to_str(rdr.interner, &tok));
|
||||||
}
|
}
|
||||||
first_read = false;
|
first_read = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub fn parse_crate_from_source_str(name: ~str,
|
||||||
source: @~str,
|
source: @~str,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
sess: @mut ParseSess) -> @ast::crate {
|
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);
|
codemap::FssNone, source);
|
||||||
let r = p.parse_crate_mod(cfg);
|
let r = p.parse_crate_mod(cfg);
|
||||||
p.abort_if_errors();
|
p.abort_if_errors();
|
||||||
|
@ -103,7 +103,7 @@ pub fn parse_expr_from_source_str(name: ~str,
|
||||||
source: @~str,
|
source: @~str,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
sess: @mut ParseSess) -> @ast::expr {
|
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);
|
codemap::FssNone, source);
|
||||||
let r = p.parse_expr();
|
let r = p.parse_expr();
|
||||||
p.abort_if_errors();
|
p.abort_if_errors();
|
||||||
|
@ -116,7 +116,7 @@ pub fn parse_item_from_source_str(name: ~str,
|
||||||
+attrs: ~[ast::attribute],
|
+attrs: ~[ast::attribute],
|
||||||
sess: @mut ParseSess)
|
sess: @mut ParseSess)
|
||||||
-> Option<@ast::item> {
|
-> 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);
|
codemap::FssNone, source);
|
||||||
let r = p.parse_item(attrs);
|
let r = p.parse_item(attrs);
|
||||||
p.abort_if_errors();
|
p.abort_if_errors();
|
||||||
|
@ -128,7 +128,7 @@ pub fn parse_stmt_from_source_str(name: ~str,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
+attrs: ~[ast::attribute],
|
+attrs: ~[ast::attribute],
|
||||||
sess: @mut ParseSess) -> @ast::stmt {
|
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);
|
codemap::FssNone, source);
|
||||||
let r = p.parse_stmt(attrs);
|
let r = p.parse_stmt(attrs);
|
||||||
p.abort_if_errors();
|
p.abort_if_errors();
|
||||||
|
@ -139,7 +139,7 @@ pub fn parse_tts_from_source_str(name: ~str,
|
||||||
source: @~str,
|
source: @~str,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
sess: @mut ParseSess) -> ~[ast::token_tree] {
|
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);
|
codemap::FssNone, source);
|
||||||
*p.quote_depth += 1u;
|
*p.quote_depth += 1u;
|
||||||
let r = p.parse_all_token_trees();
|
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)
|
sess: @mut ParseSess)
|
||||||
-> T
|
-> T
|
||||||
{
|
{
|
||||||
let p = new_parser_from_source_str(sess, cfg, name, ss,
|
let p = new_parser_from_source_str(
|
||||||
source);
|
sess,
|
||||||
|
cfg,
|
||||||
|
/*bad*/ copy name,
|
||||||
|
/*bad*/ copy ss,
|
||||||
|
source
|
||||||
|
);
|
||||||
let r = f(p);
|
let r = f(p);
|
||||||
if !p.reader.is_eof() {
|
if !p.reader.is_eof() {
|
||||||
p.reader.fatal(~"expected end-of-string");
|
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,
|
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,
|
let trdr = lexer::new_tt_reader(copy sess.span_diagnostic, sess.interner,
|
||||||
None, tts);
|
None, tts);
|
||||||
return Parser(sess, cfg, trdr as reader)
|
return Parser(sess, cfg, trdr as reader)
|
||||||
|
|
|
@ -147,16 +147,25 @@ macro_rules! maybe_whole_expr (
|
||||||
)
|
)
|
||||||
|
|
||||||
macro_rules! maybe_whole (
|
macro_rules! maybe_whole (
|
||||||
($p:expr, $constructor:ident) => ( match *$p.token {
|
($p:expr, $constructor:ident) => ( match copy *$p.token {
|
||||||
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; }
|
INTERPOLATED(token::$constructor(x)) => {
|
||||||
|
$p.bump();
|
||||||
|
return x;
|
||||||
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}) ;
|
}) ;
|
||||||
(deref $p:expr, $constructor:ident) => ( match *$p.token {
|
(deref $p:expr, $constructor:ident) => ( match copy *$p.token {
|
||||||
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; }
|
INTERPOLATED(token::$constructor(x)) => {
|
||||||
|
$p.bump();
|
||||||
|
return copy *x;
|
||||||
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}) ;
|
}) ;
|
||||||
(Some $p:expr, $constructor:ident) => ( match *$p.token {
|
(Some $p:expr, $constructor:ident) => ( match copy *$p.token {
|
||||||
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return Some(x); }
|
INTERPOLATED(token::$constructor(x)) => {
|
||||||
|
$p.bump();
|
||||||
|
return Some(x);
|
||||||
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}) ;
|
}) ;
|
||||||
(iovi $p:expr, $constructor:ident) => ( match *$p.token {
|
(iovi $p:expr, $constructor:ident) => ( match *$p.token {
|
||||||
|
@ -166,9 +175,10 @@ macro_rules! maybe_whole (
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}) ;
|
}) ;
|
||||||
(pair_empty $p:expr, $constructor:ident) => ( match *$p.token {
|
(pair_empty $p:expr, $constructor:ident) => ( match copy *$p.token {
|
||||||
INTERPOLATED(token::$constructor(x)) => {
|
INTERPOLATED(token::$constructor(x)) => {
|
||||||
$p.bump(); return (~[], x);
|
$p.bump();
|
||||||
|
return (~[], x);
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
})
|
})
|
||||||
|
@ -612,8 +622,11 @@ pub impl Parser {
|
||||||
one_tuple = true;
|
one_tuple = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let t = if ts.len() == 1 && !one_tuple { ts[0].node }
|
let t = if ts.len() == 1 && !one_tuple {
|
||||||
else { ty_tup(ts) };
|
copy ts[0].node
|
||||||
|
} else {
|
||||||
|
ty_tup(ts)
|
||||||
|
};
|
||||||
self.expect(&token::RPAREN);
|
self.expect(&token::RPAREN);
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
@ -972,7 +985,7 @@ pub impl Parser {
|
||||||
@ast::path { span: mk_sp(lo, hi),
|
@ast::path { span: mk_sp(lo, hi),
|
||||||
rp: rp,
|
rp: rp,
|
||||||
types: tps,
|
types: tps,
|
||||||
.. *path }
|
.. copy *path }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opt_lifetime() -> Option<ast::Lifetime> {
|
fn parse_opt_lifetime() -> Option<ast::Lifetime> {
|
||||||
|
@ -1440,7 +1453,12 @@ pub impl Parser {
|
||||||
|p| p.parse_token_tree()
|
|p| p.parse_token_tree()
|
||||||
);
|
);
|
||||||
let (s, z) = p.parse_sep_and_zerok();
|
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 {
|
} else {
|
||||||
tt_nonterminal(sp, p.parse_ident())
|
tt_nonterminal(sp, p.parse_ident())
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1471,7 @@ pub impl Parser {
|
||||||
|
|
||||||
// turn the next token into a tt_tok:
|
// turn the next token into a tt_tok:
|
||||||
fn parse_any_tt_tok(p: &Parser) -> token_tree{
|
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();
|
p.bump();
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
@ -1562,7 +1580,7 @@ pub impl Parser {
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let m = match_tok(*self.token);
|
let m = match_tok(copy *self.token);
|
||||||
self.bump();
|
self.bump();
|
||||||
m
|
m
|
||||||
};
|
};
|
||||||
|
@ -1665,7 +1683,7 @@ pub impl Parser {
|
||||||
fn parse_more_binops(lhs: @expr, min_prec: uint) ->
|
fn parse_more_binops(lhs: @expr, min_prec: uint) ->
|
||||||
@expr {
|
@expr {
|
||||||
if self.expr_is_complete(lhs) { return lhs; }
|
if self.expr_is_complete(lhs) { return lhs; }
|
||||||
let peeked = *self.token;
|
let peeked = copy *self.token;
|
||||||
if peeked == token::BINOP(token::OR) &&
|
if peeked == token::BINOP(token::OR) &&
|
||||||
(*self.restriction == RESTRICT_NO_BAR_OP ||
|
(*self.restriction == RESTRICT_NO_BAR_OP ||
|
||||||
*self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) {
|
*self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) {
|
||||||
|
@ -1859,7 +1877,7 @@ pub impl Parser {
|
||||||
// Turn on the restriction to stop at | or || so we can parse
|
// Turn on the restriction to stop at | or || so we can parse
|
||||||
// them as the lambda arguments
|
// them as the lambda arguments
|
||||||
let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
|
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) => {
|
expr_call(f, args, NoSugar) => {
|
||||||
let block = self.parse_lambda_block_expr();
|
let block = self.parse_lambda_block_expr();
|
||||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||||
|
@ -2441,7 +2459,7 @@ pub impl Parser {
|
||||||
fn parse_stmt(+first_item_attrs: ~[attribute]) -> @stmt {
|
fn parse_stmt(+first_item_attrs: ~[attribute]) -> @stmt {
|
||||||
maybe_whole!(self, nt_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 we have attributes then we should have an item
|
||||||
if !current_attrs.is_empty() {
|
if !current_attrs.is_empty() {
|
||||||
p.fatal(~"expected item after attrs");
|
p.fatal(~"expected item after attrs");
|
||||||
|
@ -2497,7 +2515,7 @@ pub impl Parser {
|
||||||
let item_attrs = vec::append(first_item_attrs,
|
let item_attrs = vec::append(first_item_attrs,
|
||||||
self.parse_outer_attributes());
|
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) {
|
true, false, false) {
|
||||||
iovi_item(i) => {
|
iovi_item(i) => {
|
||||||
let mut hi = i.span.hi;
|
let mut hi = i.span.hi;
|
||||||
|
@ -2614,7 +2632,7 @@ pub impl Parser {
|
||||||
self.bump();
|
self.bump();
|
||||||
stmts.push(@codemap::spanned {
|
stmts.push(@codemap::spanned {
|
||||||
node: stmt_semi(e, stmt_id),
|
node: stmt_semi(e, stmt_id),
|
||||||
.. *stmt});
|
.. copy *stmt});
|
||||||
}
|
}
|
||||||
token::RBRACE => {
|
token::RBRACE => {
|
||||||
expr = Some(e);
|
expr = Some(e);
|
||||||
|
@ -2640,8 +2658,8 @@ pub impl Parser {
|
||||||
token::SEMI => {
|
token::SEMI => {
|
||||||
self.bump();
|
self.bump();
|
||||||
stmts.push(@codemap::spanned {
|
stmts.push(@codemap::spanned {
|
||||||
node: stmt_mac((*m), true),
|
node: stmt_mac(copy *m, true),
|
||||||
.. *stmt});
|
.. copy *stmt});
|
||||||
}
|
}
|
||||||
token::RBRACE => {
|
token::RBRACE => {
|
||||||
// if a block ends in `m!(arg)` without
|
// if a block ends in `m!(arg)` without
|
||||||
|
@ -2649,7 +2667,7 @@ pub impl Parser {
|
||||||
expr = Some(
|
expr = Some(
|
||||||
self.mk_mac_expr(stmt.span.lo,
|
self.mk_mac_expr(stmt.span.lo,
|
||||||
stmt.span.hi,
|
stmt.span.hi,
|
||||||
(*m).node));
|
copy m.node));
|
||||||
}
|
}
|
||||||
_ => { stmts.push(stmt); }
|
_ => { stmts.push(stmt); }
|
||||||
}
|
}
|
||||||
|
@ -2990,6 +3008,7 @@ pub impl Parser {
|
||||||
let self_ty = if is_static { static_sty} else { self_ty };
|
let self_ty = if is_static { static_sty} else { self_ty };
|
||||||
|
|
||||||
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
||||||
|
let hi = body.span.hi;
|
||||||
let attrs = vec::append(attrs, inner_attrs);
|
let attrs = vec::append(attrs, inner_attrs);
|
||||||
@ast::method {
|
@ast::method {
|
||||||
ident: ident,
|
ident: ident,
|
||||||
|
@ -3000,7 +3019,7 @@ pub impl Parser {
|
||||||
decl: decl,
|
decl: decl,
|
||||||
body: body,
|
body: body,
|
||||||
id: self.get_id(),
|
id: self.get_id(),
|
||||||
span: mk_sp(lo, body.span.hi),
|
span: mk_sp(lo, hi),
|
||||||
self_id: self.get_id(),
|
self_id: self.get_id(),
|
||||||
vis: visa,
|
vis: visa,
|
||||||
}
|
}
|
||||||
|
@ -3161,7 +3180,7 @@ pub impl Parser {
|
||||||
declared here");
|
declared here");
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
the_dtor = Some(((*blk), (*attrs), s));
|
the_dtor = Some((copy *blk, copy *attrs, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3205,7 +3224,7 @@ pub impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
let actual_dtor = do the_dtor.map |dtor| {
|
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(),
|
codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(),
|
||||||
attrs: d_attrs,
|
attrs: d_attrs,
|
||||||
self_id: self.get_id(),
|
self_id: self.get_id(),
|
||||||
|
@ -3257,7 +3276,7 @@ pub impl Parser {
|
||||||
a_var
|
a_var
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_dtor(attrs: ~[attribute]) -> class_contents {
|
fn parse_dtor(+attrs: ~[attribute]) -> class_contents {
|
||||||
let lo = self.last_span.lo;
|
let lo = self.last_span.lo;
|
||||||
let body = self.parse_block();
|
let body = self.parse_block();
|
||||||
dtor_decl(body, attrs, mk_sp(lo, self.last_span.hi))
|
dtor_decl(body, attrs, mk_sp(lo, self.last_span.hi))
|
||||||
|
@ -3323,12 +3342,17 @@ pub impl Parser {
|
||||||
while *self.token != term {
|
while *self.token != term {
|
||||||
let mut attrs = self.parse_outer_attributes();
|
let mut attrs = self.parse_outer_attributes();
|
||||||
if first {
|
if first {
|
||||||
attrs = vec::append(attrs_remaining, attrs);
|
attrs = vec::append(/*bad*/ copy attrs_remaining, attrs);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)",
|
debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)",
|
||||||
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_item(item) => items.push(item),
|
||||||
iovi_view_item(view_item) => {
|
iovi_view_item(view_item) => {
|
||||||
self.span_fatal(view_item.span, ~"view items must be \
|
self.span_fatal(view_item.span, ~"view items must be \
|
||||||
|
@ -3456,7 +3480,7 @@ pub impl Parser {
|
||||||
outer_attrs, id_sp)
|
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],
|
outer_attrs: ~[ast::attribute],
|
||||||
id_sp: span
|
id_sp: span
|
||||||
) -> (ast::item_, ~[ast::attribute]) {
|
) -> (ast::item_, ~[ast::attribute]) {
|
||||||
|
@ -3471,12 +3495,15 @@ pub impl Parser {
|
||||||
new_sub_parser_from_file(self.sess, self.cfg,
|
new_sub_parser_from_file(self.sess, self.cfg,
|
||||||
&full_path, id_sp);
|
&full_path, id_sp);
|
||||||
let (inner, next) = p0.parse_inner_attrs_and_next();
|
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 first_item_outer_attrs = next;
|
||||||
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
||||||
return (ast::item_mod(m0), mod_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") {
|
match ::attr::first_attr_value_str_by_name(attrs, ~"path") {
|
||||||
Some(d) => copy *d,
|
Some(d) => copy *d,
|
||||||
None => default
|
None => default
|
||||||
|
@ -3632,7 +3659,8 @@ pub impl Parser {
|
||||||
|
|
||||||
return iovi_item(self.mk_item(lo, self.last_span.hi, ident,
|
return iovi_item(self.mk_item(lo, self.last_span.hi, ident,
|
||||||
item_foreign_mod(m), visibility,
|
item_foreign_mod(m), visibility,
|
||||||
maybe_append(attrs, Some(inner))));
|
maybe_append(/*bad*/ copy attrs,
|
||||||
|
Some(inner))));
|
||||||
}
|
}
|
||||||
|
|
||||||
match abi_opt {
|
match abi_opt {
|
||||||
|
@ -3648,7 +3676,7 @@ pub impl Parser {
|
||||||
self.expect(&token::SEMI);
|
self.expect(&token::SEMI);
|
||||||
iovi_view_item(@ast::view_item {
|
iovi_view_item(@ast::view_item {
|
||||||
node: view_item_extern_mod(ident, metadata, self.get_id()),
|
node: view_item_extern_mod(ident, metadata, self.get_id()),
|
||||||
attrs: attrs,
|
attrs: copy attrs,
|
||||||
vis: visibility,
|
vis: visibility,
|
||||||
span: mk_sp(lo, self.last_span.hi)
|
span: mk_sp(lo, self.last_span.hi)
|
||||||
})
|
})
|
||||||
|
@ -3691,7 +3719,7 @@ pub impl Parser {
|
||||||
declared here");
|
declared here");
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
the_dtor = Some(((*blk), (*attrs), s));
|
the_dtor = Some((copy *blk, copy *attrs, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3704,7 +3732,7 @@ pub impl Parser {
|
||||||
}
|
}
|
||||||
self.bump();
|
self.bump();
|
||||||
let mut actual_dtor = do the_dtor.map |dtor| {
|
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(),
|
codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(),
|
||||||
attrs: d_attrs,
|
attrs: d_attrs,
|
||||||
self_id: self.get_id(),
|
self_id: self.get_id(),
|
||||||
|
@ -4216,7 +4244,8 @@ pub impl Parser {
|
||||||
|
|
||||||
let mut (view_items, items, foreign_items) = (~[], ~[], ~[]);
|
let mut (view_items, items, foreign_items) = (~[], ~[], ~[]);
|
||||||
loop {
|
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,
|
foreign_items_allowed,
|
||||||
macros_allowed) {
|
macros_allowed) {
|
||||||
iovi_none =>
|
iovi_none =>
|
||||||
|
@ -4265,7 +4294,7 @@ pub impl Parser {
|
||||||
@spanned(lo, self.span.lo,
|
@spanned(lo, self.span.lo,
|
||||||
ast::crate_ { module: m,
|
ast::crate_ { module: m,
|
||||||
attrs: inner,
|
attrs: inner,
|
||||||
config: self.cfg })
|
config: copy self.cfg })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_str() -> @~str {
|
fn parse_str() -> @~str {
|
||||||
|
|
|
@ -179,14 +179,14 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
|
||||||
}
|
}
|
||||||
LIT_INT_UNSUFFIXED(i) => { i.to_str() }
|
LIT_INT_UNSUFFIXED(i) => { i.to_str() }
|
||||||
LIT_FLOAT(s, t) => {
|
LIT_FLOAT(s, t) => {
|
||||||
let mut body = *in.get(s);
|
let mut body = copy *in.get(s);
|
||||||
if body.ends_with(~".") {
|
if body.ends_with(~".") {
|
||||||
body = body + ~"0"; // `10.f` is not a float literal
|
body = body + ~"0"; // `10.f` is not a float literal
|
||||||
}
|
}
|
||||||
body + ast_util::float_ty_to_str(t)
|
body + ast_util::float_ty_to_str(t)
|
||||||
}
|
}
|
||||||
LIT_FLOAT_UNSUFFIXED(s) => {
|
LIT_FLOAT_UNSUFFIXED(s) => {
|
||||||
let mut body = *in.get(s);
|
let mut body = copy *in.get(s);
|
||||||
if body.ends_with(~".") {
|
if body.ends_with(~".") {
|
||||||
body = body + ~"0"; // `10.f` is not a float literal
|
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)) + ~"\"" }
|
LIT_STR(s) => { ~"\"" + str::escape_default(*in.get(s)) + ~"\"" }
|
||||||
|
|
||||||
/* Name components */
|
/* Name components */
|
||||||
IDENT(s, _) => *in.get(s),
|
IDENT(s, _) => copy *in.get(s),
|
||||||
LIFETIME(s) => fmt!("'%s", *in.get(s)),
|
LIFETIME(s) => fmt!("'%s", *in.get(s)),
|
||||||
UNDERSCORE => ~"_",
|
UNDERSCORE => ~"_",
|
||||||
|
|
||||||
/* Other */
|
/* Other */
|
||||||
DOC_COMMENT(s) => *in.get(s),
|
DOC_COMMENT(s) => copy *in.get(s),
|
||||||
EOF => ~"<eof>",
|
EOF => ~"<eof>",
|
||||||
INTERPOLATED(ref nt) => {
|
INTERPOLATED(ref nt) => {
|
||||||
match nt {
|
match nt {
|
||||||
|
@ -476,7 +476,7 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> {
|
||||||
~"self", ~"static",
|
~"self", ~"static",
|
||||||
];
|
];
|
||||||
for keys.each |word| {
|
for keys.each |word| {
|
||||||
words.insert(*word, ());
|
words.insert(copy *word, ());
|
||||||
}
|
}
|
||||||
words
|
words
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
|
||||||
~"while"
|
~"while"
|
||||||
];
|
];
|
||||||
for keys.each |word| {
|
for keys.each |word| {
|
||||||
words.insert(*word, ());
|
words.insert(copy *word, ());
|
||||||
}
|
}
|
||||||
words
|
words
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ pub fn reserved_keyword_table() -> HashMap<~str, ()> {
|
||||||
~"be"
|
~"be"
|
||||||
];
|
];
|
||||||
for keys.each |word| {
|
for keys.each |word| {
|
||||||
words.insert(*word, ());
|
words.insert(copy *word, ());
|
||||||
}
|
}
|
||||||
words
|
words
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue