Skip to content

Commit d74ac9e

Browse files
committed
auto merge of #6240 : brson/rust/snapshots, r=brson
2 parents b872900 + 8081e8d commit d74ac9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+138
-5842
lines changed

src/libcore/cast.rs

-46
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
//! Unsafe casting functions
1212
13-
#[cfg(not(stage0))]
1413
use sys;
15-
#[cfg(not(stage0))]
1614
use unstable;
1715

1816
pub mod rusti {
@@ -21,35 +19,11 @@ pub mod rusti {
2119
pub extern "rust-intrinsic" {
2220
fn forget<T>(+x: T);
2321

24-
#[cfg(stage0)]
25-
fn reinterpret_cast<T, U>(&&e: T) -> U;
26-
27-
#[cfg(stage1)]
28-
#[cfg(stage2)]
29-
#[cfg(stage3)]
3022
fn transmute<T,U>(e: T) -> U;
3123
}
3224
}
3325

3426
/// Casts the value at `src` to U. The two types must have the same length.
35-
#[inline(always)]
36-
#[cfg(stage0)]
37-
pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
38-
rusti::reinterpret_cast(*src)
39-
}
40-
41-
/// Unsafely copies and casts the value at `src` to U, even if the value is
42-
/// noncopyable. The two types must have the same length.
43-
#[inline(always)]
44-
#[cfg(stage0)]
45-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
46-
rusti::reinterpret_cast(*src)
47-
}
48-
49-
#[inline(always)]
50-
#[cfg(stage1)]
51-
#[cfg(stage2)]
52-
#[cfg(stage3)]
5327
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
5428
let mut dest: U = unstable::intrinsics::init();
5529
{
@@ -90,17 +64,6 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
9064
* assert!(transmute("L") == ~[76u8, 0u8]);
9165
*/
9266
#[inline(always)]
93-
#[cfg(stage0)]
94-
pub unsafe fn transmute<L, G>(thing: L) -> G {
95-
let newthing: G = reinterpret_cast(&thing);
96-
forget(thing);
97-
newthing
98-
}
99-
100-
#[inline(always)]
101-
#[cfg(stage1)]
102-
#[cfg(stage2)]
103-
#[cfg(stage3)]
10467
pub unsafe fn transmute<L, G>(thing: L) -> G {
10568
rusti::transmute(thing)
10669
}
@@ -161,15 +124,6 @@ mod tests {
161124
use cast::{bump_box_refcount, transmute};
162125

163126
#[test]
164-
#[cfg(stage0)]
165-
fn test_reinterpret_cast() {
166-
assert!(1u == unsafe { ::cast::reinterpret_cast(&1) });
167-
}
168-
169-
#[test]
170-
#[cfg(stage1)]
171-
#[cfg(stage2)]
172-
#[cfg(stage3)]
173127
fn test_transmute_copy() {
174128
assert!(1u == unsafe { ::cast::transmute_copy(&1) });
175129
}

src/libcore/container.rs

-36
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,6 @@ pub trait Mutable: Container {
2525
fn clear(&mut self);
2626
}
2727

28-
#[cfg(stage0)]
29-
pub trait Map<K, V>: Mutable {
30-
/// Return true if the map contains a value for the specified key
31-
fn contains_key(&self, key: &K) -> bool;
32-
33-
// Visits all keys and values
34-
fn each(&self, f: &fn(&K, &V) -> bool);
35-
36-
/// Visit all keys
37-
fn each_key(&self, f: &fn(&K) -> bool);
38-
39-
/// Visit all values
40-
fn each_value(&self, f: &fn(&V) -> bool);
41-
42-
/// Iterate over the map and mutate the contained values
43-
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
44-
45-
/// Return a reference to the value corresponding to the key
46-
fn find(&self, key: &K) -> Option<&'self V>;
47-
48-
/// Return a mutable reference to the value corresponding to the key
49-
fn find_mut(&mut self, key: &K) -> Option<&'self mut V>;
50-
51-
/// Insert a key-value pair into the map. An existing value for a
52-
/// key is replaced by the new value. Return true if the key did
53-
/// not already exist in the map.
54-
fn insert(&mut self, key: K, value: V) -> bool;
55-
56-
/// Remove a key-value pair from the map. Return true if the key
57-
/// was present in the map, otherwise false.
58-
fn remove(&mut self, key: &K) -> bool;
59-
}
60-
61-
#[cfg(stage1)]
62-
#[cfg(stage2)]
63-
#[cfg(stage3)]
6428
pub trait Map<K, V>: Mutable {
6529
/// Return true if the map contains a value for the specified key
6630
fn contains_key(&self, key: &K) -> bool;

src/libcore/core.rc

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ they contained the following prologue:
7474

7575
pub use kinds::{Const, Copy, Owned, Durable};
7676
pub use ops::{Drop};
77-
#[cfg(stage0)]
78-
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
79-
#[cfg(not(stage0))]
8077
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
8178
pub use ops::{BitAnd, BitOr, BitXor};
8279
pub use ops::{Shl, Shr, Index};

src/libcore/hashmap.rs

-168
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
184184
}
185185
}
186186

187-
#[cfg(stage0)]
188-
#[inline(always)]
189-
fn value_for_bucket(&self, idx: uint) -> &'self V {
190-
match self.buckets[idx] {
191-
Some(ref bkt) => &bkt.value,
192-
None => fail!(~"HashMap::find: internal logic error"),
193-
}
194-
}
195-
196-
#[cfg(stage1)]
197-
#[cfg(stage2)]
198-
#[cfg(stage3)]
199187
#[inline(always)]
200188
fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V {
201189
match self.buckets[idx] {
@@ -204,18 +192,6 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
204192
}
205193
}
206194
207-
#[cfg(stage0)]
208-
#[inline(always)]
209-
fn mut_value_for_bucket(&mut self, idx: uint) -> &'self mut V {
210-
match self.buckets[idx] {
211-
Some(ref mut bkt) => &mut bkt.value,
212-
None => unreachable()
213-
}
214-
}
215-
216-
#[cfg(stage1)]
217-
#[cfg(stage2)]
218-
#[cfg(stage3)]
219195
#[inline(always)]
220196
fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V {
221197
match self.buckets[idx] {
@@ -329,21 +305,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
329305
}
330306
331307
/// Visit all key-value pairs
332-
#[cfg(stage0)]
333-
fn each(&self, blk: &fn(&'self K, &'self V) -> bool) {
334-
for uint::range(0, self.buckets.len()) |i| {
335-
for self.buckets[i].each |bucket| {
336-
if !blk(&bucket.key, &bucket.value) {
337-
return;
338-
}
339-
}
340-
}
341-
}
342-
343-
/// Visit all key-value pairs
344-
#[cfg(stage1)]
345-
#[cfg(stage2)]
346-
#[cfg(stage3)]
347308
fn each<'a>(&'a self, blk: &fn(&'a K, &'a V) -> bool) {
348309
for uint::range(0, self.buckets.len()) |i| {
349310
for self.buckets[i].each |bucket| {
@@ -360,15 +321,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
360321
}
361322
362323
/// Visit all values
363-
#[cfg(stage0)]
364-
fn each_value(&self, blk: &fn(v: &V) -> bool) {
365-
self.each(|_, v| blk(v))
366-
}
367-
368-
/// Visit all values
369-
#[cfg(stage1)]
370-
#[cfg(stage2)]
371-
#[cfg(stage3)]
372324
fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) {
373325
self.each(|_, v| blk(v))
374326
}
@@ -386,18 +338,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
386338
}
387339
388340
/// Return a reference to the value corresponding to the key
389-
#[cfg(stage0)]
390-
fn find(&self, k: &K) -> Option<&'self V> {
391-
match self.bucket_for_key(k) {
392-
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
393-
TableFull | FoundHole(_) => None,
394-
}
395-
}
396-
397-
/// Return a reference to the value corresponding to the key
398-
#[cfg(stage1)]
399-
#[cfg(stage2)]
400-
#[cfg(stage3)]
401341
fn find<'a>(&'a self, k: &K) -> Option<&'a V> {
402342
match self.bucket_for_key(k) {
403343
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
@@ -406,21 +346,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
406346
}
407347
408348
/// Return a mutable reference to the value corresponding to the key
409-
#[cfg(stage0)]
410-
fn find_mut(&mut self, k: &K) -> Option<&'self mut V> {
411-
let idx = match self.bucket_for_key(k) {
412-
FoundEntry(idx) => idx,
413-
TableFull | FoundHole(_) => return None
414-
};
415-
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
416-
Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx)))
417-
}
418-
}
419-
420-
/// Return a mutable reference to the value corresponding to the key
421-
#[cfg(stage1)]
422-
#[cfg(stage2)]
423-
#[cfg(stage3)]
424349
fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> {
425350
let idx = match self.bucket_for_key(k) {
426351
FoundEntry(idx) => idx,
@@ -503,40 +428,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
503428
504429
/// Return the value corresponding to the key in the map, or insert
505430
/// and return the value if it doesn't exist.
506-
#[cfg(stage0)]
507-
fn find_or_insert(&mut self, k: K, v: V) -> &'self V {
508-
if self.size >= self.resize_at {
509-
// n.b.: We could also do this after searching, so
510-
// that we do not resize if this call to insert is
511-
// simply going to update a key in place. My sense
512-
// though is that it's worse to have to search through
513-
// buckets to find the right spot twice than to just
514-
// resize in this corner case.
515-
self.expand();
516-
}
517-
518-
let hash = k.hash_keyed(self.k0, self.k1) as uint;
519-
let idx = match self.bucket_for_key_with_hash(hash, &k) {
520-
TableFull => fail!(~"Internal logic error"),
521-
FoundEntry(idx) => idx,
522-
FoundHole(idx) => {
523-
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
524-
value: v});
525-
self.size += 1;
526-
idx
527-
},
528-
};
529-
530-
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
531-
::cast::transmute_region(self.value_for_bucket(idx))
532-
}
533-
}
534-
535-
/// Return the value corresponding to the key in the map, or insert
536-
/// and return the value if it doesn't exist.
537-
#[cfg(stage1)]
538-
#[cfg(stage2)]
539-
#[cfg(stage3)]
540431
fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V {
541432
if self.size >= self.resize_at {
542433
// n.b.: We could also do this after searching, so
@@ -567,41 +458,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
567458
568459
/// Return the value corresponding to the key in the map, or create,
569460
/// insert, and return a new value if it doesn't exist.
570-
#[cfg(stage0)]
571-
fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &'self V {
572-
if self.size >= self.resize_at {
573-
// n.b.: We could also do this after searching, so
574-
// that we do not resize if this call to insert is
575-
// simply going to update a key in place. My sense
576-
// though is that it's worse to have to search through
577-
// buckets to find the right spot twice than to just
578-
// resize in this corner case.
579-
self.expand();
580-
}
581-
582-
let hash = k.hash_keyed(self.k0, self.k1) as uint;
583-
let idx = match self.bucket_for_key_with_hash(hash, &k) {
584-
TableFull => fail!(~"Internal logic error"),
585-
FoundEntry(idx) => idx,
586-
FoundHole(idx) => {
587-
let v = f(&k);
588-
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
589-
value: v});
590-
self.size += 1;
591-
idx
592-
},
593-
};
594-
595-
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
596-
::cast::transmute_region(self.value_for_bucket(idx))
597-
}
598-
}
599-
600-
/// Return the value corresponding to the key in the map, or create,
601-
/// insert, and return a new value if it doesn't exist.
602-
#[cfg(stage1)]
603-
#[cfg(stage2)]
604-
#[cfg(stage3)]
605461
fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V {
606462
if self.size >= self.resize_at {
607463
// n.b.: We could also do this after searching, so
@@ -647,17 +503,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
647503
}
648504
}
649505
650-
#[cfg(stage0)]
651-
fn get(&self, k: &K) -> &'self V {
652-
match self.find(k) {
653-
Some(v) => v,
654-
None => fail!(fmt!("No entry found for key: %?", k)),
655-
}
656-
}
657-
658-
#[cfg(stage1)]
659-
#[cfg(stage2)]
660-
#[cfg(stage3)]
661506
fn get<'a>(&'a self, k: &K) -> &'a V {
662507
match self.find(k) {
663508
Some(v) => v,
@@ -676,19 +521,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
676521

677522
/// Return the value corresponding to the key in the map, using
678523
/// equivalence
679-
#[cfg(stage0)]
680-
fn find_equiv<Q:Hash + Equiv<K>>(&self, k: &Q) -> Option<&'self V> {
681-
match self.bucket_for_key_equiv(k) {
682-
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
683-
TableFull | FoundHole(_) => None,
684-
}
685-
}
686-
687-
/// Return the value corresponding to the key in the map, using
688-
/// equivalence
689-
#[cfg(stage1)]
690-
#[cfg(stage2)]
691-
#[cfg(stage3)]
692524
fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) -> Option<&'a V> {
693525
match self.bucket_for_key_equiv(k) {
694526
FoundEntry(idx) => Some(self.value_for_bucket(idx)),

src/libcore/num/f32.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,7 @@ impl Div<f32,f32> for f32 {
284284
fn div(&self, other: &f32) -> f32 { *self / *other }
285285
}
286286

287-
#[cfg(stage0,notest)]
288-
impl Modulo<f32,f32> for f32 {
289-
#[inline(always)]
290-
fn modulo(&self, other: &f32) -> f32 { *self % *other }
291-
}
292-
#[cfg(not(stage0),notest)]
287+
#[cfg(notest)]
293288
impl Rem<f32,f32> for f32 {
294289
#[inline(always)]
295290
fn rem(&self, other: &f32) -> f32 { *self % *other }

src/libcore/num/f64.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,7 @@ impl Mul<f64,f64> for f64 {
299299
impl Div<f64,f64> for f64 {
300300
fn div(&self, other: &f64) -> f64 { *self / *other }
301301
}
302-
#[cfg(stage0,notest)]
303-
impl Modulo<f64,f64> for f64 {
304-
fn modulo(&self, other: &f64) -> f64 { *self % *other }
305-
}
306-
#[cfg(not(stage0),notest)]
302+
#[cfg(notest)]
307303
impl Rem<f64,f64> for f64 {
308304
#[inline(always)]
309305
fn rem(&self, other: &f64) -> f64 { *self % *other }

0 commit comments

Comments
 (0)