@@ -88,7 +88,7 @@ pub trait AstDatabase: SourceDatabase {
8888 #[ salsa:: transparent]
8989 fn macro_arg ( & self , id : MacroCallId ) -> Option < Arc < ( tt:: Subtree , mbe:: TokenMap ) > > ;
9090 fn macro_def ( & self , id : MacroDefId ) -> Option < Arc < ( TokenExpander , mbe:: TokenMap ) > > ;
91- fn parse_macro (
91+ fn parse_macro_expansion (
9292 & self ,
9393 macro_file : MacroFile ,
9494 ) -> MacroResult < ( Parse < SyntaxNode > , Arc < mbe:: TokenMap > ) > ;
@@ -138,16 +138,13 @@ pub fn expand_hypothetical(
138138 Some ( ( node. syntax_node ( ) , token) )
139139}
140140
141- pub ( crate ) fn ast_id_map ( db : & dyn AstDatabase , file_id : HirFileId ) -> Arc < AstIdMap > {
141+ fn ast_id_map ( db : & dyn AstDatabase , file_id : HirFileId ) -> Arc < AstIdMap > {
142142 let map =
143143 db. parse_or_expand ( file_id) . map_or_else ( AstIdMap :: default, |it| AstIdMap :: from_source ( & it) ) ;
144144 Arc :: new ( map)
145145}
146146
147- pub ( crate ) fn macro_def (
148- db : & dyn AstDatabase ,
149- id : MacroDefId ,
150- ) -> Option < Arc < ( TokenExpander , mbe:: TokenMap ) > > {
147+ fn macro_def ( db : & dyn AstDatabase , id : MacroDefId ) -> Option < Arc < ( TokenExpander , mbe:: TokenMap ) > > {
151148 match id. kind {
152149 MacroDefKind :: Declarative => {
153150 let macro_call = id. ast_id ?. to_node ( db) ;
@@ -178,7 +175,7 @@ pub(crate) fn macro_def(
178175 }
179176}
180177
181- pub ( crate ) fn macro_arg_text ( db : & dyn AstDatabase , id : MacroCallId ) -> Option < GreenNode > {
178+ fn macro_arg_text ( db : & dyn AstDatabase , id : MacroCallId ) -> Option < GreenNode > {
182179 let id = match id {
183180 MacroCallId :: LazyMacro ( id) => id,
184181 MacroCallId :: EagerMacro ( _id) => {
@@ -191,16 +188,13 @@ pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<Gr
191188 Some ( arg. green ( ) . clone ( ) )
192189}
193190
194- pub ( crate ) fn macro_arg (
195- db : & dyn AstDatabase ,
196- id : MacroCallId ,
197- ) -> Option < Arc < ( tt:: Subtree , mbe:: TokenMap ) > > {
191+ fn macro_arg ( db : & dyn AstDatabase , id : MacroCallId ) -> Option < Arc < ( tt:: Subtree , mbe:: TokenMap ) > > {
198192 let arg = db. macro_arg_text ( id) ?;
199193 let ( tt, tmap) = mbe:: syntax_node_to_token_tree ( & SyntaxNode :: new_root ( arg) ) ?;
200194 Some ( Arc :: new ( ( tt, tmap) ) )
201195}
202196
203- pub ( crate ) fn macro_expand ( db : & dyn AstDatabase , id : MacroCallId ) -> MacroResult < Arc < tt:: Subtree > > {
197+ fn macro_expand ( db : & dyn AstDatabase , id : MacroCallId ) -> MacroResult < Arc < tt:: Subtree > > {
204198 macro_expand_with_arg ( db, id, None )
205199}
206200
@@ -258,7 +252,7 @@ fn macro_expand_with_arg(
258252 MacroResult { value : Some ( Arc :: new ( tt) ) , error : err. map ( |e| format ! ( "{:?}" , e) ) }
259253}
260254
261- pub ( crate ) fn expand_proc_macro (
255+ fn expand_proc_macro (
262256 db : & dyn AstDatabase ,
263257 id : MacroCallId ,
264258) -> Result < tt:: Subtree , mbe:: ExpandError > {
@@ -285,23 +279,23 @@ pub(crate) fn expand_proc_macro(
285279 expander. expand ( db, lazy_id, & macro_arg. 0 )
286280}
287281
288- pub ( crate ) fn parse_or_expand ( db : & dyn AstDatabase , file_id : HirFileId ) -> Option < SyntaxNode > {
282+ fn parse_or_expand ( db : & dyn AstDatabase , file_id : HirFileId ) -> Option < SyntaxNode > {
289283 match file_id. 0 {
290284 HirFileIdRepr :: FileId ( file_id) => Some ( db. parse ( file_id) . tree ( ) . syntax ( ) . clone ( ) ) ,
291285 HirFileIdRepr :: MacroFile ( macro_file) => {
292- db. parse_macro ( macro_file) . map ( |( it, _) | it. syntax_node ( ) ) . value
286+ db. parse_macro_expansion ( macro_file) . map ( |( it, _) | it. syntax_node ( ) ) . value
293287 }
294288 }
295289}
296290
297- pub ( crate ) fn parse_macro (
291+ fn parse_macro_expansion (
298292 db : & dyn AstDatabase ,
299293 macro_file : MacroFile ,
300294) -> MacroResult < ( Parse < SyntaxNode > , Arc < mbe:: TokenMap > ) > {
301295 parse_macro_with_arg ( db, macro_file, None )
302296}
303297
304- pub fn parse_macro_with_arg (
298+ fn parse_macro_with_arg (
305299 db : & dyn AstDatabase ,
306300 macro_file : MacroFile ,
307301 arg : Option < Arc < ( tt:: Subtree , mbe:: TokenMap ) > > ,
@@ -359,11 +353,7 @@ pub fn parse_macro_with_arg(
359353
360354 match result. error {
361355 Some ( error) => {
362- // FIXME:
363- // In future, we should propagate the actual error with recovery information
364- // instead of ignore the error here.
365-
366- // Safe check for recurisve identity macro
356+ // Safety check for recursive identity macro.
367357 let node = parse. syntax_node ( ) ;
368358 let file: HirFileId = macro_file. into ( ) ;
369359 let call_node = match file. call_node ( db) {
@@ -374,7 +364,7 @@ pub fn parse_macro_with_arg(
374364 } ;
375365
376366 if !diff ( & node, & call_node. value ) . is_empty ( ) {
377- MacroResult { value : Some ( ( parse, Arc :: new ( rev_token_map) ) ) , error : None }
367+ MacroResult { value : Some ( ( parse, Arc :: new ( rev_token_map) ) ) , error : Some ( error ) }
378368 } else {
379369 return MacroResult :: error ( error) ;
380370 }
0 commit comments