Skip to content

Commit f6411db

Browse files
committed
---
yaml --- r: 160019 b: refs/heads/try c: 7e57cd8 h: refs/heads/master i: 160017: 8dcc482 160015: e9158fb v: v3
1 parent b2395eb commit f6411db

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
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: e09d98603e608c9e47d4c89f7b4dca87a4b56da3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9c96a79a74f10bed18b031ce0ac4126c56d6cfb3
5-
refs/heads/try: d431a67cecc426a4d24dcf24d72a9147b8e08860
5+
refs/heads/try: 7e57cd843ccf303d1387ced8d331cb1c19cdaf1c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,18 @@ pub trait Int: Primitive
549549
}
550550
}
551551

552-
macro_rules! int_impl {
553-
($T:ty, $BITS:expr, $ctpop:path, $ctlz:path, $cttz:path, $bswap:path) => {
552+
macro_rules! uint_impl {
553+
($T:ty, $ActualT:ty, $BITS:expr,
554+
$ctpop:path, $ctlz:path, $cttz:path, $bswap:path) => {
554555
impl Int for $T {
555556
#[inline]
556-
fn count_ones(self) -> uint { unsafe { $ctpop(self) as uint } }
557+
fn count_ones(self) -> uint { unsafe { $ctpop(self as $ActualT) as uint } }
557558

558559
#[inline]
559-
fn leading_zeros(self) -> uint { unsafe { $ctlz(self) as uint } }
560+
fn leading_zeros(self) -> uint { unsafe { $ctlz(self as $ActualT) as uint } }
560561

561562
#[inline]
562-
fn trailing_zeros(self) -> uint { unsafe { $cttz(self) as uint } }
563+
fn trailing_zeros(self) -> uint { unsafe { $cttz(self as $ActualT) as uint } }
563564

564565
#[inline]
565566
fn rotate_left(self, n: uint) -> $T {
@@ -576,7 +577,7 @@ macro_rules! int_impl {
576577
}
577578

578579
#[inline]
579-
fn swap_bytes(self) -> $T { unsafe { $bswap(self) } }
580+
fn swap_bytes(self) -> $T { unsafe { $bswap(self as $ActualT) as $T } }
580581
}
581582
}
582583
}
@@ -585,31 +586,45 @@ macro_rules! int_impl {
585586
/// consistency with the other `bswap` intrinsics.
586587
unsafe fn bswap8(x: u8) -> u8 { x }
587588

588-
int_impl!(u8, 8,
589+
uint_impl!(u8, u8, 8,
589590
intrinsics::ctpop8,
590591
intrinsics::ctlz8,
591592
intrinsics::cttz8,
592593
bswap8)
593594

594-
int_impl!(u16, 16,
595+
uint_impl!(u16, u16, 16,
595596
intrinsics::ctpop16,
596597
intrinsics::ctlz16,
597598
intrinsics::cttz16,
598599
intrinsics::bswap16)
599600

600-
int_impl!(u32, 32,
601+
uint_impl!(u32, u32, 32,
601602
intrinsics::ctpop32,
602603
intrinsics::ctlz32,
603604
intrinsics::cttz32,
604605
intrinsics::bswap32)
605606

606-
int_impl!(u64, 64,
607+
uint_impl!(u64, u64, 64,
607608
intrinsics::ctpop64,
608609
intrinsics::ctlz64,
609610
intrinsics::cttz64,
610611
intrinsics::bswap64)
611612

612-
macro_rules! int_cast_impl {
613+
#[cfg(target_word_size = "32")]
614+
uint_impl!(uint, u32, 32,
615+
intrinsics::ctpop32,
616+
intrinsics::ctlz32,
617+
intrinsics::cttz32,
618+
intrinsics::bswap32)
619+
620+
#[cfg(target_word_size = "64")]
621+
uint_impl!(uint, u64, 64,
622+
intrinsics::ctpop64,
623+
intrinsics::ctlz64,
624+
intrinsics::cttz64,
625+
intrinsics::bswap64)
626+
627+
macro_rules! int_impl {
613628
($T:ty, $U:ty) => {
614629
impl Int for $T {
615630
#[inline]
@@ -633,15 +648,12 @@ macro_rules! int_cast_impl {
633648
}
634649
}
635650

636-
int_cast_impl!(i8, u8)
637-
int_cast_impl!(i16, u16)
638-
int_cast_impl!(i32, u32)
639-
int_cast_impl!(i64, u64)
640-
641-
#[cfg(target_word_size = "32")] int_cast_impl!(uint, u32)
642-
#[cfg(target_word_size = "64")] int_cast_impl!(uint, u64)
643-
#[cfg(target_word_size = "32")] int_cast_impl!(int, u32)
644-
#[cfg(target_word_size = "64")] int_cast_impl!(int, u64)
651+
int_impl!(i8, u8)
652+
int_impl!(i16, u16)
653+
int_impl!(i32, u32)
654+
int_impl!(i64, u64)
655+
#[cfg(target_word_size = "32")] int_impl!(int, u32)
656+
#[cfg(target_word_size = "64")] int_impl!(int, u64)
645657

646658
/// Unsigned integers
647659
pub trait UnsignedInt: Int {

0 commit comments

Comments
 (0)