summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-02-28 12:54:01 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-03-01 22:40:52 -0800
commit198cc3d850136582651489328fec221a2b98bfef (patch)
treefe47f6fab3d4ead61053684613d0b1852ec7e311 /src/libsyntax/print
parent58fd6ab90db3eb68c94695e1254a73e57bc44658 (diff)
downloadrust-198cc3d850136582651489328fec221a2b98bfef.tar.gz
rust-198cc3d850136582651489328fec221a2b98bfef.zip
libsyntax: Fix errors arising from the automated `~[T]` conversion
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pp.rs88
-rw-r--r--src/libsyntax/print/pprust.rs105
2 files changed, 115 insertions, 78 deletions
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 151f9c8b327..e9e0e483593 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -62,7 +62,7 @@
  */
 
 use std::io;
-use std::vec;
+use std::vec_ng::Vec;
 
 #[deriving(Clone, Eq)]
 pub enum Breaks {
@@ -131,7 +131,7 @@ pub fn buf_str(toks: Vec<Token> , szs: Vec<int> , left: uint, right: uint,
         if i != left {
             s.push_str(", ");
         }
-        s.push_str(format!("{}={}", szs[i], tok_str(toks[i].clone())));
+        s.push_str(format!("{}={}", szs.get(i), tok_str(toks.get(i).clone())));
         i += 1u;
         i %= n;
     }
@@ -156,9 +156,9 @@ pub fn mk_printer(out: ~io::Writer, linewidth: uint) -> Printer {
     // fall behind.
     let n: uint = 3 * linewidth;
     debug!("mk_printer {}", linewidth);
-    let token: Vec<Token> = vec::from_elem(n, Eof);
-    let size: Vec<int> = vec::from_elem(n, 0);
-    let scan_stack: Vec<uint> = vec::from_elem(n, 0u);
+    let token: Vec<Token> = Vec::from_elem(n, Eof);
+    let size: Vec<int> = Vec::from_elem(n, 0);
+    let scan_stack: Vec<uint> = Vec::from_elem(n, 0u);
     Printer {
         out: out,
         buf_len: n,
@@ -286,11 +286,11 @@ pub struct Printer {
 
 impl Printer {
     pub fn last_token(&mut self) -> Token {
-        self.token[self.right].clone()
+        (*self.token.get(self.right)).clone()
     }
     // be very careful with this!
     pub fn replace_last_token(&mut self, t: Token) {
-        self.token[self.right] = t;
+        *self.token.get_mut(self.right) = t;
     }
     pub fn pretty_print(&mut self, t: Token) -> io::IoResult<()> {
         debug!("pp ~[{},{}]", self.left, self.right);
@@ -298,8 +298,9 @@ impl Printer {
           Eof => {
             if !self.scan_stack_empty {
                 self.check_stack(0);
-                let left = self.token[self.left].clone();
-                try!(self.advance_left(left, self.size[self.left]));
+                let left = (*self.token.get(self.left)).clone();
+                let left_size = *self.size.get(self.left);
+                try!(self.advance_left(left, left_size));
             }
             self.indent(0);
             Ok(())
@@ -313,8 +314,8 @@ impl Printer {
             } else { self.advance_right(); }
             debug!("pp Begin({})/buffer ~[{},{}]",
                    b.offset, self.left, self.right);
-            self.token[self.right] = t;
-            self.size[self.right] = -self.right_total;
+            *self.token.get_mut(self.right) = t;
+            *self.size.get_mut(self.right) = -self.right_total;
             self.scan_push(self.right);
             Ok(())
           }
@@ -325,8 +326,8 @@ impl Printer {
             } else {
                 debug!("pp End/buffer ~[{},{}]", self.left, self.right);
                 self.advance_right();
-                self.token[self.right] = t;
-                self.size[self.right] = -1;
+                *self.token.get_mut(self.right) = t;
+                *self.size.get_mut(self.right) = -1;
                 self.scan_push(self.right);
                 Ok(())
             }
@@ -342,8 +343,8 @@ impl Printer {
                    b.offset, self.left, self.right);
             self.check_stack(0);
             self.scan_push(self.right);
-            self.token[self.right] = t;
-            self.size[self.right] = -self.right_total;
+            *self.token.get_mut(self.right) = t;
+            *self.size.get_mut(self.right) = -self.right_total;
             self.right_total += b.blank_space;
             Ok(())
           }
@@ -356,8 +357,8 @@ impl Printer {
                 debug!("pp String('{}')/buffer ~[{},{}]",
                        *s, self.left, self.right);
                 self.advance_right();
-                self.token[self.right] = t.clone();
-                self.size[self.right] = len;
+                *self.token.get_mut(self.right) = t.clone();
+                *self.size.get_mut(self.right) = len;
                 self.right_total += len;
                 self.check_stream()
             }
@@ -371,13 +372,15 @@ impl Printer {
             debug!("scan window is {}, longer than space on line ({})",
                    self.right_total - self.left_total, self.space);
             if !self.scan_stack_empty {
-                if self.left == self.scan_stack[self.bottom] {
+                if self.left == *self.scan_stack.get(self.bottom) {
                     debug!("setting {} to infinity and popping", self.left);
-                    self.size[self.scan_pop_bottom()] = SIZE_INFINITY;
+                    let scanned = self.scan_pop_bottom();
+                    *self.size.get_mut(scanned) = SIZE_INFINITY;
                 }
             }
-            let left = self.token[self.left].clone();
-            try!(self.advance_left(left, self.size[self.left]));
+            let left = (*self.token.get(self.left)).clone();
+            let left_size = *self.size.get(self.left);
+            try!(self.advance_left(left, left_size));
             if self.left != self.right {
                 try!(self.check_stream());
             }
@@ -393,26 +396,30 @@ impl Printer {
             self.top %= self.buf_len;
             assert!((self.top != self.bottom));
         }
-        self.scan_stack[self.top] = x;
+        *self.scan_stack.get_mut(self.top) = x;
     }
     pub fn scan_pop(&mut self) -> uint {
         assert!((!self.scan_stack_empty));
-        let x = self.scan_stack[self.top];
+        let x = *self.scan_stack.get(self.top);
         if self.top == self.bottom {
             self.scan_stack_empty = true;
-        } else { self.top += self.buf_len - 1u; self.top %= self.buf_len; }
+        } else {
+            self.top += self.buf_len - 1u; self.top %= self.buf_len;
+        }
         return x;
     }
     pub fn scan_top(&mut self) -> uint {
         assert!((!self.scan_stack_empty));
-        return self.scan_stack[self.top];
+        return *self.scan_stack.get(self.top);
     }
     pub fn scan_pop_bottom(&mut self) -> uint {
         assert!((!self.scan_stack_empty));
-        let x = self.scan_stack[self.bottom];
+        let x = *self.scan_stack.get(self.bottom);
         if self.top == self.bottom {
             self.scan_stack_empty = true;
-        } else { self.bottom += 1u; self.bottom %= self.buf_len; }
+        } else {
+            self.bottom += 1u; self.bottom %= self.buf_len;
+        }
         return x;
     }
     pub fn advance_right(&mut self) {
@@ -435,8 +442,9 @@ impl Printer {
             if self.left != self.right {
                 self.left += 1u;
                 self.left %= self.buf_len;
-                let left = self.token[self.left].clone();
-                try!(self.advance_left(left, self.size[self.left]));
+                let left = (*self.token.get(self.left)).clone();
+                let left_size = *self.size.get(self.left);
+                try!(self.advance_left(left, left_size));
             }
             ret
         } else {
@@ -446,22 +454,28 @@ impl Printer {
     pub fn check_stack(&mut self, k: int) {
         if !self.scan_stack_empty {
             let x = self.scan_top();
-            match self.token[x] {
-              Begin(_) => {
+            match self.token.get(x) {
+              &Begin(_) => {
                 if k > 0 {
-                    self.size[self.scan_pop()] = self.size[x] +
+                    let popped = self.scan_pop();
+                    *self.size.get_mut(popped) = *self.size.get(x) +
                         self.right_total;
                     self.check_stack(k - 1);
                 }
               }
-              End => {
+              &End => {
                 // paper says + not =, but that makes no sense.
-                self.size[self.scan_pop()] = 1;
+                let popped = self.scan_pop();
+                *self.size.get_mut(popped) = 1;
                 self.check_stack(k + 1);
               }
               _ => {
-                self.size[self.scan_pop()] = self.size[x] + self.right_total;
-                if k > 0 { self.check_stack(k); }
+                let popped = self.scan_pop();
+                *self.size.get_mut(popped) = *self.size.get(x) +
+                    self.right_total;
+                if k > 0 {
+                    self.check_stack(k);
+                }
               }
             }
         }
@@ -481,7 +495,7 @@ impl Printer {
         let print_stack = &mut self.print_stack;
         let n = print_stack.len();
         if n != 0u {
-            print_stack[n - 1u]
+            *print_stack.get(n - 1u)
         } else {
             PrintStackElem {
                 offset: 0,
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 25ff793d34b..d027efc1d42 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -33,6 +33,7 @@ use std::char;
 use std::str;
 use std::io;
 use std::io::MemWriter;
+use std::vec_ng::Vec;
 
 // The &mut State is stored here to prevent recursive type.
 pub enum AnnNode<'a, 'b> {
@@ -147,7 +148,7 @@ pub fn print_crate(cm: @CodeMap,
 }
 
 pub fn print_crate_(s: &mut State, krate: &ast::Crate) -> io::IoResult<()> {
-    try!(print_mod(s, &krate.module, krate.attrs));
+    try!(print_mod(s, &krate.module, krate.attrs.as_slice()));
     try!(print_remaining_comments(s));
     try!(eof(&mut s.s));
     Ok(())
@@ -319,7 +320,7 @@ pub fn in_cbox(s: &mut State) -> bool {
     let boxes = s.boxes.borrow();
     let len = boxes.get().len();
     if len == 0u { return false; }
-    return boxes.get()[len - 1u] == pp::Consistent;
+    return *boxes.get().get(len - 1u) == pp::Consistent;
 }
 
 pub fn hardbreak_if_not_bol(s: &mut State) -> io::IoResult<()> {
@@ -463,7 +464,7 @@ pub fn print_type(s: &mut State, ty: &ast::Ty) -> io::IoResult<()> {
         }
         ast::TyTup(ref elts) => {
             try!(popen(s));
-            try!(commasep(s, Inconsistent, *elts, print_type_ref));
+            try!(commasep(s, Inconsistent, elts.as_slice(), print_type_ref));
             if elts.len() == 1 {
                 try!(word(&mut s.s, ","));
             }
@@ -517,7 +518,7 @@ pub fn print_foreign_item(s: &mut State,
                           item: &ast::ForeignItem) -> io::IoResult<()> {
     try!(hardbreak_if_not_bol(s));
     try!(maybe_print_comment(s, item.span.lo));
-    try!(print_outer_attributes(s, item.attrs));
+    try!(print_outer_attributes(s, item.attrs.as_slice()));
     match item.node {
         ast::ForeignItemFn(decl, ref generics) => {
             try!(print_fn(s, decl, None, AbiSet::Rust(), item.ident, generics,
@@ -545,7 +546,7 @@ pub fn print_foreign_item(s: &mut State,
 pub fn print_item(s: &mut State, item: &ast::Item) -> io::IoResult<()> {
     try!(hardbreak_if_not_bol(s));
     try!(maybe_print_comment(s, item.span.lo));
-    try!(print_outer_attributes(s, item.attrs));
+    try!(print_outer_attributes(s, item.attrs.as_slice()));
     {
         let ann_node = NodeItem(s, item);
         try!(s.ann.pre(ann_node));
@@ -580,21 +581,21 @@ pub fn print_item(s: &mut State, item: &ast::Item) -> io::IoResult<()> {
             item.vis
         ));
         try!(word(&mut s.s, " "));
-        try!(print_block_with_attrs(s, body, item.attrs));
+        try!(print_block_with_attrs(s, body, item.attrs.as_slice()));
       }
       ast::ItemMod(ref _mod) => {
         try!(head(s, visibility_qualified(item.vis, "mod")));
         try!(print_ident(s, item.ident));
         try!(nbsp(s));
         try!(bopen(s));
-        try!(print_mod(s, _mod, item.attrs));
+        try!(print_mod(s, _mod, item.attrs.as_slice()));
         try!(bclose(s, item.span));
       }
       ast::ItemForeignMod(ref nmod) => {
         try!(head(s, "extern"));
         try!(word_nbsp(s, nmod.abis.to_str()));
         try!(bopen(s));
-        try!(print_foreign_mod(s, nmod, item.attrs));
+        try!(print_foreign_mod(s, nmod, item.attrs.as_slice()));
         try!(bclose(s, item.span));
       }
       ast::ItemTy(ty, ref params) => {
@@ -646,7 +647,7 @@ pub fn print_item(s: &mut State, item: &ast::Item) -> io::IoResult<()> {
 
         try!(space(&mut s.s));
         try!(bopen(s));
-        try!(print_inner_attributes(s, item.attrs));
+        try!(print_inner_attributes(s, item.attrs.as_slice()));
         for meth in methods.iter() {
            try!(print_method(s, *meth));
         }
@@ -706,7 +707,7 @@ pub fn print_enum_def(s: &mut State, enum_definition: &ast::EnumDef,
     try!(print_ident(s, ident));
     try!(print_generics(s, generics));
     try!(space(&mut s.s));
-    try!(print_variants(s, enum_definition.variants, span));
+    try!(print_variants(s, enum_definition.variants.as_slice(), span));
     Ok(())
 }
 
@@ -717,7 +718,7 @@ pub fn print_variants(s: &mut State,
     for &v in variants.iter() {
         try!(space_if_not_bol(s));
         try!(maybe_print_comment(s, v.span.lo));
-        try!(print_outer_attributes(s, v.node.attrs));
+        try!(print_outer_attributes(s, v.node.attrs.as_slice()));
         try!(ibox(s, indent_unit));
         try!(print_variant(s, v));
         try!(word(&mut s.s, ","));
@@ -761,7 +762,10 @@ pub fn print_struct(s: &mut State,
     if ast_util::struct_def_is_tuple_like(struct_def) {
         if !struct_def.fields.is_empty() {
             try!(popen(s));
-            try!(commasep(s, Inconsistent, struct_def.fields, |s, field| {
+            try!(commasep(s,
+                          Inconsistent,
+                          struct_def.fields.as_slice(),
+                          |s, field| {
                 match field.node.kind {
                     ast::NamedField(..) => fail!("unexpected named field"),
                     ast::UnnamedField => {
@@ -787,7 +791,8 @@ pub fn print_struct(s: &mut State,
                 ast::NamedField(ident, visibility) => {
                     try!(hardbreak_if_not_bol(s));
                     try!(maybe_print_comment(s, field.span.lo));
-                    try!(print_outer_attributes(s, field.node.attrs));
+                    try!(print_outer_attributes(s,
+                                                field.node.attrs.as_slice()));
                     try!(print_visibility(s, visibility));
                     try!(print_ident(s, ident));
                     try!(word_nbsp(s, ":"));
@@ -857,7 +862,10 @@ pub fn print_variant(s: &mut State, v: &ast::Variant) -> io::IoResult<()> {
                                      arg: &ast::VariantArg) -> io::IoResult<()> {
                     print_type(s, arg.ty)
                 }
-                try!(commasep(s, Consistent, *args, print_variant_arg));
+                try!(commasep(s,
+                              Consistent,
+                              args.as_slice(),
+                              print_variant_arg));
                 try!(pclose(s));
             }
         }
@@ -881,7 +889,7 @@ pub fn print_variant(s: &mut State, v: &ast::Variant) -> io::IoResult<()> {
 pub fn print_ty_method(s: &mut State, m: &ast::TypeMethod) -> io::IoResult<()> {
     try!(hardbreak_if_not_bol(s));
     try!(maybe_print_comment(s, m.span.lo));
-    try!(print_outer_attributes(s, m.attrs));
+    try!(print_outer_attributes(s, m.attrs.as_slice()));
     try!(print_ty_fn(s,
                        None,
                        None,
@@ -907,12 +915,12 @@ pub fn print_trait_method(s: &mut State,
 pub fn print_method(s: &mut State, meth: &ast::Method) -> io::IoResult<()> {
     try!(hardbreak_if_not_bol(s));
     try!(maybe_print_comment(s, meth.span.lo));
-    try!(print_outer_attributes(s, meth.attrs));
+    try!(print_outer_attributes(s, meth.attrs.as_slice()));
     try!(print_fn(s, meth.decl, Some(meth.purity), AbiSet::Rust(),
                     meth.ident, &meth.generics, Some(meth.explicit_self.node),
                     meth.vis));
     try!(word(&mut s.s, " "));
-    print_block_with_attrs(s, meth.body, meth.attrs)
+    print_block_with_attrs(s, meth.body, meth.attrs.as_slice())
 }
 
 pub fn print_outer_attributes(s: &mut State,
@@ -1184,7 +1192,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
             try!(word(&mut s.s, "mut"));
             if exprs.len() > 0u { try!(nbsp(s)); }
         }
-        try!(commasep_exprs(s, Inconsistent, *exprs));
+        try!(commasep_exprs(s, Inconsistent, exprs.as_slice()));
         try!(word(&mut s.s, "]"));
         try!(end(s));
       }
@@ -1207,7 +1215,11 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
       ast::ExprStruct(ref path, ref fields, wth) => {
         try!(print_path(s, path, true));
         try!(word(&mut s.s, "{"));
-        try!(commasep_cmnt(s, Consistent, (*fields), print_field, get_span));
+        try!(commasep_cmnt(s,
+                           Consistent,
+                           fields.as_slice(),
+                           print_field,
+                           get_span));
         match wth {
             Some(expr) => {
                 try!(ibox(s, indent_unit));
@@ -1225,7 +1237,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
       }
       ast::ExprTup(ref exprs) => {
         try!(popen(s));
-        try!(commasep_exprs(s, Inconsistent, *exprs));
+        try!(commasep_exprs(s, Inconsistent, exprs.as_slice()));
         if exprs.len() == 1 {
             try!(word(&mut s.s, ","));
         }
@@ -1233,16 +1245,16 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
       }
       ast::ExprCall(func, ref args) => {
         try!(print_expr(s, func));
-        try!(print_call_post(s, *args));
+        try!(print_call_post(s, args.as_slice()));
       }
       ast::ExprMethodCall(ident, ref tys, ref args) => {
         let base_args = args.slice_from(1);
-        try!(print_expr(s, args[0]));
+        try!(print_expr(s, *args.get(0)));
         try!(word(&mut s.s, "."));
         try!(print_ident(s, ident));
         if tys.len() > 0u {
             try!(word(&mut s.s, "::<"));
-            try!(commasep(s, Inconsistent, *tys, print_type_ref));
+            try!(commasep(s, Inconsistent, tys.as_slice(), print_type_ref));
             try!(word(&mut s.s, ">"));
         }
         try!(print_call_post(s, base_args));
@@ -1455,7 +1467,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
         try!(print_ident(s, id));
         if tys.len() > 0u {
             try!(word(&mut s.s, "::<"));
-            try!(commasep(s, Inconsistent, *tys, print_type_ref));
+            try!(commasep(s, Inconsistent, tys.as_slice(), print_type_ref));
             try!(word(&mut s.s, ">"));
         }
       }
@@ -1649,7 +1661,7 @@ fn print_path_(s: &mut State,
                 }
                 try!(commasep(s,
                                 Inconsistent,
-                                segment.types.map_to_vec(|&t| t),
+                                segment.types.map_to_vec(|&t| t).as_slice(),
                                 print_type_ref));
             }
 
@@ -1708,7 +1720,7 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) -> io::IoResult<()> {
           Some(ref args) => {
             if !args.is_empty() {
               try!(popen(s));
-              try!(commasep(s, Inconsistent, *args,
+              try!(commasep(s, Inconsistent, args.as_slice(),
                               |s, &p| print_pat(s, p)));
               try!(pclose(s));
             } else { }
@@ -1727,7 +1739,7 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) -> io::IoResult<()> {
             Ok(())
         }
         fn get_span(f: &ast::FieldPat) -> codemap::Span { return f.pat.span; }
-        try!(commasep_cmnt(s, Consistent, *fields,
+        try!(commasep_cmnt(s, Consistent, fields.as_slice(),
                              |s, f| print_field(s,f),
                              get_span));
         if etc {
@@ -1738,7 +1750,10 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) -> io::IoResult<()> {
       }
       ast::PatTup(ref elts) => {
         try!(popen(s));
-        try!(commasep(s, Inconsistent, *elts, |s, &p| print_pat(s, p)));
+        try!(commasep(s,
+                      Inconsistent,
+                      elts.as_slice(),
+                      |s, &p| print_pat(s, p)));
         if elts.len() == 1 {
             try!(word(&mut s.s, ","));
         }
@@ -1761,7 +1776,10 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) -> io::IoResult<()> {
       }
       ast::PatVec(ref before, slice, ref after) => {
         try!(word(&mut s.s, "["));
-        try!(commasep(s, Inconsistent, *before, |s, &p| print_pat(s, p)));
+        try!(commasep(s,
+                      Inconsistent,
+                      before.as_slice(),
+                      |s, &p| print_pat(s, p)));
         for &p in slice.iter() {
             if !before.is_empty() { try!(word_space(s, ",")); }
             match *p {
@@ -1773,7 +1791,10 @@ pub fn print_pat(s: &mut State, pat: &ast::Pat) -> io::IoResult<()> {
             try!(print_pat(s, p));
             if !after.is_empty() { try!(word_space(s, ",")); }
         }
-        try!(commasep(s, Inconsistent, *after, |s, &p| print_pat(s, p)));
+        try!(commasep(s,
+                      Inconsistent,
+                      after.as_slice(),
+                      |s, &p| print_pat(s, p)));
         try!(word(&mut s.s, "]"));
       }
     }
@@ -1842,7 +1863,7 @@ pub fn print_fn_args(s: &mut State, decl: &ast::FnDecl,
     for &explicit_self in opt_explicit_self.iter() {
         let m = match explicit_self {
             ast::SelfStatic => ast::MutImmutable,
-            _ => match decl.inputs[0].pat.node {
+            _ => match decl.inputs.get(0).pat.node {
                 ast::PatIdent(ast::BindByValue(m), _, _) => m,
                 _ => ast::MutImmutable
             }
@@ -1986,7 +2007,7 @@ pub fn print_generics(s: &mut State,
             ints.push(i);
         }
 
-        try!(commasep(s, Inconsistent, ints,
+        try!(commasep(s, Inconsistent, ints.as_slice(),
                         |s, &i| print_item(s, generics, i)));
         try!(word(&mut s.s, ">"));
     }
@@ -2041,7 +2062,7 @@ pub fn print_view_path(s: &mut State, vp: &ast::ViewPath) -> io::IoResult<()> {
             try!(print_path(s, path, false));
             try!(word(&mut s.s, "::{"));
         }
-        try!(commasep(s, Inconsistent, (*idents), |s, w| {
+        try!(commasep(s, Inconsistent, idents.as_slice(), |s, w| {
             print_ident(s, w.node.name)
         }));
         word(&mut s.s, "}")
@@ -2057,7 +2078,7 @@ pub fn print_view_paths(s: &mut State,
 pub fn print_view_item(s: &mut State, item: &ast::ViewItem) -> io::IoResult<()> {
     try!(hardbreak_if_not_bol(s));
     try!(maybe_print_comment(s, item.span.lo));
-    try!(print_outer_attributes(s, item.attrs));
+    try!(print_outer_attributes(s, item.attrs.as_slice()));
     try!(print_visibility(s, item.vis));
     match item.node {
         ast::ViewItemExternMod(id, ref optional_path, _) => {
@@ -2073,7 +2094,7 @@ pub fn print_view_item(s: &mut State, item: &ast::ViewItem) -> io::IoResult<()>
 
         ast::ViewItemUse(ref vps) => {
             try!(head(s, "use"));
-            try!(print_view_paths(s, *vps));
+            try!(print_view_paths(s, vps.as_slice()));
         }
     }
     try!(word(&mut s.s, ";"));
@@ -2103,7 +2124,7 @@ pub fn print_arg(s: &mut State, input: &ast::Arg) -> io::IoResult<()> {
             match input.pat.node {
                 ast::PatIdent(_, ref path, _) if
                     path.segments.len() == 1 &&
-                    path.segments[0].identifier.name ==
+                    path.segments.get(0).identifier.name ==
                         parse::token::special_idents::invalid.name => {
                     // Do nothing.
                 }
@@ -2286,7 +2307,7 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) -> io::IoResult<()> {
       ast::LitBinary(ref arr) => {
         try!(ibox(s, indent_unit));
         try!(word(&mut s.s, "["));
-        try!(commasep_cmnt(s, Inconsistent, *arr.borrow(),
+        try!(commasep_cmnt(s, Inconsistent, arr.borrow().as_slice(),
                              |s, u| word(&mut s.s, format!("{}", *u)),
                              |_| lit.span));
         try!(word(&mut s.s, "]"));
@@ -2303,7 +2324,7 @@ pub fn next_lit(s: &mut State, pos: BytePos) -> Option<comments::Literal> {
     match s.literals {
       Some(ref lits) => {
         while s.cur_cmnt_and_lit.cur_lit < lits.len() {
-            let ltrl = (*lits)[s.cur_cmnt_and_lit.cur_lit].clone();
+            let ltrl = (*(*lits).get(s.cur_cmnt_and_lit.cur_lit)).clone();
             if ltrl.pos > pos { return None; }
             s.cur_cmnt_and_lit.cur_lit += 1u;
             if ltrl.pos == pos { return Some(ltrl); }
@@ -2335,7 +2356,7 @@ pub fn print_comment(s: &mut State,
         comments::Mixed => {
             assert_eq!(cmnt.lines.len(), 1u);
             try!(zerobreak(&mut s.s));
-            try!(word(&mut s.s, cmnt.lines[0]));
+            try!(word(&mut s.s, *cmnt.lines.get(0)));
             try!(zerobreak(&mut s.s));
         }
         comments::Isolated => {
@@ -2352,7 +2373,7 @@ pub fn print_comment(s: &mut State,
         comments::Trailing => {
             try!(word(&mut s.s, " "));
             if cmnt.lines.len() == 1u {
-                try!(word(&mut s.s, cmnt.lines[0]));
+                try!(word(&mut s.s, *cmnt.lines.get(0)));
                 try!(hardbreak(&mut s.s));
             } else {
                 try!(ibox(s, 0u));
@@ -2414,7 +2435,7 @@ pub fn next_comment(s: &mut State) -> Option<comments::Comment> {
     match s.comments {
         Some(ref cmnts) => {
             if s.cur_cmnt_and_lit.cur_cmnt < cmnts.len() {
-                Some(cmnts[s.cur_cmnt_and_lit.cur_cmnt].clone())
+                Some((*cmnts.get(s.cur_cmnt_and_lit.cur_cmnt)).clone())
             } else {
                 None
             }
@@ -2535,6 +2556,8 @@ mod test {
     use codemap;
     use parse::token;
 
+    use std::vec_ng::Vec;
+
     #[test]
     fn test_fun_to_str() {
         let abba_ident = token::str_to_ident("abba");