@@ -13,52 +13,19 @@ mod inner {
13
13
Err ( _) => Err ( ( ) ) ,
14
14
}
15
15
}
16
-
17
- #[ cfg( feature = "bumpalo" ) ]
18
- unsafe impl Allocator for crate :: BumpWrapper < ' _ > {
19
- #[ inline]
20
- fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , core:: alloc:: AllocError > {
21
- match self . 0 . try_alloc_layout ( layout) {
22
- Ok ( ptr) => Ok ( NonNull :: slice_from_raw_parts ( ptr, layout. size ( ) ) ) ,
23
- Err ( _) => Err ( core:: alloc:: AllocError ) ,
24
- }
25
- }
26
- #[ inline]
27
- unsafe fn deallocate ( & self , _ptr : NonNull < u8 > , _layout : Layout ) { }
28
- }
29
16
}
30
17
31
18
#[ cfg( not( feature = "nightly" ) ) ]
32
19
mod inner {
33
20
use crate :: alloc:: alloc:: Layout ;
34
- use core:: ptr:: NonNull ;
35
-
36
- #[ cfg( feature = "bumpalo" ) ]
37
- use allocator_api2:: alloc:: AllocError ;
38
-
39
21
pub use allocator_api2:: alloc:: { Allocator , Global } ;
22
+ use core:: ptr:: NonNull ;
40
23
24
+ #[ allow( clippy:: map_err_ignore) ]
41
25
pub ( crate ) fn do_alloc < A : Allocator > ( alloc : & A , layout : Layout ) -> Result < NonNull < u8 > , ( ) > {
42
26
match alloc. allocate ( layout) {
43
27
Ok ( ptr) => Ok ( ptr. cast ( ) ) ,
44
28
Err ( _) => Err ( ( ) ) ,
45
29
}
46
30
}
47
-
48
- #[ cfg( feature = "bumpalo" ) ]
49
- unsafe impl Allocator for crate :: BumpWrapper < ' _ > {
50
- #[ allow( clippy:: map_err_ignore) ]
51
- fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocError > {
52
- match self . 0 . try_alloc_layout ( layout) {
53
- Ok ( ptr) => Ok ( unsafe {
54
- NonNull :: new_unchecked ( core:: ptr:: slice_from_raw_parts_mut (
55
- ptr. as_ptr ( ) ,
56
- layout. size ( ) ,
57
- ) )
58
- } ) ,
59
- Err ( _) => Err ( AllocError ) ,
60
- }
61
- }
62
- unsafe fn deallocate ( & self , _ptr : NonNull < u8 > , _layout : Layout ) { }
63
- }
64
31
}
0 commit comments