diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-02-28 12:54:01 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-03-01 22:40:52 -0800 |
| commit | 198cc3d850136582651489328fec221a2b98bfef (patch) | |
| tree | fe47f6fab3d4ead61053684613d0b1852ec7e311 /src/libsyntax/util | |
| parent | 58fd6ab90db3eb68c94695e1254a73e57bc44658 (diff) | |
| download | rust-198cc3d850136582651489328fec221a2b98bfef.tar.gz rust-198cc3d850136582651489328fec221a2b98bfef.zip | |
libsyntax: Fix errors arising from the automated `~[T]` conversion
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 10 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 7969cacb765..ba154a8d892 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -21,6 +21,7 @@ use std::cmp::Equiv; use std::fmt; use std::hash::Hash; use std::rc::Rc; +use std::vec_ng::Vec; pub struct Interner<T> { priv map: RefCell<HashMap<T, Name>>, @@ -68,7 +69,7 @@ impl<T:Eq + Hash + Freeze + Clone + 'static> Interner<T> { pub fn get(&self, idx: Name) -> T { let vect = self.vect.borrow(); - vect.get()[idx].clone() + (*vect.get().get(idx as uint)).clone() } pub fn len(&self) -> uint { @@ -189,21 +190,21 @@ impl StrInterner { let new_idx = self.len() as Name; // leave out of map to avoid colliding let mut vect = self.vect.borrow_mut(); - let existing = vect.get()[idx].clone(); + let existing = (*vect.get().get(idx as uint)).clone(); vect.get().push(existing); new_idx } pub fn get(&self, idx: Name) -> RcStr { let vect = self.vect.borrow(); - vect.get()[idx].clone() + (*vect.get().get(idx as uint)).clone() } /// Returns this string with lifetime tied to the interner. Since /// strings may never be removed from the interner, this is safe. pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str { let vect = self.vect.borrow(); - let s: &str = vect.get()[idx].as_slice(); + let s: &str = vect.get().get(idx as uint).as_slice(); unsafe { cast::transmute(s) } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 36243350d21..03fc30e2fd7 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -15,6 +15,8 @@ use parse::{new_parser_from_source_str}; use parse::parser::Parser; use parse::token; +use std::vec_ng::Vec; + // map a string to tts, using a made-up filename: return both the TokenTree's // and the ParseSess pub fn string_to_tts_and_sess (source_str : ~str) -> (Vec<ast::TokenTree> , @ParseSess) { diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 22bf0f0a53f..9eb9871bb21 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -7,8 +7,10 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. + use std::mem; -use std::vec; +use std::vec_ng::Vec; +use std::vec_ng; /// A vector type optimized for cases where the size is almost always 0 or 1 pub enum SmallVector<T> { @@ -73,7 +75,7 @@ impl<T> SmallVector<T> { pub fn get<'a>(&'a self, idx: uint) -> &'a T { match *self { One(ref v) if idx == 0 => v, - Many(ref vs) => &vs[idx], + Many(ref vs) => vs.get(idx), _ => fail!("out of bounds access") } } @@ -104,7 +106,7 @@ impl<T> SmallVector<T> { pub enum MoveItems<T> { priv ZeroIterator, priv OneIterator(T), - priv ManyIterator(vec::MoveItems<T>), + priv ManyIterator(vec_ng::MoveItems<T>), } impl<T> Iterator<T> for MoveItems<T> { @@ -136,6 +138,8 @@ impl<T> Iterator<T> for MoveItems<T> { mod test { use super::*; + use std::vec_ng::Vec; + #[test] fn test_len() { let v: SmallVector<int> = SmallVector::zero(); |
