diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 87e1dd2d22c..27483ae94a5 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -158,7 +158,7 @@ pub fn mk_handler(emitter: Option) -> @handler { } }; - @mut HandlerT { mut err_count: 0, emit: emit } as @handler + @mut HandlerT { err_count: 0, emit: emit } as @handler } #[deriving_eq] diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs index 6d117f5ad23..8b8e48bd522 100644 --- a/src/libsyntax/ext/pipes/mod.rs +++ b/src/libsyntax/ext/pipes/mod.rs @@ -73,7 +73,7 @@ pub fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident, let rdr = tt_rdr as reader; let rust_parser = Parser(sess, cfg, rdr.dup()); - let proto = rust_parser.parse_proto(cx.str_of(id)); + let mut proto = rust_parser.parse_proto(cx.str_of(id)); // check for errors visit(proto, cx); diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index e8e4c939907..25760aa01b6 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -27,8 +27,8 @@ use core::to_str::ToStr; use core::vec; pub trait gen_send { - fn gen_send(&self, cx: ext_ctxt, try: bool) -> @ast::item; - fn to_ty(&self, cx: ext_ctxt) -> @ast::Ty; + fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item; + fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty; } pub trait to_type_decls { @@ -47,7 +47,7 @@ pub trait gen_init { } pub impl gen_send for message { - fn gen_send(&self, cx: ext_ctxt, try: bool) -> @ast::item { + fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item { debug!("pipec: gen_send"); match *self { message(ref _id, span, ref tys, this, Some(ref next_state)) => { @@ -193,7 +193,7 @@ pub impl gen_send for message { } } - fn to_ty(&self, cx: ext_ctxt) -> @ast::Ty { + fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty { cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span()) .add_tys(cx.ty_vars_global(self.get_params()))) } @@ -259,10 +259,14 @@ pub impl to_type_decls for state { recv => (*self).dir.reverse() }; let mut items = ~[]; - for self.messages.each |m| { - if dir == send { - items.push(m.gen_send(cx, true)); - items.push(m.gen_send(cx, false)); + + { + let messages = &mut *self.messages; + for vec::each_mut(*messages) |m| { + if dir == send { + items.push(m.gen_send(cx, true)); + items.push(m.gen_send(cx, false)); + } } } @@ -395,7 +399,8 @@ pub impl gen_init for protocol { } cx.ty_path_ast_builder(path(~[cx.ident_of(~"super"), - cx.ident_of(~"__Buffer")], self.span) + cx.ident_of(~"__Buffer")], + copy self.span) .add_tys(cx.ty_vars_global(params))) } @@ -453,12 +458,12 @@ pub impl gen_init for protocol { } items.push(cx.item_mod(cx.ident_of(~"client"), - self.span, + copy self.span, client_states)); items.push(cx.item_mod(cx.ident_of(~"server"), - self.span, + copy self.span, server_states)); - cx.item_mod(cx.ident_of(self.name), self.span, items) + cx.item_mod(cx.ident_of(self.name), copy self.span, items) } } diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index da67e48dfa6..7c6dc1f937d 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -16,7 +16,6 @@ use ext::base::ext_ctxt; use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path}; use core::cmp; -use core::dvec::DVec; use core::to_str::ToStr; #[deriving_eq] @@ -45,26 +44,24 @@ pub struct next_state { tys: ~[@ast::Ty], } -pub enum message { - // name, span, data, current state, next state - message(~str, span, ~[@ast::Ty], state, Option) -} +// name, span, data, current state, next state +pub struct message(~str, span, ~[@ast::Ty], state, Option); pub impl message { - fn name(&self) -> ~str { + fn name(&mut self) -> ~str { match *self { message(ref id, _, _, _, _) => (*id) } } - fn span(&self) -> span { + fn span(&mut self) -> span { match *self { message(_, span, _, _, _) => span } } /// Return the type parameters actually used by this message - fn get_params(&self) -> ~[ast::ty_param] { + fn get_params(&mut self) -> ~[ast::ty_param] { match *self { message(_, _, _, this, _) => this.ty_params } @@ -80,7 +77,7 @@ pub struct state_ { span: span, dir: direction, ty_params: ~[ast::ty_param], - messages: DVec, + messages: @mut ~[message], proto: protocol } @@ -121,17 +118,17 @@ pub impl state_ { } } -pub type protocol = @protocol_; +pub type protocol = @mut protocol_; pub fn protocol(name: ~str, +span: span) -> protocol { - @protocol_(name, span) + @mut protocol_(name, span) } pub fn protocol_(name: ~str, span: span) -> protocol_ { protocol_ { name: name, span: span, - states: DVec(), + states: @mut ~[], bounded: None } } @@ -139,30 +136,30 @@ pub fn protocol_(name: ~str, span: span) -> protocol_ { pub struct protocol_ { name: ~str, span: span, - states: DVec, + states: @mut ~[state], - mut bounded: Option, + bounded: Option, } pub impl protocol_ { /// Get a state. - fn get_state(&self, name: ~str) -> state { + fn get_state(&mut self, name: ~str) -> state { self.states.find(|i| i.name == name).get() } - fn get_state_by_id(&self, id: uint) -> state { self.states[id] } + fn get_state_by_id(&mut self, id: uint) -> state { self.states[id] } - fn has_state(&self, name: ~str) -> bool { + fn has_state(&mut self, name: ~str) -> bool { self.states.find(|i| i.name == name).is_some() } - fn filename(&self) -> ~str { + fn filename(&mut self) -> ~str { ~"proto://" + self.name } - fn num_states(&self) -> uint { self.states.len() } + fn num_states(&mut self) -> uint { self.states.len() } - fn has_ty_params(&self) -> bool { + fn has_ty_params(&mut self) -> bool { for self.states.each |s| { if s.ty_params.len() > 0 { return true; @@ -170,7 +167,7 @@ pub impl protocol_ { } false } - fn is_bounded(&self) -> bool { + fn is_bounded(&mut self) -> bool { let bounded = self.bounded.get(); bounded } @@ -179,7 +176,7 @@ pub impl protocol_ { pub impl protocol { fn add_state_poly(&self, name: ~str, ident: ast::ident, dir: direction, +ty_params: ~[ast::ty_param]) -> state { - let messages = DVec(); + let messages = @mut ~[]; let state = @state_ { id: self.states.len(), diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 3817f89b817..a9502ff2902 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -59,7 +59,7 @@ pub fn new_tt_reader(sp_diag: span_handler, let r = @mut TtReader { sp_diag: sp_diag, interner: itr, - mut cur: @mut TtFrame { + cur: @mut TtFrame { readme: @mut src, idx: 0u, dotdotdoted: false,