Skip to content

Commit eba2e26

Browse files
committed
---
yaml --- r: 46905 b: refs/heads/try c: ab25349 h: refs/heads/master i: 46903: 0dc7b75 v: v3
1 parent 6f37ec6 commit eba2e26

Some content is hidden

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

53 files changed

+1179
-1709
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 6d98ca94ccab88be224eb2703fb496c2d003a562
5+
refs/heads/try: ab2534974caf39e69b401442ff1a9077b94c46c1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector};
199199
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
200200
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
201201

202-
pub use num::{Num, NumCast};
202+
pub use num::Num;
203203
pub use ptr::Ptr;
204204
pub use to_str::ToStr;
205205
pub use clone::Clone;

branches/try/src/libcore/hashmap.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ pub mod linear {
383383
},
384384
};
385385
386-
self.value_for_bucket(idx)
386+
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
387+
::cast::transmute_region(self.value_for_bucket(idx))
388+
}
387389
}
388390
389391
/// Return the value corresponding to the key in the map, or create,
@@ -412,7 +414,9 @@ pub mod linear {
412414
},
413415
};
414416
415-
self.value_for_bucket(idx)
417+
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
418+
::cast::transmute_region(self.value_for_bucket(idx))
419+
}
416420
}
417421
418422
fn consume(&mut self, f: fn(K, V)) {

branches/try/src/libcore/num/f32.rs

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use cmath;
1414
use cmp;
1515
use libc::{c_float, c_int};
1616
use num;
17-
use num::NumCast;
1817
use option::Option;
1918
use from_str;
2019
use to_str;
@@ -284,6 +283,11 @@ impl f32: num::Num {
284283
pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; }
285284
#[inline(always)]
286285
pure fn neg(&self) -> f32 { return -*self; }
286+
287+
#[inline(always)]
288+
pure fn to_int(&self) -> int { return *self as int; }
289+
#[inline(always)]
290+
static pure fn from_int(n: int) -> f32 { return n as f32; }
287291
}
288292

289293
impl f32: num::Zero {
@@ -296,30 +300,6 @@ impl f32: num::One {
296300
static pure fn one() -> f32 { 1.0 }
297301
}
298302

299-
pub impl f32: NumCast {
300-
/**
301-
* Cast `n` to an `f32`
302-
*/
303-
#[inline(always)]
304-
static pure fn from<N:NumCast>(n: N) -> f32 { n.to_f32() }
305-
306-
#[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 }
307-
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }
308-
#[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 }
309-
#[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 }
310-
#[inline(always)] pure fn to_uint(&self) -> uint { *self as uint }
311-
312-
#[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 }
313-
#[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 }
314-
#[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 }
315-
#[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 }
316-
#[inline(always)] pure fn to_int(&self) -> int { *self as int }
317-
318-
#[inline(always)] pure fn to_f32(&self) -> f32 { *self }
319-
#[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 }
320-
#[inline(always)] pure fn to_float(&self) -> float { *self as float }
321-
}
322-
323303
#[abi="rust-intrinsic"]
324304
pub extern {
325305
fn floorf32(val: f32) -> f32;
@@ -565,63 +545,6 @@ impl f32: num::FromStrRadix {
565545
}
566546
}
567547

568-
#[test]
569-
pub fn test_num() {
570-
let ten: f32 = num::cast(10);
571-
let two: f32 = num::cast(2);
572-
573-
assert (ten.add(&two) == num::cast(12));
574-
assert (ten.sub(&two) == num::cast(8));
575-
assert (ten.mul(&two) == num::cast(20));
576-
assert (ten.div(&two) == num::cast(5));
577-
assert (ten.modulo(&two) == num::cast(0));
578-
}
579-
580-
#[test]
581-
fn test_numcast() {
582-
assert (20u == 20f32.to_uint());
583-
assert (20u8 == 20f32.to_u8());
584-
assert (20u16 == 20f32.to_u16());
585-
assert (20u32 == 20f32.to_u32());
586-
assert (20u64 == 20f32.to_u64());
587-
assert (20i == 20f32.to_int());
588-
assert (20i8 == 20f32.to_i8());
589-
assert (20i16 == 20f32.to_i16());
590-
assert (20i32 == 20f32.to_i32());
591-
assert (20i64 == 20f32.to_i64());
592-
assert (20f == 20f32.to_float());
593-
assert (20f32 == 20f32.to_f32());
594-
assert (20f64 == 20f32.to_f64());
595-
596-
assert (20f32 == NumCast::from(20u));
597-
assert (20f32 == NumCast::from(20u8));
598-
assert (20f32 == NumCast::from(20u16));
599-
assert (20f32 == NumCast::from(20u32));
600-
assert (20f32 == NumCast::from(20u64));
601-
assert (20f32 == NumCast::from(20i));
602-
assert (20f32 == NumCast::from(20i8));
603-
assert (20f32 == NumCast::from(20i16));
604-
assert (20f32 == NumCast::from(20i32));
605-
assert (20f32 == NumCast::from(20i64));
606-
assert (20f32 == NumCast::from(20f));
607-
assert (20f32 == NumCast::from(20f32));
608-
assert (20f32 == NumCast::from(20f64));
609-
610-
assert (20f32 == num::cast(20u));
611-
assert (20f32 == num::cast(20u8));
612-
assert (20f32 == num::cast(20u16));
613-
assert (20f32 == num::cast(20u32));
614-
assert (20f32 == num::cast(20u64));
615-
assert (20f32 == num::cast(20i));
616-
assert (20f32 == num::cast(20i8));
617-
assert (20f32 == num::cast(20i16));
618-
assert (20f32 == num::cast(20i32));
619-
assert (20f32 == num::cast(20i64));
620-
assert (20f32 == num::cast(20f));
621-
assert (20f32 == num::cast(20f32));
622-
assert (20f32 == num::cast(20f64));
623-
}
624-
625548
//
626549
// Local Variables:
627550
// mode: rust

branches/try/src/libcore/num/f64.rs

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use cmp;
1515
use libc::{c_double, c_int};
1616
use libc;
1717
use num;
18-
use num::NumCast;
1918
use option::Option;
2019
use to_str;
2120
use from_str;
@@ -308,30 +307,11 @@ impl f64: num::Num {
308307
pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; }
309308
#[inline(always)]
310309
pure fn neg(&self) -> f64 { return -*self; }
311-
}
312310

313-
pub impl f64: NumCast {
314-
/**
315-
* Cast `n` to an `f64`
316-
*/
317311
#[inline(always)]
318-
static pure fn from<N:NumCast>(n: N) -> f64 { n.to_f64() }
319-
320-
#[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 }
321-
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }
322-
#[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 }
323-
#[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 }
324-
#[inline(always)] pure fn to_uint(&self) -> uint { *self as uint }
325-
326-
#[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 }
327-
#[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 }
328-
#[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 }
329-
#[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 }
330-
#[inline(always)] pure fn to_int(&self) -> int { *self as int }
331-
332-
#[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 }
333-
#[inline(always)] pure fn to_f64(&self) -> f64 { *self }
334-
#[inline(always)] pure fn to_float(&self) -> float { *self as float }
312+
pure fn to_int(&self) -> int { return *self as int; }
313+
#[inline(always)]
314+
static pure fn from_int(n: int) -> f64 { return n as f64; }
335315
}
336316

337317
impl f64: num::Zero {
@@ -589,63 +569,6 @@ impl f64: num::FromStrRadix {
589569
}
590570
}
591571

592-
#[test]
593-
pub fn test_num() {
594-
let ten: f64 = num::cast(10);
595-
let two: f64 = num::cast(2);
596-
597-
assert (ten.add(&two) == num::cast(12));
598-
assert (ten.sub(&two) == num::cast(8));
599-
assert (ten.mul(&two) == num::cast(20));
600-
assert (ten.div(&two) == num::cast(5));
601-
assert (ten.modulo(&two) == num::cast(0));
602-
}
603-
604-
#[test]
605-
fn test_numcast() {
606-
assert (20u == 20f64.to_uint());
607-
assert (20u8 == 20f64.to_u8());
608-
assert (20u16 == 20f64.to_u16());
609-
assert (20u32 == 20f64.to_u32());
610-
assert (20u64 == 20f64.to_u64());
611-
assert (20i == 20f64.to_int());
612-
assert (20i8 == 20f64.to_i8());
613-
assert (20i16 == 20f64.to_i16());
614-
assert (20i32 == 20f64.to_i32());
615-
assert (20i64 == 20f64.to_i64());
616-
assert (20f == 20f64.to_float());
617-
assert (20f32 == 20f64.to_f32());
618-
assert (20f64 == 20f64.to_f64());
619-
620-
assert (20f64 == NumCast::from(20u));
621-
assert (20f64 == NumCast::from(20u8));
622-
assert (20f64 == NumCast::from(20u16));
623-
assert (20f64 == NumCast::from(20u32));
624-
assert (20f64 == NumCast::from(20u64));
625-
assert (20f64 == NumCast::from(20i));
626-
assert (20f64 == NumCast::from(20i8));
627-
assert (20f64 == NumCast::from(20i16));
628-
assert (20f64 == NumCast::from(20i32));
629-
assert (20f64 == NumCast::from(20i64));
630-
assert (20f64 == NumCast::from(20f));
631-
assert (20f64 == NumCast::from(20f32));
632-
assert (20f64 == NumCast::from(20f64));
633-
634-
assert (20f64 == num::cast(20u));
635-
assert (20f64 == num::cast(20u8));
636-
assert (20f64 == num::cast(20u16));
637-
assert (20f64 == num::cast(20u32));
638-
assert (20f64 == num::cast(20u64));
639-
assert (20f64 == num::cast(20i));
640-
assert (20f64 == num::cast(20i8));
641-
assert (20f64 == num::cast(20i16));
642-
assert (20f64 == num::cast(20i32));
643-
assert (20f64 == num::cast(20i64));
644-
assert (20f64 == num::cast(20f));
645-
assert (20f64 == num::cast(20f32));
646-
assert (20f64 == num::cast(20f64));
647-
}
648-
649572
//
650573
// Local Variables:
651574
// mode: rust

branches/try/src/libcore/num/float.rs

Lines changed: 20 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use cmp::{Eq, Ord};
2626
use cmp;
2727
use f64;
2828
use num;
29-
use num::NumCast;
29+
use num::Num::from_int;
3030
use option::{None, Option, Some};
3131
use str;
3232
use uint;
@@ -417,6 +417,11 @@ impl float: num::Num {
417417
pure fn modulo(&self, other: &float) -> float { return *self % *other; }
418418
#[inline(always)]
419419
pure fn neg(&self) -> float { return -*self; }
420+
421+
#[inline(always)]
422+
pure fn to_int(&self) -> int { return *self as int; }
423+
#[inline(always)]
424+
static pure fn from_int(&self, n: int) -> float { return n as float; }
420425
}
421426
422427
impl float: num::Zero {
@@ -429,30 +434,6 @@ impl float: num::One {
429434
static pure fn one() -> float { 1.0 }
430435
}
431436
432-
pub impl float: NumCast {
433-
/**
434-
* Cast `n` to a `float`
435-
*/
436-
#[inline(always)]
437-
static pure fn from<N:NumCast>(n: N) -> float { n.to_float() }
438-
439-
#[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 }
440-
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }
441-
#[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 }
442-
#[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 }
443-
#[inline(always)] pure fn to_uint(&self) -> uint { *self as uint }
444-
445-
#[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 }
446-
#[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 }
447-
#[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 }
448-
#[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 }
449-
#[inline(always)] pure fn to_int(&self) -> int { *self as int }
450-
451-
#[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 }
452-
#[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 }
453-
#[inline(always)] pure fn to_float(&self) -> float { *self }
454-
}
455-
456437
impl float: num::Round {
457438
#[inline(always)]
458439
pure fn round(&self, mode: num::RoundMode) -> float {
@@ -676,60 +657,21 @@ pub fn test_round() {
676657
}
677658

678659
#[test]
679-
pub fn test_num() {
680-
let ten: float = num::cast(10);
681-
let two: float = num::cast(2);
682-
683-
assert (ten.add(&two) == num::cast(12));
684-
assert (ten.sub(&two) == num::cast(8));
685-
assert (ten.mul(&two) == num::cast(20));
686-
assert (ten.div(&two) == num::cast(5));
687-
assert (ten.modulo(&two) == num::cast(0));
688-
}
660+
pub fn test_traits() {
661+
fn test<U:num::Num cmp::Eq>(ten: &U) {
662+
assert (ten.to_int() == 10);
663+
664+
let two: U = from_int(2);
665+
assert (two.to_int() == 2);
666+
667+
assert (ten.add(&two) == from_int(12));
668+
assert (ten.sub(&two) == from_int(8));
669+
assert (ten.mul(&two) == from_int(20));
670+
assert (ten.div(&two) == from_int(5));
671+
assert (ten.modulo(&two) == from_int(0));
672+
}
689673

690-
#[test]
691-
fn test_numcast() {
692-
assert (20u == 20f.to_uint());
693-
assert (20u8 == 20f.to_u8());
694-
assert (20u16 == 20f.to_u16());
695-
assert (20u32 == 20f.to_u32());
696-
assert (20u64 == 20f.to_u64());
697-
assert (20i == 20f.to_int());
698-
assert (20i8 == 20f.to_i8());
699-
assert (20i16 == 20f.to_i16());
700-
assert (20i32 == 20f.to_i32());
701-
assert (20i64 == 20f.to_i64());
702-
assert (20f == 20f.to_float());
703-
assert (20f32 == 20f.to_f32());
704-
assert (20f64 == 20f.to_f64());
705-
706-
assert (20f == NumCast::from(20u));
707-
assert (20f == NumCast::from(20u8));
708-
assert (20f == NumCast::from(20u16));
709-
assert (20f == NumCast::from(20u32));
710-
assert (20f == NumCast::from(20u64));
711-
assert (20f == NumCast::from(20i));
712-
assert (20f == NumCast::from(20i8));
713-
assert (20f == NumCast::from(20i16));
714-
assert (20f == NumCast::from(20i32));
715-
assert (20f == NumCast::from(20i64));
716-
assert (20f == NumCast::from(20f));
717-
assert (20f == NumCast::from(20f32));
718-
assert (20f == NumCast::from(20f64));
719-
720-
assert (20f == num::cast(20u));
721-
assert (20f == num::cast(20u8));
722-
assert (20f == num::cast(20u16));
723-
assert (20f == num::cast(20u32));
724-
assert (20f == num::cast(20u64));
725-
assert (20f == num::cast(20i));
726-
assert (20f == num::cast(20i8));
727-
assert (20f == num::cast(20i16));
728-
assert (20f == num::cast(20i32));
729-
assert (20f == num::cast(20i64));
730-
assert (20f == num::cast(20f));
731-
assert (20f == num::cast(20f32));
732-
assert (20f == num::cast(20f64));
674+
test(&10.0);
733675
}
734676

735677

0 commit comments

Comments
 (0)