diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 09:13:51 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 09:13:51 -0800 |
| commit | 0c981875e46763a9b3cd53443bf73dfd3e291d18 (patch) | |
| tree | b0d1f49551beab62865f5945d588a8a65931c9f5 /src/libsyntax/util | |
| parent | 5da25386b3e70a5a538f75fbd5b42a8db04dd93d (diff) | |
| parent | 3c32cd1be27f321658382e39d34f5d993d99ae8b (diff) | |
| download | rust-0c981875e46763a9b3cd53443bf73dfd3e291d18.tar.gz rust-0c981875e46763a9b3cd53443bf73dfd3e291d18.zip | |
rollup merge of #21340: pshc/libsyntax-no-more-ints
Collaboration with @rylev! I didn't change `int` in the [quasi-quoter](https://github.com/pshc/rust/blob/99ae1a30f3ca28c0f7e431620560d30e44627124/src/libsyntax/ext/quote.rs#L328), because I'm not sure if there will be adverse effects. Addresses #21095.
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 34 |
3 files changed, 25 insertions, 25 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 5dca39f1aea..66b225f30dd 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! An "interner" is a data structure that associates values with uint tags and +//! An "interner" is a data structure that associates values with usize tags and //! allows bidirectional lookup; i.e. given a value, one can easily find the //! type, and vice versa. @@ -70,10 +70,10 @@ impl<T: Eq + Hash<Hasher> + Clone + 'static> Interner<T> { pub fn get(&self, idx: Name) -> T { let vect = self.vect.borrow(); - (*vect)[idx.uint()].clone() + (*vect)[idx.usize()].clone() } - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { let vect = self.vect.borrow(); (*vect).len() } @@ -190,16 +190,16 @@ impl StrInterner { let new_idx = Name(self.len() as u32); // leave out of map to avoid colliding let mut vect = self.vect.borrow_mut(); - let existing = (*vect)[idx.uint()].clone(); + let existing = (*vect)[idx.usize()].clone(); vect.push(existing); new_idx } pub fn get(&self, idx: Name) -> RcStr { - (*self.vect.borrow())[idx.uint()].clone() + (*self.vect.borrow())[idx.usize()].clone() } - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.vect.borrow().len() } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 83bbff8473d..5466b7337e7 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -130,10 +130,10 @@ pub fn matches_codepattern(a : &str, b : &str) -> bool { } } -/// Given a string and an index, return the first uint >= idx +/// Given a string and an index, return the first usize >= idx /// that is a non-ws-char or is outside of the legal range of /// the string. -fn scan_for_non_ws_or_end(a : &str, idx: uint) -> uint { +fn scan_for_non_ws_or_end(a : &str, idx: usize) -> usize { let mut i = idx; let len = a.len(); while (i < len) && (is_whitespace(a.char_at(i))) { diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index b68c9926391..d8bac19805b 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -89,7 +89,7 @@ impl<T> SmallVector<T> { } } - pub fn get<'a>(&'a self, idx: uint) -> &'a T { + pub fn get<'a>(&'a self, idx: usize) -> &'a T { match self.repr { One(ref v) if idx == 0 => v, Many(ref vs) => &vs[idx], @@ -126,7 +126,7 @@ impl<T> SmallVector<T> { IntoIter { repr: repr } } - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { match self.repr { Zero => 0, One(..) => 1, @@ -165,7 +165,7 @@ impl<T> Iterator for IntoIter<T> { } } - fn size_hint(&self) -> (uint, Option<uint>) { + fn size_hint(&self) -> (usize, Option<usize>) { match self.repr { ZeroIterator => (0, Some(0)), OneIterator(..) => (1, Some(1)), @@ -191,17 +191,17 @@ mod test { #[test] fn test_len() { - let v: SmallVector<int> = SmallVector::zero(); + let v: SmallVector<isize> = SmallVector::zero(); assert_eq!(0, v.len()); - assert_eq!(1, SmallVector::one(1i).len()); - assert_eq!(5, SmallVector::many(vec!(1i, 2, 3, 4, 5)).len()); + assert_eq!(1, SmallVector::one(1is).len()); + assert_eq!(5, SmallVector::many(vec!(1is, 2, 3, 4, 5)).len()); } #[test] fn test_push_get() { let mut v = SmallVector::zero(); - v.push(1i); + v.push(1is); assert_eq!(1, v.len()); assert_eq!(&1, v.get(0)); v.push(2); @@ -214,7 +214,7 @@ mod test { #[test] fn test_from_iter() { - let v: SmallVector<int> = (vec!(1i, 2, 3)).into_iter().collect(); + let v: SmallVector<isize> = (vec![1is, 2, 3]).into_iter().collect(); assert_eq!(3, v.len()); assert_eq!(&1, v.get(0)); assert_eq!(&2, v.get(1)); @@ -224,31 +224,31 @@ mod test { #[test] fn test_move_iter() { let v = SmallVector::zero(); - let v: Vec<int> = v.into_iter().collect(); + let v: Vec<isize> = v.into_iter().collect(); assert_eq!(Vec::new(), v); - let v = SmallVector::one(1i); - assert_eq!(vec!(1i), v.into_iter().collect::<Vec<_>>()); + let v = SmallVector::one(1is); + assert_eq!(vec!(1is), v.into_iter().collect::<Vec<_>>()); - let v = SmallVector::many(vec!(1i, 2i, 3i)); - assert_eq!(vec!(1i, 2i, 3i), v.into_iter().collect::<Vec<_>>()); + let v = SmallVector::many(vec!(1is, 2is, 3is)); + assert_eq!(vec!(1is, 2is, 3is), v.into_iter().collect::<Vec<_>>()); } #[test] #[should_fail] fn test_expect_one_zero() { - let _: int = SmallVector::zero().expect_one(""); + let _: isize = SmallVector::zero().expect_one(""); } #[test] #[should_fail] fn test_expect_one_many() { - SmallVector::many(vec!(1i, 2)).expect_one(""); + SmallVector::many(vec!(1is, 2)).expect_one(""); } #[test] fn test_expect_one_one() { - assert_eq!(1i, SmallVector::one(1i).expect_one("")); - assert_eq!(1i, SmallVector::many(vec!(1i)).expect_one("")); + assert_eq!(1is, SmallVector::one(1is).expect_one("")); + assert_eq!(1is, SmallVector::many(vec!(1is)).expect_one("")); } } |
