File tree Expand file tree Collapse file tree 5 files changed +14
-18
lines changed Expand file tree Collapse file tree 5 files changed +14
-18
lines changed Original file line number Diff line number Diff line change 8383#![ feature( lang_items) ]
8484#![ feature( no_std) ]
8585#![ feature( nonzero) ]
86+ #![ feature( num_bits_bytes) ]
8687#![ feature( optin_builtin_traits) ]
8788#![ feature( placement_in_syntax) ]
8889#![ feature( placement_new_protocol) ]
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use heap;
1515use super :: oom;
1616use super :: boxed:: Box ;
1717use core:: ops:: Drop ;
18+ use core;
1819
1920/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
2021/// a buffer of memory on the heap without having to worry about all the corner cases
@@ -443,11 +444,8 @@ impl<T> Drop for RawVec<T> {
443444// user-space. e.g. PAE or x32
444445
445446#[ inline]
446- #[ cfg( target_pointer_width = "64" ) ]
447- fn alloc_guard ( _alloc_size : usize ) { }
448-
449- #[ inline]
450- #[ cfg( target_pointer_width = "32" ) ]
451447fn alloc_guard ( alloc_size : usize ) {
452- assert ! ( alloc_size <= :: core:: isize :: MAX as usize , "capacity overflow" ) ;
448+ if core:: usize:: BITS < 64 {
449+ assert ! ( alloc_size <= :: core:: isize :: MAX as usize , "capacity overflow" ) ;
450+ }
453451}
Original file line number Diff line number Diff line change @@ -1340,12 +1340,7 @@ impl<T> Pointer for *const T {
13401340 f. flags |= 1 << ( FlagV1 :: SignAwareZeroPad as u32 ) ;
13411341
13421342 if let None = f. width {
1343- // The formats need two extra bytes, for the 0x
1344- if cfg ! ( target_pointer_width = "32" ) {
1345- f. width = Some ( 10 ) ;
1346- } else {
1347- f. width = Some ( 18 ) ;
1348- }
1343+ f. width = Some ( ( :: usize:: BITS /4 ) + 2 ) ;
13491344 }
13501345 }
13511346 f. flags |= 1 << ( FlagV1 :: Alternate as u32 ) ;
Original file line number Diff line number Diff line change @@ -144,11 +144,11 @@ pub trait Hasher {
144144 #[ inline]
145145 #[ stable( feature = "hasher_write" , since = "1.3.0" ) ]
146146 fn write_usize ( & mut self , i : usize ) {
147- if cfg ! ( target_pointer_width = "32" ) {
148- self . write_u32 ( i as u32 )
149- } else {
150- self . write_u64 ( i as u64 )
151- }
147+ let bytes = unsafe {
148+ :: slice :: from_raw_parts ( & i as * const usize as * const u8 ,
149+ mem :: size_of :: < usize > ( ) )
150+ } ;
151+ self . write ( bytes ) ;
152152 }
153153
154154 /// Write a single `i8` into this hasher.
Original file line number Diff line number Diff line change @@ -2234,7 +2234,9 @@ step_impl_signed!(isize i8 i16 i32);
22342234step_impl_unsigned ! ( u64 ) ;
22352235#[ cfg( target_pointer_width = "64" ) ]
22362236step_impl_signed ! ( i64 ) ;
2237- #[ cfg( target_pointer_width = "32" ) ]
2237+ // If the target pointer width is not 64-bits, we
2238+ // assume here that it is less than 64-bits.
2239+ #[ cfg( not( target_pointer_width = "64" ) ) ]
22382240step_impl_no_between ! ( u64 i64 ) ;
22392241
22402242/// An adapter for stepping range iterators by a custom amount.
You can’t perform that action at this time.
0 commit comments