Skip to content

switch to using #[cfg(not(stage0))] consistently #6186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ pub mod rusti {
#[cfg(stage0)]
fn reinterpret_cast<T, U>(&&e: T) -> U;

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn transmute<T,U>(e: T) -> U;
}
}
Expand All @@ -45,9 +43,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
}

#[inline(always)]
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = unstable::intrinsics::init();
{
Expand Down Expand Up @@ -96,9 +92,7 @@ pub unsafe fn transmute<L, G>(thing: L) -> G {
}

#[inline(always)]
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
pub unsafe fn transmute<L, G>(thing: L) -> G {
rusti::transmute(thing)
}
Expand Down Expand Up @@ -165,9 +159,7 @@ mod tests {
}

#[test]
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn test_transmute_copy() {
assert!(1u == unsafe { ::cast::transmute_copy(&1) });
}
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ pub trait Map<K, V>: Mutable {
fn remove(&mut self, key: &K) -> bool;
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
pub trait Map<K, V>: Mutable {
/// Return true if the map contains a value for the specified key
fn contains_key(&self, key: &K) -> bool;
Expand Down
40 changes: 10 additions & 30 deletions src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
}
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V {
match self.buckets[idx] {
Expand All @@ -213,9 +211,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
}
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V {
match self.buckets[idx] {
Expand Down Expand Up @@ -341,9 +337,7 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
}

/// Visit all key-value pairs
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn each<'a>(&'a self, blk: &fn(&'a K, &'a V) -> bool) {
for uint::range(0, self.buckets.len()) |i| {
for self.buckets[i].each |bucket| {
Expand All @@ -366,9 +360,7 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
}

/// Visit all values
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) {
self.each(|_, v| blk(v))
}
Expand All @@ -395,9 +387,7 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
}

/// Return a reference to the value corresponding to the key
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn find<'a>(&'a self, k: &K) -> Option<&'a V> {
match self.bucket_for_key(k) {
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
Expand All @@ -418,9 +408,7 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
}

/// Return a mutable reference to the value corresponding to the key
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[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,
Expand Down Expand Up @@ -534,9 +522,7 @@ 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(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[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
Expand Down Expand Up @@ -599,9 +585,7 @@ 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(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[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
Expand Down Expand Up @@ -655,9 +639,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
}
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn get<'a>(&'a self, k: &K) -> &'a V {
match self.find(k) {
Some(v) => v,
Expand Down Expand Up @@ -686,9 +668,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {

/// Return the value corresponding to the key in the map, using
/// equivalence
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) -> Option<&'a V> {
match self.bucket_for_key_equiv(k) {
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/num/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ pub fn test_num<T:Num + NumCast>(ten: T, two: T) {
assert_eq!(ten.div(&two), ten / two);
assert_eq!(ten.modulo(&two), ten % two);
}
#[cfg(stage1,test)]
#[cfg(stage2,test)]
#[cfg(stage3,test)]
#[cfg(not(stage0), test)]
pub fn test_num<T:Num + NumCast>(ten: T, two: T) {
assert_eq!(ten.add(&two), cast(12));
assert_eq!(ten.sub(&two), cast(8));
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/num/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use core::cmp::{Ord, Eq};
use ops::{Add, Sub, Mul, Div, Neg};
#[cfg(stage0)]
use Rem = ops::Modulo;
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
use ops::{Add, Sub, Mul, Div, Rem, Neg};
use option::{None, Option, Some};
use char;
Expand Down
28 changes: 7 additions & 21 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ impl<T> BaseIter<T> for Option<T> {
}

/// Performs an operation on the contained value by reference
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) {
match *self { None => (), Some(ref t) => { f(t); } }
Expand All @@ -128,9 +126,7 @@ impl<T> MutableIter<T> for Option<T> {
match *self { None => (), Some(ref mut t) => { f(t); } }
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(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); } }
Expand Down Expand Up @@ -210,9 +206,7 @@ pub impl<T> Option<T> {
* Update an optional value by optionally running its content by reference
* through a function that returns an option.
*/
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> {
match *self { Some(ref x) => f(x), None => None }
Expand All @@ -226,9 +220,7 @@ pub impl<T> Option<T> {
}

/// Maps a `some` value from one type to another by reference
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> {
match *self { Some(ref x) => Some(f(x)), None => None }
Expand All @@ -249,9 +241,7 @@ pub impl<T> Option<T> {
}

/// Applies a function to the contained value or returns a default
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U {
match *self { None => def, Some(ref t) => f(t) }
Expand Down Expand Up @@ -318,9 +308,7 @@ pub impl<T> Option<T> {
case explicitly.
*/
#[inline(always)]
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn get_ref<'a>(&'a self) -> &'a T {
match *self {
Some(ref x) => x,
Expand Down Expand Up @@ -366,9 +354,7 @@ pub impl<T> Option<T> {
case explicitly.
*/
#[inline(always)]
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
match *self {
Some(ref mut x) => x,
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ pub impl<T, E> Result<T, E> {
#[inline(always)]
fn get_ref(&self) -> &'self T { get_ref(self) }

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline(always)]
fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) }

Expand Down
4 changes: 1 addition & 3 deletions src/libcore/rt/rtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ pub trait EventLoop {
/// The asynchronous I/O services. Not all event loops may provide one
#[cfg(stage0)]
fn io(&mut self) -> Option<&'self mut IoFactoryObject>;
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject>;
}

Expand Down
8 changes: 2 additions & 6 deletions src/libcore/rt/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ impl EventLoop for UvEventLoop {
Some(&mut self.uvio)
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject> {
Some(&mut self.uvio)
}
Expand Down Expand Up @@ -104,9 +102,7 @@ pub impl UvIoFactory {
match self { &UvIoFactory(ref mut ptr) => ptr }
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
match self { &UvIoFactory(ref mut ptr) => ptr }
}
Expand Down
16 changes: 4 additions & 12 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2356,9 +2356,7 @@ pub trait StrSlice<'self> {
fn any(&self, it: &fn(char) -> bool) -> bool;
fn contains<'a>(&self, needle: &'a str) -> bool;
fn contains_char(&self, needle: char) -> bool;
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
fn char_iter(&self) -> StrCharIterator<'self>;
fn each(&self, it: &fn(u8) -> bool);
fn eachi(&self, it: &fn(uint, u8) -> bool);
Expand Down Expand Up @@ -2420,9 +2418,7 @@ impl<'self> StrSlice<'self> for &'self str {
contains_char(*self, needle)
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
#[inline]
fn char_iter(&self) -> StrCharIterator<'self> {
StrCharIterator {
Expand Down Expand Up @@ -2615,17 +2611,13 @@ impl Clone for ~str {
}
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
pub struct StrCharIterator<'self> {
priv index: uint,
priv string: &'self str,
}

#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[cfg(not(stage0))]
impl<'self> Iterator<char> for StrCharIterator<'self> {
#[inline]
fn next(&mut self) -> Option<char> {
Expand Down
Loading