@@ -27,21 +27,20 @@ use crate::{
27
27
ast:: { self , AstNode } ,
28
28
db:: ExpandDatabase ,
29
29
mod_path:: ModPath ,
30
- EagerCallInfo , ExpandError , ExpandResult , ExpandTo , ExpansionSpanMap , InFile , Intern ,
30
+ AstId , EagerCallInfo , ExpandError , ExpandResult , ExpandTo , ExpansionSpanMap , InFile , Intern ,
31
31
MacroCallId , MacroCallKind , MacroCallLoc , MacroDefId , MacroDefKind ,
32
32
} ;
33
33
34
34
pub fn expand_eager_macro_input (
35
35
db : & dyn ExpandDatabase ,
36
36
krate : CrateId ,
37
- macro_call : InFile < ast:: MacroCall > ,
37
+ macro_call : & ast:: MacroCall ,
38
+ ast_id : AstId < ast:: MacroCall > ,
38
39
def : MacroDefId ,
39
40
call_site : Span ,
40
41
resolver : & dyn Fn ( ModPath ) -> Option < MacroDefId > ,
41
42
) -> 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) ;
45
44
46
45
// Note:
47
46
// When `lazy_expand` is called, its *parent* file must already exist.
@@ -50,7 +49,7 @@ pub fn expand_eager_macro_input(
50
49
let arg_id = MacroCallLoc {
51
50
def,
52
51
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 } ,
54
53
call_site,
55
54
}
56
55
. intern ( db) ;
@@ -87,9 +86,8 @@ pub fn expand_eager_macro_input(
87
86
let loc = MacroCallLoc {
88
87
def,
89
88
krate,
90
-
91
89
kind : MacroCallKind :: FnLike {
92
- ast_id : call_id ,
90
+ ast_id,
93
91
expand_to,
94
92
eager : Some ( Arc :: new ( EagerCallInfo {
95
93
arg : Arc :: new ( subtree) ,
@@ -106,14 +104,12 @@ pub fn expand_eager_macro_input(
106
104
fn lazy_expand (
107
105
db : & dyn ExpandDatabase ,
108
106
def : & MacroDefId ,
109
- macro_call : InFile < ast:: MacroCall > ,
107
+ macro_call : & ast:: MacroCall ,
108
+ ast_id : AstId < ast:: MacroCall > ,
110
109
krate : CrateId ,
111
110
call_site : Span ,
112
111
) -> 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) ;
117
113
let id = def. make_call (
118
114
db,
119
115
krate,
@@ -183,12 +179,14 @@ fn eager_macro_recur(
183
179
continue ;
184
180
}
185
181
} ;
182
+ let ast_id = db. ast_id_map ( curr. file_id ) . ast_id ( & call) ;
186
183
let ExpandResult { value, err } = match def. kind {
187
184
MacroDefKind :: BuiltInEager ( ..) => {
188
185
let ExpandResult { value, err } = expand_eager_macro_input (
189
186
db,
190
187
krate,
191
- curr. with_value ( call. clone ( ) ) ,
188
+ & call,
189
+ curr. with_value ( ast_id) ,
192
190
def,
193
191
call_site,
194
192
macro_resolver,
@@ -218,7 +216,7 @@ fn eager_macro_recur(
218
216
| MacroDefKind :: BuiltInDerive ( ..)
219
217
| MacroDefKind :: ProcMacro ( ..) => {
220
218
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) ;
222
220
223
221
// replace macro inside
224
222
let ExpandResult { value, err : error } = eager_macro_recur (
0 commit comments