11use alloc_wg:: {
2+ alloc:: Global ,
23 boxed:: Box ,
34 collections:: CollectionAllocErr :: * ,
45 vec,
@@ -1125,7 +1126,7 @@ fn test_try_reserve() {
11251126
11261127 {
11271128 // Note: basic stuff is checked by test_reserve
1128- let mut empty_bytes: Vec < u8 , _ > = Vec :: new ( ) ;
1129+ let mut empty_bytes: Vec < u8 , _ > = Vec :: new_in ( Global ) ;
11291130
11301131 // Check isize::MAX doesn't count as an overflow
11311132 if let Err ( CapacityOverflow ) = empty_bytes. try_reserve ( MAX_CAP ) {
@@ -1163,7 +1164,8 @@ fn test_try_reserve() {
11631164
11641165 {
11651166 // Same basic idea, but with non-zero len
1166- let mut ten_bytes: Vec < u8 > = vec ! [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
1167+ let mut ten_bytes: Vec < u8 , _ > = vec ! [ try in Global ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1168+ . expect ( "Unable to allocate ten bytes" ) ;
11671169
11681170 if let Err ( CapacityOverflow ) = ten_bytes. try_reserve ( MAX_CAP - 10 ) {
11691171 panic ! ( "isize::MAX shouldn't trigger an overflow!" ) ;
@@ -1188,7 +1190,8 @@ fn test_try_reserve() {
11881190
11891191 {
11901192 // Same basic idea, but with interesting type size
1191- let mut ten_u32s: Vec < u32 > = vec ! [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
1193+ let mut ten_u32s: Vec < u32 , _ > = vec ! [ try in Global ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1194+ . expect ( "Unable to allocate 40 bytes" ) ;
11921195
11931196 if let Err ( CapacityOverflow ) = ten_u32s. try_reserve ( MAX_CAP / 4 - 10 ) {
11941197 panic ! ( "isize::MAX shouldn't trigger an overflow!" ) ;
@@ -1225,7 +1228,7 @@ fn test_try_reserve_exact() {
12251228 let guards_against_isize = size_of :: < usize > ( ) < 8 ;
12261229
12271230 {
1228- let mut empty_bytes: Vec < u8 > = Vec :: new ( ) ;
1231+ let mut empty_bytes: Vec < u8 , _ > = Vec :: new_in ( Global ) ;
12291232
12301233 if let Err ( CapacityOverflow ) = empty_bytes. try_reserve_exact ( MAX_CAP ) {
12311234 panic ! ( "isize::MAX shouldn't trigger an overflow!" ) ;
@@ -1256,7 +1259,8 @@ fn test_try_reserve_exact() {
12561259 }
12571260
12581261 {
1259- let mut ten_bytes: Vec < u8 > = vec ! [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
1262+ let mut ten_bytes: Vec < u8 , _ > = vec ! [ try in Global ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1263+ . expect ( "Unable to allocate ten bytes" ) ;
12601264
12611265 if let Err ( CapacityOverflow ) = ten_bytes. try_reserve_exact ( MAX_CAP - 10 ) {
12621266 panic ! ( "isize::MAX shouldn't trigger an overflow!" ) ;
@@ -1279,7 +1283,8 @@ fn test_try_reserve_exact() {
12791283 }
12801284
12811285 {
1282- let mut ten_u32s: Vec < u32 > = vec ! [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
1286+ let mut ten_u32s: Vec < u32 , _ > = vec ! [ try in Global ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1287+ . expect ( "Unable to allocate 40 bytes" ) ;
12831288
12841289 if let Err ( CapacityOverflow ) = ten_u32s. try_reserve_exact ( MAX_CAP / 4 - 10 ) {
12851290 panic ! ( "isize::MAX shouldn't trigger an overflow!" ) ;
0 commit comments