syntax: de-mode and prepare for de-modeing rustc

This commit is contained in:
Alex Crichton 2013-04-17 12:15:08 -04:00
parent be9f4ef65f
commit 3c7aea3a6a
30 changed files with 363 additions and 364 deletions

View file

@ -255,13 +255,13 @@ pub impl AbiSet {
} }
impl to_bytes::IterBytes for Abi { impl to_bytes::IterBytes for Abi {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
self.index().iter_bytes(lsb0, f) self.index().iter_bytes(lsb0, f)
} }
} }
impl to_bytes::IterBytes for AbiSet { impl to_bytes::IterBytes for AbiSet {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
self.bits.iter_bytes(lsb0, f) self.bits.iter_bytes(lsb0, f)
} }
} }

View file

@ -97,7 +97,7 @@ impl<D:Decoder> Decodable<D> for ident {
} }
impl to_bytes::IterBytes for ident { impl to_bytes::IterBytes for ident {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
self.repr.iter_bytes(lsb0, f) self.repr.iter_bytes(lsb0, f)
} }
} }
@ -284,7 +284,7 @@ pub enum binding_mode {
} }
impl to_bytes::IterBytes for binding_mode { impl to_bytes::IterBytes for binding_mode {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
bind_by_copy => 0u8.iter_bytes(lsb0, f), bind_by_copy => 0u8.iter_bytes(lsb0, f),
@ -330,7 +330,7 @@ pub enum pat_ {
pub enum mutability { m_mutbl, m_imm, m_const, } pub enum mutability { m_mutbl, m_imm, m_const, }
impl to_bytes::IterBytes for mutability { impl to_bytes::IterBytes for mutability {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -345,7 +345,7 @@ pub enum Sigil {
} }
impl to_bytes::IterBytes for Sigil { impl to_bytes::IterBytes for Sigil {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
} }
@ -428,7 +428,7 @@ pub enum inferable<T> {
} }
impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> { impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
expl(ref t) => expl(ref t) =>
to_bytes::iter_bytes_2(&0u8, t, lsb0, f), to_bytes::iter_bytes_2(&0u8, t, lsb0, f),
@ -446,7 +446,7 @@ impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
pub enum rmode { by_ref, by_copy } pub enum rmode { by_ref, by_copy }
impl to_bytes::IterBytes for rmode { impl to_bytes::IterBytes for rmode {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -781,7 +781,7 @@ impl ToStr for int_ty {
} }
impl to_bytes::IterBytes for int_ty { impl to_bytes::IterBytes for int_ty {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -798,7 +798,7 @@ impl ToStr for uint_ty {
} }
impl to_bytes::IterBytes for uint_ty { impl to_bytes::IterBytes for uint_ty {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -815,7 +815,7 @@ impl ToStr for float_ty {
} }
impl to_bytes::IterBytes for float_ty { impl to_bytes::IterBytes for float_ty {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -860,7 +860,7 @@ impl ToStr for Onceness {
} }
impl to_bytes::IterBytes for Onceness { impl to_bytes::IterBytes for Onceness {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f); (*self as uint).iter_bytes(lsb0, f);
} }
} }
@ -911,7 +911,7 @@ pub enum ty_ {
} }
impl to_bytes::IterBytes for Ty { impl to_bytes::IterBytes for Ty {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f); to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
} }
} }
@ -979,7 +979,7 @@ impl ToStr for purity {
} }
impl to_bytes::IterBytes for purity { impl to_bytes::IterBytes for purity {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -994,7 +994,7 @@ pub enum ret_style {
} }
impl to_bytes::IterBytes for ret_style { impl to_bytes::IterBytes for ret_style {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
@ -1268,7 +1268,7 @@ pub enum item_ {
pub enum struct_mutability { struct_mutable, struct_immutable } pub enum struct_mutability { struct_mutable, struct_immutable }
impl to_bytes::IterBytes for struct_mutability { impl to_bytes::IterBytes for struct_mutability {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }

View file

@ -115,7 +115,7 @@ pub struct Ctx {
pub type vt = visit::vt<@mut Ctx>; pub type vt = visit::vt<@mut Ctx>;
pub fn extend(cx: @mut Ctx, +elt: ident) -> @path { pub fn extend(cx: @mut Ctx, elt: ident) -> @path {
@(vec::append(copy cx.path, ~[path_name(elt)])) @(vec::append(copy cx.path, ~[path_name(elt)]))
} }
@ -132,7 +132,7 @@ pub fn mk_ast_map_visitor() -> vt {
}); });
} }
pub fn map_crate(diag: @span_handler, c: crate) -> map { pub fn map_crate(diag: @span_handler, c: @crate) -> map {
let cx = @mut Ctx { let cx = @mut Ctx {
map: @mut HashMap::new(), map: @mut HashMap::new(),
path: ~[], path: ~[],
@ -148,8 +148,8 @@ pub fn map_crate(diag: @span_handler, c: crate) -> map {
// the item itself. // the item itself.
pub fn map_decoded_item(diag: @span_handler, pub fn map_decoded_item(diag: @span_handler,
map: map, map: map,
+path: path, path: path,
ii: inlined_item) { ii: &inlined_item) {
// I believe it is ok for the local IDs of inlined items from other crates // I believe it is ok for the local IDs of inlined items from other crates
// to overlap with the local ids from this crate, so just generate the ids // to overlap with the local ids from this crate, so just generate the ids
// starting from 0. (In particular, I think these ids are only used in // starting from 0. (In particular, I think these ids are only used in
@ -167,7 +167,7 @@ pub fn map_decoded_item(diag: @span_handler,
// methods get added to the AST map when their impl is visited. Since we // methods get added to the AST map when their impl is visited. Since we
// don't decode and instantiate the impl, but just the method, we have to // don't decode and instantiate the impl, but just the method, we have to
// add it to the table now: // add it to the table now:
match ii { match *ii {
ii_item(*) | ii_dtor(*) => { /* fallthrough */ } ii_item(*) | ii_dtor(*) => { /* fallthrough */ }
ii_foreign(i) => { ii_foreign(i) => {
cx.map.insert(i.id, node_foreign_item(i, cx.map.insert(i.id, node_foreign_item(i,
@ -190,7 +190,7 @@ pub fn map_fn(
body: &blk, body: &blk,
sp: codemap::span, sp: codemap::span,
id: node_id, id: node_id,
&&cx: @mut Ctx, cx: @mut Ctx,
v: visit::vt<@mut Ctx> v: visit::vt<@mut Ctx>
) { ) {
for decl.inputs.each |a| { for decl.inputs.each |a| {
@ -222,7 +222,7 @@ pub fn map_fn(
visit::visit_fn(fk, decl, body, sp, id, cx, v); visit::visit_fn(fk, decl, body, sp, id, cx, v);
} }
pub fn map_block(b: &blk, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_block(b: &blk, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b)); cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b));
visit::visit_block(b, cx, v); visit::visit_block(b, cx, v);
} }
@ -239,24 +239,24 @@ pub fn number_pat(cx: @mut Ctx, pat: @pat) {
}; };
} }
pub fn map_local(loc: @local, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_local(loc: @local, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
number_pat(cx, loc.node.pat); number_pat(cx, loc.node.pat);
visit::visit_local(loc, cx, v); visit::visit_local(loc, cx, v);
} }
pub fn map_arm(arm: &arm, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_arm(arm: &arm, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
number_pat(cx, arm.pats[0]); number_pat(cx, arm.pats[0]);
visit::visit_arm(arm, cx, v); visit::visit_arm(arm, cx, v);
} }
pub fn map_method(impl_did: def_id, impl_path: @path, pub fn map_method(impl_did: def_id, impl_path: @path,
m: @method, &&cx: @mut Ctx) { m: @method, cx: @mut Ctx) {
cx.map.insert(m.id, node_method(m, impl_did, impl_path)); cx.map.insert(m.id, node_method(m, impl_did, impl_path));
cx.map.insert(m.self_id, node_local(cx.local_id)); cx.map.insert(m.self_id, node_local(cx.local_id));
cx.local_id += 1u; cx.local_id += 1u;
} }
pub fn map_item(i: @item, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_item(i: @item, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
let item_path = @/* FIXME (#2543) */ copy cx.path; let item_path = @/* FIXME (#2543) */ copy cx.path;
cx.map.insert(i.id, node_item(i, item_path)); cx.map.insert(i.id, node_item(i, item_path));
match i.node { match i.node {
@ -355,13 +355,13 @@ pub fn map_struct_def(
} }
} }
pub fn map_expr(ex: @expr, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_expr(ex: @expr, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
cx.map.insert(ex.id, node_expr(ex)); cx.map.insert(ex.id, node_expr(ex));
visit::visit_expr(ex, cx, v); visit::visit_expr(ex, cx, v);
} }
pub fn map_stmt(stmt: @stmt, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) { pub fn map_stmt(stmt: @stmt, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
cx.map.insert(stmt_id(*stmt), node_stmt(stmt)); cx.map.insert(stmt_id(stmt), node_stmt(stmt));
visit::visit_stmt(stmt, cx, v); visit::visit_stmt(stmt, cx, v);
} }
@ -408,7 +408,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
} }
Some(&node_stmt(stmt)) => { Some(&node_stmt(stmt)) => {
fmt!("stmt %s (id=%?)", fmt!("stmt %s (id=%?)",
pprust::stmt_to_str(*stmt, itr), id) pprust::stmt_to_str(stmt, itr), id)
} }
Some(&node_arg(_, _)) => { // add more info here Some(&node_arg(_, _)) => { // add more info here
fmt!("arg (id=%?)", id) fmt!("arg (id=%?)", id)
@ -430,7 +430,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
pub fn node_item_query<Result>(items: map, id: node_id, pub fn node_item_query<Result>(items: map, id: node_id,
query: &fn(@item) -> Result, query: &fn(@item) -> Result,
+error_msg: ~str) -> Result { error_msg: ~str) -> Result {
match items.find(&id) { match items.find(&id) {
Some(&node_item(it, _)) => query(it), Some(&node_item(it, _)) => query(it),
_ => fail!(error_msg) _ => fail!(error_msg)

View file

@ -39,7 +39,7 @@ pub fn local_def(id: node_id) -> def_id {
pub fn is_local(did: ast::def_id) -> bool { did.crate == local_crate } pub fn is_local(did: ast::def_id) -> bool { did.crate == local_crate }
pub fn stmt_id(s: stmt) -> node_id { pub fn stmt_id(s: &stmt) -> node_id {
match s.node { match s.node {
stmt_decl(_, id) => id, stmt_decl(_, id) => id,
stmt_expr(_, id) => id, stmt_expr(_, id) => id,
@ -200,7 +200,7 @@ pub fn is_call_expr(e: @expr) -> bool {
// This makes def_id hashable // This makes def_id hashable
impl to_bytes::IterBytes for def_id { impl to_bytes::IterBytes for def_id {
#[inline(always)] #[inline(always)]
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
} }
} }
@ -211,7 +211,7 @@ pub fn block_from_expr(e: @expr) -> blk {
} }
pub fn default_block( pub fn default_block(
+stmts1: ~[@stmt], stmts1: ~[@stmt],
expr1: Option<@expr>, expr1: Option<@expr>,
id1: node_id id1: node_id
) -> blk_ { ) -> blk_ {
@ -224,7 +224,7 @@ pub fn default_block(
} }
} }
pub fn ident_to_path(s: span, +i: ident) -> @Path { pub fn ident_to_path(s: span, i: ident) -> @Path {
@ast::Path { span: s, @ast::Path { span: s,
global: false, global: false,
idents: ~[i], idents: ~[i],
@ -232,7 +232,7 @@ pub fn ident_to_path(s: span, +i: ident) -> @Path {
types: ~[] } types: ~[] }
} }
pub fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat { pub fn ident_to_pat(id: node_id, s: span, i: ident) -> @pat {
@ast::pat { id: id, @ast::pat { id: id,
node: pat_ident(bind_by_copy, ident_to_path(s, i), None), node: pat_ident(bind_by_copy, ident_to_path(s, i), None),
span: s } span: s }
@ -300,7 +300,7 @@ pub fn struct_field_visibility(field: ast::struct_field) -> visibility {
pub trait inlined_item_utils { pub trait inlined_item_utils {
fn ident(&self) -> ident; fn ident(&self) -> ident;
fn id(&self) -> ast::node_id; fn id(&self) -> ast::node_id;
fn accept<E>(&self, e: E, v: visit::vt<E>); fn accept<E: Copy>(&self, e: E, v: visit::vt<E>);
} }
impl inlined_item_utils for inlined_item { impl inlined_item_utils for inlined_item {
@ -322,7 +322,7 @@ impl inlined_item_utils for inlined_item {
} }
} }
fn accept<E>(&self, e: E, v: visit::vt<E>) { fn accept<E: Copy>(&self, e: E, v: visit::vt<E>) {
match *self { match *self {
ii_item(i) => (v.visit_item)(i, e, v), ii_item(i) => (v.visit_item)(i, e, v),
ii_foreign(i) => (v.visit_foreign_item)(i, e, v), ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
@ -435,7 +435,7 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> {
visit_local: |l| vfn(l.node.id), visit_local: |l| vfn(l.node.id),
visit_block: |b| vfn(b.node.id), visit_block: |b| vfn(b.node.id),
visit_stmt: |s| vfn(ast_util::stmt_id(*s)), visit_stmt: |s| vfn(ast_util::stmt_id(s)),
visit_arm: |_| {}, visit_arm: |_| {},
visit_pat: |p| vfn(p.id), visit_pat: |p| vfn(p.id),
visit_decl: |_| {}, visit_decl: |_| {},
@ -491,7 +491,7 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> {
}) })
} }
pub fn visit_ids_for_inlined_item(item: inlined_item, vfn: @fn(node_id)) { pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(node_id)) {
item.accept((), id_visitor(vfn)); item.accept((), id_visitor(vfn));
} }
@ -505,7 +505,7 @@ pub fn compute_id_range(visit_ids_fn: &fn(@fn(node_id))) -> id_range {
id_range { min: *min, max: *max } id_range { min: *min, max: *max }
} }
pub fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { pub fn compute_id_range_for_inlined_item(item: &inlined_item) -> id_range {
compute_id_range(|f| visit_ids_for_inlined_item(item, f)) compute_id_range(|f| visit_ids_for_inlined_item(item, f))
} }
@ -609,7 +609,7 @@ pub fn mk_rename (id:ident, to:Name, tail:SyntaxContext, table: &mut SCTable)
pub fn mk_sctable() -> SCTable { ~[EmptyCtxt] } pub fn mk_sctable() -> SCTable { ~[EmptyCtxt] }
/// Add a value to the end of a vec, return its index /// Add a value to the end of a vec, return its index
fn idx_push<T>(vec: &mut ~[T], +val: T) -> uint { fn idx_push<T>(vec: &mut ~[T], val: T) -> uint {
vec.push(val); vec.push(val);
vec.len() - 1 vec.len() - 1
} }

View file

@ -31,12 +31,12 @@ pub fn mk_name_value_item_str(name: @~str, value: @~str)
mk_name_value_item(name, value_lit) mk_name_value_item(name, value_lit)
} }
pub fn mk_name_value_item(name: @~str, +value: ast::lit) pub fn mk_name_value_item(name: @~str, value: ast::lit)
-> @ast::meta_item { -> @ast::meta_item {
@dummy_spanned(ast::meta_name_value(name, value)) @dummy_spanned(ast::meta_name_value(name, value))
} }
pub fn mk_list_item(name: @~str, +items: ~[@ast::meta_item]) -> pub fn mk_list_item(name: @~str, items: ~[@ast::meta_item]) ->
@ast::meta_item { @ast::meta_item {
@dummy_spanned(ast::meta_list(name, items)) @dummy_spanned(ast::meta_list(name, items))
} }
@ -51,8 +51,8 @@ pub fn mk_attr(item: @ast::meta_item) -> ast::attribute {
is_sugared_doc: false }) is_sugared_doc: false })
} }
pub fn mk_sugared_doc_attr(+text: ~str, pub fn mk_sugared_doc_attr(text: ~str,
+lo: BytePos, +hi: BytePos) -> ast::attribute { lo: BytePos, hi: BytePos) -> ast::attribute {
let style = doc_comment_style(text); let style = doc_comment_style(text);
let lit = spanned(lo, hi, ast::lit_str(@text)); let lit = spanned(lo, hi, ast::lit_str(@text));
let attr = ast::attribute_ { let attr = ast::attribute_ {

View file

@ -71,7 +71,7 @@ impl Sub<BytePos, BytePos> for BytePos {
} }
impl to_bytes::IterBytes for BytePos { impl to_bytes::IterBytes for BytePos {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f) (**self).iter_bytes(lsb0, f)
} }
} }
@ -89,7 +89,7 @@ impl cmp::Ord for CharPos {
} }
impl to_bytes::IterBytes for CharPos { impl to_bytes::IterBytes for CharPos {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f) (**self).iter_bytes(lsb0, f)
} }
} }
@ -141,20 +141,20 @@ impl<D:Decoder> Decodable<D> for span {
} }
} }
pub fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> { pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> spanned<T> {
respan(mk_sp(lo, hi), t) respan(mk_sp(lo, hi), t)
} }
pub fn respan<T>(sp: span, +t: T) -> spanned<T> { pub fn respan<T>(sp: span, t: T) -> spanned<T> {
spanned {node: t, span: sp} spanned {node: t, span: sp}
} }
pub fn dummy_spanned<T>(+t: T) -> spanned<T> { pub fn dummy_spanned<T>(t: T) -> spanned<T> {
respan(dummy_sp(), t) respan(dummy_sp(), t)
} }
/* assuming that we're not in macro expansion */ /* assuming that we're not in macro expansion */
pub fn mk_sp(+lo: BytePos, +hi: BytePos) -> span { pub fn mk_sp(lo: BytePos, hi: BytePos) -> span {
span {lo: lo, hi: hi, expn_info: None} span {lo: lo, hi: hi, expn_info: None}
} }
@ -247,7 +247,7 @@ pub impl FileMap {
// UNCHECKED INVARIANT: these offsets must be added in the right // UNCHECKED INVARIANT: these offsets must be added in the right
// order and must be in the right places; there is shared knowledge // order and must be in the right places; there is shared knowledge
// about what ends a line between this file and parse.rs // about what ends a line between this file and parse.rs
fn next_line(&self, +pos: BytePos) { fn next_line(&self, pos: BytePos) {
// the new charpos must be > the last one (or it's the first one). // the new charpos must be > the last one (or it's the first one).
let lines = &mut *self.lines; let lines = &mut *self.lines;
assert!((lines.len() == 0) || (lines[lines.len() - 1] < pos)); assert!((lines.len() == 0) || (lines[lines.len() - 1] < pos));
@ -287,14 +287,14 @@ pub impl CodeMap {
} }
/// Add a new FileMap to the CodeMap and return it /// Add a new FileMap to the CodeMap and return it
fn new_filemap(&self, +filename: FileName, src: @~str) -> @FileMap { fn new_filemap(&self, filename: FileName, src: @~str) -> @FileMap {
return self.new_filemap_w_substr(filename, FssNone, src); return self.new_filemap_w_substr(filename, FssNone, src);
} }
fn new_filemap_w_substr( fn new_filemap_w_substr(
&self, &self,
+filename: FileName, filename: FileName,
+substr: FileSubstr, substr: FileSubstr,
src: @~str src: @~str
) -> @FileMap { ) -> @FileMap {
let files = &mut *self.files; let files = &mut *self.files;
@ -325,11 +325,11 @@ pub impl CodeMap {
} }
/// Lookup source information about a BytePos /// Lookup source information about a BytePos
pub fn lookup_char_pos(&self, +pos: BytePos) -> Loc { pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
return self.lookup_pos(pos); return self.lookup_pos(pos);
} }
pub fn lookup_char_pos_adj(&self, +pos: BytePos) -> LocWithOpt pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
{ {
let loc = self.lookup_char_pos(pos); let loc = self.lookup_char_pos(pos);
match (loc.file.substr) { match (loc.file.substr) {
@ -405,7 +405,7 @@ pub impl CodeMap {
priv impl CodeMap { priv impl CodeMap {
fn lookup_filemap_idx(&self, +pos: BytePos) -> uint { fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
let files = &*self.files; let files = &*self.files;
let len = files.len(); let len = files.len();
let mut a = 0u; let mut a = 0u;
@ -440,7 +440,7 @@ priv impl CodeMap {
return FileMapAndLine {fm: f, line: a}; return FileMapAndLine {fm: f, line: a};
} }
fn lookup_pos(&self, +pos: BytePos) -> Loc { fn lookup_pos(&self, pos: BytePos) -> Loc {
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos); let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
let line = a + 1u; // Line numbers start at 1 let line = a + 1u; // Line numbers start at 1
let chpos = self.bytepos_to_local_charpos(pos); let chpos = self.bytepos_to_local_charpos(pos);
@ -466,7 +466,7 @@ priv impl CodeMap {
lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint()) lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint())
} }
fn lookup_byte_offset(&self, +bpos: BytePos) fn lookup_byte_offset(&self, bpos: BytePos)
-> FileMapAndBytePos { -> FileMapAndBytePos {
let idx = self.lookup_filemap_idx(bpos); let idx = self.lookup_filemap_idx(bpos);
let fm = self.files[idx]; let fm = self.files[idx];
@ -476,7 +476,7 @@ priv impl CodeMap {
// Converts an absolute BytePos to a CharPos relative to the file it is // Converts an absolute BytePos to a CharPos relative to the file it is
// located in // located in
fn bytepos_to_local_charpos(&self, +bpos: BytePos) -> CharPos { fn bytepos_to_local_charpos(&self, bpos: BytePos) -> CharPos {
debug!("codemap: converting %? to char pos", bpos); debug!("codemap: converting %? to char pos", bpos);
let idx = self.lookup_filemap_idx(bpos); let idx = self.lookup_filemap_idx(bpos);
let map = self.files[idx]; let map = self.files[idx];

View file

@ -239,7 +239,7 @@ priv impl @ext_ctxt {
} }
} }
fn expr(&self, span: span, +node: ast::expr_) -> @ast::expr { fn expr(&self, span: span, node: ast::expr_) -> @ast::expr {
@ast::expr { @ast::expr {
id: self.next_id(), id: self.next_id(),
callee_id: self.next_id(), callee_id: self.next_id(),
@ -248,7 +248,7 @@ priv impl @ext_ctxt {
} }
} }
fn path(&self, span: span, +strs: ~[ast::ident]) -> @ast::Path { fn path(&self, span: span, strs: ~[ast::ident]) -> @ast::Path {
@ast::Path { @ast::Path {
span: span, span: span,
global: false, global: false,
@ -258,7 +258,7 @@ priv impl @ext_ctxt {
} }
} }
fn path_global(&self, span: span, +strs: ~[ast::ident]) -> @ast::Path { fn path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::Path {
@ast::Path { @ast::Path {
span: span, span: span,
global: true, global: true,
@ -271,8 +271,8 @@ priv impl @ext_ctxt {
fn path_tps( fn path_tps(
&self, &self,
span: span, span: span,
+strs: ~[ast::ident], strs: ~[ast::ident],
+tps: ~[@ast::Ty] tps: ~[@ast::Ty]
) -> @ast::Path { ) -> @ast::Path {
@ast::Path { @ast::Path {
span: span, span: span,
@ -286,8 +286,8 @@ priv impl @ext_ctxt {
fn path_tps_global( fn path_tps_global(
&self, &self,
span: span, span: span,
+strs: ~[ast::ident], strs: ~[ast::ident],
+tps: ~[@ast::Ty] tps: ~[@ast::Ty]
) -> @ast::Path { ) -> @ast::Path {
@ast::Path { @ast::Path {
span: span, span: span,
@ -301,8 +301,8 @@ priv impl @ext_ctxt {
fn ty_path( fn ty_path(
&self, &self,
span: span, span: span,
+strs: ~[ast::ident], strs: ~[ast::ident],
+tps: ~[@ast::Ty] tps: ~[@ast::Ty]
) -> @ast::Ty { ) -> @ast::Ty {
@ast::Ty { @ast::Ty {
id: self.next_id(), id: self.next_id(),
@ -349,13 +349,13 @@ priv impl @ext_ctxt {
span: span})) span: span}))
} }
fn lambda(&self, +blk: ast::blk) -> @ast::expr { fn lambda(&self, blk: ast::blk) -> @ast::expr {
let ext_cx = *self; let ext_cx = *self;
let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk)); let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
quote_expr!( || $blk_e ) quote_expr!( || $blk_e )
} }
fn blk(&self, span: span, +stmts: ~[@ast::stmt]) -> ast::blk { fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk {
codemap::spanned { codemap::spanned {
node: ast::blk_ { node: ast::blk_ {
view_items: ~[], view_items: ~[],
@ -381,19 +381,19 @@ priv impl @ext_ctxt {
} }
} }
fn expr_path(&self, span: span, +strs: ~[ast::ident]) -> @ast::expr { fn expr_path(&self, span: span, strs: ~[ast::ident]) -> @ast::expr {
self.expr(span, ast::expr_path(self.path(span, strs))) self.expr(span, ast::expr_path(self.path(span, strs)))
} }
fn expr_path_global( fn expr_path_global(
&self, &self,
span: span, span: span,
+strs: ~[ast::ident] strs: ~[ast::ident]
) -> @ast::expr { ) -> @ast::expr {
self.expr(span, ast::expr_path(self.path_global(span, strs))) self.expr(span, ast::expr_path(self.path_global(span, strs)))
} }
fn expr_var(&self, span: span, +var: ~str) -> @ast::expr { fn expr_var(&self, span: span, var: ~str) -> @ast::expr {
self.expr_path(span, ~[self.ident_of(var)]) self.expr_path(span, ~[self.ident_of(var)])
} }
@ -410,7 +410,7 @@ priv impl @ext_ctxt {
&self, &self,
span: span, span: span,
expr: @ast::expr, expr: @ast::expr,
+args: ~[@ast::expr] args: ~[@ast::expr]
) -> @ast::expr { ) -> @ast::expr {
self.expr(span, ast::expr_call(expr, args, ast::NoSugar)) self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
} }
@ -420,7 +420,7 @@ priv impl @ext_ctxt {
span: span, span: span,
expr: @ast::expr, expr: @ast::expr,
ident: ast::ident, ident: ast::ident,
+args: ~[@ast::expr] args: ~[@ast::expr]
) -> @ast::expr { ) -> @ast::expr {
self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar)) self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar))
} }
@ -429,7 +429,7 @@ priv impl @ext_ctxt {
self.lambda(self.expr_blk(expr)) self.lambda(self.expr_blk(expr))
} }
fn lambda_stmts(&self, span: span, +stmts: ~[@ast::stmt]) -> @ast::expr { fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda(self.blk(span, stmts)) self.lambda(self.blk(span, stmts))
} }
} }
@ -597,7 +597,7 @@ fn mk_deser_impl(
fn mk_ser_method( fn mk_ser_method(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
+ser_body: ast::blk ser_body: ast::blk
) -> @ast::method { ) -> @ast::method {
let ty_s = @ast::Ty { let ty_s = @ast::Ty {
id: cx.next_id(), id: cx.next_id(),
@ -660,7 +660,7 @@ fn mk_deser_method(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
ty: @ast::Ty, ty: @ast::Ty,
+deser_body: ast::blk deser_body: ast::blk
) -> @ast::method { ) -> @ast::method {
let ty_d = @ast::Ty { let ty_d = @ast::Ty {
id: cx.next_id(), id: cx.next_id(),
@ -864,7 +864,7 @@ fn mk_enum_ser_impl(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
+enum_def: ast::enum_def, enum_def: ast::enum_def,
generics: &ast::Generics generics: &ast::Generics
) -> @ast::item { ) -> @ast::item {
let body = mk_enum_ser_body( let body = mk_enum_ser_body(
@ -881,7 +881,7 @@ fn mk_enum_deser_impl(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
+enum_def: ast::enum_def, enum_def: ast::enum_def,
generics: &ast::Generics generics: &ast::Generics
) -> @ast::item { ) -> @ast::item {
let body = mk_enum_deser_body( let body = mk_enum_deser_body(
@ -974,7 +974,7 @@ fn mk_enum_ser_body(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
name: ast::ident, name: ast::ident,
+variants: ~[ast::variant] variants: ~[ast::variant]
) -> @ast::expr { ) -> @ast::expr {
let arms = do variants.mapi |v_idx, variant| { let arms = do variants.mapi |v_idx, variant| {
match variant.node.kind { match variant.node.kind {
@ -1219,37 +1219,37 @@ mod test {
impl Encoder for TestEncoder { impl Encoder for TestEncoder {
fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } fn emit_nil(&self) { self.add_to_log(CallToEmitNil) }
fn emit_uint(&self, +v: uint) {self.add_to_log(CallToEmitUint(v)); } fn emit_uint(&self, v: uint) {self.add_to_log(CallToEmitUint(v)); }
fn emit_u64(&self, +_v: u64) { self.add_unknown_to_log(); } fn emit_u64(&self, _v: u64) { self.add_unknown_to_log(); }
fn emit_u32(&self, +_v: u32) { self.add_unknown_to_log(); } fn emit_u32(&self, _v: u32) { self.add_unknown_to_log(); }
fn emit_u16(&self, +_v: u16) { self.add_unknown_to_log(); } fn emit_u16(&self, _v: u16) { self.add_unknown_to_log(); }
fn emit_u8(&self, +_v: u8) { self.add_unknown_to_log(); } fn emit_u8(&self, _v: u8) { self.add_unknown_to_log(); }
fn emit_int(&self, +_v: int) { self.add_unknown_to_log(); } fn emit_int(&self, _v: int) { self.add_unknown_to_log(); }
fn emit_i64(&self, +_v: i64) { self.add_unknown_to_log(); } fn emit_i64(&self, _v: i64) { self.add_unknown_to_log(); }
fn emit_i32(&self, +_v: i32) { self.add_unknown_to_log(); } fn emit_i32(&self, _v: i32) { self.add_unknown_to_log(); }
fn emit_i16(&self, +_v: i16) { self.add_unknown_to_log(); } fn emit_i16(&self, _v: i16) { self.add_unknown_to_log(); }
fn emit_i8(&self, +_v: i8) { self.add_unknown_to_log(); } fn emit_i8(&self, _v: i8) { self.add_unknown_to_log(); }
fn emit_bool(&self, +_v: bool) { self.add_unknown_to_log(); } fn emit_bool(&self, _v: bool) { self.add_unknown_to_log(); }
fn emit_f64(&self, +_v: f64) { self.add_unknown_to_log(); } fn emit_f64(&self, _v: f64) { self.add_unknown_to_log(); }
fn emit_f32(&self, +_v: f32) { self.add_unknown_to_log(); } fn emit_f32(&self, _v: f32) { self.add_unknown_to_log(); }
fn emit_float(&self, +_v: float) { self.add_unknown_to_log(); } fn emit_float(&self, _v: float) { self.add_unknown_to_log(); }
fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); } fn emit_char(&self, _v: char) { self.add_unknown_to_log(); }
fn emit_str(&self, +_v: &str) { self.add_unknown_to_log(); } fn emit_str(&self, _v: &str) { self.add_unknown_to_log(); }
fn emit_enum(&self, name: &str, f: &fn()) { fn emit_enum(&self, name: &str, f: &fn()) {
self.add_to_log(CallToEmitEnum(name.to_str())); f(); } self.add_to_log(CallToEmitEnum(name.to_str())); f(); }
fn emit_enum_variant(&self, name: &str, +id: uint, fn emit_enum_variant(&self, name: &str, id: uint,
+cnt: uint, f: &fn()) { cnt: uint, f: &fn()) {
self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt));
f(); f();
} }
fn emit_enum_variant_arg(&self, +idx: uint, f: &fn()) { fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) {
self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); self.add_to_log(CallToEmitEnumVariantArg (idx)); f();
} }
@ -1261,10 +1261,10 @@ mod test {
self.emit_enum_variant_arg(idx, f) self.emit_enum_variant_arg(idx, f)
} }
fn emit_struct(&self, name: &str, +len: uint, f: &fn()) { fn emit_struct(&self, name: &str, len: uint, f: &fn()) {
self.add_to_log(CallToEmitStruct (name.to_str(),len)); f(); self.add_to_log(CallToEmitStruct (name.to_str(),len)); f();
} }
fn emit_struct_field(&self, name: &str, +idx: uint, f: &fn()) { fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) {
self.add_to_log(CallToEmitField (name.to_str(),idx)); f(); self.add_to_log(CallToEmitField (name.to_str(),idx)); f();
} }
@ -1294,10 +1294,10 @@ mod test {
f(); f();
} }
fn emit_seq(&self, +_len: uint, f: &fn()) { fn emit_seq(&self, _len: uint, f: &fn()) {
self.add_unknown_to_log(); f(); self.add_unknown_to_log(); f();
} }
fn emit_seq_elt(&self, +_idx: uint, f: &fn()) { fn emit_seq_elt(&self, _idx: uint, f: &fn()) {
self.add_unknown_to_log(); f(); self.add_unknown_to_log(); f();
} }

View file

@ -238,7 +238,7 @@ pub trait ext_ctxt {
fn ident_of(@mut self, st: ~str) -> ast::ident; fn ident_of(@mut self, st: ~str) -> ast::ident;
} }
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, +cfg: ast::crate_cfg) pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg)
-> @ext_ctxt { -> @ext_ctxt {
struct CtxtRepr { struct CtxtRepr {
parse_sess: @mut parse::ParseSess, parse_sess: @mut parse::ParseSess,
@ -439,7 +439,7 @@ pub enum MapChain<K,V> {
impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// Constructor. I don't think we need a zero-arg one. // Constructor. I don't think we need a zero-arg one.
fn new(+init: ~HashMap<K,@V>) -> @mut MapChain<K,V> { fn new(init: ~HashMap<K,@V>) -> @mut MapChain<K,V> {
@mut BaseMapChain(init) @mut BaseMapChain(init)
} }
@ -509,7 +509,7 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
} }
// insert the binding into the top-level map // insert the binding into the top-level map
fn insert (&mut self, +key: K, +ext: @V) -> bool { fn insert (&mut self, key: K, ext: @V) -> bool {
// can't abstract over get_map because of flow sensitivity... // can't abstract over get_map because of flow sensitivity...
match *self { match *self {
BaseMapChain (~ref mut map) => map.insert(key, ext), BaseMapChain (~ref mut map) => map.insert(key, ext),

View file

@ -27,7 +27,7 @@ pub struct Field {
pub fn mk_expr(cx: @ext_ctxt, pub fn mk_expr(cx: @ext_ctxt,
sp: codemap::span, sp: codemap::span,
+expr: ast::expr_) expr: ast::expr_)
-> @ast::expr { -> @ast::expr {
@ast::expr { @ast::expr {
id: cx.next_id(), id: cx.next_id(),
@ -63,12 +63,12 @@ pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
cx.next_id(); // see ast_util::op_expr_callee_id cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e)) mk_expr(cx, sp, ast::expr_unary(op, e))
} }
pub fn mk_raw_path(sp: span, +idents: ~[ast::ident]) -> @ast::Path { pub fn mk_raw_path(sp: span, idents: ~[ast::ident]) -> @ast::Path {
mk_raw_path_(sp, idents, ~[]) mk_raw_path_(sp, idents, ~[])
} }
pub fn mk_raw_path_(sp: span, pub fn mk_raw_path_(sp: span,
+idents: ~[ast::ident], idents: ~[ast::ident],
+types: ~[@ast::Ty]) types: ~[@ast::Ty])
-> @ast::Path { -> @ast::Path {
@ast::Path { span: sp, @ast::Path { span: sp,
global: false, global: false,
@ -76,23 +76,23 @@ pub fn mk_raw_path_(sp: span,
rp: None, rp: None,
types: types } types: types }
} }
pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::Path { pub fn mk_raw_path_global(sp: span, idents: ~[ast::ident]) -> @ast::Path {
mk_raw_path_global_(sp, idents, ~[]) mk_raw_path_global_(sp, idents, ~[])
} }
pub fn mk_raw_path_global_(sp: span, pub fn mk_raw_path_global_(sp: span,
+idents: ~[ast::ident], idents: ~[ast::ident],
+types: ~[@ast::Ty]) -> @ast::Path { types: ~[@ast::Ty]) -> @ast::Path {
@ast::Path { span: sp, @ast::Path { span: sp,
global: true, global: true,
idents: idents, idents: idents,
rp: None, rp: None,
types: types } types: types }
} }
pub fn mk_path(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident]) pub fn mk_path(cx: @ext_ctxt, sp: span, idents: ~[ast::ident])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents))) mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents)))
} }
pub fn mk_path_global(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident]) pub fn mk_path_global(cx: @ext_ctxt, sp: span, idents: ~[ast::ident])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents))) mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents)))
} }
@ -100,7 +100,7 @@ pub fn mk_access_(cx: @ext_ctxt, sp: span, p: @ast::expr, m: ast::ident)
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_field(p, m, ~[])) mk_expr(cx, sp, ast::expr_field(p, m, ~[]))
} }
pub fn mk_access(cx: @ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident) pub fn mk_access(cx: @ext_ctxt, sp: span, p: ~[ast::ident], m: ast::ident)
-> @ast::expr { -> @ast::expr {
let pathexpr = mk_path(cx, sp, p); let pathexpr = mk_path(cx, sp, p);
return mk_access_(cx, sp, pathexpr, m); return mk_access_(cx, sp, pathexpr, m);
@ -115,25 +115,25 @@ pub fn mk_method_call(cx: @ext_ctxt,
sp: span, sp: span,
rcvr_expr: @ast::expr, rcvr_expr: @ast::expr,
method_ident: ast::ident, method_ident: ast::ident,
+args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_method_call(rcvr_expr, method_ident, ~[], args, ast::NoSugar)) mk_expr(cx, sp, ast::expr_method_call(rcvr_expr, method_ident, ~[], args, ast::NoSugar))
} }
pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr, pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr,
+args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar)) mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar))
} }
pub fn mk_call(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident], pub fn mk_call(cx: @ext_ctxt, sp: span, fn_path: ~[ast::ident],
+args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path(cx, sp, fn_path); let pathexpr = mk_path(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); return mk_call_(cx, sp, pathexpr, args);
} }
pub fn mk_call_global(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident], pub fn mk_call_global(cx: @ext_ctxt, sp: span, fn_path: ~[ast::ident],
+args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path_global(cx, sp, fn_path); let pathexpr = mk_path_global(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); return mk_call_(cx, sp, pathexpr, args);
} }
// e = expr, t = type // e = expr, t = type
pub fn mk_base_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr]) pub fn mk_base_vec_e(cx: @ext_ctxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
let vecexpr = ast::expr_vec(exprs, ast::m_imm); let vecexpr = ast::expr_vec(exprs, ast::m_imm);
mk_expr(cx, sp, vecexpr) mk_expr(cx, sp, vecexpr)
@ -143,20 +143,20 @@ pub fn mk_vstore_e(cx: @ext_ctxt, sp: span, expr: @ast::expr,
@ast::expr { @ast::expr {
mk_expr(cx, sp, ast::expr_vstore(expr, vst)) mk_expr(cx, sp, ast::expr_vstore(expr, vst))
} }
pub fn mk_uniq_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr]) pub fn mk_uniq_vec_e(cx: @ext_ctxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq) mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq)
} }
pub fn mk_slice_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr]) pub fn mk_slice_vec_e(cx: @ext_ctxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_slice) ast::expr_vstore_slice)
} }
pub fn mk_base_str(cx: @ext_ctxt, sp: span, +s: ~str) -> @ast::expr { pub fn mk_base_str(cx: @ext_ctxt, sp: span, s: ~str) -> @ast::expr {
let lit = ast::lit_str(@s); let lit = ast::lit_str(@s);
return mk_lit(cx, sp, lit); return mk_lit(cx, sp, lit);
} }
pub fn mk_uniq_str(cx: @ext_ctxt, sp: span, +s: ~str) -> @ast::expr { pub fn mk_uniq_str(cx: @ext_ctxt, sp: span, s: ~str) -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq) mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq)
} }
pub fn mk_field(sp: span, f: &Field) -> ast::field { pub fn mk_field(sp: span, f: &Field) -> ast::field {
@ -170,8 +170,8 @@ pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] {
} }
pub fn mk_struct_e(cx: @ext_ctxt, pub fn mk_struct_e(cx: @ext_ctxt,
sp: span, sp: span,
+ctor_path: ~[ast::ident], ctor_path: ~[ast::ident],
+fields: ~[Field]) fields: ~[Field])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, mk_expr(cx, sp,
ast::expr_struct(mk_raw_path(sp, ctor_path), ast::expr_struct(mk_raw_path(sp, ctor_path),
@ -180,8 +180,8 @@ pub fn mk_struct_e(cx: @ext_ctxt,
} }
pub fn mk_global_struct_e(cx: @ext_ctxt, pub fn mk_global_struct_e(cx: @ext_ctxt,
sp: span, sp: span,
+ctor_path: ~[ast::ident], ctor_path: ~[ast::ident],
+fields: ~[Field]) fields: ~[Field])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, mk_expr(cx, sp,
ast::expr_struct(mk_raw_path_global(sp, ctor_path), ast::expr_struct(mk_raw_path_global(sp, ctor_path),
@ -190,7 +190,7 @@ pub fn mk_global_struct_e(cx: @ext_ctxt,
} }
pub fn mk_glob_use(cx: @ext_ctxt, pub fn mk_glob_use(cx: @ext_ctxt,
sp: span, sp: span,
+path: ~[ast::ident]) -> @ast::view_item { path: ~[ast::ident]) -> @ast::view_item {
let glob = @codemap::spanned { let glob = @codemap::spanned {
node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()), node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()),
span: sp, span: sp,
@ -226,8 +226,8 @@ pub fn mk_local(cx: @ext_ctxt, sp: span, mutbl: bool,
@codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp } @codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
} }
pub fn mk_block(cx: @ext_ctxt, span: span, pub fn mk_block(cx: @ext_ctxt, span: span,
+view_items: ~[@ast::view_item], view_items: ~[@ast::view_item],
+stmts: ~[@ast::stmt], stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> @ast::expr { expr: Option<@ast::expr>) -> @ast::expr {
let blk = codemap::spanned { let blk = codemap::spanned {
node: ast::blk_ { node: ast::blk_ {
@ -243,7 +243,7 @@ pub fn mk_block(cx: @ext_ctxt, span: span,
} }
pub fn mk_block_(cx: @ext_ctxt, pub fn mk_block_(cx: @ext_ctxt,
span: span, span: span,
+stmts: ~[@ast::stmt]) stmts: ~[@ast::stmt])
-> ast::blk { -> ast::blk {
codemap::spanned { codemap::spanned {
node: ast::blk_ { node: ast::blk_ {
@ -307,7 +307,7 @@ pub fn mk_copy(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e)) mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e))
} }
pub fn mk_pat(cx: @ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat { pub fn mk_pat(cx: @ext_ctxt, span: span, pat: ast::pat_) -> @ast::pat {
@ast::pat { id: cx.next_id(), node: pat, span: span } @ast::pat { id: cx.next_id(), node: pat, span: span }
} }
pub fn mk_pat_wild(cx: @ext_ctxt, span: span) -> @ast::pat { pub fn mk_pat_wild(cx: @ext_ctxt, span: span) -> @ast::pat {
@ -335,7 +335,7 @@ pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt,
pub fn mk_pat_enum(cx: @ext_ctxt, pub fn mk_pat_enum(cx: @ext_ctxt,
span: span, span: span,
path: @ast::Path, path: @ast::Path,
+subpats: ~[@ast::pat]) subpats: ~[@ast::pat])
-> @ast::pat { -> @ast::pat {
let pat = ast::pat_enum(path, Some(subpats)); let pat = ast::pat_enum(path, Some(subpats));
mk_pat(cx, span, pat) mk_pat(cx, span, pat)
@ -343,7 +343,7 @@ pub fn mk_pat_enum(cx: @ext_ctxt,
pub fn mk_pat_struct(cx: @ext_ctxt, pub fn mk_pat_struct(cx: @ext_ctxt,
span: span, span: span,
path: @ast::Path, path: @ast::Path,
+field_pats: ~[ast::field_pat]) field_pats: ~[ast::field_pat])
-> @ast::pat { -> @ast::pat {
let pat = ast::pat_struct(path, field_pats, false); let pat = ast::pat_struct(path, field_pats, false);
mk_pat(cx, span, pat) mk_pat(cx, span, pat)
@ -360,7 +360,7 @@ pub fn mk_stmt(cx: @ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
} }
pub fn mk_ty_path(cx: @ext_ctxt, pub fn mk_ty_path(cx: @ext_ctxt,
span: span, span: span,
+idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
let ty = build::mk_raw_path(span, idents); let ty = build::mk_raw_path(span, idents);
let ty = ast::ty_path(ty, cx.next_id()); let ty = ast::ty_path(ty, cx.next_id());
@ -369,7 +369,7 @@ pub fn mk_ty_path(cx: @ext_ctxt,
} }
pub fn mk_ty_path_global(cx: @ext_ctxt, pub fn mk_ty_path_global(cx: @ext_ctxt,
span: span, span: span,
+idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
let ty = build::mk_raw_path_global(span, idents); let ty = build::mk_raw_path_global(span, idents);
let ty = ast::ty_path(ty, cx.next_id()); let ty = ast::ty_path(ty, cx.next_id());
@ -399,7 +399,7 @@ pub fn mk_ty_infer(cx: @ext_ctxt, span: span) -> @ast::Ty {
} }
pub fn mk_trait_ref_global(cx: @ext_ctxt, pub fn mk_trait_ref_global(cx: @ext_ctxt,
span: span, span: span,
+idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::trait_ref -> @ast::trait_ref
{ {
mk_trait_ref_(cx, build::mk_raw_path_global(span, idents)) mk_trait_ref_(cx, build::mk_raw_path_global(span, idents))
@ -430,12 +430,12 @@ pub fn mk_arg(cx: @ext_ctxt,
id: cx.next_id() id: cx.next_id()
} }
} }
pub fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { pub fn mk_fn_decl(inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl {
ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val } ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val }
} }
pub fn mk_trait_ty_param_bound_global(cx: @ext_ctxt, pub fn mk_trait_ty_param_bound_global(cx: @ext_ctxt,
span: span, span: span,
+idents: ~[ast::ident]) idents: ~[ast::ident])
-> ast::TyParamBound { -> ast::TyParamBound {
ast::TraitTyParamBound(mk_trait_ref_global(cx, span, idents)) ast::TraitTyParamBound(mk_trait_ref_global(cx, span, idents))
} }

View file

@ -91,7 +91,7 @@ fn create_derived_encodable_impl(
fn create_encode_method( fn create_encode_method(
cx: @ext_ctxt, cx: @ext_ctxt,
span: span, span: span,
+statements: ~[@stmt] statements: ~[@stmt]
) -> @method { ) -> @method {
// Create the `e` parameter. // Create the `e` parameter.
let e_arg_type = build::mk_ty_rptr( let e_arg_type = build::mk_ty_rptr(

View file

@ -64,7 +64,7 @@ fn create_derived_iter_bytes_impl(cx: @ext_ctxt,
// signature of the `iter_bytes` method. // signature of the `iter_bytes` method.
fn create_iter_bytes_method(cx: @ext_ctxt, fn create_iter_bytes_method(cx: @ext_ctxt,
span: span, span: span,
+statements: ~[@stmt]) statements: ~[@stmt])
-> @method { -> @method {
// Create the `lsb0` parameter. // Create the `lsb0` parameter.
let bool_ident = cx.ident_of(~"bool"); let bool_ident = cx.ident_of(~"bool");

View file

@ -142,7 +142,7 @@ pub fn expand_deriving(cx: @ext_ctxt,
result result
} }
fn create_impl_item(cx: @ext_ctxt, span: span, +item: item_) -> @item { fn create_impl_item(cx: @ext_ctxt, span: span, item: item_) -> @item {
let doc_attr = respan(span, let doc_attr = respan(span,
ast::lit_str(@~"Automatically derived.")); ast::lit_str(@~"Automatically derived."));
let doc_attr = respan(span, ast::meta_name_value(@~"doc", doc_attr)); let doc_attr = respan(span, ast::meta_name_value(@~"doc", doc_attr));

View file

@ -237,8 +237,8 @@ macro_rules! without_macro_scoping(
// Support for item-position macro invocations, exactly the same // Support for item-position macro invocations, exactly the same
// logic as for expression-position macro invocations. // logic as for expression-position macro invocations.
pub fn expand_item_mac(+extsbox: @mut SyntaxEnv, pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, &&it: @ast::item, cx: @ext_ctxt, it: @ast::item,
fld: @ast_fold) fld: @ast_fold)
-> Option<@ast::item> { -> Option<@ast::item> {
let (pth, tts) = match it.node { let (pth, tts) = match it.node {

View file

@ -34,7 +34,7 @@ mod syntax {
pub use parse; pub use parse;
} }
pub fn path(+ids: ~[ident], span: span) -> @ast::Path { pub fn path(ids: ~[ident], span: span) -> @ast::Path {
@ast::Path { span: span, @ast::Path { span: span,
global: false, global: false,
idents: ids, idents: ids,
@ -42,7 +42,7 @@ pub fn path(+ids: ~[ident], span: span) -> @ast::Path {
types: ~[] } types: ~[] }
} }
pub fn path_global(+ids: ~[ident], span: span) -> @ast::Path { pub fn path_global(ids: ~[ident], span: span) -> @ast::Path {
@ast::Path { span: span, @ast::Path { span: span,
global: true, global: true,
idents: ids, idents: ids,
@ -52,7 +52,7 @@ pub fn path_global(+ids: ~[ident], span: span) -> @ast::Path {
pub trait append_types { pub trait append_types {
fn add_ty(&self, ty: @ast::Ty) -> @ast::Path; fn add_ty(&self, ty: @ast::Ty) -> @ast::Path;
fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::Path; fn add_tys(&self, tys: ~[@ast::Ty]) -> @ast::Path;
} }
impl append_types for @ast::Path { impl append_types for @ast::Path {
@ -63,7 +63,7 @@ impl append_types for @ast::Path {
} }
} }
fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::Path { fn add_tys(&self, tys: ~[@ast::Ty]) -> @ast::Path {
@ast::Path { @ast::Path {
types: vec::append(copy self.types, tys), types: vec::append(copy self.types, tys),
.. copy **self .. copy **self
@ -76,63 +76,63 @@ pub trait ext_ctxt_ast_builder {
-> ast::TyParam; -> ast::TyParam;
fn arg(&self, name: ident, ty: @ast::Ty) -> ast::arg; fn arg(&self, name: ident, ty: @ast::Ty) -> ast::arg;
fn expr_block(&self, e: @ast::expr) -> ast::blk; fn expr_block(&self, e: @ast::expr) -> ast::blk;
fn fn_decl(&self, +inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl; fn fn_decl(&self, inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl;
fn item(&self, name: ident, span: span, +node: ast::item_) -> @ast::item; fn item(&self, name: ident, span: span, node: ast::item_) -> @ast::item;
fn item_fn_poly(&self, fn item_fn_poly(&self,
ame: ident, ame: ident,
+inputs: ~[ast::arg], inputs: ~[ast::arg],
output: @ast::Ty, output: @ast::Ty,
+generics: Generics, generics: Generics,
+body: ast::blk) -> @ast::item; body: ast::blk) -> @ast::item;
fn item_fn(&self, fn item_fn(&self,
name: ident, name: ident,
+inputs: ~[ast::arg], inputs: ~[ast::arg],
output: @ast::Ty, output: @ast::Ty,
+body: ast::blk) -> @ast::item; body: ast::blk) -> @ast::item;
fn item_enum_poly(&self, fn item_enum_poly(&self,
name: ident, name: ident,
span: span, span: span,
+enum_definition: ast::enum_def, enum_definition: ast::enum_def,
+generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_enum(&self, fn item_enum(&self,
name: ident, name: ident,
span: span, span: span,
+enum_definition: ast::enum_def) -> @ast::item; enum_definition: ast::enum_def) -> @ast::item;
fn item_struct_poly(&self, fn item_struct_poly(&self,
name: ident, name: ident,
span: span, span: span,
+struct_def: ast::struct_def, struct_def: ast::struct_def,
+generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_struct(&self, fn item_struct(&self,
name: ident, name: ident,
span: span, span: span,
+struct_def: ast::struct_def) -> @ast::item; struct_def: ast::struct_def) -> @ast::item;
fn struct_expr(&self, fn struct_expr(&self,
path: @ast::Path, path: @ast::Path,
+fields: ~[ast::field]) -> @ast::expr; fields: ~[ast::field]) -> @ast::expr;
fn variant(&self, fn variant(&self,
name: ident, name: ident,
span: span, span: span,
+tys: ~[@ast::Ty]) -> ast::variant; tys: ~[@ast::Ty]) -> ast::variant;
fn item_mod(&self, fn item_mod(&self,
name: ident, name: ident,
span: span, span: span,
+items: ~[@ast::item]) -> @ast::item; items: ~[@ast::item]) -> @ast::item;
fn ty_path_ast_builder(&self, path: @ast::Path) -> @ast::Ty; fn ty_path_ast_builder(&self, path: @ast::Path) -> @ast::Ty;
fn item_ty_poly(&self, fn item_ty_poly(&self,
name: ident, name: ident,
span: span, span: span,
ty: @ast::Ty, ty: @ast::Ty,
+generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_ty(&self, name: ident, span: span, ty: @ast::Ty) -> @ast::item; fn item_ty(&self, name: ident, span: span, ty: @ast::Ty) -> @ast::item;
fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty]; fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty];
fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty]; fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty];
fn ty_field_imm(&self, name: ident, ty: @ast::Ty) -> ast::ty_field; fn ty_field_imm(&self, name: ident, ty: @ast::Ty) -> ast::ty_field;
fn field_imm(&self, name: ident, e: @ast::expr) -> ast::field; fn field_imm(&self, name: ident, e: @ast::expr) -> ast::field;
fn block(&self, +stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk; fn block(&self, stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
fn stmt_let(&self, ident: ident, e: @ast::expr) -> @ast::stmt; fn stmt_let(&self, ident: ident, e: @ast::expr) -> @ast::stmt;
fn stmt_expr(&self, e: @ast::expr) -> @ast::stmt; fn stmt_expr(&self, e: @ast::expr) -> @ast::stmt;
fn block_expr(&self, +b: ast::blk) -> @ast::expr; fn block_expr(&self, b: ast::blk) -> @ast::expr;
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty; fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty;
fn ty_infer(&self) -> @ast::Ty; fn ty_infer(&self) -> @ast::Ty;
fn ty_nil_ast_builder(&self) -> @ast::Ty; fn ty_nil_ast_builder(&self) -> @ast::Ty;
@ -148,7 +148,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
], dummy_sp()).add_ty(ty)) ], dummy_sp()).add_ty(ty))
} }
fn block_expr(&self, +b: ast::blk) -> @ast::expr { fn block_expr(&self, b: ast::blk) -> @ast::expr {
@expr { @expr {
id: self.next_id(), id: self.next_id(),
callee_id: self.next_id(), callee_id: self.next_id(),
@ -215,7 +215,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
} }
fn block(&self, +stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk { fn block(&self, stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
let blk = ast::blk_ { let blk = ast::blk_ {
view_items: ~[], view_items: ~[],
stmts: stmts, stmts: stmts,
@ -231,7 +231,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
self.block(~[], e) self.block(~[], e)
} }
fn fn_decl(&self, +inputs: ~[ast::arg], fn fn_decl(&self, inputs: ~[ast::arg],
output: @ast::Ty) -> ast::fn_decl { output: @ast::Ty) -> ast::fn_decl {
ast::fn_decl { ast::fn_decl {
inputs: inputs, inputs: inputs,
@ -241,7 +241,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn item(&self, name: ident, span: span, fn item(&self, name: ident, span: span,
+node: ast::item_) -> @ast::item { node: ast::item_) -> @ast::item {
// XXX: Would be nice if our generated code didn't violate // XXX: Would be nice if our generated code didn't violate
// Rust coding conventions // Rust coding conventions
@ -265,10 +265,10 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn item_fn_poly(&self, name: ident, fn item_fn_poly(&self, name: ident,
+inputs: ~[ast::arg], inputs: ~[ast::arg],
output: @ast::Ty, output: @ast::Ty,
+generics: Generics, generics: Generics,
+body: ast::blk) -> @ast::item { body: ast::blk) -> @ast::item {
self.item(name, self.item(name,
dummy_sp(), dummy_sp(),
ast::item_fn(self.fn_decl(inputs, output), ast::item_fn(self.fn_decl(inputs, output),
@ -280,9 +280,9 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
fn item_fn(&self, fn item_fn(&self,
name: ident, name: ident,
+inputs: ~[ast::arg], inputs: ~[ast::arg],
output: @ast::Ty, output: @ast::Ty,
+body: ast::blk body: ast::blk
) -> @ast::item { ) -> @ast::item {
self.item_fn_poly( self.item_fn_poly(
name, name,
@ -294,13 +294,13 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn item_enum_poly(&self, name: ident, span: span, fn item_enum_poly(&self, name: ident, span: span,
+enum_definition: ast::enum_def, enum_definition: ast::enum_def,
+generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(name, span, ast::item_enum(enum_definition, generics)) self.item(name, span, ast::item_enum(enum_definition, generics))
} }
fn item_enum(&self, name: ident, span: span, fn item_enum(&self, name: ident, span: span,
+enum_definition: ast::enum_def) -> @ast::item { enum_definition: ast::enum_def) -> @ast::item {
self.item_enum_poly(name, span, enum_definition, self.item_enum_poly(name, span, enum_definition,
ast_util::empty_generics()) ast_util::empty_generics())
} }
@ -308,7 +308,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
fn item_struct( fn item_struct(
&self, name: ident, &self, name: ident,
span: span, span: span,
+struct_def: ast::struct_def struct_def: ast::struct_def
) -> @ast::item { ) -> @ast::item {
self.item_struct_poly( self.item_struct_poly(
name, name,
@ -322,14 +322,14 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
&self, &self,
name: ident, name: ident,
span: span, span: span,
+struct_def: ast::struct_def, struct_def: ast::struct_def,
+generics: Generics generics: Generics
) -> @ast::item { ) -> @ast::item {
self.item(name, span, ast::item_struct(@struct_def, generics)) self.item(name, span, ast::item_struct(@struct_def, generics))
} }
fn struct_expr(&self, path: @ast::Path, fn struct_expr(&self, path: @ast::Path,
+fields: ~[ast::field]) -> @ast::expr { fields: ~[ast::field]) -> @ast::expr {
@ast::expr { @ast::expr {
id: self.next_id(), id: self.next_id(),
callee_id: self.next_id(), callee_id: self.next_id(),
@ -339,7 +339,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn variant(&self, name: ident, span: span, fn variant(&self, name: ident, span: span,
+tys: ~[@ast::Ty]) -> ast::variant { tys: ~[@ast::Ty]) -> ast::variant {
let args = do tys.map |ty| { let args = do tys.map |ty| {
ast::variant_arg { ty: *ty, id: self.next_id() } ast::variant_arg { ty: *ty, id: self.next_id() }
}; };
@ -358,7 +358,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn item_mod(&self, name: ident, span: span, fn item_mod(&self, name: ident, span: span,
+items: ~[@ast::item]) -> @ast::item { items: ~[@ast::item]) -> @ast::item {
// XXX: Total hack: import `core::kinds::Owned` to work around a // XXX: Total hack: import `core::kinds::Owned` to work around a
// parser bug whereby `fn f<T:::kinds::Owned>` doesn't parse. // parser bug whereby `fn f<T:::kinds::Owned>` doesn't parse.
@ -425,7 +425,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
} }
fn item_ty_poly(&self, name: ident, span: span, ty: @ast::Ty, fn item_ty_poly(&self, name: ident, span: span, ty: @ast::Ty,
+generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(name, span, ast::item_ty(ty, generics)) self.item(name, span, ast::item_ty(ty, generics))
} }

View file

@ -19,13 +19,13 @@ use parse::token;
use core::prelude::*; use core::prelude::*;
pub trait proto_parser { pub trait proto_parser {
fn parse_proto(&self, +id: ~str) -> protocol; fn parse_proto(&self, id: ~str) -> protocol;
fn parse_state(&self, proto: protocol); fn parse_state(&self, proto: protocol);
fn parse_message(&self, state: state); fn parse_message(&self, state: state);
} }
impl proto_parser for parser::Parser { impl proto_parser for parser::Parser {
fn parse_proto(&self, +id: ~str) -> protocol { fn parse_proto(&self, id: ~str) -> protocol {
let proto = protocol(id, *self.span); let proto = protocol(id, *self.span);
self.parse_seq_to_before_end( self.parse_seq_to_before_end(

View file

@ -81,8 +81,8 @@ pub struct state_ {
} }
pub impl state_ { pub impl state_ {
fn add_message(@self, +name: ~str, span: span, fn add_message(@self, name: ~str, span: span,
+data: ~[@ast::Ty], +next: Option<next_state>) { data: ~[@ast::Ty], next: Option<next_state>) {
self.messages.push(message(name, span, data, self, self.messages.push(message(name, span, data, self,
next)); next));
} }
@ -119,11 +119,11 @@ pub impl state_ {
pub type protocol = @mut protocol_; pub type protocol = @mut protocol_;
pub fn protocol(+name: ~str, +span: span) -> protocol { pub fn protocol(name: ~str, span: span) -> protocol {
@mut protocol_(name, span) @mut protocol_(name, span)
} }
pub fn protocol_(+name: ~str, span: span) -> protocol_ { pub fn protocol_(name: ~str, span: span) -> protocol_ {
protocol_ { protocol_ {
name: name, name: name,
span: span, span: span,
@ -177,10 +177,10 @@ pub impl protocol_ {
pub impl protocol_ { pub impl protocol_ {
fn add_state_poly(@mut self, fn add_state_poly(@mut self,
+name: ~str, name: ~str,
ident: ast::ident, ident: ast::ident,
dir: direction, dir: direction,
+generics: ast::Generics) generics: ast::Generics)
-> state { -> state {
let messages = @mut ~[]; let messages = @mut ~[];
let states = &*self.states; let states = &*self.states;

View file

@ -419,7 +419,7 @@ fn ids_ext(cx: @ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
strs.map(|str| cx.parse_sess().interner.intern(@copy *str)) strs.map(|str| cx.parse_sess().interner.intern(@copy *str))
} }
fn id_ext(cx: @ext_ctxt, +str: ~str) -> ast::ident { fn id_ext(cx: @ext_ctxt, str: ~str) -> ast::ident {
cx.parse_sess().interner.intern(@str) cx.parse_sess().interner.intern(@str)
} }
@ -734,8 +734,8 @@ fn expand_tts(cx: @ext_ctxt,
fn expand_parse_call(cx: @ext_ctxt, fn expand_parse_call(cx: @ext_ctxt,
sp: span, sp: span,
+parse_method: ~str, parse_method: ~str,
+arg_exprs: ~[@ast::expr], arg_exprs: ~[@ast::expr],
tts: &[ast::token_tree]) -> @ast::expr { tts: &[ast::token_tree]) -> @ast::expr {
let tts_expr = expand_tts(cx, sp, tts); let tts_expr = expand_tts(cx, sp, tts);

View file

@ -98,9 +98,9 @@ pub enum matcher_pos_up { /* to break a circularity */
matcher_pos_up(Option<~MatcherPos>) matcher_pos_up(Option<~MatcherPos>)
} }
pub fn is_some(&&mpu: matcher_pos_up) -> bool { pub fn is_some(mpu: &matcher_pos_up) -> bool {
match &mpu { match *mpu {
&matcher_pos_up(None) => false, matcher_pos_up(None) => false,
_ => true _ => true
} }
} }
@ -115,9 +115,9 @@ pub struct MatcherPos {
sp_lo: BytePos, sp_lo: BytePos,
} }
pub fn copy_up(&& mpu: matcher_pos_up) -> ~MatcherPos { pub fn copy_up(mpu: &matcher_pos_up) -> ~MatcherPos {
match &mpu { match *mpu {
&matcher_pos_up(Some(ref mp)) => copy (*mp), matcher_pos_up(Some(ref mp)) => copy (*mp),
_ => fail!() _ => fail!()
} }
} }
@ -132,7 +132,7 @@ pub fn count_names(ms: &[matcher]) -> uint {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
pub fn initial_matcher_pos(+ms: ~[matcher], +sep: Option<Token>, lo: BytePos) pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos)
-> ~MatcherPos { -> ~MatcherPos {
let mut match_idx_hi = 0u; let mut match_idx_hi = 0u;
for ms.each |elt| { for ms.each |elt| {
@ -220,7 +220,7 @@ pub enum parse_result {
pub fn parse_or_else( pub fn parse_or_else(
sess: @mut ParseSess, sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
rdr: @reader, rdr: @reader,
ms: ~[matcher] ms: ~[matcher]
) -> HashMap<ident, @named_match> { ) -> HashMap<ident, @named_match> {
@ -257,7 +257,7 @@ pub fn parse(
/* at end of sequence */ /* at end of sequence */
if idx >= len { if idx >= len {
// can't move out of `match`es, so: // can't move out of `match`es, so:
if is_some(ei.up) { if is_some(&ei.up) {
// hack: a matcher sequence is repeating iff it has a // hack: a matcher sequence is repeating iff it has a
// parent (the top level is just a container) // parent (the top level is just a container)
@ -267,7 +267,7 @@ pub fn parse(
if idx == len { if idx == len {
// pop from the matcher position // pop from the matcher position
let mut new_pos = copy_up(ei.up); let mut new_pos = copy_up(&ei.up);
// update matches (the MBE "parse tree") by appending // update matches (the MBE "parse tree") by appending
// each tree as a subtree. // each tree as a subtree.
@ -394,7 +394,7 @@ pub fn parse(
match ei.elts[ei.idx].node { match ei.elts[ei.idx].node {
match_nonterminal(_, name, idx) => { match_nonterminal(_, name, idx) => {
ei.matches[idx].push(@matched_nonterminal( ei.matches[idx].push(@matched_nonterminal(
parse_nt(rust_parser, *sess.interner.get(name)))); parse_nt(&rust_parser, *sess.interner.get(name))));
ei.idx += 1u; ei.idx += 1u;
} }
_ => fail!() _ => fail!()
@ -411,7 +411,7 @@ pub fn parse(
} }
} }
pub fn parse_nt(p: Parser, name: ~str) -> nonterminal { pub fn parse_nt(p: &Parser, name: ~str) -> nonterminal {
match name { match name {
~"item" => match p.parse_item(~[]) { ~"item" => match p.parse_item(~[]) {
Some(i) => token::nt_item(i), Some(i) => token::nt_item(i),

View file

@ -53,7 +53,7 @@ pub struct TtReader {
pub fn new_tt_reader(sp_diag: @span_handler, pub fn new_tt_reader(sp_diag: @span_handler,
itr: @ident_interner, itr: @ident_interner,
interp: Option<HashMap<ident,@named_match>>, interp: Option<HashMap<ident,@named_match>>,
+src: ~[ast::token_tree]) src: ~[ast::token_tree])
-> @mut TtReader { -> @mut TtReader {
let r = @mut TtReader { let r = @mut TtReader {
sp_diag: sp_diag, sp_diag: sp_diag,
@ -109,7 +109,7 @@ pub fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
fn lookup_cur_matched_by_matched(r: &mut TtReader, fn lookup_cur_matched_by_matched(r: &mut TtReader,
start: @named_match) start: @named_match)
-> @named_match { -> @named_match {
fn red(+ad: @named_match, idx: &uint) -> @named_match { fn red(ad: @named_match, idx: &uint) -> @named_match {
match *ad { match *ad {
matched_nonterminal(_) => { matched_nonterminal(_) => {
// end of the line; duplicate henceforth // end of the line; duplicate henceforth

View file

@ -27,11 +27,11 @@ pub enum OptVec<T> {
Vec(~[T]) Vec(~[T])
} }
pub fn with<T>(+t: T) -> OptVec<T> { pub fn with<T>(t: T) -> OptVec<T> {
Vec(~[t]) Vec(~[t])
} }
pub fn from<T>(+t: ~[T]) -> OptVec<T> { pub fn from<T>(t: ~[T]) -> OptVec<T> {
if t.len() == 0 { if t.len() == 0 {
Empty Empty
} else { } else {
@ -40,7 +40,7 @@ pub fn from<T>(+t: ~[T]) -> OptVec<T> {
} }
impl<T> OptVec<T> { impl<T> OptVec<T> {
fn push(&mut self, +t: T) { fn push(&mut self, t: T) {
match *self { match *self {
Vec(ref mut v) => { Vec(ref mut v) => {
v.push(t); v.push(t);
@ -91,7 +91,7 @@ impl<T> OptVec<T> {
} }
} }
pub fn take_vec<T>(+v: OptVec<T>) -> ~[T] { pub fn take_vec<T>(v: OptVec<T>) -> ~[T] {
match v { match v {
Empty => ~[], Empty => ~[],
Vec(v) => v Vec(v) => v
@ -99,7 +99,7 @@ pub fn take_vec<T>(+v: OptVec<T>) -> ~[T] {
} }
impl<T:Copy> OptVec<T> { impl<T:Copy> OptVec<T> {
fn prepend(&self, +t: T) -> OptVec<T> { fn prepend(&self, t: T) -> OptVec<T> {
let mut v0 = ~[t]; let mut v0 = ~[t];
match *self { match *self {
Empty => {} Empty => {}
@ -157,7 +157,7 @@ impl<A> BaseIter<A> for OptVec<A> {
impl<A> iter::ExtendedIter<A> for OptVec<A> { impl<A> iter::ExtendedIter<A> for OptVec<A> {
#[inline(always)] #[inline(always)]
fn eachi(&self, blk: &fn(+v: uint, v: &A) -> bool) { fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) {
iter::eachi(self, blk) iter::eachi(self, blk)
} }
#[inline(always)] #[inline(always)]
@ -169,7 +169,7 @@ impl<A> iter::ExtendedIter<A> for OptVec<A> {
iter::any(self, blk) iter::any(self, blk)
} }
#[inline(always)] #[inline(always)]
fn foldl<B>(&self, +b0: B, blk: &fn(&B, &A) -> B) -> B { fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B {
iter::foldl(self, b0, blk) iter::foldl(self, b0, blk)
} }
#[inline(always)] #[inline(always)]

View file

@ -40,7 +40,7 @@ pub fn expr_is_simple_block(e: @ast::expr) -> bool {
} }
} }
pub fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { pub fn stmt_ends_with_semi(stmt: &ast::stmt) -> bool {
return match stmt.node { return match stmt.node {
ast::stmt_decl(d, _) => { ast::stmt_decl(d, _) => {
match d.node { match d.node {

View file

@ -319,7 +319,7 @@ pub struct lit {
pub fn gather_comments_and_literals(span_diagnostic: pub fn gather_comments_and_literals(span_diagnostic:
@diagnostic::span_handler, @diagnostic::span_handler,
+path: ~str, path: ~str,
srdr: @io::Reader) srdr: @io::Reader)
-> (~[cmnt], ~[lit]) { -> (~[cmnt], ~[lit]) {
let src = @str::from_bytes(srdr.read_whole_stream()); let src = @str::from_bytes(srdr.read_whole_stream());

View file

@ -28,13 +28,13 @@ pub struct SeqSep {
trailing_sep_allowed: bool trailing_sep_allowed: bool
} }
pub fn seq_sep_trailing_disallowed(+t: token::Token) -> SeqSep { pub fn seq_sep_trailing_disallowed(t: token::Token) -> SeqSep {
SeqSep { SeqSep {
sep: Some(t), sep: Some(t),
trailing_sep_allowed: false, trailing_sep_allowed: false,
} }
} }
pub fn seq_sep_trailing_allowed(+t: token::Token) -> SeqSep { pub fn seq_sep_trailing_allowed(t: token::Token) -> SeqSep {
SeqSep { SeqSep {
sep: Some(t), sep: Some(t),
trailing_sep_allowed: true, trailing_sep_allowed: true,

View file

@ -126,7 +126,7 @@ pub fn parse_crate_from_source_str(
pub fn parse_expr_from_source_str( pub fn parse_expr_from_source_str(
name: ~str, name: ~str,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
sess: @mut ParseSess sess: @mut ParseSess
) -> @ast::expr { ) -> @ast::expr {
let p = new_parser_from_source_str( let p = new_parser_from_source_str(
@ -142,8 +142,8 @@ pub fn parse_expr_from_source_str(
pub fn parse_item_from_source_str( pub fn parse_item_from_source_str(
name: ~str, name: ~str,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
+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( let p = new_parser_from_source_str(
@ -159,7 +159,7 @@ pub fn parse_item_from_source_str(
pub fn parse_meta_from_source_str( pub fn parse_meta_from_source_str(
name: ~str, name: ~str,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
sess: @mut ParseSess sess: @mut ParseSess
) -> @ast::meta_item { ) -> @ast::meta_item {
let p = new_parser_from_source_str( let p = new_parser_from_source_str(
@ -175,8 +175,8 @@ pub fn parse_meta_from_source_str(
pub fn parse_stmt_from_source_str( pub fn parse_stmt_from_source_str(
name: ~str, name: ~str,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
+attrs: ~[ast::attribute], attrs: ~[ast::attribute],
sess: @mut ParseSess sess: @mut ParseSess
) -> @ast::stmt { ) -> @ast::stmt {
let p = new_parser_from_source_str( let p = new_parser_from_source_str(
@ -192,7 +192,7 @@ pub fn parse_stmt_from_source_str(
pub fn parse_tts_from_source_str( pub fn parse_tts_from_source_str(
name: ~str, name: ~str,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
sess: @mut ParseSess sess: @mut ParseSess
) -> ~[ast::token_tree] { ) -> ~[ast::token_tree] {
let p = new_parser_from_source_str( let p = new_parser_from_source_str(
@ -207,20 +207,20 @@ pub fn parse_tts_from_source_str(
} }
pub fn parse_from_source_str<T>( pub fn parse_from_source_str<T>(
f: &fn (Parser) -> T, f: &fn(&Parser) -> T,
name: ~str, ss: codemap::FileSubstr, name: ~str, ss: codemap::FileSubstr,
source: @~str, source: @~str,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
sess: @mut ParseSess sess: @mut ParseSess
) -> T { ) -> T {
let p = new_parser_from_source_str( let p = new_parser_from_source_str(
sess, sess,
cfg, cfg,
/*bad*/ copy name, name,
/*bad*/ copy ss, ss,
source 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");
} }
@ -236,9 +236,9 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id {
} }
pub fn new_parser_from_source_str(sess: @mut ParseSess, pub fn new_parser_from_source_str(sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
+name: ~str, name: ~str,
+ss: codemap::FileSubstr, ss: codemap::FileSubstr,
source: @~str) source: @~str)
-> Parser { -> Parser {
let filemap = sess.cm.new_filemap_w_substr(name, ss, source); let filemap = sess.cm.new_filemap_w_substr(name, ss, source);
@ -254,7 +254,7 @@ pub fn new_parser_from_source_str(sess: @mut ParseSess,
/// that draws from that string /// that draws from that string
pub fn new_parser_result_from_file( pub fn new_parser_result_from_file(
sess: @mut ParseSess, sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
path: &Path path: &Path
) -> Result<Parser, ~str> { ) -> Result<Parser, ~str> {
match io::read_whole_file_str(path) { match io::read_whole_file_str(path) {
@ -274,7 +274,7 @@ pub fn new_parser_result_from_file(
/// if the file doesn't exist /// if the file doesn't exist
pub fn new_parser_from_file( pub fn new_parser_from_file(
sess: @mut ParseSess, sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
path: &Path path: &Path
) -> Parser { ) -> Parser {
match new_parser_result_from_file(sess, cfg, path) { match new_parser_result_from_file(sess, cfg, path) {
@ -289,7 +289,7 @@ pub fn new_parser_from_file(
/// error messages correctly when the file does not exist. /// error messages correctly when the file does not exist.
pub fn new_sub_parser_from_file( pub fn new_sub_parser_from_file(
sess: @mut ParseSess, sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
path: &Path, path: &Path,
sp: span sp: span
) -> Parser { ) -> Parser {
@ -303,8 +303,8 @@ pub fn new_sub_parser_from_file(
pub fn new_parser_from_tts( pub fn new_parser_from_tts(
sess: @mut ParseSess, sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
+tts: ~[ast::token_tree] tts: ~[ast::token_tree]
) -> Parser { ) -> Parser {
let trdr = lexer::new_tt_reader( let trdr = lexer::new_tt_reader(
copy sess.span_diagnostic, copy sess.span_diagnostic,
@ -316,7 +316,7 @@ pub fn new_parser_from_tts(
} }
// abort if necessary // abort if necessary
pub fn maybe_aborted<T>(+result : T, p: Parser) -> T { pub fn maybe_aborted<T>(result : T, p: Parser) -> T {
p.abort_if_errors(); p.abort_if_errors();
result result
} }

View file

@ -66,7 +66,7 @@ pub enum ObsoleteSyntax {
impl to_bytes::IterBytes for ObsoleteSyntax { impl to_bytes::IterBytes for ObsoleteSyntax {
#[inline(always)] #[inline(always)]
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f); (*self as uint).iter_bytes(lsb0, f);
} }
} }

View file

@ -201,7 +201,7 @@ macro_rules! maybe_whole (
) )
fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>) fn maybe_append(lhs: ~[attribute], rhs: Option<~[attribute]>)
-> ~[attribute] { -> ~[attribute] {
match rhs { match rhs {
None => lhs, None => lhs,
@ -220,8 +220,8 @@ struct ParsedItemsAndViewItems {
/* ident is handled by common.rs */ /* ident is handled by common.rs */
pub fn Parser(sess: @mut ParseSess, pub fn Parser(sess: @mut ParseSess,
+cfg: ast::crate_cfg, cfg: ast::crate_cfg,
+rdr: @reader) rdr: @reader)
-> Parser { -> Parser {
let tok0 = copy rdr.next_token(); let tok0 = copy rdr.next_token();
let interner = rdr.interner(); let interner = rdr.interner();
@ -299,7 +299,7 @@ pub impl Parser {
*self.tokens_consumed += 1u; *self.tokens_consumed += 1u;
} }
// EFFECT: replace the current token and span with the given one // EFFECT: replace the current token and span with the given one
fn replace_token(&self, +next: token::Token, +lo: BytePos, +hi: BytePos) { fn replace_token(&self, next: token::Token, lo: BytePos, hi: BytePos) {
*self.token = next; *self.token = next;
*self.span = mk_sp(lo, hi); *self.span = mk_sp(lo, hi);
} }
@ -713,7 +713,7 @@ pub impl Parser {
fn parse_box_or_uniq_pointee( fn parse_box_or_uniq_pointee(
&self, &self,
sigil: ast::Sigil, sigil: ast::Sigil,
ctor: &fn(+v: mt) -> ty_) -> ty_ ctor: &fn(v: mt) -> ty_) -> ty_
{ {
// @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types: // @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types:
match *self.token { match *self.token {
@ -1112,7 +1112,7 @@ pub impl Parser {
spanned(lo, e.span.hi, ast::field_ { mutbl: m, ident: i, expr: e }) spanned(lo, e.span.hi, ast::field_ { mutbl: m, ident: i, expr: e })
} }
fn mk_expr(&self, +lo: BytePos, +hi: BytePos, +node: expr_) -> @expr { fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
@expr { @expr {
id: self.get_id(), id: self.get_id(),
callee_id: self.get_id(), callee_id: self.get_id(),
@ -1121,7 +1121,7 @@ pub impl Parser {
} }
} }
fn mk_mac_expr(&self, +lo: BytePos, +hi: BytePos, +m: mac_) -> @expr { fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr {
@expr { @expr {
id: self.get_id(), id: self.get_id(),
callee_id: self.get_id(), callee_id: self.get_id(),
@ -1897,7 +1897,7 @@ pub impl Parser {
fn parse_sugary_call_expr(&self, keyword: ~str, fn parse_sugary_call_expr(&self, keyword: ~str,
sugar: CallSugar, sugar: CallSugar,
ctor: &fn(+v: @expr) -> expr_) -> @expr { ctor: &fn(v: @expr) -> expr_) -> @expr {
let lo = self.last_span; let lo = self.last_span;
// Parse the callee `foo` in // Parse the callee `foo` in
// for foo || { // for foo || {
@ -2472,7 +2472,7 @@ pub impl Parser {
}) })
} }
fn parse_stmt(&self, +first_item_attrs: ~[attribute]) -> @stmt { fn parse_stmt(&self, 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]) {
@ -2612,7 +2612,7 @@ pub impl Parser {
// parse the rest of a block expression or function body // parse the rest of a block expression or function body
fn parse_block_tail_(&self, lo: BytePos, s: blk_check_mode, fn parse_block_tail_(&self, lo: BytePos, s: blk_check_mode,
+first_item_attrs: ~[attribute]) -> blk { first_item_attrs: ~[attribute]) -> blk {
let mut stmts = ~[]; let mut stmts = ~[];
let mut expr = None; let mut expr = None;
@ -2658,7 +2658,7 @@ pub impl Parser {
expr = Some(e); expr = Some(e);
} }
copy t => { copy t => {
if classify::stmt_ends_with_semi(*stmt) { if classify::stmt_ends_with_semi(stmt) {
self.fatal( self.fatal(
fmt!( fmt!(
"expected `;` or `}` after \ "expected `;` or `}` after \
@ -2696,7 +2696,7 @@ pub impl Parser {
_ => { // All other kinds of statements: _ => { // All other kinds of statements:
stmts.push(stmt); stmts.push(stmt);
if classify::stmt_ends_with_semi(*stmt) { if classify::stmt_ends_with_semi(stmt) {
self.expect(&token::SEMI); self.expect(&token::SEMI);
} }
} }
@ -2891,7 +2891,7 @@ pub impl Parser {
&fn(&Parser) -> arg_or_capture_item &fn(&Parser) -> arg_or_capture_item
) -> (self_ty, fn_decl) { ) -> (self_ty, fn_decl) {
fn maybe_parse_self_ty( fn maybe_parse_self_ty(
cnstr: &fn(+v: mutability) -> ast::self_ty_, cnstr: &fn(v: mutability) -> ast::self_ty_,
p: &Parser p: &Parser
) -> ast::self_ty_ { ) -> ast::self_ty_ {
// We need to make sure it isn't a mode or a type // We need to make sure it isn't a mode or a type
@ -3064,9 +3064,9 @@ pub impl Parser {
(id, generics) (id, generics)
} }
fn mk_item(&self, +lo: BytePos, +hi: BytePos, +ident: ident, fn mk_item(&self, lo: BytePos, hi: BytePos, ident: ident,
+node: item_, vis: visibility, node: item_, vis: visibility,
+attrs: ~[attribute]) -> @item { attrs: ~[attribute]) -> @item {
@ast::item { ident: ident, @ast::item { ident: ident,
attrs: attrs, attrs: attrs,
id: self.get_id(), id: self.get_id(),
@ -3305,7 +3305,7 @@ pub impl Parser {
None) None)
} }
fn token_is_pound_or_doc_comment(&self, ++tok: token::Token) -> bool { fn token_is_pound_or_doc_comment(&self, tok: token::Token) -> bool {
match tok { match tok {
token::POUND | token::DOC_COMMENT(_) => true, token::POUND | token::DOC_COMMENT(_) => true,
_ => false _ => false
@ -3340,7 +3340,7 @@ pub impl Parser {
a_var a_var
} }
fn parse_dtor(&self, +attrs: ~[attribute]) -> class_contents { fn parse_dtor(&self, 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))
@ -3392,7 +3392,7 @@ pub impl Parser {
// given a termination token and a vector of already-parsed // given a termination token and a vector of already-parsed
// attributes (of length 0 or 1), parse all of the items in a module // attributes (of length 0 or 1), parse all of the items in a module
fn parse_mod_items(&self, term: token::Token, fn parse_mod_items(&self, term: token::Token,
+first_item_attrs: ~[attribute]) -> _mod { first_item_attrs: ~[attribute]) -> _mod {
// parse all of the items up to closing or an attribute. // parse all of the items up to closing or an attribute.
// view items are legal here. // view items are legal here.
let ParsedItemsAndViewItems { let ParsedItemsAndViewItems {
@ -3553,7 +3553,7 @@ pub impl Parser {
outer_attrs, id_sp) outer_attrs, id_sp)
} }
fn eval_src_mod_from_path(&self, prefix: Path, +path: Path, fn eval_src_mod_from_path(&self, 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]) {
@ -3576,7 +3576,7 @@ pub impl Parser {
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
@ -3584,7 +3584,7 @@ pub impl Parser {
} }
} }
fn parse_item_foreign_fn(&self, +attrs: ~[attribute]) -> @foreign_item { fn parse_item_foreign_fn(&self, attrs: ~[attribute]) -> @foreign_item {
let lo = self.span.lo; let lo = self.span.lo;
let vis = self.parse_visibility(); let vis = self.parse_visibility();
let purity = self.parse_fn_purity(); let purity = self.parse_fn_purity();
@ -3601,7 +3601,7 @@ pub impl Parser {
} }
fn parse_item_foreign_const(&self, vis: ast::visibility, fn parse_item_foreign_const(&self, vis: ast::visibility,
+attrs: ~[attribute]) -> @foreign_item { attrs: ~[attribute]) -> @foreign_item {
let lo = self.span.lo; let lo = self.span.lo;
// XXX: Obsolete; remove after snap. // XXX: Obsolete; remove after snap.
@ -3638,7 +3638,7 @@ pub impl Parser {
else { self.unexpected(); } else { self.unexpected(); }
} }
fn parse_foreign_item(&self, +attrs: ~[attribute]) -> @foreign_item { fn parse_foreign_item(&self, attrs: ~[attribute]) -> @foreign_item {
let vis = self.parse_visibility(); let vis = self.parse_visibility();
if self.is_keyword(&~"const") || self.is_keyword(&~"static") { if self.is_keyword(&~"const") || self.is_keyword(&~"static") {
self.parse_item_foreign_const(vis, attrs) self.parse_item_foreign_const(vis, attrs)
@ -3648,8 +3648,8 @@ pub impl Parser {
} }
fn parse_foreign_mod_items(&self, sort: ast::foreign_mod_sort, fn parse_foreign_mod_items(&self, sort: ast::foreign_mod_sort,
+abis: AbiSet, abis: AbiSet,
+first_item_attrs: ~[attribute]) first_item_attrs: ~[attribute])
-> foreign_mod { -> foreign_mod {
// Shouldn't be any view items since we've already parsed an item attr // Shouldn't be any view items since we've already parsed an item attr
let ParsedItemsAndViewItems { let ParsedItemsAndViewItems {
@ -3987,7 +3987,7 @@ pub impl Parser {
// flags; on failure, return iovi_none. // flags; on failure, return iovi_none.
fn parse_item_or_view_item( fn parse_item_or_view_item(
&self, &self,
+attrs: ~[attribute], attrs: ~[attribute],
items_allowed: bool, items_allowed: bool,
foreign_items_allowed: bool, foreign_items_allowed: bool,
macros_allowed: bool macros_allowed: bool
@ -4198,7 +4198,7 @@ pub impl Parser {
return iovi_none; return iovi_none;
} }
fn parse_item(&self, +attrs: ~[attribute]) -> Option<@ast::item> { fn parse_item(&self, attrs: ~[attribute]) -> Option<@ast::item> {
match self.parse_item_or_view_item(attrs, true, false, true) { match self.parse_item_or_view_item(attrs, true, false, true) {
iovi_none => iovi_none =>
None, None,
@ -4337,7 +4337,7 @@ pub impl Parser {
// parse a view item. // parse a view item.
fn parse_view_item( fn parse_view_item(
&self, &self,
+attrs: ~[attribute], attrs: ~[attribute],
vis: visibility vis: visibility
) -> @view_item { ) -> @view_item {
let lo = self.span.lo; let lo = self.span.lo;
@ -4363,7 +4363,7 @@ pub impl Parser {
// - mod_items uses VIEW_ITEMS_AND_ITEMS_ALLOWED // - mod_items uses VIEW_ITEMS_AND_ITEMS_ALLOWED
// - block_tail_ uses IMPORTS_AND_ITEMS_ALLOWED // - block_tail_ uses IMPORTS_AND_ITEMS_ALLOWED
// - foreign_mod_items uses FOREIGN_ITEMS_ALLOWED // - foreign_mod_items uses FOREIGN_ITEMS_ALLOWED
fn parse_items_and_view_items(&self, +first_item_attrs: ~[attribute], fn parse_items_and_view_items(&self, first_item_attrs: ~[attribute],
mode: view_item_parse_mode, mode: view_item_parse_mode,
macros_allowed: bool) macros_allowed: bool)
-> ParsedItemsAndViewItems { -> ParsedItemsAndViewItems {

View file

@ -104,7 +104,7 @@ pub impl token {
} }
} }
pub fn tok_str(++t: token) -> ~str { pub fn tok_str(t: token) -> ~str {
match t { match t {
STRING(s, len) => return fmt!("STR(%s,%d)", *s, len), STRING(s, len) => return fmt!("STR(%s,%d)", *s, len),
BREAK(_) => return ~"BREAK", BREAK(_) => return ~"BREAK",
@ -398,7 +398,7 @@ pub impl Printer {
self.right %= self.buf_len; self.right %= self.buf_len;
assert!((self.right != self.left)); assert!((self.right != self.left));
} }
fn advance_left(&mut self, ++x: token, L: int) { fn advance_left(&mut self, x: token, L: int) {
debug!("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right, debug!("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right,
self.left, L); self.left, L);
if L >= 0 { if L >= 0 {

View file

@ -134,7 +134,7 @@ pub fn print_crate(cm: @CodeMap,
print_crate_(s, crate); print_crate_(s, crate);
} }
pub fn print_crate_(s: @ps, &&crate: @ast::crate) { pub fn print_crate_(s: @ps, crate: @ast::crate) {
print_mod(s, &crate.node.module, crate.node.attrs); print_mod(s, &crate.node.module, crate.node.attrs);
print_remaining_comments(s); print_remaining_comments(s);
eof(s.s); eof(s.s);
@ -164,7 +164,7 @@ pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str {
to_str(tts, print_tts, intr) to_str(tts, print_tts, intr)
} }
pub fn stmt_to_str(s: ast::stmt, intr: @ident_interner) -> ~str { pub fn stmt_to_str(s: &ast::stmt, intr: @ident_interner) -> ~str {
to_str(s, print_stmt, intr) to_str(s, print_stmt, intr)
} }
@ -177,7 +177,7 @@ pub fn generics_to_str(generics: &ast::Generics,
to_str(generics, print_generics, intr) to_str(generics, print_generics, intr)
} }
pub fn path_to_str(&&p: @ast::Path, intr: @ident_interner) -> ~str { pub fn path_to_str(p: @ast::Path, intr: @ident_interner) -> ~str {
to_str(p, |a,b| print_path(a, b, false), intr) to_str(p, |a,b| print_path(a, b, false), intr)
} }
@ -312,7 +312,7 @@ pub fn synth_comment(s: @ps, text: ~str) {
word(s.s, ~"*/"); word(s.s, ~"*/");
} }
pub fn commasep<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) { pub fn commasep<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
box(s, 0u, b); box(s, 0u, b);
let mut first = true; let mut first = true;
for elts.each |elt| { for elts.each |elt| {
@ -323,8 +323,8 @@ pub fn commasep<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
} }
pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
get_span: &fn(IN) -> codemap::span) { get_span: &fn(IN) -> codemap::span) {
box(s, 0u, b); box(s, 0u, b);
let len = elts.len(); let len = elts.len();
let mut i = 0u; let mut i = 0u;
@ -343,7 +343,7 @@ pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
} }
pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) { pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) {
fn expr_span(&&expr: @ast::expr) -> codemap::span { return expr.span; } fn expr_span(expr: @ast::expr) -> codemap::span { return expr.span; }
commasep_cmnt(s, b, exprs, print_expr, expr_span); commasep_cmnt(s, b, exprs, print_expr, expr_span);
} }
@ -371,7 +371,7 @@ pub fn print_opt_lifetime(s: @ps, lifetime: Option<@ast::Lifetime>) {
} }
} }
pub fn print_type(s: @ps, &&ty: @ast::Ty) { pub fn print_type(s: @ps, ty: @ast::Ty) {
maybe_print_comment(s, ty.span.lo); maybe_print_comment(s, ty.span.lo);
ibox(s, 0u); ibox(s, 0u);
match ty.node { match ty.node {
@ -465,7 +465,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
} }
} }
pub fn print_item(s: @ps, &&item: @ast::item) { pub fn print_item(s: @ps, item: @ast::item) {
hardbreak_if_not_bol(s); hardbreak_if_not_bol(s);
maybe_print_comment(s, item.span.lo); maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs); print_outer_attributes(s, item.attrs);
@ -760,7 +760,7 @@ pub fn print_tt(s: @ps, tt: ast::token_tree) {
} }
} }
pub fn print_tts(s: @ps, &&tts: &[ast::token_tree]) { pub fn print_tts(s: @ps, tts: &[ast::token_tree]) {
ibox(s, 0); ibox(s, 0);
for tts.eachi |i, tt| { for tts.eachi |i, tt| {
if i != 0 { if i != 0 {
@ -872,7 +872,7 @@ pub fn print_attribute(s: @ps, attr: ast::attribute) {
} }
pub fn print_stmt(s: @ps, st: ast::stmt) { pub fn print_stmt(s: @ps, st: &ast::stmt) {
maybe_print_comment(s, st.span.lo); maybe_print_comment(s, st.span.lo);
match st.node { match st.node {
ast::stmt_decl(decl, _) => { ast::stmt_decl(decl, _) => {
@ -950,7 +950,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
for blk.node.view_items.each |vi| { print_view_item(s, *vi); } for blk.node.view_items.each |vi| { print_view_item(s, *vi); }
for blk.node.stmts.each |st| { for blk.node.stmts.each |st| {
print_stmt(s, **st); print_stmt(s, *st);
} }
match blk.node.expr { match blk.node.expr {
Some(expr) => { Some(expr) => {
@ -1089,7 +1089,7 @@ pub fn print_call_post(s: @ps,
} }
} }
pub fn print_expr(s: @ps, &&expr: @ast::expr) { pub fn print_expr(s: @ps, expr: @ast::expr) {
fn print_field(s: @ps, field: ast::field) { fn print_field(s: @ps, field: ast::field) {
ibox(s, indent_unit); ibox(s, indent_unit);
if field.node.mutbl == ast::m_mutbl { word_nbsp(s, ~"mut"); } if field.node.mutbl == ast::m_mutbl { word_nbsp(s, ~"mut"); }
@ -1454,7 +1454,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) {
word_nbsp(s, ~"mut"); word_nbsp(s, ~"mut");
} }
fn print_local(s: @ps, &&loc: @ast::local) { fn print_local(s: @ps, loc: @ast::local) {
ibox(s, indent_unit); ibox(s, indent_unit);
print_local_decl(s, loc); print_local_decl(s, loc);
end(s); end(s);
@ -1485,7 +1485,7 @@ pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) {
print_expr(s, coll); print_expr(s, coll);
} }
pub fn print_path(s: @ps, &&path: @ast::Path, colons_before_params: bool) { pub fn print_path(s: @ps, path: @ast::Path, colons_before_params: bool) {
maybe_print_comment(s, path.span.lo); maybe_print_comment(s, path.span.lo);
if path.global { word(s.s, ~"::"); } if path.global { word(s.s, ~"::"); }
let mut first = true; let mut first = true;
@ -1513,15 +1513,15 @@ pub fn print_path(s: @ps, &&path: @ast::Path, colons_before_params: bool) {
} }
} }
pub fn print_irrefutable_pat(s: @ps, &&pat: @ast::pat) { pub fn print_irrefutable_pat(s: @ps, pat: @ast::pat) {
print_pat(s, pat, false) print_pat(s, pat, false)
} }
pub fn print_refutable_pat(s: @ps, &&pat: @ast::pat) { pub fn print_refutable_pat(s: @ps, pat: @ast::pat) {
print_pat(s, pat, true) print_pat(s, pat, true)
} }
pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) { pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
maybe_print_comment(s, pat.span.lo); maybe_print_comment(s, pat.span.lo);
let ann_node = node_pat(s, pat); let ann_node = node_pat(s, pat);
(s.ann.pre)(ann_node); (s.ann.pre)(ann_node);
@ -1758,12 +1758,12 @@ pub fn print_bounds(s: @ps, bounds: @OptVec<ast::TyParamBound>) {
} }
} }
pub fn print_lifetime(s: @ps, &&lifetime: &ast::Lifetime) { pub fn print_lifetime(s: @ps, lifetime: &ast::Lifetime) {
word(s.s, ~"'"); word(s.s, ~"'");
print_ident(s, lifetime.ident); print_ident(s, lifetime.ident);
} }
pub fn print_generics(s: @ps, &&generics: &ast::Generics) { pub fn print_generics(s: @ps, generics: &ast::Generics) {
let total = generics.lifetimes.len() + generics.ty_params.len(); let total = generics.lifetimes.len() + generics.ty_params.len();
if total > 0 { if total > 0 {
word(s.s, ~"<"); word(s.s, ~"<");
@ -1790,7 +1790,7 @@ pub fn print_generics(s: @ps, &&generics: &ast::Generics) {
} }
} }
pub fn print_meta_item(s: @ps, &&item: @ast::meta_item) { pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
ibox(s, indent_unit); ibox(s, indent_unit);
match item.node { match item.node {
ast::meta_word(name) => word(s.s, *name), ast::meta_word(name) => word(s.s, *name),
@ -1814,7 +1814,7 @@ pub fn print_meta_item(s: @ps, &&item: @ast::meta_item) {
end(s); end(s);
} }
pub fn print_view_path(s: @ps, &&vp: @ast::view_path) { pub fn print_view_path(s: @ps, vp: @ast::view_path) {
match vp.node { match vp.node {
ast::view_path_simple(ident, path, namespace, _) => { ast::view_path_simple(ident, path, namespace, _) => {
if namespace == ast::module_ns { if namespace == ast::module_ns {
@ -2006,7 +2006,7 @@ pub fn print_remaining_comments(s: @ps) {
} }
} }
pub fn print_literal(s: @ps, &&lit: @ast::lit) { pub fn print_literal(s: @ps, lit: @ast::lit) {
maybe_print_comment(s, lit.span.lo); maybe_print_comment(s, lit.span.lo);
match next_lit(s, lit.span.lo) { match next_lit(s, lit.span.lo) {
Some(ref ltrl) => { Some(ref ltrl) => {
@ -2137,7 +2137,7 @@ pub fn print_string(s: @ps, st: &str) {
word(s.s, ~"\""); word(s.s, ~"\"");
} }
pub fn to_str<T>(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str { pub fn to_str<T: Copy>(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str {
do io::with_str_writer |wr| { do io::with_str_writer |wr| {
let s = rust_printer(wr, intr); let s = rust_printer(wr, intr);
f(s, t); f(s, t);

View file

@ -17,11 +17,10 @@
#[license = "MIT/ASL2"]; #[license = "MIT/ASL2"];
#[crate_type = "lib"]; #[crate_type = "lib"];
#[legacy_modes];
#[allow(vecs_implicitly_copyable)]; #[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)]; #[allow(non_camel_case_types)];
#[allow(deprecated_mode)]; #[deny(deprecated_mode)];
#[deny(deprecated_pattern)];
#[no_core]; #[no_core];

View file

@ -101,7 +101,7 @@ pub struct Visitor<E> {
pub type visitor<E> = @Visitor<E>; pub type visitor<E> = @Visitor<E>;
pub fn default_visitor<E>() -> visitor<E> { pub fn default_visitor<E: Copy>() -> visitor<E> {
return @Visitor { return @Visitor {
visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e), visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e),
visit_view_item: |a,b,c|visit_view_item::<E>(a, b, c), visit_view_item: |a,b,c|visit_view_item::<E>(a, b, c),
@ -127,18 +127,18 @@ pub fn default_visitor<E>() -> visitor<E> {
}; };
} }
pub fn visit_crate<E>(c: crate, e: E, v: vt<E>) { pub fn visit_crate<E: Copy>(c: &crate, e: E, v: vt<E>) {
(v.visit_mod)(&c.node.module, c.span, crate_node_id, e, v); (v.visit_mod)(&c.node.module, c.span, crate_node_id, e, v);
} }
pub fn visit_mod<E>(m: &_mod, _sp: span, _id: node_id, e: E, v: vt<E>) { pub fn visit_mod<E: Copy>(m: &_mod, _sp: span, _id: node_id, e: E, v: vt<E>) {
for m.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); } for m.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); }
for m.items.each |i| { (v.visit_item)(*i, e, v); } for m.items.each |i| { (v.visit_item)(*i, e, v); }
} }
pub fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { } pub fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { }
pub fn visit_local<E>(loc: @local, e: E, v: vt<E>) { pub fn visit_local<E: Copy>(loc: @local, e: E, v: vt<E>) {
(v.visit_pat)(loc.node.pat, e, v); (v.visit_pat)(loc.node.pat, e, v);
(v.visit_ty)(loc.node.ty, e, v); (v.visit_ty)(loc.node.ty, e, v);
match loc.node.init { match loc.node.init {
@ -147,11 +147,11 @@ pub fn visit_local<E>(loc: @local, e: E, v: vt<E>) {
} }
} }
fn visit_trait_ref<E>(tref: @ast::trait_ref, e: E, v: vt<E>) { fn visit_trait_ref<E: Copy>(tref: @ast::trait_ref, e: E, v: vt<E>) {
visit_path(tref.path, e, v); visit_path(tref.path, e, v);
} }
pub fn visit_item<E>(i: @item, e: E, v: vt<E>) { pub fn visit_item<E: Copy>(i: @item, e: E, v: vt<E>) {
match i.node { match i.node {
item_const(t, ex) => { item_const(t, ex) => {
(v.visit_ty)(t, e, v); (v.visit_ty)(t, e, v);
@ -216,10 +216,10 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
} }
} }
pub fn visit_enum_def<E>(enum_definition: ast::enum_def, pub fn visit_enum_def<E: Copy>(enum_definition: ast::enum_def,
tps: &Generics, tps: &Generics,
e: E, e: E,
v: vt<E>) { v: vt<E>) {
for enum_definition.variants.each |vr| { for enum_definition.variants.each |vr| {
match vr.node.kind { match vr.node.kind {
tuple_variant_kind(ref variant_args) => { tuple_variant_kind(ref variant_args) => {
@ -237,7 +237,7 @@ pub fn visit_enum_def<E>(enum_definition: ast::enum_def,
pub fn skip_ty<E>(_t: @Ty, _e: E, _v: vt<E>) {} pub fn skip_ty<E>(_t: @Ty, _e: E, _v: vt<E>) {}
pub fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) { pub fn visit_ty<E: Copy>(t: @Ty, e: E, v: vt<E>) {
match t.node { match t.node {
ty_box(mt) | ty_uniq(mt) | ty_box(mt) | ty_uniq(mt) |
ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => {
@ -265,11 +265,11 @@ pub fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
} }
} }
pub fn visit_path<E>(p: @Path, e: E, v: vt<E>) { pub fn visit_path<E: Copy>(p: @Path, e: E, v: vt<E>) {
for p.types.each |tp| { (v.visit_ty)(*tp, e, v); } for p.types.each |tp| { (v.visit_ty)(*tp, e, v); }
} }
pub fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { pub fn visit_pat<E: Copy>(p: @pat, e: E, v: vt<E>) {
match p.node { match p.node {
pat_enum(path, ref children) => { pat_enum(path, ref children) => {
visit_path(path, e, v); visit_path(path, e, v);
@ -315,7 +315,7 @@ pub fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
} }
} }
pub fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { pub fn visit_foreign_item<E: Copy>(ni: @foreign_item, e: E, v: vt<E>) {
match ni.node { match ni.node {
foreign_item_fn(ref fd, _, ref generics) => { foreign_item_fn(ref fd, _, ref generics) => {
visit_fn_decl(fd, e, v); visit_fn_decl(fd, e, v);
@ -327,8 +327,8 @@ pub fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
} }
} }
pub fn visit_ty_param_bounds<E>(bounds: @OptVec<TyParamBound>, pub fn visit_ty_param_bounds<E: Copy>(bounds: @OptVec<TyParamBound>,
e: E, v: vt<E>) { e: E, v: vt<E>) {
for bounds.each |bound| { for bounds.each |bound| {
match *bound { match *bound {
TraitTyParamBound(ty) => visit_trait_ref(ty, e, v), TraitTyParamBound(ty) => visit_trait_ref(ty, e, v),
@ -337,13 +337,13 @@ pub fn visit_ty_param_bounds<E>(bounds: @OptVec<TyParamBound>,
} }
} }
pub fn visit_generics<E>(generics: &Generics, e: E, v: vt<E>) { pub fn visit_generics<E: Copy>(generics: &Generics, e: E, v: vt<E>) {
for generics.ty_params.each |tp| { for generics.ty_params.each |tp| {
visit_ty_param_bounds(tp.bounds, e, v); visit_ty_param_bounds(tp.bounds, e, v);
} }
} }
pub fn visit_fn_decl<E>(fd: &fn_decl, e: E, v: vt<E>) { pub fn visit_fn_decl<E: Copy>(fd: &fn_decl, e: E, v: vt<E>) {
for fd.inputs.each |a| { for fd.inputs.each |a| {
(v.visit_pat)(a.pat, e, v); (v.visit_pat)(a.pat, e, v);
(v.visit_ty)(a.ty, e, v); (v.visit_ty)(a.ty, e, v);
@ -355,7 +355,7 @@ pub fn visit_fn_decl<E>(fd: &fn_decl, e: E, v: vt<E>) {
// visit_fn() and check for fk_method(). I named this visit_method_helper() // visit_fn() and check for fk_method(). I named this visit_method_helper()
// because it is not a default impl of any method, though I doubt that really // because it is not a default impl of any method, though I doubt that really
// clarifies anything. - Niko // clarifies anything. - Niko
pub fn visit_method_helper<E>(m: &method, e: E, v: vt<E>) { pub fn visit_method_helper<E: Copy>(m: &method, e: E, v: vt<E>) {
(v.visit_fn)( (v.visit_fn)(
&fk_method( &fk_method(
/* FIXME (#2543) */ copy m.ident, /* FIXME (#2543) */ copy m.ident,
@ -390,28 +390,28 @@ pub fn visit_struct_dtor_helper<E>(dtor: struct_dtor, generics: &Generics,
} }
pub fn visit_fn<E>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span, pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
_id: node_id, e: E, v: vt<E>) { _id: node_id, e: E, v: vt<E>) {
visit_fn_decl(decl, e, v); visit_fn_decl(decl, e, v);
let generics = generics_of_fn(fk); let generics = generics_of_fn(fk);
(v.visit_generics)(&generics, e, v); (v.visit_generics)(&generics, e, v);
(v.visit_block)(body, e, v); (v.visit_block)(body, e, v);
} }
pub fn visit_ty_method<E>(m: &ty_method, e: E, v: vt<E>) { pub fn visit_ty_method<E: Copy>(m: &ty_method, e: E, v: vt<E>) {
for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); } for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
(v.visit_generics)(&m.generics, e, v); (v.visit_generics)(&m.generics, e, v);
(v.visit_ty)(m.decl.output, e, v); (v.visit_ty)(m.decl.output, e, v);
} }
pub fn visit_trait_method<E>(m: &trait_method, e: E, v: vt<E>) { pub fn visit_trait_method<E: Copy>(m: &trait_method, e: E, v: vt<E>) {
match *m { match *m {
required(ref ty_m) => (v.visit_ty_method)(ty_m, e, v), required(ref ty_m) => (v.visit_ty_method)(ty_m, e, v),
provided(m) => visit_method_helper(m, e, v) provided(m) => visit_method_helper(m, e, v)
} }
} }
pub fn visit_struct_def<E>( pub fn visit_struct_def<E: Copy>(
sd: @struct_def, sd: @struct_def,
_nm: ast::ident, _nm: ast::ident,
generics: &Generics, generics: &Generics,
@ -433,15 +433,15 @@ pub fn visit_struct_def<E>(
} }
} }
pub fn visit_struct_field<E>(sf: @struct_field, e: E, v: vt<E>) { pub fn visit_struct_field<E: Copy>(sf: @struct_field, e: E, v: vt<E>) {
(v.visit_ty)(sf.node.ty, e, v); (v.visit_ty)(sf.node.ty, e, v);
} }
pub fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) { pub fn visit_struct_method<E: Copy>(m: @method, e: E, v: vt<E>) {
visit_method_helper(m, e, v); visit_method_helper(m, e, v);
} }
pub fn visit_block<E>(b: &blk, e: E, v: vt<E>) { pub fn visit_block<E: Copy>(b: &blk, e: E, v: vt<E>) {
for b.node.view_items.each |vi| { for b.node.view_items.each |vi| {
(v.visit_view_item)(*vi, e, v); (v.visit_view_item)(*vi, e, v);
} }
@ -460,7 +460,7 @@ pub fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
} }
} }
pub fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { pub fn visit_decl<E: Copy>(d: @decl, e: E, v: vt<E>) {
match d.node { match d.node {
decl_local(ref locs) => { decl_local(ref locs) => {
for locs.each |loc| { for locs.each |loc| {
@ -475,7 +475,7 @@ pub fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) {
match eo { None => (), Some(ex) => (v.visit_expr)(ex, e, v) } match eo { None => (), Some(ex) => (v.visit_expr)(ex, e, v) }
} }
pub fn visit_exprs<E>(exprs: &[@expr], e: E, v: vt<E>) { pub fn visit_exprs<E: Copy>(exprs: &[@expr], e: E, v: vt<E>) {
for exprs.each |ex| { (v.visit_expr)(*ex, e, v); } for exprs.each |ex| { (v.visit_expr)(*ex, e, v); }
} }
@ -483,7 +483,7 @@ pub fn visit_mac<E>(_m: mac, _e: E, _v: vt<E>) {
/* no user-serviceable parts inside */ /* no user-serviceable parts inside */
} }
pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { pub fn visit_expr<E: Copy>(ex: @expr, e: E, v: vt<E>) {
match ex.node { match ex.node {
expr_vstore(x, _) => (v.visit_expr)(x, e, v), expr_vstore(x, _) => (v.visit_expr)(x, e, v),
expr_vec(ref es, _) => visit_exprs(*es, e, v), expr_vec(ref es, _) => visit_exprs(*es, e, v),
@ -588,7 +588,7 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
(v.visit_expr_post)(ex, e, v); (v.visit_expr_post)(ex, e, v);
} }
pub fn visit_arm<E>(a: &arm, e: E, v: vt<E>) { pub fn visit_arm<E: Copy>(a: &arm, e: E, v: vt<E>) {
for a.pats.each |p| { (v.visit_pat)(*p, e, v); } for a.pats.each |p| { (v.visit_pat)(*p, e, v); }
visit_expr_opt(a.guard, e, v); visit_expr_opt(a.guard, e, v);
(v.visit_block)(&a.body, e, v); (v.visit_block)(&a.body, e, v);
@ -655,67 +655,67 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
m: &_mod, m: &_mod,
sp: span, sp: span,
id: node_id, id: node_id,
&&e: (), e: (),
v: vt<()> v: vt<()>
) { ) {
f(m, sp, id); f(m, sp, id);
visit_mod(m, sp, id, e, v); visit_mod(m, sp, id, e, v);
} }
fn v_view_item(f: @fn(@view_item), vi: @view_item, &&e: (), v: vt<()>) { fn v_view_item(f: @fn(@view_item), vi: @view_item, e: (), v: vt<()>) {
f(vi); f(vi);
visit_view_item(vi, e, v); visit_view_item(vi, e, v);
} }
fn v_foreign_item(f: @fn(@foreign_item), ni: @foreign_item, &&e: (), fn v_foreign_item(f: @fn(@foreign_item), ni: @foreign_item, e: (),
v: vt<()>) { v: vt<()>) {
f(ni); f(ni);
visit_foreign_item(ni, e, v); visit_foreign_item(ni, e, v);
} }
fn v_item(f: @fn(@item), i: @item, &&e: (), v: vt<()>) { fn v_item(f: @fn(@item), i: @item, e: (), v: vt<()>) {
f(i); f(i);
visit_item(i, e, v); visit_item(i, e, v);
} }
fn v_local(f: @fn(@local), l: @local, &&e: (), v: vt<()>) { fn v_local(f: @fn(@local), l: @local, e: (), v: vt<()>) {
f(l); f(l);
visit_local(l, e, v); visit_local(l, e, v);
} }
fn v_block(f: @fn(&ast::blk), bl: &ast::blk, &&e: (), v: vt<()>) { fn v_block(f: @fn(&ast::blk), bl: &ast::blk, e: (), v: vt<()>) {
f(bl); f(bl);
visit_block(bl, e, v); visit_block(bl, e, v);
} }
fn v_stmt(f: @fn(@stmt), st: @stmt, &&e: (), v: vt<()>) { fn v_stmt(f: @fn(@stmt), st: @stmt, e: (), v: vt<()>) {
f(st); f(st);
visit_stmt(st, e, v); visit_stmt(st, e, v);
} }
fn v_arm(f: @fn(&arm), a: &arm, &&e: (), v: vt<()>) { fn v_arm(f: @fn(&arm), a: &arm, e: (), v: vt<()>) {
f(a); f(a);
visit_arm(a, e, v); visit_arm(a, e, v);
} }
fn v_pat(f: @fn(@pat), p: @pat, &&e: (), v: vt<()>) { fn v_pat(f: @fn(@pat), p: @pat, e: (), v: vt<()>) {
f(p); f(p);
visit_pat(p, e, v); visit_pat(p, e, v);
} }
fn v_decl(f: @fn(@decl), d: @decl, &&e: (), v: vt<()>) { fn v_decl(f: @fn(@decl), d: @decl, e: (), v: vt<()>) {
f(d); f(d);
visit_decl(d, e, v); visit_decl(d, e, v);
} }
fn v_expr(f: @fn(@expr), ex: @expr, &&e: (), v: vt<()>) { fn v_expr(f: @fn(@expr), ex: @expr, e: (), v: vt<()>) {
f(ex); f(ex);
visit_expr(ex, e, v); visit_expr(ex, e, v);
} }
fn v_expr_post(f: @fn(@expr), ex: @expr, &&_e: (), _v: vt<()>) { fn v_expr_post(f: @fn(@expr), ex: @expr, _e: (), _v: vt<()>) {
f(ex); f(ex);
} }
fn v_ty(f: @fn(@Ty), ty: @Ty, &&e: (), v: vt<()>) { fn v_ty(f: @fn(@Ty), ty: @Ty, e: (), v: vt<()>) {
f(ty); f(ty);
visit_ty(ty, e, v); visit_ty(ty, e, v);
} }
fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, &&e: (), v: vt<()>) { fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, e: (), v: vt<()>) {
f(ty); f(ty);
visit_ty_method(ty, e, v); visit_ty_method(ty, e, v);
} }
fn v_trait_method(f: @fn(&trait_method), fn v_trait_method(f: @fn(&trait_method),
m: &trait_method, m: &trait_method,
&&e: (), e: (),
v: vt<()>) { v: vt<()>) {
f(m); f(m);
visit_trait_method(m, e, v); visit_trait_method(m, e, v);
@ -726,7 +726,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
nm: ident, nm: ident,
generics: &Generics, generics: &Generics,
id: node_id, id: node_id,
&&e: (), e: (),
v: vt<()> v: vt<()>
) { ) {
f(sd, nm, generics, id); f(sd, nm, generics, id);
@ -735,7 +735,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
fn v_generics( fn v_generics(
f: @fn(&Generics), f: @fn(&Generics),
ps: &Generics, ps: &Generics,
&&e: (), e: (),
v: vt<()> v: vt<()>
) { ) {
f(ps); f(ps);
@ -748,20 +748,20 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
body: &blk, body: &blk,
sp: span, sp: span,
id: node_id, id: node_id,
&&e: (), e: (),
v: vt<()> v: vt<()>
) { ) {
f(fk, decl, body, sp, id); f(fk, decl, body, sp, id);
visit_fn(fk, decl, body, sp, id, e, v); visit_fn(fk, decl, body, sp, id, e, v);
} }
let visit_ty: @fn(@Ty, &&x: (), vt<()>) = let visit_ty: @fn(@Ty, x: (), vt<()>) =
|a,b,c| v_ty(v.visit_ty, a, b, c); |a,b,c| v_ty(v.visit_ty, a, b, c);
fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, &&e: (), fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, e: (),
v: vt<()>) { v: vt<()>) {
f(sf); f(sf);
visit_struct_field(sf, e, v); visit_struct_field(sf, e, v);
} }
fn v_struct_method(f: @fn(@method), m: @method, &&e: (), v: vt<()>) { fn v_struct_method(f: @fn(@method), m: @method, e: (), v: vt<()>) {
f(m); f(m);
visit_struct_method(m, e, v); visit_struct_method(m, e, v);
} }