diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-06-07 21:53:47 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-06-07 21:53:47 -0700 |
| commit | 26faa37305f59e2b09a92b089b78abc4f01da8e8 (patch) | |
| tree | 68f2618785f4b7fbe324f4ae9839e3c57b2fedd1 /src/libsyntax/parse | |
| parent | 847c5e4e9892ef56873ac52a552997267c4d385a (diff) | |
| download | rust-26faa37305f59e2b09a92b089b78abc4f01da8e8.tar.gz rust-26faa37305f59e2b09a92b089b78abc4f01da8e8.zip | |
syntax: Add a lot of copy keywords
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/common.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/eval.rs | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 35afb79ce63..c0a2f9b9e6e 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -209,6 +209,9 @@ impl parser_common for parser { ret v; } + // FIXME: A lot of callers go through here, only to copy out the T and + // discard the spanned<> wrapper. I feel as though there should be a + // version of this that does not return a spanned result. fn parse_seq<T: copy>(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> spanned<[T]> { let lo = self.span.lo; @@ -218,4 +221,4 @@ impl parser_common for parser { self.bump(); ret spanned(lo, hi, result); } -} \ No newline at end of file +} diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 98d75499878..254d5cc5d5d 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -44,7 +44,7 @@ optional suffix then adding the .rs extension. fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>) -> ([@ast::view_item], [@ast::item], [ast::attribute]) { - fn companion_file(prefix: str, suffix: option<str>) -> str { + fn companion_file(+prefix: str, suffix: option<str>) -> str { ret alt suffix { option::some(s) { path::connect(prefix, s) } option::none { prefix } @@ -66,8 +66,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>) #debug("found companion mod"); let p0 = new_parser_from_file(cx.sess, cx.cfg, modpath, SOURCE_FILE); let inner_attrs = p0.parse_inner_attrs_and_next(); - let first_item_outer_attrs = inner_attrs.next; - let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); + let m0 = p0.parse_mod_items(token::EOF, inner_attrs.next); cx.sess.chpos = p0.reader.chpos; cx.sess.byte_pos = cx.sess.byte_pos + p0.reader.pos; ret (m0.view_items, m0.items, inner_attrs.inner); @@ -102,7 +101,8 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, let first_item_outer_attrs = inner_attrs.next; let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); - let i = p0.mk_item(cdir.span.lo, cdir.span.hi, id, + let i = p0.mk_item(cdir.span.lo, cdir.span.hi, + /* FIXME: bad */ copy id, ast::item_mod(m0), ast::public, mod_attrs); // Thread defids, chpos and byte_pos through the parsers cx.sess.chpos = p0.reader.chpos; @@ -118,7 +118,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, let (m0, a0) = eval_crate_directives_to_mod( cx, cdirs, full_path, none); let i = - @{ident: id, + @{ident: /* FIXME: bad */ copy id, attrs: attrs + a0, id: cx.sess.next_id, node: ast::item_mod(m0), |
