File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change @@ -2543,7 +2543,6 @@ mod test_map {
2543
2543
use super :: HashMap ;
2544
2544
use rand:: { thread_rng, Rng } ;
2545
2545
use std:: cell:: RefCell ;
2546
- use std:: mem:: size_of;
2547
2546
use std:: usize;
2548
2547
use std:: vec:: Vec ;
2549
2548
use CollectionAllocErr :: * ;
@@ -3406,30 +3405,14 @@ mod test_map {
3406
3405
3407
3406
const MAX_USIZE : usize = usize:: MAX ;
3408
3407
3409
- // HashMap and RawTables use complicated size calculations
3410
- // hashes_size is sizeof(u8) * capacity;
3411
- // pairs_size is sizeof((K. V)) * capacity;
3412
- // alignment_hashes_size is 8
3413
- // alignment_pairs size is 4
3414
- let size_of_multiplier = ( size_of :: < u8 > ( ) + size_of :: < ( u8 , u8 ) > ( ) ) . next_power_of_two ( ) ;
3415
- // The following formula is used to calculate the new capacity
3416
- let max_no_ovf = ( ( MAX_USIZE / 8 ) * 7 ) / size_of_multiplier - 1 ;
3417
-
3418
3408
if let Err ( CapacityOverflow ) = empty_bytes. try_reserve ( MAX_USIZE ) {
3419
3409
} else {
3420
3410
panic ! ( "usize::MAX should trigger an overflow!" ) ;
3421
3411
}
3422
3412
3423
- if size_of :: < usize > ( ) < 8 {
3424
- if let Err ( CapacityOverflow ) = empty_bytes. try_reserve ( max_no_ovf) {
3425
- } else {
3426
- panic ! ( "isize::MAX + 1 should trigger a CapacityOverflow!" )
3427
- }
3413
+ if let Err ( AllocErr ) = empty_bytes. try_reserve ( MAX_USIZE / 8 ) {
3428
3414
} else {
3429
- if let Err ( AllocErr ) = empty_bytes. try_reserve ( max_no_ovf) {
3430
- } else {
3431
- panic ! ( "isize::MAX + 1 should trigger an OOM!" )
3432
- }
3415
+ panic ! ( "usize::MAX / 8 should trigger an OOM!" )
3433
3416
}
3434
3417
}
3435
3418
You can’t perform that action at this time.
0 commit comments