@@ -106,30 +106,22 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
106106 span,
107107 kind : AllocatorKind :: Global ,
108108 global : item. ident ,
109- core : Ident :: from_str ( "core" ) ,
109+ core : Ident :: with_empty_ctxt ( Symbol :: gensym ( "core" ) ) ,
110110 cx : ExtCtxt :: new ( self . sess , ecfg, self . resolver ) ,
111111 } ;
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+ } ;
129117
130118 let mut ret = SmallVector :: new ( ) ;
131119 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+ } ) ) ;
133125 return ret;
134126 }
135127
@@ -182,6 +174,7 @@ impl<'a> AllocFnFactory<'a> {
182174 let method = self . cx . path (
183175 self . span ,
184176 vec ! [
177+ Ident :: from_str( "self" ) ,
185178 self . core,
186179 Ident :: from_str( "alloc" ) ,
187180 Ident :: from_str( "GlobalAlloc" ) ,
@@ -232,6 +225,7 @@ impl<'a> AllocFnFactory<'a> {
232225 let layout_new = self . cx . path (
233226 self . span ,
234227 vec ! [
228+ Ident :: from_str( "self" ) ,
235229 self . core,
236230 Ident :: from_str( "alloc" ) ,
237231 Ident :: from_str( "Layout" ) ,
@@ -298,6 +292,7 @@ impl<'a> AllocFnFactory<'a> {
298292 let opaque = self . cx . path (
299293 self . span ,
300294 vec ! [
295+ Ident :: from_str( "self" ) ,
301296 self . core,
302297 Ident :: from_str( "alloc" ) ,
303298 Ident :: from_str( "Opaque" ) ,
0 commit comments