@@ -26,12 +26,21 @@ use alloc::collections::VecDeque;
26
26
use alloc:: rc:: Rc ;
27
27
use alloc:: string:: String ;
28
28
use alloc:: vec:: Vec ;
29
+ use allocator_api2:: alloc:: Allocator ;
29
30
use core:: cmp:: Ordering ;
30
31
use core:: convert:: identity;
31
32
use core:: fmt:: Debug ;
32
33
use core:: ops:: { Deref , DerefMut } ;
33
34
use smallvec:: SmallVec ;
34
35
36
+ #[ cfg( not( feature = "allocator-api2" ) ) ]
37
+ use core as allocator_api2;
38
+
39
+ #[ cfg( not( feature = "allocator-api2" ) ) ]
40
+ use alloc:: vec as bump_vec;
41
+ #[ cfg( feature = "allocator-api2" ) ]
42
+ use allocator_api2:: vec as bump_vec;
43
+
35
44
#[ derive( Debug , Clone , Default ) ]
36
45
pub struct Bump ( Rc < bumpalo:: Bump > ) ;
37
46
@@ -42,7 +51,7 @@ impl Bump {
42
51
}
43
52
44
53
// simply delegating beause `Rc<bumpalo::Bump>` does not implement `Allocator`
45
- unsafe impl allocator_api2 :: alloc :: Allocator for Bump {
54
+ unsafe impl Allocator for Bump {
46
55
fn allocate (
47
56
& self ,
48
57
layout : core:: alloc:: Layout ,
@@ -85,7 +94,8 @@ unsafe impl allocator_api2::alloc::Allocator for Bump {
85
94
old_layout : core:: alloc:: Layout ,
86
95
new_layout : core:: alloc:: Layout ,
87
96
) -> Result < core:: ptr:: NonNull < [ u8 ] > , allocator_api2:: alloc:: AllocError > {
88
- self . 0 . deref ( ) . shrink ( ptr, old_layout, new_layout)
97
+ let f = self . 0 . deref ( ) . shrink ( ptr, old_layout, new_layout) ;
98
+ f
89
99
}
90
100
}
91
101
@@ -230,8 +240,8 @@ pub struct LiveRangeListEntry {
230
240
pub index : LiveRangeIndex ,
231
241
}
232
242
233
- pub type LiveRangeList = allocator_api2 :: vec :: Vec < LiveRangeListEntry , Bump > ;
234
- pub type UseList = allocator_api2 :: vec :: Vec < Use , Bump > ;
243
+ pub type LiveRangeList = bump_vec :: Vec < LiveRangeListEntry , Bump > ;
244
+ pub type UseList = bump_vec :: Vec < Use , Bump > ;
235
245
236
246
#[ derive( Clone , Debug ) ]
237
247
pub struct LiveRange {
0 commit comments