about summary refs log tree commit diff
path: root/src/libstd/num/i8.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-04-14 20:04:14 +1000
committerAlex Crichton <alex@alexcrichton.com>2014-04-15 19:45:00 -0700
commit54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d (patch)
treeefe91e930ac4527e3057fe65571df112ef5b8607 /src/libstd/num/i8.rs
parent93dc55518840ee3cbd570c0d85aa7a445752af8b (diff)
downloadrust-54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d.tar.gz
rust-54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d.zip
Use the unsigned integer types for bitwise intrinsics.
Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just
exposing the internal LLVM names pointlessly (LLVM doesn't have "signed
integers" or "unsigned integers", it just has sized integer types
with (un)signed *operations*).

These operations are semantically working with raw bytes, which the
unsigned types model better.
Diffstat (limited to 'src/libstd/num/i8.rs')
-rw-r--r--src/libstd/num/i8.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs
index 061ffddf231..2d349fa7f4f 100644
--- a/src/libstd/num/i8.rs
+++ b/src/libstd/num/i8.rs
@@ -28,17 +28,17 @@ int_module!(i8, 8)
 impl Bitwise for i8 {
     /// Returns the number of ones in the binary representation of the number.
     #[inline]
-    fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
+    fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self as u8) as i8 } }
 
     /// Returns the number of leading zeros in the in the binary representation
     /// of the number.
     #[inline]
-    fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
+    fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self as u8) as i8 } }
 
     /// Returns the number of trailing zeros in the in the binary representation
     /// of the number.
     #[inline]
-    fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
+    fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self as u8) as i8 } }
 }
 
 impl CheckedAdd for i8 {