@@ -27,21 +27,20 @@ use crate::{
2727 ast:: { self , AstNode } ,
2828 db:: ExpandDatabase ,
2929 mod_path:: ModPath ,
30- EagerCallInfo , ExpandError , ExpandResult , ExpandTo , ExpansionSpanMap , InFile , Intern ,
30+ AstId , EagerCallInfo , ExpandError , ExpandResult , ExpandTo , ExpansionSpanMap , InFile , Intern ,
3131 MacroCallId , MacroCallKind , MacroCallLoc , MacroDefId , MacroDefKind ,
3232} ;
3333
3434pub fn expand_eager_macro_input (
3535 db : & dyn ExpandDatabase ,
3636 krate : CrateId ,
37- macro_call : InFile < ast:: MacroCall > ,
37+ macro_call : & ast:: MacroCall ,
38+ ast_id : AstId < ast:: MacroCall > ,
3839 def : MacroDefId ,
3940 call_site : Span ,
4041 resolver : & dyn Fn ( ModPath ) -> Option < MacroDefId > ,
4142) -> ExpandResult < Option < MacroCallId > > {
42- let ast_map = db. ast_id_map ( macro_call. file_id ) ;
43- let call_id = InFile :: new ( macro_call. file_id , ast_map. ast_id ( & macro_call. value ) ) ;
44- let expand_to = ExpandTo :: from_call_site ( & macro_call. value ) ;
43+ let expand_to = ExpandTo :: from_call_site ( macro_call) ;
4544
4645 // Note:
4746 // When `lazy_expand` is called, its *parent* file must already exist.
@@ -50,7 +49,7 @@ pub fn expand_eager_macro_input(
5049 let arg_id = MacroCallLoc {
5150 def,
5251 krate,
53- kind : MacroCallKind :: FnLike { ast_id : call_id , expand_to : ExpandTo :: Expr , eager : None } ,
52+ kind : MacroCallKind :: FnLike { ast_id, expand_to : ExpandTo :: Expr , eager : None } ,
5453 call_site,
5554 }
5655 . intern ( db) ;
@@ -87,9 +86,8 @@ pub fn expand_eager_macro_input(
8786 let loc = MacroCallLoc {
8887 def,
8988 krate,
90-
9189 kind : MacroCallKind :: FnLike {
92- ast_id : call_id ,
90+ ast_id,
9391 expand_to,
9492 eager : Some ( Arc :: new ( EagerCallInfo {
9593 arg : Arc :: new ( subtree) ,
@@ -106,14 +104,12 @@ pub fn expand_eager_macro_input(
106104fn lazy_expand (
107105 db : & dyn ExpandDatabase ,
108106 def : & MacroDefId ,
109- macro_call : InFile < ast:: MacroCall > ,
107+ macro_call : & ast:: MacroCall ,
108+ ast_id : AstId < ast:: MacroCall > ,
110109 krate : CrateId ,
111110 call_site : Span ,
112111) -> ExpandResult < ( InFile < Parse < SyntaxNode > > , Arc < ExpansionSpanMap > ) > {
113- let ast_id = db. ast_id_map ( macro_call. file_id ) . ast_id ( & macro_call. value ) ;
114-
115- let expand_to = ExpandTo :: from_call_site ( & macro_call. value ) ;
116- let ast_id = macro_call. with_value ( ast_id) ;
112+ let expand_to = ExpandTo :: from_call_site ( macro_call) ;
117113 let id = def. make_call (
118114 db,
119115 krate,
@@ -183,12 +179,14 @@ fn eager_macro_recur(
183179 continue ;
184180 }
185181 } ;
182+ let ast_id = db. ast_id_map ( curr. file_id ) . ast_id ( & call) ;
186183 let ExpandResult { value, err } = match def. kind {
187184 MacroDefKind :: BuiltInEager ( ..) => {
188185 let ExpandResult { value, err } = expand_eager_macro_input (
189186 db,
190187 krate,
191- curr. with_value ( call. clone ( ) ) ,
188+ & call,
189+ curr. with_value ( ast_id) ,
192190 def,
193191 call_site,
194192 macro_resolver,
@@ -218,7 +216,7 @@ fn eager_macro_recur(
218216 | MacroDefKind :: BuiltInDerive ( ..)
219217 | MacroDefKind :: ProcMacro ( ..) => {
220218 let ExpandResult { value : ( parse, tm) , err } =
221- lazy_expand ( db, & def, curr. with_value ( call . clone ( ) ) , krate, call_site) ;
219+ lazy_expand ( db, & def, & call , curr. with_value ( ast_id ) , krate, call_site) ;
222220
223221 // replace macro inside
224222 let ExpandResult { value, err : error } = eager_macro_recur (
0 commit comments