about summary refs log tree commit diff
path: root/src/libsyntax/util
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2014-07-06 01:17:59 -0700
committerCorey Richardson <corey@octayn.net>2014-07-09 00:49:54 -0700
commit092c5078be5b9abfc4e1a80e3ef9d015d321479c (patch)
tree46b19fe160154e14c412e928e676daa809407913 /src/libsyntax/util
parentf512779554a436d11dd9ffde4c198da6241dfd58 (diff)
downloadrust-092c5078be5b9abfc4e1a80e3ef9d015d321479c.tar.gz
rust-092c5078be5b9abfc4e1a80e3ef9d015d321479c.zip
ast: make Name its own type
Diffstat (limited to 'src/libsyntax/util')
-rw-r--r--src/libsyntax/util/interner.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index 55fff38f991..b370678c6df 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -52,7 +52,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
         }
 
         let mut vect = self.vect.borrow_mut();
-        let new_idx = (*vect).len() as Name;
+        let new_idx = Name((*vect).len() as u32);
         (*map).insert(val.clone(), new_idx);
         (*vect).push(val);
         new_idx
@@ -60,7 +60,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
 
     pub fn gensym(&self, val: T) -> Name {
         let mut vect = self.vect.borrow_mut();
-        let new_idx = (*vect).len() as Name;
+        let new_idx = Name((*vect).len() as u32);
         // leave out of .map to avoid colliding
         (*vect).push(val);
         new_idx
@@ -68,7 +68,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
 
     pub fn get(&self, idx: Name) -> T {
         let vect = self.vect.borrow();
-        (*(*vect).get(idx as uint)).clone()
+        (*(*vect).get(idx.uint())).clone()
     }
 
     pub fn len(&self) -> uint {
@@ -155,7 +155,7 @@ impl StrInterner {
             None => (),
         }
 
-        let new_idx = self.len() as Name;
+        let new_idx = Name(self.len() as u32);
         let val = RcStr::new(val);
         map.insert(val.clone(), new_idx);
         self.vect.borrow_mut().push(val);
@@ -163,7 +163,7 @@ impl StrInterner {
     }
 
     pub fn gensym(&self, val: &str) -> Name {
-        let new_idx = self.len() as Name;
+        let new_idx = Name(self.len() as u32);
         // leave out of .map to avoid colliding
         self.vect.borrow_mut().push(RcStr::new(val));
         new_idx
@@ -180,23 +180,23 @@ impl StrInterner {
     /// Create a gensym with the same name as an existing
     /// entry.
     pub fn gensym_copy(&self, idx : Name) -> Name {
-        let new_idx = self.len() as Name;
+        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.get(idx as uint)).clone();
+        let existing = (*vect.get(idx.uint())).clone();
         vect.push(existing);
         new_idx
     }
 
     pub fn get(&self, idx: Name) -> RcStr {
-        (*self.vect.borrow().get(idx as uint)).clone()
+        (*self.vect.borrow().get(idx.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 uint).as_slice();
+        let s: &str = vect.get(idx.uint()).as_slice();
         unsafe {
             mem::transmute(s)
         }