File tree 5 files changed +14
-18
lines changed
5 files changed +14
-18
lines changed Original file line number Diff line number Diff line change 83
83
#![ feature( lang_items) ]
84
84
#![ feature( no_std) ]
85
85
#![ feature( nonzero) ]
86
+ #![ feature( num_bits_bytes) ]
86
87
#![ feature( optin_builtin_traits) ]
87
88
#![ feature( placement_in_syntax) ]
88
89
#![ feature( placement_new_protocol) ]
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use heap;
15
15
use super :: oom;
16
16
use super :: boxed:: Box ;
17
17
use core:: ops:: Drop ;
18
+ use core;
18
19
19
20
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
20
21
/// 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> {
443
444
// user-space. e.g. PAE or x32
444
445
445
446
#[ inline]
446
- #[ cfg( target_pointer_width = "64" ) ]
447
- fn alloc_guard ( _alloc_size : usize ) { }
448
-
449
- #[ inline]
450
- #[ cfg( target_pointer_width = "32" ) ]
451
447
fn 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
+ }
453
451
}
Original file line number Diff line number Diff line change @@ -1340,12 +1340,7 @@ impl<T> Pointer for *const T {
1340
1340
f. flags |= 1 << ( FlagV1 :: SignAwareZeroPad as u32 ) ;
1341
1341
1342
1342
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 ) ;
1349
1344
}
1350
1345
}
1351
1346
f. flags |= 1 << ( FlagV1 :: Alternate as u32 ) ;
Original file line number Diff line number Diff line change @@ -144,11 +144,11 @@ pub trait Hasher {
144
144
#[ inline]
145
145
#[ stable( feature = "hasher_write" , since = "1.3.0" ) ]
146
146
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 ) ;
152
152
}
153
153
154
154
/// 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);
2234
2234
step_impl_unsigned ! ( u64 ) ;
2235
2235
#[ cfg( target_pointer_width = "64" ) ]
2236
2236
step_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" ) ) ]
2238
2240
step_impl_no_between ! ( u64 i64 ) ;
2239
2241
2240
2242
/// An adapter for stepping range iterators by a custom amount.
You can’t perform that action at this time.
0 commit comments