@@ -35,6 +35,7 @@ use std::{cmp, fs};
35
35
36
36
use syntax:: ast;
37
37
use syntax:: attr;
38
+ use syntax:: edition:: Edition ;
38
39
use syntax:: ext:: base:: SyntaxExtension ;
39
40
use syntax:: symbol:: Symbol ;
40
41
use syntax:: visit;
@@ -535,7 +536,10 @@ impl<'a> CrateLoader<'a> {
535
536
mem:: transmute :: < * mut u8 , fn ( & mut Registry ) > ( sym)
536
537
} ;
537
538
538
- struct MyRegistrar ( Vec < ( ast:: Name , Lrc < SyntaxExtension > ) > ) ;
539
+ struct MyRegistrar {
540
+ extensions : Vec < ( ast:: Name , Lrc < SyntaxExtension > ) > ,
541
+ edition : Edition ,
542
+ }
539
543
540
544
impl Registry for MyRegistrar {
541
545
fn register_custom_derive ( & mut self ,
@@ -544,36 +548,38 @@ impl<'a> CrateLoader<'a> {
544
548
attributes : & [ & ' static str ] ) {
545
549
let attrs = attributes. iter ( ) . cloned ( ) . map ( Symbol :: intern) . collect :: < Vec < _ > > ( ) ;
546
550
let derive = ProcMacroDerive :: new ( expand, attrs. clone ( ) ) ;
547
- let derive = SyntaxExtension :: ProcMacroDerive ( Box :: new ( derive) , attrs) ;
548
- self . 0 . push ( ( Symbol :: intern ( trait_name) , Lrc :: new ( derive) ) ) ;
551
+ let derive = SyntaxExtension :: ProcMacroDerive (
552
+ Box :: new ( derive) , attrs, self . edition
553
+ ) ;
554
+ self . extensions . push ( ( Symbol :: intern ( trait_name) , Lrc :: new ( derive) ) ) ;
549
555
}
550
556
551
557
fn register_attr_proc_macro ( & mut self ,
552
558
name : & str ,
553
559
expand : fn ( TokenStream , TokenStream ) -> TokenStream ) {
554
560
let expand = SyntaxExtension :: AttrProcMacro (
555
- Box :: new ( AttrProcMacro { inner : expand } )
561
+ Box :: new ( AttrProcMacro { inner : expand } ) , self . edition
556
562
) ;
557
- self . 0 . push ( ( Symbol :: intern ( name) , Lrc :: new ( expand) ) ) ;
563
+ self . extensions . push ( ( Symbol :: intern ( name) , Lrc :: new ( expand) ) ) ;
558
564
}
559
565
560
566
fn register_bang_proc_macro ( & mut self ,
561
567
name : & str ,
562
568
expand : fn ( TokenStream ) -> TokenStream ) {
563
569
let expand = SyntaxExtension :: ProcMacro (
564
- Box :: new ( BangProcMacro { inner : expand } )
570
+ Box :: new ( BangProcMacro { inner : expand } ) , self . edition
565
571
) ;
566
- self . 0 . push ( ( Symbol :: intern ( name) , Lrc :: new ( expand) ) ) ;
572
+ self . extensions . push ( ( Symbol :: intern ( name) , Lrc :: new ( expand) ) ) ;
567
573
}
568
574
}
569
575
570
- let mut my_registrar = MyRegistrar ( Vec :: new ( ) ) ;
576
+ let mut my_registrar = MyRegistrar { extensions : Vec :: new ( ) , edition : root . edition } ;
571
577
registrar ( & mut my_registrar) ;
572
578
573
579
// Intentionally leak the dynamic library. We can't ever unload it
574
580
// since the library can make things that will live arbitrarily long.
575
581
mem:: forget ( lib) ;
576
- my_registrar. 0
582
+ my_registrar. extensions
577
583
}
578
584
579
585
/// Look for a plugin registrar. Returns library path, crate
0 commit comments