rustc: "as Trait" can now be written "as @Trait".

There is also code for ~Trait and &Trait, but these are currently (incorrectly)
synonyms for "as @Trait" and "as &Trait".
This commit is contained in:
Patrick Walton
2012-08-14 15:27:06 -07:00
parent fd0f616ceb
commit fe9d07dda6
27 changed files with 125 additions and 83 deletions

View File

@@ -11,7 +11,7 @@ import dvec::{DVec, dvec};
import parse::classify::*;
import util::interner;
type ident_interner = @interner::interner<@~str>;
type ident_interner = interner::interner<@~str>;
// The ps is stored here to prevent recursive type.
enum ann_node {
@@ -30,7 +30,7 @@ fn no_ann() -> pp_ann {
type ps =
@{s: pp::printer,
cm: option<codemap>,
intr: @interner::interner<@~str>,
intr: interner::interner<@~str>,
comments: option<~[comments::cmnt]>,
literals: option<~[comments::lit]>,
mut cur_cmnt: uint,
@@ -51,8 +51,8 @@ fn end(s: ps) {
fn rust_printer(writer: io::Writer) -> ps {
return @{s: pp::mk_printer(writer, default_columns),
cm: none::<codemap>,
intr: @interner::mk::<@~str>(|x| str::hash(*x),
|x,y| str::eq(*x, *y)),
intr: interner::mk::<@~str>(|x| str::hash(*x),
|x,y| str::eq(*x, *y)),
comments: none::<~[comments::cmnt]>,
literals: none::<~[comments::lit]>,
mut cur_cmnt: 0u,
@@ -81,7 +81,7 @@ const default_columns: uint = 78u;
// Requires you to pass an input filename and reader so that
// it can scan the input text for comments and literals to
// copy forward.
fn print_crate(cm: codemap, intr: @interner::interner<@~str>,
fn print_crate(cm: codemap, intr: interner::interner<@~str>,
span_diagnostic: diagnostic::span_handler,
crate: @ast::crate, filename: ~str, in: io::Reader,
out: io::Writer, ann: pp_ann, is_expanded: bool) {
@@ -690,14 +690,14 @@ fn print_tt(s: ps, tt: ast::token_tree) {
}
_ => { s.s.token_tree_last_was_ident = false; }
}
word(s.s, parse::token::to_str(*s.intr, tk));
word(s.s, parse::token::to_str(s.intr, tk));
}
ast::tt_seq(_, tts, sep, zerok) => {
word(s.s, ~"$(");
for tts.each() |tt_elt| { print_tt(s, tt_elt); }
word(s.s, ~")");
match sep {
some(tk) => word(s.s, parse::token::to_str(*s.intr, tk)),
some(tk) => word(s.s, parse::token::to_str(s.intr, tk)),
none => ()
}
word(s.s, if zerok { ~"*" } else { ~"+" });