@@ -531,8 +531,9 @@ impl ExprCollector<'_> {
531531 }
532532 }
533533 ast:: Expr :: MacroCall ( e) => {
534+ let macro_ptr = AstPtr :: new ( & e) ;
534535 let mut ids = vec ! [ ] ;
535- self . collect_macro_call ( e, syntax_ptr . clone ( ) , true , |this, expansion| {
536+ self . collect_macro_call ( e, macro_ptr , true , |this, expansion| {
536537 ids. push ( match expansion {
537538 Some ( it) => this. collect_expr ( it) ,
538539 None => this. alloc_expr ( Expr :: Missing , syntax_ptr. clone ( ) ) ,
@@ -555,7 +556,7 @@ impl ExprCollector<'_> {
555556 fn collect_macro_call < F : FnMut ( & mut Self , Option < T > ) , T : ast:: AstNode > (
556557 & mut self ,
557558 e : ast:: MacroCall ,
558- syntax_ptr : AstPtr < ast:: Expr > ,
559+ syntax_ptr : AstPtr < ast:: MacroCall > ,
559560 is_error_recoverable : bool ,
560561 mut collector : F ,
561562 ) {
@@ -643,10 +644,14 @@ impl ExprCollector<'_> {
643644
644645 // Note that macro could be expended to multiple statements
645646 if let Some ( ast:: Expr :: MacroCall ( m) ) = stmt. expr ( ) {
647+ let macro_ptr = AstPtr :: new ( & m) ;
646648 let syntax_ptr = AstPtr :: new ( & stmt. expr ( ) . unwrap ( ) ) ;
647649
648- self . collect_macro_call ( m, syntax_ptr. clone ( ) , false , |this, expansion| {
649- match expansion {
650+ self . collect_macro_call (
651+ m,
652+ macro_ptr,
653+ false ,
654+ |this, expansion| match expansion {
650655 Some ( expansion) => {
651656 let statements: ast:: MacroStmts = expansion;
652657
@@ -660,8 +665,8 @@ impl ExprCollector<'_> {
660665 let expr = this. alloc_expr ( Expr :: Missing , syntax_ptr. clone ( ) ) ;
661666 this. statements_in_scope . push ( Statement :: Expr ( expr) ) ;
662667 }
663- }
664- } ) ;
668+ } ,
669+ ) ;
665670 } else {
666671 let expr = self . collect_expr_opt ( stmt. expr ( ) ) ;
667672 self . statements_in_scope . push ( Statement :: Expr ( expr) ) ;
@@ -848,8 +853,23 @@ impl ExprCollector<'_> {
848853 Pat :: Missing
849854 }
850855 }
856+ ast:: Pat :: MacroPat ( mac) => match mac. macro_call ( ) {
857+ Some ( call) => {
858+ let macro_ptr = AstPtr :: new ( & call) ;
859+ let mut pat = None ;
860+ self . collect_macro_call ( call, macro_ptr, true , |this, expanded_pat| {
861+ pat = Some ( this. collect_pat_opt ( expanded_pat) ) ;
862+ } ) ;
863+
864+ match pat {
865+ Some ( pat) => return pat,
866+ None => Pat :: Missing ,
867+ }
868+ }
869+ None => Pat :: Missing ,
870+ } ,
851871 // FIXME: implement
852- ast:: Pat :: RangePat ( _) | ast :: Pat :: MacroPat ( _ ) => Pat :: Missing ,
872+ ast:: Pat :: RangePat ( _) => Pat :: Missing ,
853873 } ;
854874 let ptr = AstPtr :: new ( & pat) ;
855875 self . alloc_pat ( pattern, Either :: Left ( ptr) )
0 commit comments