@@ -106,30 +106,22 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
106
106
span,
107
107
kind : AllocatorKind :: Global ,
108
108
global : item. ident ,
109
- core : Ident :: from_str ( "core" ) ,
109
+ core : Ident :: with_empty_ctxt ( Symbol :: gensym ( "core" ) ) ,
110
110
cx : ExtCtxt :: new ( self . sess , ecfg, self . resolver ) ,
111
111
} ;
112
- //let super_path = f.cx.path(f.span, vec![Ident::from_str("super"), f.global]);
113
- let super_path = f. cx . path ( f. span , vec ! [ f. global] ) ;
114
- let mut items = vec ! [
115
- f. cx. item_extern_crate( f. span, f. core) ,
116
- f. cx. item_use_simple(
117
- f. span,
118
- respan( f. span. shrink_to_lo( ) , VisibilityKind :: Inherited ) ,
119
- super_path,
120
- ) ,
121
- ] ;
122
- for method in ALLOCATOR_METHODS {
123
- items. push ( f. allocator_fn ( method) ) ;
124
- }
125
- let name = f. kind . fn_name ( "allocator_abi" ) ;
126
- let allocator_abi = Ident :: with_empty_ctxt ( Symbol :: gensym ( & name) ) ;
127
- let module = f. cx . item_mod ( span, span, allocator_abi, Vec :: new ( ) , items) ;
128
- let module = f. cx . monotonic_expander ( ) . fold_item ( module) . pop ( ) . unwrap ( ) ;
112
+
113
+ let extcore = {
114
+ let extcore = f. cx . item_extern_crate ( item. span , f. core ) ;
115
+ f. cx . monotonic_expander ( ) . fold_item ( extcore) . pop ( ) . unwrap ( )
116
+ } ;
129
117
130
118
let mut ret = SmallVector :: new ( ) ;
131
119
ret. push ( item) ;
132
- ret. push ( module) ;
120
+ ret. push ( extcore) ;
121
+ ret. extend ( ALLOCATOR_METHODS . iter ( ) . map ( |method| {
122
+ let method = f. allocator_fn ( method) ;
123
+ f. cx . monotonic_expander ( ) . fold_item ( method) . pop ( ) . unwrap ( )
124
+ } ) ) ;
133
125
return ret;
134
126
}
135
127
@@ -182,6 +174,7 @@ impl<'a> AllocFnFactory<'a> {
182
174
let method = self . cx . path (
183
175
self . span ,
184
176
vec ! [
177
+ Ident :: from_str( "self" ) ,
185
178
self . core,
186
179
Ident :: from_str( "alloc" ) ,
187
180
Ident :: from_str( "GlobalAlloc" ) ,
@@ -232,6 +225,7 @@ impl<'a> AllocFnFactory<'a> {
232
225
let layout_new = self . cx . path (
233
226
self . span ,
234
227
vec ! [
228
+ Ident :: from_str( "self" ) ,
235
229
self . core,
236
230
Ident :: from_str( "alloc" ) ,
237
231
Ident :: from_str( "Layout" ) ,
@@ -298,6 +292,7 @@ impl<'a> AllocFnFactory<'a> {
298
292
let opaque = self . cx . path (
299
293
self . span ,
300
294
vec ! [
295
+ Ident :: from_str( "self" ) ,
301
296
self . core,
302
297
Ident :: from_str( "alloc" ) ,
303
298
Ident :: from_str( "Opaque" ) ,
0 commit comments