diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-05-19 19:46:54 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-05-19 23:34:32 -0700 |
| commit | 66319b027888ceddf024a5919e007caceaf369f3 (patch) | |
| tree | d210e635c950974972a086f7caa4268be6f33c93 /src/libcore | |
| parent | 3a481c0f88025318eba7c48907a5c1d966e01d27 (diff) | |
| download | rust-66319b027888ceddf024a5919e007caceaf369f3.tar.gz rust-66319b027888ceddf024a5919e007caceaf369f3.zip | |
Register snapshots
Diffstat (limited to 'src/libcore')
32 files changed, 16 insertions, 1818 deletions
diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 8b48376caac..4e71b62f10c 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -24,20 +24,6 @@ pub mod rusti { } /// Casts the value at `src` to U. The two types must have the same length. -#[cfg(not(stage0))] -pub unsafe fn transmute_copy<T, U>(src: &T) -> U { - let mut dest: U = unstable::intrinsics::uninit(); - { - let dest_ptr: *mut u8 = rusti::transmute(&mut dest); - let src_ptr: *u8 = rusti::transmute(src); - unstable::intrinsics::memmove64(dest_ptr, - src_ptr, - sys::size_of::<U>() as u64); - } - dest -} - -#[cfg(stage0)] pub unsafe fn transmute_copy<T, U>(src: &T) -> U { let mut dest: U = unstable::intrinsics::init(); { diff --git a/src/libcore/char.rs b/src/libcore/char.rs index f977845eb8a..bd70f59212d 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -12,9 +12,6 @@ use option::{None, Option, Some}; use str; -#[cfg(stage0)] -use str::StrSlice; -#[cfg(not(stage0))] use str::{StrSlice, OwnedStr}; use u32; use uint; @@ -191,21 +188,6 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> { } } -#[cfg(stage0)] -pub fn escape_unicode(c: char) -> ~str { - let s = u32::to_str_radix(c as u32, 16u); - let (c, pad) = (if c <= '\xff' { ('x', 2u) } - else if c <= '\uffff' { ('u', 4u) } - else { ('U', 8u) }); - assert!(str::len(s) <= pad); - let mut out = ~"\\"; - str::push_str(&mut out, str::from_char(c)); - for uint::range(str::len(s), pad) |_i| - { str::push_str(&mut out, ~"0"); } - str::push_str(&mut out, s); - out -} - /// /// Return the hexadecimal unicode escape of a char. /// @@ -215,7 +197,6 @@ pub fn escape_unicode(c: char) -> ~str { /// - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN` /// - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN` /// -#[cfg(not(stage0))] pub fn escape_unicode(c: char) -> ~str { let s = u32::to_str_radix(c as u32, 16u); let (c, pad) = cond!( @@ -258,23 +239,7 @@ pub fn escape_default(c: char) -> ~str { } } -#[cfg(stage0)] -pub fn len_utf8_bytes(c: char) -> uint { - static max_one_b: uint = 128u; - static max_two_b: uint = 2048u; - static max_three_b: uint = 65536u; - static max_four_b: uint = 2097152u; - - let code = c as uint; - if code < max_one_b { 1u } - else if code < max_two_b { 2u } - else if code < max_three_b { 3u } - else if code < max_four_b { 4u } - else { fail!("invalid character!") } -} - /// Returns the amount of bytes this character would need if encoded in utf8 -#[cfg(not(stage0))] pub fn len_utf8_bytes(c: char) -> uint { static MAX_ONE_B: uint = 128u; static MAX_TWO_B: uint = 2048u; diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index a5df97e3d57..5796be7b1e4 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -127,33 +127,6 @@ struct AnnihilateStats { n_bytes_freed: uint } -#[cfg(stage0)] -unsafe fn each_live_alloc(read_next_before: bool, - f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) { - //! Walks the internal list of allocations - - use managed; - - let task: *Task = transmute(rustrt::rust_get_task()); - let box = (*task).boxed_region.live_allocs; - let mut box: *mut BoxRepr = transmute(copy box); - while box != mut_null() { - let next_before = transmute(copy (*box).header.next); - let uniq = - (*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE; - - if !f(box, uniq) { - return; - } - - if read_next_before { - box = next_before; - } else { - box = transmute(copy (*box).header.next); - } - } -} -#[cfg(not(stage0))] unsafe fn each_live_alloc(read_next_before: bool, f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool { //! Walks the internal list of allocations diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 1d5d7764954..505aa5881c5 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -30,31 +30,15 @@ pub trait Map<K, V>: Mutable { fn contains_key(&self, key: &K) -> bool; // Visits all keys and values - #[cfg(stage0)] - fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool); - // Visits all keys and values - #[cfg(not(stage0))] fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool) -> bool; /// Visit all keys - #[cfg(stage0)] - fn each_key(&self, f: &fn(&K) -> bool); - /// Visit all keys - #[cfg(not(stage0))] fn each_key(&self, f: &fn(&K) -> bool) -> bool; /// Visit all values - #[cfg(stage0)] - fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool); - /// Visit all values - #[cfg(not(stage0))] fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool; /// Iterate over the map and mutate the contained values - #[cfg(stage0)] - fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool); - /// Iterate over the map and mutate the contained values - #[cfg(not(stage0))] fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool; /// Return a reference to the value corresponding to the key @@ -81,43 +65,6 @@ pub trait Map<K, V>: Mutable { fn pop(&mut self, k: &K) -> Option<V>; } -#[cfg(stage0)] -pub trait Set<T>: Mutable { - /// Return true if the set contains a value - fn contains(&self, value: &T) -> bool; - - /// Add a value to the set. Return true if the value was not already - /// present in the set. - fn insert(&mut self, value: T) -> bool; - - /// Remove a value from the set. Return true if the value was - /// present in the set. - fn remove(&mut self, value: &T) -> bool; - - /// Return true if the set has no elements in common with `other`. - /// This is equivalent to checking for an empty intersection. - fn is_disjoint(&self, other: &Self) -> bool; - - /// Return true if the set is a subset of another - fn is_subset(&self, other: &Self) -> bool; - - /// Return true if the set is a superset of another - fn is_superset(&self, other: &Self) -> bool; - - /// Visit the values representing the difference - fn difference(&self, other: &Self, f: &fn(&T) -> bool); - - /// Visit the values representing the symmetric difference - fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool); - - /// Visit the values representing the intersection - fn intersection(&self, other: &Self, f: &fn(&T) -> bool); - - /// Visit the values representing the union - fn union(&self, other: &Self, f: &fn(&T) -> bool); -} - -#[cfg(not(stage0))] pub trait Set<T>: Mutable { /// Return true if the set contains a value fn contains(&self, value: &T) -> bool; diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 6a427297cc2..611b95a7745 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -171,11 +171,6 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool { return true; } -#[cfg(stage0)] -unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) { - _walk_safe_point(fp, sp, visitor); -} -#[cfg(not(stage0))] unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool { _walk_safe_point(fp, sp, visitor) } @@ -303,11 +298,6 @@ unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> boo return true; } -#[cfg(stage0)] -unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) { - _walk_gc_roots(mem, sentinel, visitor); -} -#[cfg(not(stage0))] unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> bool { _walk_gc_roots(mem, sentinel, visitor) } diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index ebc15174c5c..d116c966c5c 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -19,8 +19,6 @@ * CPRNG like rand::rng. */ -#[cfg(stage0)] -use cast; use container::Container; use old_iter::BaseIter; use rt::io::Writer; @@ -78,14 +76,6 @@ pub trait Streaming { fn reset(&mut self); } -// XXX: Ugly workaround for bootstrapping. -#[cfg(stage0)] -fn transmute_for_stage0<'a>(bytes: &'a [const u8]) -> &'a [u8] { - unsafe { - cast::transmute(bytes) - } -} -#[cfg(not(stage0))] fn transmute_for_stage0<'a>(bytes: &'a [u8]) -> &'a [u8] { bytes } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index fe44bfba114..4770d388951 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -87,22 +87,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> { } #[inline(always)] - #[cfg(stage0)] - fn bucket_sequence(&self, hash: uint, - op: &fn(uint) -> bool) { - let start_idx = self.to_bucket(hash); - let len_buckets = self.buckets.len(); - let mut idx = start_idx; - loop { - if !op(idx) { return; } - idx = self.next_bucket(idx, len_buckets); - if idx == start_idx { - return; - } - } - } - #[inline(always)] - #[cfg(not(stage0))] fn bucket_sequence(&self, hash: uint, op: &fn(uint) -> bool) -> bool { let start_idx = self.to_bucket(hash); @@ -318,19 +302,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Visit all key-value pairs - #[cfg(stage0)] - fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) { - for uint::range(0, self.buckets.len()) |i| { - for self.buckets[i].each |bucket| { - if !blk(&bucket.key, &bucket.value) { - return; - } - } - } - } - - /// Visit all key-value pairs - #[cfg(not(stage0))] fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool { for uint::range(0, self.buckets.len()) |i| { for self.buckets[i].each |bucket| { @@ -343,44 +314,16 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Visit all keys - #[cfg(stage0)] - fn each_key(&self, blk: &fn(k: &K) -> bool) { - self.each(|k, _| blk(k)) - } - - /// Visit all keys - #[cfg(not(stage0))] fn each_key(&self, blk: &fn(k: &K) -> bool) -> bool { self.each(|k, _| blk(k)) } /// Visit all values - #[cfg(stage0)] - fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) { - self.each(|_, v| blk(v)) - } - - /// Visit all values - #[cfg(not(stage0))] fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) -> bool { self.each(|_, v| blk(v)) } /// Iterate over the map and mutate the contained values - #[cfg(stage0)] - fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) { - for uint::range(0, self.buckets.len()) |i| { - match self.buckets[i] { - Some(Bucket{key: ref key, value: ref mut value, _}) => { - if !blk(key, value) { return } - } - None => () - } - } - } - - /// Iterate over the map and mutate the contained values - #[cfg(not(stage0))] fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) -> bool { for uint::range(0, self.buckets.len()) |i| { match self.buckets[i] { @@ -402,19 +345,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } /// Return a mutable reference to the value corresponding to the key - #[cfg(stage0)] - fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { - let idx = match self.bucket_for_key(k) { - FoundEntry(idx) => idx, - TableFull | FoundHole(_) => return None - }; - unsafe { - Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx))) - } - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(not(stage0))] fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { let idx = match self.bucket_for_key(k) { FoundEntry(idx) => idx, @@ -485,38 +415,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, or insert /// and return the value if it doesn't exist. - #[cfg(stage0)] - fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V { - if self.size >= self.resize_at { - // n.b.: We could also do this after searching, so - // that we do not resize if this call to insert is - // simply going to update a key in place. My sense - // though is that it's worse to have to search through - // buckets to find the right spot twice than to just - // resize in this corner case. - self.expand(); - } - - let hash = k.hash_keyed(self.k0, self.k1) as uint; - let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!("Internal logic error"), - FoundEntry(idx) => idx, - FoundHole(idx) => { - self.buckets[idx] = Some(Bucket{hash: hash, key: k, - value: v}); - self.size += 1; - idx - }, - }; - - unsafe { - ::cast::transmute_region(self.value_for_bucket(idx)) - } - } - - /// Return the value corresponding to the key in the map, or insert - /// and return the value if it doesn't exist. - #[cfg(not(stage0))] fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so @@ -545,39 +443,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - #[cfg(stage0)] - fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V { - if self.size >= self.resize_at { - // n.b.: We could also do this after searching, so - // that we do not resize if this call to insert is - // simply going to update a key in place. My sense - // though is that it's worse to have to search through - // buckets to find the right spot twice than to just - // resize in this corner case. - self.expand(); - } - - let hash = k.hash_keyed(self.k0, self.k1) as uint; - let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!("Internal logic error"), - FoundEntry(idx) => idx, - FoundHole(idx) => { - let v = f(&k); - self.buckets[idx] = Some(Bucket{hash: hash, key: k, - value: v}); - self.size += 1; - idx - }, - }; - - unsafe { - ::cast::transmute_region(self.value_for_bucket(idx)) - } - } - - /// Return the value corresponding to the key in the map, or create, - /// insert, and return a new value if it doesn't exist. - #[cfg(not(stage0))] fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so @@ -680,9 +545,6 @@ pub struct HashSet<T> { impl<T:Hash + Eq> BaseIter<T> for HashSet<T> { /// Visit all values in order - #[cfg(stage0)] - fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } - #[cfg(not(stage0))] fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) } fn size_hint(&self) -> Option<uint> { Some(self.len()) } } @@ -734,32 +596,11 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> { } /// Visit the values representing the difference - #[cfg(stage0)] - fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) { - for self.each |v| { - if !other.contains(v) { - if !f(v) { return } - } - } - } - - /// Visit the values representing the difference - #[cfg(not(stage0))] fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool { self.each(|v| other.contains(v) || f(v)) } /// Visit the values representing the symmetric difference - #[cfg(stage0)] - fn symmetric_difference(&self, - other: &HashSet<T>, - f: &fn(&T) -> bool) { - self.difference(other, f); - other.difference(self, f); - } - - /// Visit the values representing the symmetric difference - #[cfg(not(stage0))] fn symmetric_difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool { @@ -767,37 +608,11 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> { } /// Visit the values representing the intersection - #[cfg(stage0)] - fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) { - for self.each |v| { - if other.contains(v) { - if !f(v) { return } - } - } - } - - /// Visit the values representing the intersection - #[cfg(not(stage0))] fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool { self.each(|v| !other.contains(v) || f(v)) } /// Visit the values representing the union - #[cfg(stage0)] - fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) { - for self.each |v| { - if !f(v) { return } - } - - for other.each |v| { - if !self.contains(v) { - if !f(v) { return } - } - } - } - - /// Visit the values representing the union - #[cfg(not(stage0))] fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool { self.each(f) && other.each(|v| self.contains(v) || f(v)) } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 7d76d8d30cd..2ffd362519f 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -282,9 +282,6 @@ pub trait ReaderUtil { * * None right now. */ - #[cfg(stage0)] - fn each_byte(&self, it: &fn(int) -> bool); - #[cfg(not(stage0))] fn each_byte(&self, it: &fn(int) -> bool) -> bool; /** @@ -294,9 +291,6 @@ pub trait ReaderUtil { * * None right now. */ - #[cfg(stage0)] - fn each_char(&self, it: &fn(char) -> bool); - #[cfg(not(stage0))] fn each_char(&self, it: &fn(char) -> bool) -> bool; /** @@ -306,9 +300,6 @@ pub trait ReaderUtil { * * None right now. */ - #[cfg(stage0)] - fn each_line(&self, it: &fn(&str) -> bool); - #[cfg(not(stage0))] fn each_line(&self, it: &fn(&str) -> bool) -> bool; /** @@ -720,13 +711,6 @@ impl<T:Reader> ReaderUtil for T { bytes } - #[cfg(stage0)] - fn each_byte(&self, it: &fn(int) -> bool) { - while !self.eof() { - if !it(self.read_byte()) { break; } - } - } - #[cfg(not(stage0))] fn each_byte(&self, it: &fn(int) -> bool) -> bool { while !self.eof() { if !it(self.read_byte()) { return false; } @@ -734,13 +718,6 @@ impl<T:Reader> ReaderUtil for T { return true; } - #[cfg(stage0)] - fn each_char(&self, it: &fn(char) -> bool) { - while !self.eof() { - if !it(self.read_char()) { break; } - } - } - #[cfg(not(stage0))] fn each_char(&self, it: &fn(char) -> bool) -> bool { while !self.eof() { if !it(self.read_char()) { return false; } @@ -748,27 +725,6 @@ impl<T:Reader> ReaderUtil for T { return true; } - #[cfg(stage0)] - fn each_line(&self, it: &fn(s: &str) -> bool) { - while !self.eof() { - // include the \n, so that we can distinguish an entirely empty - // line read after "...\n", and the trailing empty line in - // "...\n\n". - let mut line = self.read_until('\n' as u8, true); - - // blank line at the end of the reader is ignored - if self.eof() && line.is_empty() { break; } - - // trim the \n, so that each_line is consistent with read_line - let n = str::len(line); - if line[n-1] == '\n' as u8 { - unsafe { str::raw::set_len(&mut line, n-1); } - } - - if !it(line) { break; } - } - } - #[cfg(not(stage0))] fn each_line(&self, it: &fn(s: &str) -> bool) -> bool { while !self.eof() { // include the \n, so that we can distinguish an entirely empty diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index ae4af3812d2..57a076bb082 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -40,17 +40,12 @@ much easier to implement. */ -#[cfg(not(stage0))] use cmp::Ord; -#[cfg(not(stage0))] use option::{Option, Some, None}; -#[cfg(not(stage0))] use vec::OwnedVector; -#[cfg(not(stage0))] use num::{One, Zero}; -#[cfg(not(stage0))] use ops::{Add, Mul}; +use cmp::Ord; +use option::{Option, Some, None}; +use vec::OwnedVector; +use num::{One, Zero}; +use ops::{Add, Mul}; -#[cfg(stage0)] -pub trait Times { - fn times(&self, it: &fn() -> bool); -} -#[cfg(not(stage0))] pub trait Times { fn times(&self, it: &fn() -> bool) -> bool; } @@ -67,7 +62,6 @@ pub trait Times { * ~~~ */ #[inline(always)] -#[cfg(not(stage0))] pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] { let mut v = ~[]; for iter |x| { v.push(x) } @@ -86,7 +80,6 @@ pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] { * ~~~~ */ #[inline(always)] -#[cfg(not(stage0))] pub fn any<T>(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> bool { for iter |x| { @@ -108,29 +101,6 @@ pub fn any<T>(predicate: &fn(T) -> bool, * ~~~~ */ #[inline(always)] -#[cfg(stage0)] -pub fn all<T>(predicate: &fn(T) -> bool, - iter: &fn(f: &fn(T) -> bool)) -> bool { - for iter |x| { - if !predicate(x) { - return false; - } - } - return true; -} - -/** - * Return true if `predicate` is true for all values yielded by an internal iterator. - * - * # Example: - * - * ~~~~ - * assert!(all(|&x: &uint| x < 6, |f| uint::range(1, 6, f))); - * assert!(!all(|&x: &uint| x < 5, |f| uint::range(1, 6, f))); - * ~~~~ - */ -#[inline(always)] -#[cfg(not(stage0))] pub fn all<T>(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> bool { // If we ever break, iter will return false, so this will only return true @@ -149,7 +119,6 @@ pub fn all<T>(predicate: &fn(T) -> bool, * ~~~~ */ #[inline(always)] -#[cfg(not(stage0))] pub fn find<T>(predicate: &fn(&T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> { for iter |x| { @@ -171,7 +140,6 @@ pub fn find<T>(predicate: &fn(&T) -> bool, * ~~~~ */ #[inline] -#[cfg(not(stage0))] pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> { let mut result = None; for iter |x| { @@ -198,7 +166,6 @@ pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> { * ~~~~ */ #[inline] -#[cfg(not(stage0))] pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> { let mut result = None; for iter |x| { @@ -223,7 +190,6 @@ pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> { * assert_eq!(fold(0i, |f| int::range(1, 5, f), |a, x| *a += x), 10); * ~~~~ */ -#[cfg(not(stage0))] #[inline] pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T, U)) -> T { let mut result = start; @@ -247,7 +213,6 @@ pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T, * } * ~~~~ */ -#[cfg(not(stage0))] #[inline] pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&mut T, &U)) -> T { let mut result = start; @@ -267,7 +232,6 @@ pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&m * assert_eq!(do sum |f| { xs.each(f) }, 10); * ~~~~ */ -#[cfg(not(stage0))] #[inline(always)] pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { fold_ref(Zero::zero::<T>(), iter, |a, x| *a = a.add(x)) @@ -283,7 +247,6 @@ pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { * assert_eq!(do product |f| { xs.each(f) }, 24); * ~~~~ */ -#[cfg(not(stage0))] #[inline(always)] pub fn product<T: One + Mul<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { fold_ref(One::one::<T>(), iter, |a, x| *a = a.mul(x)) diff --git a/src/libcore/iterator.rs b/src/libcore/iterator.rs index ecf76a39fcd..a5679e6dbff 100644 --- a/src/libcore/iterator.rs +++ b/src/libcore/iterator.rs @@ -43,11 +43,7 @@ pub trait IteratorUtil<A> { fn take(self, n: uint) -> TakeIterator<Self>; fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>) -> ScanIterator<'r, A, B, Self, St>; - #[cfg(stage0)] - fn advance(&mut self, f: &fn(A) -> bool); - #[cfg(not(stage0))] fn advance(&mut self, f: &fn(A) -> bool) -> bool; - #[cfg(not(stage0))] fn to_vec(&mut self) -> ~[A]; fn nth(&mut self, n: uint) -> Option<A>; fn last(&mut self) -> Option<A>; @@ -121,21 +117,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { /// A shim implementing the `for` loop iteration protocol for iterator objects #[inline] - #[cfg(stage0)] - fn advance(&mut self, f: &fn(A) -> bool) { - loop { - match self.next() { - Some(x) => { - if !f(x) { return; } - } - None => { return; } - } - } - } - - /// A shim implementing the `for` loop iteration protocol for iterator objects - #[inline] - #[cfg(not(stage0))] fn advance(&mut self, f: &fn(A) -> bool) -> bool { loop { match self.next() { @@ -147,7 +128,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { } } - #[cfg(not(stage0))] #[inline(always)] fn to_vec(&mut self) -> ~[A] { iter::to_vec::<A>(|f| self.advance(f)) diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index eeafc4cf786..d9b3e35b6b9 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -51,9 +51,3 @@ pub trait Owned { pub trait Const { // Empty. } - -#[lang="durable"] -#[cfg(stage0)] -pub trait Durable { - // Empty. -} diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index d580f7aa26c..d5dc0dd4730 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -248,18 +248,8 @@ impl Orderable for f32 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } - #[cfg(stage0)] - #[inline(always)] - fn clamp(&self, mn: &f32, mx: &f32) -> f32 { - if self.is_NaN() { *self } - else if !(*self <= *mx) { *mx } - else if !(*self >= *mn) { *mn } - else { *self } - } - /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[cfg(not(stage0))] #[inline(always)] fn clamp(&self, mn: &f32, mx: &f32) -> f32 { cond!( diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index d140df30c42..6e2496e2e45 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -270,18 +270,8 @@ impl Orderable for f64 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } - #[cfg(stage0)] - #[inline(always)] - fn clamp(&self, mn: &f64, mx: &f64) -> f64 { - if self.is_NaN() { *self } - else if !(*self <= *mx) { *mx } - else if !(*self >= *mn) { *mn } - else { *self } - } - /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[cfg(not(stage0))] #[inline(always)] fn clamp(&self, mn: &f64, mx: &f64) -> f64 { cond!( diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index d0e6174ec63..3c31a7d5745 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -108,37 +108,17 @@ pub fn _range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { - _range_step(start, stop, step, it); -} -#[cfg(not(stage0))] pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool { _range_step(start, stop, step, it) } #[inline(always)] -#[cfg(stage0)] -/// Iterate over the range [`lo`..`hi`) -pub fn range(lo: T, hi: T, it: &fn(T) -> bool) { - range_step(lo, hi, 1 as T, it); -} - -#[inline(always)] -#[cfg(not(stage0))] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: T, hi: T, it: &fn(T) -> bool) -> bool { range_step(lo, hi, 1 as T, it) } #[inline(always)] -#[cfg(stage0)] -/// Iterate over the range [`hi`..`lo`) -pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { - range_step(hi, lo, -1 as T, it); -} -#[inline(always)] -#[cfg(not(stage0))] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) -> bool { range_step(hi, lo, -1 as T, it) @@ -187,15 +167,7 @@ impl Orderable for T { if *self > *other { *self } else { *other } } - #[cfg(stage0)] - #[inline(always)] - fn clamp(&self, mn: &T, mx: &T) -> T { - if *self > *mx { *mx } else - if *self < *mn { *mn } else { *self } - } - /// Returns the number constrained within the range `mn <= self <= mx`. - #[cfg(not(stage0))] #[inline(always)] fn clamp(&self, mn: &T, mx: &T) -> T { cond!( diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index f3e14094505..66ff16cbeb1 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -77,38 +77,17 @@ pub fn _range_step(start: T, return true; } -#[cfg(stage0)] -pub fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) { - _range_step(start, stop, step, it); -} -#[cfg(not(stage0))] pub fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) -> bool { _range_step(start, stop, step, it) } #[inline(always)] -#[cfg(stage0)] -/// Iterate over the range [`lo`..`hi`) -pub fn range(lo: T, hi: T, it: &fn(T) -> bool) { - range_step(lo, hi, 1 as T_SIGNED, it); -} - -#[inline(always)] -#[cfg(not(stage0))] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: T, hi: T, it: &fn(T) -> bool) -> bool { range_step(lo, hi, 1 as T_SIGNED, it) } #[inline(always)] -#[cfg(stage0)] -/// Iterate over the range [`hi`..`lo`) -pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { - range_step(hi, lo, -1 as T_SIGNED, it); -} - -#[inline(always)] -#[cfg(not(stage0))] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) -> bool { range_step(hi, lo, -1 as T_SIGNED, it) @@ -153,15 +132,7 @@ impl Orderable for T { if *self > *other { *self } else { *other } } - #[cfg(stage0)] - #[inline(always)] - fn clamp(&self, mn: &T, mx: &T) -> T { - if *self > *mx { *mx } else - if *self < *mn { *mn } else { *self } - } - /// Returns the number constrained within the range `mn <= self <= mx`. - #[cfg(not(stage0))] #[inline(always)] fn clamp(&self, mn: &T, mx: &T) -> T { cond!( diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index b4c9bb65371..763c305f221 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -154,29 +154,6 @@ pub mod inst { return true; } - #[cfg(stage0)] - impl iter::Times for uint { - #[inline(always)] - /// - /// A convenience form for basic iteration. Given a uint `x`, - /// `for x.times { ... }` executes the given block x times. - /// - /// Equivalent to `for uint::range(0, x) |_| { ... }`. - /// - /// Not defined on all integer types to permit unambiguous - /// use with integer literals of inferred integer-type as - /// the self-value (eg. `for 100.times { ... }`). - /// - fn times(&self, it: &fn() -> bool) { - let mut i = *self; - while i > 0 { - if !it() { break } - i -= 1; - } - } - } - - #[cfg(not(stage0))] impl iter::Times for uint { #[inline(always)] /// diff --git a/src/libcore/old_iter.rs b/src/libcore/old_iter.rs index 12b7ce1eb6e..389b643572c 100644 --- a/src/libcore/old_iter.rs +++ b/src/libcore/old_iter.rs @@ -22,39 +22,20 @@ use vec; /// A function used to initialize the elements of a sequence pub type InitOp<'self,T> = &'self fn(uint) -> T; -#[cfg(stage0)] -pub trait BaseIter<A> { - fn each(&self, blk: &fn(v: &A) -> bool); - fn size_hint(&self) -> Option<uint>; -} -#[cfg(not(stage0))] pub trait BaseIter<A> { fn each(&self, blk: &fn(v: &A) -> bool) -> bool; fn size_hint(&self) -> Option<uint>; } -#[cfg(stage0)] -pub trait ReverseIter<A>: BaseIter<A> { - fn each_reverse(&self, blk: &fn(&A) -> bool); -} -#[cfg(not(stage0))] pub trait ReverseIter<A>: BaseIter<A> { fn each_reverse(&self, blk: &fn(&A) -> bool) -> bool; } -#[cfg(stage0)] -pub trait MutableIter<A>: BaseIter<A> { - fn each_mut(&mut self, blk: &fn(&mut A) -> bool); -} -#[cfg(not(stage0))] pub trait MutableIter<A>: BaseIter<A> { fn each_mut(&mut self, blk: &fn(&mut A) -> bool) -> bool; } pub trait ExtendedIter<A> { - #[cfg(stage0)] - fn eachi(&self, blk: &fn(uint, v: &A) -> bool); - #[cfg(not(stage0))] fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool; fn all(&self, blk: &fn(&A) -> bool) -> bool; fn any(&self, blk: &fn(&A) -> bool) -> bool; @@ -64,11 +45,6 @@ pub trait ExtendedIter<A> { fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B]; } -#[cfg(stage0)] -pub trait ExtendedMutableIter<A> { - fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool); -} -#[cfg(not(stage0))] pub trait ExtendedMutableIter<A> { fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool) -> bool; } @@ -127,11 +103,6 @@ pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) { - _eachi(this, blk); -} -#[cfg(not(stage0))] pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { _eachi(this, blk) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 71c242bb69b..bc1ffcdc81a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -112,13 +112,6 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> { impl<T> BaseIter<T> for Option<T> { /// Performs an operation on the contained value by reference #[inline(always)] - #[cfg(stage0)] - fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) { - match *self { None => (), Some(ref t) => { f(t); } } - } - /// Performs an operation on the contained value by reference - #[inline(always)] - #[cfg(not(stage0))] fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) -> bool { match *self { None => true, Some(ref t) => { f(t) } } } @@ -130,12 +123,6 @@ impl<T> BaseIter<T> for Option<T> { } impl<T> MutableIter<T> for Option<T> { - #[cfg(stage0)] - #[inline(always)] - fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) { - match *self { None => (), Some(ref mut t) => { f(t); } } - } - #[cfg(not(stage0))] #[inline(always)] fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) -> bool { match *self { None => true, Some(ref mut t) => { f(t) } } @@ -143,11 +130,6 @@ impl<T> MutableIter<T> for Option<T> { } impl<A> ExtendedIter<A> for Option<A> { - #[cfg(stage0)] - pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - old_iter::eachi(self, blk) - } - #[cfg(not(stage0))] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 2625d03588b..b6943462f06 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -575,37 +575,8 @@ pub fn tmpdir() -> Path { getenv_nonempty("WINDIR")))).get_or_default(Path("C:\\Windows")) } } + /// Recursively walk a directory structure -#[cfg(stage0)] -pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) { - - walk_dir_(p, f); - - fn walk_dir_(p: &Path, f: &fn(&Path) -> bool) -> bool { - let mut keepgoing = true; - do list_dir(p).each |q| { - let path = &p.push(*q); - if !f(path) { - keepgoing = false; - false - } else { - if path_is_dir(path) { - if !walk_dir_(path, f) { - keepgoing = false; - false - } else { - true - } - } else { - true - } - } - } - return keepgoing; - } -} -/// Recursively walk a directory structure -#[cfg(not(stage0))] pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) -> bool { list_dir(p).each(|q| { let path = &p.push(*q); diff --git a/src/libcore/rt/comm.rs b/src/libcore/rt/comm.rs index 4b5732b2d3a..93afbea8278 100644 --- a/src/libcore/rt/comm.rs +++ b/src/libcore/rt/comm.rs @@ -22,9 +22,6 @@ use ops::Drop; use kinds::Owned; use rt::sched::Coroutine; use rt::local_sched; -#[cfg(stage0)] -use unstable::intrinsics::{atomic_xchg}; -#[cfg(not(stage0))] use unstable::intrinsics::{atomic_xchg, atomic_load}; use util::Void; use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable}; @@ -210,10 +207,6 @@ impl<T> PortOne<T> { } impl<T> Peekable<T> for PortOne<T> { - #[cfg(stage0)] - fn peek(&self) -> bool { fail!() } - - #[cfg(not(stage0))] fn peek(&self) -> bool { unsafe { let packet: *mut Packet<T> = self.inner.packet(); diff --git a/src/libcore/rt/io/mod.rs b/src/libcore/rt/io/mod.rs index 802e069a738..0ec51a3aa94 100644 --- a/src/libcore/rt/io/mod.rs +++ b/src/libcore/rt/io/mod.rs @@ -253,18 +253,13 @@ pub use self::stdio::println; pub use self::file::FileStream; pub use self::net::ip::IpAddr; -#[cfg(not(stage0))] pub use self::net::tcp::TcpListener; -#[cfg(not(stage0))] pub use self::net::tcp::TcpStream; pub use self::net::udp::UdpStream; // Some extension traits that all Readers and Writers get. -#[cfg(not(stage0))] // Requires condition! fixes pub use self::extensions::ReaderUtil; -#[cfg(not(stage0))] // Requires condition! fixes pub use self::extensions::ReaderByteConversions; -#[cfg(not(stage0))] // Requires condition! fixes pub use self::extensions::WriterByteConversions; /// Synchronous, non-blocking file I/O. @@ -272,7 +267,6 @@ pub mod file; /// Synchronous, non-blocking network I/O. pub mod net { - #[cfg(not(stage0))] pub mod tcp; pub mod udp; pub mod ip; @@ -288,7 +282,6 @@ pub mod mem; pub mod stdio; /// Implementations for Option -#[cfg(not(stage0))] // Requires condition! fixes mod option; /// Basic stream compression. XXX: Belongs with other flate code @@ -298,7 +291,6 @@ pub mod flate; pub mod comm_adapters; /// Extension traits -#[cfg(not(stage0))] // Requires condition! fixes mod extensions; /// Non-I/O things needed by the I/O module diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index e86416f2499..fbb67537232 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -24,35 +24,6 @@ pub fn Frame(fp: *Word) -> Frame { } } -#[cfg(stage0)] -pub fn walk_stack(visit: &fn(Frame) -> bool) { - - debug!("beginning stack walk"); - - do frame_address |frame_pointer| { - let mut frame_address: *Word = unsafe { - transmute(frame_pointer) - }; - loop { - let fr = Frame(frame_address); - - debug!("frame: %x", unsafe { transmute(fr.fp) }); - visit(fr); - - unsafe { - let next_fp: **Word = transmute(frame_address); - frame_address = *next_fp; - if *frame_address == 0u { - debug!("encountered task_start_wrapper. ending walk"); - // This is the task_start_wrapper_frame. There is - // no stack beneath it and it is a foreign frame. - break; - } - } - } - } -} -#[cfg(not(stage0))] pub fn walk_stack(visit: &fn(Frame) -> bool) -> bool { debug!("beginning stack walk"); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index a3cb180ed26..a760ff8f262 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -557,27 +557,12 @@ pub fn slice<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { } /// Splits a string into substrings at each occurrence of a given character -#[cfg(stage0)] -pub fn each_split_char<'a>(s: &'a str, sep: char, it: &fn(&'a str) -> bool) { - each_split_char_inner(s, sep, len(s), true, true, it); -} - -/// Splits a string into substrings at each occurrence of a given character -#[cfg(not(stage0))] pub fn each_split_char<'a>(s: &'a str, sep: char, it: &fn(&'a str) -> bool) -> bool { each_split_char_inner(s, sep, len(s), true, true, it) } /// Like `each_split_char`, but a trailing empty string is omitted -#[cfg(stage0)] -pub fn each_split_char_no_trailing<'a>(s: &'a str, - sep: char, - it: &fn(&'a str) -> bool) { - each_split_char_inner(s, sep, len(s), true, false, it); -} -/// Like `each_split_char`, but a trailing empty string is omitted -#[cfg(not(stage0))] pub fn each_split_char_no_trailing<'a>(s: &'a str, sep: char, it: &fn(&'a str) -> bool) -> bool { @@ -590,20 +575,6 @@ pub fn each_split_char_no_trailing<'a>(s: &'a str, * * The character must be a valid UTF-8/ASCII character */ -#[cfg(stage0)] -pub fn each_splitn_char<'a>(s: &'a str, - sep: char, - count: uint, - it: &fn(&'a str) -> bool) { - each_split_char_inner(s, sep, count, true, true, it); -} -/** - * Splits a string into substrings at each occurrence of a given - * character up to 'count' times. - * - * The character must be a valid UTF-8/ASCII character - */ -#[cfg(not(stage0))] pub fn each_splitn_char<'a>(s: &'a str, sep: char, count: uint, @@ -612,14 +583,6 @@ pub fn each_splitn_char<'a>(s: &'a str, } /// Like `each_split_char`, but omits empty strings -#[cfg(stage0)] -pub fn each_split_char_nonempty<'a>(s: &'a str, - sep: char, - it: &fn(&'a str) -> bool) { - each_split_char_inner(s, sep, len(s), false, false, it); -} -/// Like `each_split_char`, but omits empty strings -#[cfg(not(stage0))] pub fn each_split_char_nonempty<'a>(s: &'a str, sep: char, it: &fn(&'a str) -> bool) -> bool { @@ -659,14 +622,6 @@ fn each_split_char_inner<'a>(s: &'a str, } /// Splits a string into substrings using a character function -#[cfg(stage0)] -pub fn each_split<'a>(s: &'a str, - sepfn: &fn(char) -> bool, - it: &fn(&'a str) -> bool) { - each_split_inner(s, sepfn, len(s), true, true, it); -} -/// Splits a string into substrings using a character function -#[cfg(not(stage0))] pub fn each_split<'a>(s: &'a str, sepfn: &fn(char) -> bool, it: &fn(&'a str) -> bool) -> bool { @@ -674,14 +629,6 @@ pub fn each_split<'a>(s: &'a str, } /// Like `each_split`, but a trailing empty string is omitted -#[cfg(stage0)] -pub fn each_split_no_trailing<'a>(s: &'a str, - sepfn: &fn(char) -> bool, - it: &fn(&'a str) -> bool) { - each_split_inner(s, sepfn, len(s), true, false, it); -} -/// Like `each_split`, but a trailing empty string is omitted -#[cfg(not(stage0))] pub fn each_split_no_trailing<'a>(s: &'a str, sepfn: &fn(char) -> bool, it: &fn(&'a str) -> bool) -> bool { @@ -692,18 +639,6 @@ pub fn each_split_no_trailing<'a>(s: &'a str, * Splits a string into substrings using a character function, cutting at * most `count` times. */ -#[cfg(stage0)] -pub fn each_splitn<'a>(s: &'a str, - sepfn: &fn(char) -> bool, - count: uint, - it: &fn(&'a str) -> bool) { - each_split_inner(s, sepfn, count, true, true, it); -} -/** - * Splits a string into substrings using a character function, cutting at - * most `count` times. - */ -#[cfg(not(stage0))] pub fn each_splitn<'a>(s: &'a str, sepfn: &fn(char) -> bool, count: uint, @@ -712,14 +647,6 @@ pub fn each_splitn<'a>(s: &'a str, } /// Like `each_split`, but omits empty strings -#[cfg(stage0)] -pub fn each_split_nonempty<'a>(s: &'a str, - sepfn: &fn(char) -> bool, - it: &fn(&'a str) -> bool) { - each_split_inner(s, sepfn, len(s), false, false, it); -} -/// Like `each_split`, but omits empty strings -#[cfg(not(stage0))] pub fn each_split_nonempty<'a>(s: &'a str, sepfn: &fn(char) -> bool, it: &fn(&'a str) -> bool) -> bool { @@ -754,36 +681,6 @@ fn each_split_inner<'a>(s: &'a str, } // See Issue #1932 for why this is a naive search -#[cfg(stage0)] -fn iter_matches<'a,'b>(s: &'a str, sep: &'b str, - f: &fn(uint, uint) -> bool) { - let sep_len = len(sep), l = len(s); - assert!(sep_len > 0u); - let mut i = 0u, match_start = 0u, match_i = 0u; - - while i < l { - if s[i] == sep[match_i] { - if match_i == 0u { match_start = i; } - match_i += 1u; - // Found a match - if match_i == sep_len { - if !f(match_start, i + 1u) { return; } - match_i = 0u; - } - i += 1u; - } else { - // Failed match, backtrack - if match_i > 0u { - match_i = 0u; - i = match_start + 1u; - } else { - i += 1u; - } - } - } -} -// See Issue #1932 for why this is a naive search -#[cfg(not(stage0))] fn iter_matches<'a,'b>(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) -> bool { let sep_len = len(sep), l = len(s); @@ -813,18 +710,6 @@ fn iter_matches<'a,'b>(s: &'a str, sep: &'b str, return true; } -#[cfg(stage0)] -fn iter_between_matches<'a,'b>(s: &'a str, - sep: &'b str, - f: &fn(uint, uint) -> bool) { - let mut last_end = 0u; - for iter_matches(s, sep) |from, to| { - if !f(last_end, from) { return; } - last_end = to; - } - f(last_end, len(s)); -} -#[cfg(not(stage0))] fn iter_between_matches<'a,'b>(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) -> bool { @@ -847,26 +732,6 @@ fn iter_between_matches<'a,'b>(s: &'a str, * assert!(v == ["", "XXX", "YYY", ""]); * ~~~ */ -#[cfg(stage0)] -pub fn each_split_str<'a,'b>(s: &'a str, - sep: &'b str, - it: &fn(&'a str) -> bool) { - for iter_between_matches(s, sep) |from, to| { - if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; } - } -} -/** - * Splits a string into a vector of the substrings separated by a given string - * - * # Example - * - * ~~~ - * let mut v = ~[]; - * for each_split_str(".XXX.YYY.", ".") |subs| { v.push(subs); } - * assert!(v == ["", "XXX", "YYY", ""]); - * ~~~ - */ -#[cfg(not(stage0))] pub fn each_split_str<'a,'b>(s: &'a str, sep: &'b str, it: &fn(&'a str) -> bool) -> bool { @@ -876,18 +741,6 @@ pub fn each_split_str<'a,'b>(s: &'a str, return true; } -#[cfg(stage0)] -pub fn each_split_str_nonempty<'a,'b>(s: &'a str, - sep: &'b str, - it: &fn(&'a str) -> bool) { - for iter_between_matches(s, sep) |from, to| { - if to > from { - if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; } - } - } -} - -#[cfg(not(stage0))] pub fn each_split_str_nonempty<'a,'b>(s: &'a str, sep: &'b str, it: &fn(&'a str) -> bool) -> bool { @@ -936,14 +789,6 @@ pub fn levdistance(s: &str, t: &str) -> uint { /** * Splits a string into substrings separated by LF ('\n'). */ -#[cfg(stage0)] -pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) { - each_split_char_no_trailing(s, '\n', it); -} -/** - * Splits a string into substrings separated by LF ('\n'). - */ -#[cfg(not(stage0))] pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool { each_split_char_no_trailing(s, '\n', it) } @@ -952,22 +797,6 @@ pub fn each_line<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool { * Splits a string into substrings separated by LF ('\n') * and/or CR LF ("\r\n") */ -#[cfg(stage0)] -pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) { - for each_line(s) |s| { - let l = s.len(); - if l > 0u && s[l - 1u] == '\r' as u8 { - if !it( unsafe { raw::slice_bytes(s, 0, l - 1) } ) { return; } - } else { - if !it( s ) { return; } - } - } -} -/** - * Splits a string into substrings separated by LF ('\n') - * and/or CR LF ("\r\n") - */ -#[cfg(not(stage0))] pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool { for each_line(s) |s| { let l = s.len(); @@ -981,12 +810,6 @@ pub fn each_line_any<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool { } /// Splits a string into substrings separated by whitespace -#[cfg(stage0)] -pub fn each_word<'a>(s: &'a str, it: &fn(&'a str) -> bool) { - each_split_nonempty(s, char::is_whitespace, it); -} -/// Splits a string into substrings separated by whitespace -#[cfg(not(stage0))] pub fn each_word<'a>(s: &'a str, it: &fn(&'a str) -> bool) -> bool { each_split_nonempty(s, char::is_whitespace, it) } @@ -1063,13 +886,6 @@ pub fn _each_split_within<'a>(ss: &'a str, return cont; } -#[cfg(stage0)] -pub fn each_split_within<'a>(ss: &'a str, - lim: uint, - it: &fn(&'a str) -> bool) { - _each_split_within(ss, lim, it); -} -#[cfg(not(stage0))] pub fn each_split_within<'a>(ss: &'a str, lim: uint, it: &fn(&'a str) -> bool) -> bool { @@ -1352,33 +1168,12 @@ pub fn map(ss: &str, ff: &fn(char) -> char) -> ~str { /// Iterate over the bytes in a string #[inline(always)] -#[cfg(stage0)] -pub fn each(s: &str, it: &fn(u8) -> bool) { - eachi(s, |_i, b| it(b)) -} -/// Iterate over the bytes in a string -#[inline(always)] -#[cfg(not(stage0))] pub fn each(s: &str, it: &fn(u8) -> bool) -> bool { eachi(s, |_i, b| it(b)) } /// Iterate over the bytes in a string, with indices #[inline(always)] -#[cfg(stage0)] -pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) { - let mut pos = 0; - let len = s.len(); - - while pos < len { - if !it(pos, s[pos]) { break; } - pos += 1; - } -} - -/// Iterate over the bytes in a string, with indices -#[inline(always)] -#[cfg(not(stage0))] pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool { let mut pos = 0; let len = s.len(); @@ -1392,30 +1187,12 @@ pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool { /// Iterate over the bytes in a string in reverse #[inline(always)] -#[cfg(stage0)] -pub fn each_reverse(s: &str, it: &fn(u8) -> bool) { - eachi_reverse(s, |_i, b| it(b) ) -} -/// Iterate over the bytes in a string in reverse -#[inline(always)] -#[cfg(not(stage0))] pub fn each_reverse(s: &str, it: &fn(u8) -> bool) -> bool { eachi_reverse(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string in reverse, with indices #[inline(always)] -#[cfg(stage0)] -pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) { - let mut pos = s.len(); - while pos > 0 { - pos -= 1; - if !it(pos, s[pos]) { break; } - } -} -/// Iterate over the bytes in a string in reverse, with indices -#[inline(always)] -#[cfg(not(stage0))] pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool { let mut pos = s.len(); while pos > 0 { @@ -1427,19 +1204,6 @@ pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool { /// Iterate over each char of a string, without allocating #[inline(always)] -#[cfg(stage0)] -pub fn each_char(s: &str, it: &fn(char) -> bool) { - let mut i = 0; - let len = len(s); - while i < len { - let CharRange {ch, next} = char_range_at(s, i); - if !it(ch) { return; } - i = next; - } -} -/// Iterate over each char of a string, without allocating -#[inline(always)] -#[cfg(not(stage0))] pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool { let mut i = 0; let len = len(s); @@ -1453,21 +1217,6 @@ pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool { /// Iterates over the chars in a string, with indices #[inline(always)] -#[cfg(stage0)] -pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) { - let mut pos = 0; - let mut ch_pos = 0u; - let len = s.len(); - while pos < len { - let CharRange {ch, next} = char_range_at(s, pos); - pos = next; - if !it(ch_pos, ch) { break; } - ch_pos += 1u; - } -} -/// Iterates over the chars in a string, with indices -#[inline(always)] -#[cfg(not(stage0))] pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool { let mut pos = 0; let mut ch_pos = 0u; @@ -1483,35 +1232,12 @@ pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool { /// Iterates over the chars in a string in reverse #[inline(always)] -#[cfg(stage0)] -pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) { - each_chari_reverse(s, |_, c| it(c)) -} -/// Iterates over the chars in a string in reverse -#[inline(always)] -#[cfg(not(stage0))] pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) -> bool { each_chari_reverse(s, |_, c| it(c)) } // Iterates over the chars in a string in reverse, with indices #[inline(always)] -#[cfg(stage0)] -pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) { - let mut pos = s.len(); - let mut ch_pos = s.char_len(); - while pos > 0 { - let CharRange {ch, next} = char_range_at_reverse(s, pos); - pos = next; - ch_pos -= 1; - - if !it(ch_pos, ch) { break; } - - } -} -// Iterates over the chars in a string in reverse, with indices -#[inline(always)] -#[cfg(not(stage0))] pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) -> bool { let mut pos = s.len(); let mut ch_pos = s.char_len(); @@ -2761,22 +2487,14 @@ pub trait StrSlice<'self> { fn contains<'a>(&self, needle: &'a str) -> bool; fn contains_char(&self, needle: char) -> bool; fn char_iter(&self) -> StrCharIterator<'self>; - #[cfg(stage0)] fn each(&self, it: &fn(u8) -> bool); - #[cfg(not(stage0))] fn each(&self, it: &fn(u8) -> bool) -> bool; - #[cfg(stage0)] fn eachi(&self, it: &fn(uint, u8) -> bool); - #[cfg(not(stage0))] fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool; - #[cfg(stage0)] fn each_reverse(&self, it: &fn(u8) -> bool); - #[cfg(not(stage0))] fn each_reverse(&self, it: &fn(u8) -> bool) -> bool; - #[cfg(stage0)] fn eachi_reverse(&self, it: &fn(uint, u8) -> bool); - #[cfg(not(stage0))] fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool; - #[cfg(stage0)] fn each_char(&self, it: &fn(char) -> bool); - #[cfg(not(stage0))] fn each_char(&self, it: &fn(char) -> bool) -> bool; - #[cfg(stage0)] fn each_chari(&self, it: &fn(uint, char) -> bool); - #[cfg(not(stage0))] fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool; - #[cfg(stage0)] fn each_char_reverse(&self, it: &fn(char) -> bool); - #[cfg(not(stage0))] fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool; - #[cfg(stage0)] fn each_chari_reverse(&self, it: &fn(uint, char) -> bool); - #[cfg(not(stage0))] fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool; + fn each(&self, it: &fn(u8) -> bool) -> bool; + fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool; + fn each_reverse(&self, it: &fn(u8) -> bool) -> bool; + fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool; + fn each_char(&self, it: &fn(char) -> bool) -> bool; + fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool; + fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool; + fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool; fn ends_with(&self, needle: &str) -> bool; fn is_empty(&self) -> bool; fn is_whitespace(&self) -> bool; @@ -2784,17 +2502,8 @@ pub trait StrSlice<'self> { fn len(&self) -> uint; fn char_len(&self) -> uint; fn slice(&self, begin: uint, end: uint) -> &'self str; - #[cfg(stage0)] - fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool); - #[cfg(not(stage0))] fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) -> bool; - #[cfg(stage0)] - fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool); - #[cfg(not(stage0))] fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) -> bool; - #[cfg(stage0)] - fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool); - #[cfg(not(stage0))] fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) -> bool; fn starts_with<'a>(&self, needle: &'a str) -> bool; fn substr(&self, begin: uint, n: uint) -> &'self str; @@ -2848,83 +2557,34 @@ impl<'self> StrSlice<'self> for &'self str { /// Iterate over the bytes in a string #[inline] - #[cfg(stage0)] - fn each(&self, it: &fn(u8) -> bool) { each(*self, it) } - /// Iterate over the bytes in a string - #[inline] - #[cfg(not(stage0))] fn each(&self, it: &fn(u8) -> bool) -> bool { each(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - #[cfg(stage0)] - fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) } - /// Iterate over the bytes in a string, with indices - #[inline] - #[cfg(not(stage0))] fn eachi(&self, it: &fn(uint, u8) -> bool) -> bool { eachi(*self, it) } /// Iterate over the bytes in a string #[inline] - #[cfg(stage0)] - fn each_reverse(&self, it: &fn(u8) -> bool) { each_reverse(*self, it) } - /// Iterate over the bytes in a string - #[inline] - #[cfg(not(stage0))] fn each_reverse(&self, it: &fn(u8) -> bool) -> bool { each_reverse(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - #[cfg(stage0)] - fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) { - eachi_reverse(*self, it) - } - /// Iterate over the bytes in a string, with indices - #[inline] - #[cfg(not(stage0))] fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) -> bool { eachi_reverse(*self, it) } /// Iterate over the chars in a string #[inline] - #[cfg(stage0)] - fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) } - /// Iterate over the chars in a string - #[inline] - #[cfg(not(stage0))] fn each_char(&self, it: &fn(char) -> bool) -> bool { each_char(*self, it) } /// Iterate over the chars in a string, with indices #[inline] - #[cfg(stage0)] - fn each_chari(&self, it: &fn(uint, char) -> bool) { - each_chari(*self, it) - } - /// Iterate over the chars in a string, with indices - #[inline] - #[cfg(not(stage0))] fn each_chari(&self, it: &fn(uint, char) -> bool) -> bool { each_chari(*self, it) } /// Iterate over the chars in a string in reverse #[inline] - #[cfg(stage0)] - fn each_char_reverse(&self, it: &fn(char) -> bool) { - each_char_reverse(*self, it) - } - /// Iterate over the chars in a string in reverse - #[inline] - #[cfg(not(stage0))] fn each_char_reverse(&self, it: &fn(char) -> bool) -> bool { each_char_reverse(*self, it) } /// Iterate over the chars in a string in reverse, with indices from the /// end #[inline] - #[cfg(stage0)] - fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) { - each_chari_reverse(*self, it) - } - /// Iterate over the chars in a string in reverse, with indices from the - /// end - #[inline] - #[cfg(not(stage0))] fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) -> bool { each_chari_reverse(*self, it) } @@ -2969,13 +2629,6 @@ impl<'self> StrSlice<'self> for &'self str { } /// Splits a string into substrings using a character function #[inline] - #[cfg(stage0)] - fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) { - each_split(*self, sepfn, it) - } - /// Splits a string into substrings using a character function - #[inline] - #[cfg(not(stage0))] fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool) -> bool { each_split(*self, sepfn, it) } @@ -2983,15 +2636,6 @@ impl<'self> StrSlice<'self> for &'self str { * Splits a string into substrings at each occurrence of a given character */ #[inline] - #[cfg(stage0)] - fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) { - each_split_char(*self, sep, it) - } - /** - * Splits a string into substrings at each occurrence of a given character - */ - #[inline] - #[cfg(not(stage0))] fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool) -> bool { each_split_char(*self, sep, it) } @@ -3000,16 +2644,6 @@ impl<'self> StrSlice<'self> for &'self str { * string */ #[inline] - #[cfg(stage0)] - fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) { - each_split_str(*self, sep, it) - } - /** - * Splits a string into a vector of the substrings separated by a given - * string - */ - #[inline] - #[cfg(not(stage0))] fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) -> bool { each_split_str(*self, sep, it) } diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 2ac8fc5f073..8d287b5c51f 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -110,11 +110,6 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); assert!(was_present); } -#[cfg(stage0)] -pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) { - tasks.each(|k| blk(*k)) -} -#[cfg(not(stage0))] pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) -> bool { tasks.each(|k| blk(*k)) } diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index ad42881ffa0..5b66e94c1b4 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -22,11 +22,6 @@ use str; pub type Cb<'self> = &'self fn(buf: &[u8]) -> bool; -#[cfg(stage0)] -pub trait IterBytes { - fn iter_bytes(&self, lsb0: bool, f: Cb); -} - /** * A trait to implement in order to make a type hashable; * This works in combination with the trait `Hash::Hash`, and @@ -34,7 +29,6 @@ pub trait IterBytes { * modified when default methods and trait inheritence are * completed. */ -#[cfg(not(stage0))] pub trait IterBytes { /** * Call the provided callback `f` one or more times with @@ -53,16 +47,6 @@ pub trait IterBytes { fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool; } -#[cfg(stage0)] -impl IterBytes for bool { - #[inline(always)] - fn iter_bytes(&self, _lsb0: bool, f: Cb) { - f([ - *self as u8 - ]); - } -} -#[cfg(not(stage0))] impl IterBytes for bool { #[inline(always)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { @@ -72,16 +56,6 @@ impl IterBytes for bool { } } -#[cfg(stage0)] -impl IterBytes for u8 { - #[inline(always)] - fn iter_bytes(&self, _lsb0: bool, f: Cb) { - f([ - *self - ]); - } -} -#[cfg(not(stage0))] impl IterBytes for u8 { #[inline(always)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { @@ -91,24 +65,6 @@ impl IterBytes for u8 { } } -#[cfg(stage0)] -impl IterBytes for u16 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - if lsb0 { - f([ - *self as u8, - (*self >> 8) as u8 - ]); - } else { - f([ - (*self >> 8) as u8, - *self as u8 - ]); - } - } -} -#[cfg(not(stage0))] impl IterBytes for u16 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -126,28 +82,6 @@ impl IterBytes for u16 { } } -#[cfg(stage0)] -impl IterBytes for u32 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - if lsb0 { - f([ - *self as u8, - (*self >> 8) as u8, - (*self >> 16) as u8, - (*self >> 24) as u8, - ]); - } else { - f([ - (*self >> 24) as u8, - (*self >> 16) as u8, - (*self >> 8) as u8, - *self as u8 - ]); - } - } -} -#[cfg(not(stage0))] impl IterBytes for u32 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -169,36 +103,6 @@ impl IterBytes for u32 { } } -#[cfg(stage0)] -impl IterBytes for u64 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - if lsb0 { - f([ - *self as u8, - (*self >> 8) as u8, - (*self >> 16) as u8, - (*self >> 24) as u8, - (*self >> 32) as u8, - (*self >> 40) as u8, - (*self >> 48) as u8, - (*self >> 56) as u8 - ]); - } else { - f([ - (*self >> 56) as u8, - (*self >> 48) as u8, - (*self >> 40) as u8, - (*self >> 32) as u8, - (*self >> 24) as u8, - (*self >> 16) as u8, - (*self >> 8) as u8, - *self as u8 - ]); - } - } -} -#[cfg(not(stage0))] impl IterBytes for u64 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -228,14 +132,6 @@ impl IterBytes for u64 { } } -#[cfg(stage0)] -impl IterBytes for i8 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u8).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for i8 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -243,14 +139,6 @@ impl IterBytes for i8 { } } -#[cfg(stage0)] -impl IterBytes for i16 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u16).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for i16 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -258,14 +146,6 @@ impl IterBytes for i16 { } } -#[cfg(stage0)] -impl IterBytes for i32 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u32).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for i32 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -273,14 +153,6 @@ impl IterBytes for i32 { } } -#[cfg(stage0)] -impl IterBytes for i64 { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u64).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for i64 { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -288,14 +160,6 @@ impl IterBytes for i64 { } } -#[cfg(stage0)] -impl IterBytes for char { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u32).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for char { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -303,14 +167,7 @@ impl IterBytes for char { } } -#[cfg(target_word_size = "32", stage0)] -impl IterBytes for uint { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u32).iter_bytes(lsb0, f) - } -} -#[cfg(target_word_size = "32", not(stage0))] +#[cfg(target_word_size = "32")] impl IterBytes for uint { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -318,14 +175,7 @@ impl IterBytes for uint { } } -#[cfg(target_word_size = "64", stage0)] -impl IterBytes for uint { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as u64).iter_bytes(lsb0, f) - } -} -#[cfg(target_word_size = "64", not(stage0))] +#[cfg(target_word_size = "64")] impl IterBytes for uint { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -333,14 +183,6 @@ impl IterBytes for uint { } } -#[cfg(stage0)] -impl IterBytes for int { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as uint).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl IterBytes for int { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -348,18 +190,6 @@ impl IterBytes for int { } } -#[cfg(stage0)] -impl<'self,A:IterBytes> IterBytes for &'self [A] { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - for (*self).each |elt| { - do elt.iter_bytes(lsb0) |bytes| { - f(bytes) - } - } - } -} -#[cfg(not(stage0))] impl<'self,A:IterBytes> IterBytes for &'self [A] { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -367,18 +197,6 @@ impl<'self,A:IterBytes> IterBytes for &'self [A] { } } -#[cfg(stage0)] -impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - match *self { - (ref a, ref b) => { - iter_bytes_2(a, b, lsb0, f); - } - } - } -} -#[cfg(not(stage0))] impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -388,18 +206,6 @@ impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) { } } -#[cfg(stage0)] -impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - match *self { - (ref a, ref b, ref c) => { - iter_bytes_3(a, b, c, lsb0, f); - } - } - } -} -#[cfg(not(stage0))] impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -416,14 +222,6 @@ fn borrow<'x,A>(a: &'x [A]) -> &'x [A] { a } -#[cfg(stage0)] -impl<A:IterBytes> IterBytes for ~[A] { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - borrow(*self).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl<A:IterBytes> IterBytes for ~[A] { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -431,14 +229,6 @@ impl<A:IterBytes> IterBytes for ~[A] { } } -#[cfg(stage0)] -impl<A:IterBytes> IterBytes for @[A] { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - borrow(*self).iter_bytes(lsb0, f) - } -} -#[cfg(not(stage0))] impl<A:IterBytes> IterBytes for @[A] { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -449,57 +239,18 @@ impl<A:IterBytes> IterBytes for @[A] { // NOTE: remove all of these after a snapshot, the new for-loop iteration // protocol makes these unnecessary. -#[cfg(stage0)] -pub fn iter_bytes_2<A:IterBytes,B:IterBytes>(a: &A, b: &B, - lsb0: bool, z: Cb) { - let mut flag = true; - a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); -} -#[cfg(not(stage0))] #[inline(always)] pub fn iter_bytes_2<A:IterBytes,B:IterBytes>(a: &A, b: &B, lsb0: bool, z: Cb) -> bool { a.iter_bytes(lsb0, z) && b.iter_bytes(lsb0, z) } -#[cfg(stage0)] -pub fn iter_bytes_3<A: IterBytes, - B: IterBytes, - C: IterBytes>(a: &A, b: &B, c: &C, - lsb0: bool, z: Cb) { - let mut flag = true; - a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); -} -#[cfg(not(stage0))] pub fn iter_bytes_3<A: IterBytes, B: IterBytes, C: IterBytes>(a: &A, b: &B, c: &C, lsb0: bool, z: Cb) -> bool { a.iter_bytes(lsb0, z) && b.iter_bytes(lsb0, z) && c.iter_bytes(lsb0, z) } -#[cfg(stage0)] -pub fn iter_bytes_4<A: IterBytes, - B: IterBytes, - C: IterBytes, - D: IterBytes>(a: &A, b: &B, c: &C, - d: &D, - lsb0: bool, z: Cb) { - let mut flag = true; - a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); -} -#[cfg(not(stage0))] pub fn iter_bytes_4<A: IterBytes, B: IterBytes, C: IterBytes, @@ -510,26 +261,6 @@ pub fn iter_bytes_4<A: IterBytes, d.iter_bytes(lsb0, z) } -#[cfg(stage0)] -pub fn iter_bytes_5<A: IterBytes, - B: IterBytes, - C: IterBytes, - D: IterBytes, - E: IterBytes>(a: &A, b: &B, c: &C, - d: &D, e: &E, - lsb0: bool, z: Cb) { - let mut flag = true; - a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); - if !flag { return; } - e.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); -} -#[cfg(not(stage0))] pub fn iter_bytes_5<A: IterBytes, B: IterBytes, C: IterBytes, @@ -541,16 +272,6 @@ pub fn iter_bytes_5<A: IterBytes, d.iter_bytes(lsb0, z) && e.iter_bytes(lsb0, z) } -#[cfg(stage0)] -impl<'self> IterBytes for &'self str { - #[inline(always)] - fn iter_bytes(&self, _lsb0: bool, f: Cb) { - do str::byte_slice(*self) |bytes| { - f(bytes); - } - } -} -#[cfg(not(stage0))] impl<'self> IterBytes for &'self str { #[inline(always)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { @@ -560,16 +281,6 @@ impl<'self> IterBytes for &'self str { } } -#[cfg(stage0)] -impl IterBytes for ~str { - #[inline(always)] - fn iter_bytes(&self, _lsb0: bool, f: Cb) { - do str::byte_slice(*self) |bytes| { - f(bytes); - } - } -} -#[cfg(not(stage0))] impl IterBytes for ~str { #[inline(always)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { @@ -579,16 +290,6 @@ impl IterBytes for ~str { } } -#[cfg(stage0)] -impl IterBytes for @str { - #[inline(always)] - fn iter_bytes(&self, _lsb0: bool, f: Cb) { - do str::byte_slice(*self) |bytes| { - f(bytes); - } - } -} -#[cfg(not(stage0))] impl IterBytes for @str { #[inline(always)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { @@ -598,17 +299,6 @@ impl IterBytes for @str { } } -#[cfg(stage0)] -impl<A:IterBytes> IterBytes for Option<A> { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - match *self { - Some(ref a) => iter_bytes_2(&0u8, a, lsb0, f), - None => 1u8.iter_bytes(lsb0, f) - } - } -} -#[cfg(not(stage0))] impl<A:IterBytes> IterBytes for Option<A> { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -619,14 +309,6 @@ impl<A:IterBytes> IterBytes for Option<A> { } } -#[cfg(stage0)] -impl<'self,A:IterBytes> IterBytes for &'self A { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (**self).iter_bytes(lsb0, f); - } -} -#[cfg(not(stage0))] impl<'self,A:IterBytes> IterBytes for &'self A { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -634,14 +316,6 @@ impl<'self,A:IterBytes> IterBytes for &'self A { } } -#[cfg(stage0)] -impl<A:IterBytes> IterBytes for @A { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (**self).iter_bytes(lsb0, f); - } -} -#[cfg(not(stage0))] impl<A:IterBytes> IterBytes for @A { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -649,14 +323,6 @@ impl<A:IterBytes> IterBytes for @A { } } -#[cfg(stage0)] -impl<A:IterBytes> IterBytes for ~A { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (**self).iter_bytes(lsb0, f); - } -} -#[cfg(not(stage0))] impl<A:IterBytes> IterBytes for ~A { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { @@ -666,16 +332,6 @@ impl<A:IterBytes> IterBytes for ~A { // NB: raw-pointer IterBytes does _not_ dereference // to the target; it just gives you the pointer-bytes. -#[cfg(stage0)] -impl<A> IterBytes for *const A { - #[inline(always)] - fn iter_bytes(&self, lsb0: bool, f: Cb) { - (*self as uint).iter_bytes(lsb0, f); - } -} -// NB: raw-pointer IterBytes does _not_ dereference -// to the target; it just gives you the pointer-bytes. -#[cfg(not(stage0))] impl<A> IterBytes for *const A { #[inline(always)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index c9485654b50..13b892e700e 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -57,56 +57,24 @@ impl<T> Map<uint, T> for TrieMap<T> { /// Visit all key-value pairs in order #[inline(always)] - #[cfg(stage0)] - fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { - self.root.each(f); - } - - /// Visit all key-value pairs in order - #[inline(always)] - #[cfg(not(stage0))] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { self.root.each(f) } /// Visit all keys in order #[inline(always)] - #[cfg(stage0)] - fn each_key(&self, f: &fn(&uint) -> bool) { - self.each(|k, _| f(k)) - } - - /// Visit all keys in order - #[inline(always)] - #[cfg(not(stage0))] fn each_key(&self, f: &fn(&uint) -> bool) -> bool { self.each(|k, _| f(k)) } /// Visit all values in order #[inline(always)] - #[cfg(stage0)] - fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) { - self.each(|_, v| f(v)) - } - - /// Visit all values in order - #[inline(always)] - #[cfg(not(stage0))] fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool { self.each(|_, v| f(v)) } /// Iterate over the map and mutate the contained values #[inline(always)] - #[cfg(stage0)] - fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) { - self.root.mutate_values(f); - } - - /// Iterate over the map and mutate the contained values - #[inline(always)] - #[cfg(not(stage0))] fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool { self.root.mutate_values(f) } @@ -183,40 +151,18 @@ pub impl<T> TrieMap<T> { /// Visit all key-value pairs in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { - self.root.each_reverse(f); - } - - /// Visit all key-value pairs in reverse order - #[inline(always)] - #[cfg(not(stage0))] fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { self.root.each_reverse(f) } /// Visit all keys in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_key_reverse(&self, f: &fn(&uint) -> bool) { - self.each_reverse(|k, _| f(k)) - } - /// Visit all keys in reverse order - #[inline(always)] - #[cfg(not(stage0))] fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool { self.each_reverse(|k, _| f(k)) } /// Visit all values in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_value_reverse(&self, f: &fn(&T) -> bool) { - self.each_reverse(|_, v| f(v)) - } - /// Visit all values in reverse order - #[inline(always)] - #[cfg(not(stage0))] fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool { self.each_reverse(|_, v| f(v)) } @@ -229,9 +175,6 @@ pub struct TrieSet { impl BaseIter<uint> for TrieSet { /// Visit all values in order #[inline(always)] - #[cfg(stage0)] - fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) } - #[cfg(not(stage0))] fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } #[inline(always)] fn size_hint(&self) -> Option<uint> { Some(self.len()) } @@ -240,11 +183,6 @@ impl BaseIter<uint> for TrieSet { impl ReverseIter<uint> for TrieSet { /// Visit all values in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_reverse(&self, f: &fn(&uint) -> bool) { - self.map.each_key_reverse(f) - } - #[cfg(not(stage0))] fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key_reverse(f) } @@ -351,19 +289,6 @@ fn chunk(n: uint, idx: uint) -> uint { (n >> sh) & MASK } -#[cfg(stage0)] -fn find_mut<'r, T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> { - unsafe { - (match *child { - External(_, ref value) => Some(cast::transmute_mut(value)), - Internal(ref x) => find_mut(cast::transmute_mut(&x.children[chunk(key, idx)]), - key, idx + 1), - Nothing => None - }).map_consume(|x| cast::transmute_mut_region(x)) - } -} - -#[cfg(not(stage0))] fn find_mut<'r, T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> { match *child { External(_, ref mut value) => Some(value), diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 3b7fdcc85be..d76da6fcc66 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -14,19 +14,6 @@ pub mod general_category { - #[cfg(stage0)] - fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { - use cmp::{Equal, Less, Greater}; - use vec::bsearch; - use option::None; - (do bsearch(r) |&(lo,hi)| { - if lo <= c && c <= hi { Equal } - else if hi < c { Less } - else { Greater } - }) != None - } - - #[cfg(not(stage0))] fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use cmp::{Equal, Less, Greater}; use vec::bsearch; @@ -1462,19 +1449,6 @@ pub mod general_category { } pub mod derived_property { - #[cfg(stage0)] - fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { - use cmp::{Equal, Less, Greater}; - use vec::bsearch; - use option::None; - (do bsearch(r) |&(lo,hi)| { - if lo <= c && c <= hi { Equal } - else if hi < c { Less } - else { Greater } - }) != None - } - - #[cfg(not(stage0))] fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use cmp::{Equal, Less, Greater}; use vec::bsearch; diff --git a/src/libcore/unstable/intrinsics.rs b/src/libcore/unstable/intrinsics.rs index 1636abedf7a..f332ecc63fc 100644 --- a/src/libcore/unstable/intrinsics.rs +++ b/src/libcore/unstable/intrinsics.rs @@ -43,17 +43,13 @@ pub extern "rust-intrinsic" { pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int; /// Atomic load, sequentially consistent. - #[cfg(not(stage0))] pub fn atomic_load(src: &int) -> int; /// Atomic load, acquire ordering. - #[cfg(not(stage0))] pub fn atomic_load_acq(src: &int) -> int; /// Atomic store, sequentially consistent. - #[cfg(not(stage0))] pub fn atomic_store(dst: &mut int, val: int); /// Atomic store, release ordering. - #[cfg(not(stage0))] pub fn atomic_store_rel(dst: &mut int, val: int); /// Atomic exchange, sequentially consistent. @@ -111,7 +107,6 @@ pub extern "rust-intrinsic" { pub unsafe fn init<T>() -> T; /// Create an uninitialized value. - #[cfg(not(stage0))] pub unsafe fn uninit<T>() -> T; /// Move a value out of scope without running drop glue. diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 1249392484d..4b599d7562b 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -269,15 +269,6 @@ pub unsafe fn local_free(ptr: *c_char) { } } -#[cfg(stage0)] -#[lang="borrow_as_imm"] -#[inline(always)] -pub unsafe fn borrow_as_imm(a: *u8) { - let a: *mut BoxRepr = transmute(a); - (*a).header.ref_count |= FROZEN_BIT; -} - -#[cfg(not(stage0))] #[lang="borrow_as_imm"] #[inline(always)] pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint { @@ -296,7 +287,6 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint { old_ref_count } -#[cfg(not(stage0))] #[lang="borrow_as_mut"] #[inline(always)] pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint { @@ -316,7 +306,6 @@ pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint { } -#[cfg(not(stage0))] #[lang="record_borrow"] pub unsafe fn record_borrow(a: *u8, old_ref_count: uint, file: *c_char, line: size_t) { @@ -332,7 +321,6 @@ pub unsafe fn record_borrow(a: *u8, old_ref_count: uint, } } -#[cfg(not(stage0))] #[lang="unrecord_borrow"] pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint, file: *c_char, line: size_t) { @@ -356,19 +344,6 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint, } } -#[cfg(stage0)] -#[lang="return_to_mut"] -#[inline(always)] -pub unsafe fn return_to_mut(a: *u8) { - // Sometimes the box is null, if it is conditionally frozen. - // See e.g. #4904. - if !a.is_null() { - let a: *mut BoxRepr = transmute(a); - (*a).header.ref_count &= !FROZEN_BIT; - } -} - -#[cfg(not(stage0))] #[lang="return_to_mut"] #[inline(always)] pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint, @@ -388,19 +363,6 @@ pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint, } } -#[cfg(stage0)] -#[lang="check_not_borrowed"] -#[inline(always)] -pub unsafe fn check_not_borrowed(a: *u8) { - let a: *mut BoxRepr = transmute(a); - if ((*a).header.ref_count & FROZEN_BIT) != 0 { - do str::as_buf("XXX") |file_p, _| { - fail_borrowed(a, file_p as *c_char, 0); - } - } -} - -#[cfg(not(stage0))] #[lang="check_not_borrowed"] #[inline(always)] pub unsafe fn check_not_borrowed(a: *u8, diff --git a/src/libcore/unstable/sync.rs b/src/libcore/unstable/sync.rs index 091031f51fd..734368c70c4 100644 --- a/src/libcore/unstable/sync.rs +++ b/src/libcore/unstable/sync.rs @@ -41,18 +41,6 @@ impl<T: Owned> UnsafeAtomicRcBox<T> { } #[inline(always)] - #[cfg(stage0)] - pub unsafe fn get(&self) -> *mut T - { - let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); - assert!(data.count > 0); - let r: *mut T = cast::transmute(data.data.get_mut_ref()); - cast::forget(data); - return r; - } - - #[inline(always)] - #[cfg(not(stage0))] pub unsafe fn get(&self) -> *mut T { let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); @@ -63,18 +51,6 @@ impl<T: Owned> UnsafeAtomicRcBox<T> { } #[inline(always)] - #[cfg(stage0)] - pub unsafe fn get_immut(&self) -> *T - { - let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); - assert!(data.count > 0); - let r: *T = cast::transmute(data.data.get_mut_ref()); - cast::forget(data); - return r; - } - - #[inline(always)] - #[cfg(not(stage0))] pub unsafe fn get_immut(&self) -> *T { let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data); diff --git a/src/libcore/util.rs b/src/libcore/util.rs index eaf1e31d403..e2b91594d12 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -60,7 +60,6 @@ pub fn swap<T>(x: &mut T, y: &mut T) { * deinitialising or copying either one. */ #[inline] -#[cfg(not(stage0))] pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) { if x == y { return } @@ -79,29 +78,6 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) { } /** - * Swap the values at two mutable locations of the same type, without - * deinitialising or copying either one. - */ -#[inline] -#[cfg(stage0)] -pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) { - if x == y { return } - - // Give ourselves some scratch space to work with - let mut tmp: T = intrinsics::init(); - let t = ptr::to_mut_unsafe_ptr(&mut tmp); - - // Perform the swap - ptr::copy_memory(t, x, 1); - ptr::copy_memory(x, y, 1); - ptr::copy_memory(y, t, 1); - - // y and t now point to the same thing, but we need to completely forget t - // because it's no longer relevant. - cast::forget(tmp); -} - -/** * Replace the value at a mutable location with a new one, returning the old * value, without deinitialising or copying either one. */ diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index f12e70faa8f..14dcde2381b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -583,21 +583,6 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) { } /// Remove the last element from a vector and return it -#[cfg(not(stage0))] -pub fn pop<T>(v: &mut ~[T]) -> T { - let ln = v.len(); - if ln == 0 { - fail!("sorry, cannot vec::pop an empty vector") - } - let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); - unsafe { - let val = util::replace_ptr(valptr, intrinsics::uninit()); - raw::set_len(v, ln - 1u); - val - } -} - -#[cfg(stage0)] pub fn pop<T>(v: &mut ~[T]) -> T { let ln = v.len(); if ln == 0 { @@ -672,7 +657,6 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) { } #[inline(always)] -#[cfg(not(stage0))] pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) { let new_len = v.len() + rhs.len(); reserve(&mut *v, new_len); @@ -688,25 +672,7 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) { } } -#[inline(always)] -#[cfg(stage0)] -pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) { - let new_len = v.len() + rhs.len(); - reserve(&mut *v, new_len); - unsafe { - do as_mut_buf(rhs) |p, len| { - for uint::range(0, len) |i| { - let x = util::replace_ptr(ptr::mut_offset(p, i), - intrinsics::init()); - push(&mut *v, x); - } - } - raw::set_len(&mut rhs, 0); - } -} - /// Shorten a vector, dropping excess elements. -#[cfg(not(stage0))] pub fn truncate<T>(v: &mut ~[T], newlen: uint) { do as_mut_buf(*v) |p, oldlen| { assert!(newlen <= oldlen); @@ -720,26 +686,10 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) { unsafe { raw::set_len(&mut *v, newlen); } } -/// Shorten a vector, dropping excess elements. -#[cfg(stage0)] -pub fn truncate<T>(v: &mut ~[T], newlen: uint) { - do as_mut_buf(*v) |p, oldlen| { - assert!(newlen <= oldlen); - unsafe { - // This loop is optimized out for non-drop types. - for uint::range(newlen, oldlen) |i| { - util::replace_ptr(ptr::mut_offset(p, i), intrinsics::init()); - } - } - } - unsafe { raw::set_len(&mut *v, newlen); } -} - /** * Remove consecutive repeated elements from a vector; if the vector is * sorted, this removes all duplicates. */ -#[cfg(not(stage0))] pub fn dedup<T:Eq>(v: &mut ~[T]) { unsafe { if v.len() < 1 { return; } @@ -773,45 +723,6 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) { } } -/** - * Remove consecutive repeated elements from a vector; if the vector is - * sorted, this removes all duplicates. - */ -#[cfg(stage0)] -pub fn dedup<T:Eq>(v: &mut ~[T]) { - unsafe { - if v.len() < 1 { return; } - let mut last_written = 0, next_to_read = 1; - do as_const_buf(*v) |p, ln| { - // We have a mutable reference to v, so we can make arbitrary - // changes. (cf. push and pop) - let p = p as *mut T; - // last_written < next_to_read <= ln - while next_to_read < ln { - // last_written < next_to_read < ln - if *ptr::mut_offset(p, next_to_read) == - *ptr::mut_offset(p, last_written) { - util::replace_ptr(ptr::mut_offset(p, next_to_read), - intrinsics::init()); - } else { - last_written += 1; - // last_written <= next_to_read < ln - if next_to_read != last_written { - util::swap_ptr(ptr::mut_offset(p, last_written), - ptr::mut_offset(p, next_to_read)); - } - } - // last_written <= next_to_read < ln - next_to_read += 1; - // last_written < next_to_read <= ln - } - } - // last_written < next_to_read == ln - raw::set_len(v, last_written + 1); - } -} - - // Appending #[inline(always)] pub fn append<T:Copy>(lhs: ~[T], rhs: &const [T]) -> ~[T] { @@ -1557,9 +1468,6 @@ pub fn _each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) { _each(v, f); } -#[cfg(not(stage0))] pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool { _each(v, f) } /// Like `each()`, but for the case where you have @@ -1584,11 +1492,6 @@ pub fn _each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool return broke; } -#[cfg(stage0)] -pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) { - _each_mut(v, f); -} -#[cfg(not(stage0))] pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool { _each_mut(v, f) } @@ -1608,11 +1511,6 @@ pub fn _each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn each_const<t>(v: &const [t], f: &fn(elem: &const t) -> bool) { - _each_const(v, f); -} -#[cfg(not(stage0))] pub fn each_const<t>(v: &const [t], f: &fn(elem: &const t) -> bool) -> bool { _each_const(v, f) } @@ -1632,9 +1530,6 @@ pub fn _eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { _eachi(v, f); } -#[cfg(not(stage0))] pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool { _eachi(v, f) } @@ -1657,11 +1552,6 @@ pub fn _eachi_mut<'r,T>(v: &'r mut [T], return true; } -#[cfg(stage0)] -pub fn eachi_mut<'r,T>(v: &'r mut [T], f: &fn(uint, v: &'r mut T) -> bool) { - _eachi_mut(v, f); -} -#[cfg(not(stage0))] pub fn eachi_mut<'r,T>(v: &'r mut [T], f: &fn(uint, v: &'r mut T) -> bool) -> bool { _eachi_mut(v, f) @@ -1677,11 +1567,6 @@ pub fn _each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool { _eachi_reverse(v, |_i, v| blk(v)) } -#[cfg(stage0)] -pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) { - _each_reverse(v, blk); -} -#[cfg(not(stage0))] pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool { _each_reverse(v, blk) } @@ -1704,11 +1589,6 @@ pub fn _eachi_reverse<'r,T>(v: &'r [T], return true; } -#[cfg(stage0)] -pub fn eachi_reverse<'r,T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) { - _eachi_reverse(v, blk); -} -#[cfg(not(stage0))] pub fn eachi_reverse<'r,T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) -> bool { _eachi_reverse(v, blk) @@ -1732,11 +1612,6 @@ pub fn _each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool { return true; } -#[cfg(stage0)] -pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { - _each2(v1, v2, f); -} -#[cfg(not(stage0))] pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool { _each2(v1, v2, f) } @@ -1760,12 +1635,6 @@ pub fn _each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) return true; } -#[cfg(stage0)] -pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) { - _each2_mut(v1, v2, f); -} - -#[cfg(not(stage0))] pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) -> bool { _each2_mut(v1, v2, f) } @@ -1838,29 +1707,6 @@ pub fn each_permutation<T:Copy>(values: &[T], fun: &fn(perm : &[T]) -> bool) -> * ~~~ * */ -#[cfg(stage0)] -pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) { - assert!(1u <= n); - if n > v.len() { return; } - for uint::range(0, v.len() - n + 1) |i| { - if !it(v.slice(i, i + n)) { return } - } -} -/** - * Iterate over all contiguous windows of length `n` of the vector `v`. - * - * # Example - * - * Print the adjacent pairs of a vector (i.e. `[1,2]`, `[2,3]`, `[3,4]`) - * - * ~~~ - * for windowed(2, &[1,2,3,4]) |v| { - * io::println(fmt!("%?", v)); - * } - * ~~~ - * - */ -#[cfg(not(stage0))] pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) -> bool { assert!(1u <= n); if n > v.len() { return true; } @@ -2133,13 +1979,7 @@ pub trait ImmutableVector<'self, T> { fn last_opt(&self) -> Option<&'self T>; fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>; fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>; - #[cfg(stage0)] - fn each_reverse(&self, blk: &fn(&T) -> bool); - #[cfg(not(stage0))] fn each_reverse(&self, blk: &fn(&T) -> bool) -> bool; - #[cfg(stage0)] - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool); - #[cfg(not(stage0))] fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) -> bool; fn foldr<'a, U>(&'a self, z: U, p: &fn(t: &'a T, u: U) -> U) -> U; fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U]; @@ -2226,25 +2066,11 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { /// Iterates over a vector's elements in reverse. #[inline] - #[cfg(stage0)] - fn each_reverse(&self, blk: &fn(&T) -> bool) { - each_reverse(*self, blk) - } - /// Iterates over a vector's elements in reverse. - #[inline] - #[cfg(not(stage0))] fn each_reverse(&self, blk: &fn(&T) -> bool) -> bool { each_reverse(*self, blk) } /// Iterates over a vector's elements and indices in reverse. - #[cfg(stage0)] - #[inline] - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) { - eachi_reverse(*self, blk) - } - /// Iterates over a vector's elements and indices in reverse. - #[cfg(not(stage0))] #[inline] fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) -> bool { eachi_reverse(*self, blk) @@ -2780,12 +2606,6 @@ pub mod bytes { // ITERATION TRAIT METHODS impl<'self,A> old_iter::BaseIter<A> for &'self [A] { - #[cfg(stage0)] - #[inline(always)] - fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { - each(*self, blk) - } - #[cfg(not(stage0))] #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) @@ -2796,12 +2616,6 @@ impl<'self,A> old_iter::BaseIter<A> for &'self [A] { // FIXME(#4148): This should be redundant impl<A> old_iter::BaseIter<A> for ~[A] { - #[cfg(stage0)] - #[inline(always)] - fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { - each(*self, blk) - } - #[cfg(not(stage0))] #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) @@ -2812,12 +2626,6 @@ impl<A> old_iter::BaseIter<A> for ~[A] { // FIXME(#4148): This should be redundant impl<A> old_iter::BaseIter<A> for @[A] { - #[cfg(stage0)] - #[inline(always)] - fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { - each(*self, blk) - } - #[cfg(not(stage0))] #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) @@ -2827,12 +2635,6 @@ impl<A> old_iter::BaseIter<A> for @[A] { } impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] { - #[cfg(stage0)] - #[inline(always)] - fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { - each_mut(*self, blk) - } - #[cfg(not(stage0))] #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool { each_mut(*self, blk) @@ -2841,12 +2643,6 @@ impl<'self,A> old_iter::MutableIter<A> for &'self mut [A] { // FIXME(#4148): This should be redundant impl<A> old_iter::MutableIter<A> for ~[A] { - #[cfg(stage0)] - #[inline(always)] - fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { - each_mut(*self, blk) - } - #[cfg(not(stage0))] #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool { each_mut(*self, blk) @@ -2854,15 +2650,6 @@ impl<A> old_iter::MutableIter<A> for ~[A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl<A> old_iter::MutableIter<A> for @mut [A] { - #[inline(always)] - fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) { - each_mut(*self, blk) - } -} - -#[cfg(not(stage0))] impl<A> old_iter::MutableIter<A> for @mut [A] { #[inline(always)] fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) -> bool { @@ -2871,11 +2658,6 @@ impl<A> old_iter::MutableIter<A> for @mut [A] { } impl<'self,A> old_iter::ExtendedIter<A> for &'self [A] { - #[cfg(stage0)] - pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - old_iter::eachi(self, blk) - } - #[cfg(not(stage0))] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } @@ -2902,12 +2684,6 @@ impl<'self,A> old_iter::ExtendedIter<A> for &'self [A] { impl<'self,A> old_iter::ExtendedMutableIter<A> for &'self mut [A] { #[inline(always)] - #[cfg(stage0)] - pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) { - eachi_mut(*self, blk) - } - #[inline(always)] - #[cfg(not(stage0))] pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) -> bool { eachi_mut(*self, blk) } @@ -2915,11 +2691,6 @@ impl<'self,A> old_iter::ExtendedMutableIter<A> for &'self mut [A] { // FIXME(#4148): This should be redundant impl<A> old_iter::ExtendedIter<A> for ~[A] { - #[cfg(stage0)] - pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - old_iter::eachi(self, blk) - } - #[cfg(not(stage0))] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } @@ -2946,11 +2717,6 @@ impl<A> old_iter::ExtendedIter<A> for ~[A] { // FIXME(#4148): This should be redundant impl<A> old_iter::ExtendedIter<A> for @[A] { - #[cfg(stage0)] - pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - old_iter::eachi(self, blk) - } - #[cfg(not(stage0))] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } |
