File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,22 @@ impl<'db> SemanticsImpl<'db> {
315315 pub fn expand ( & self , macro_call : & ast:: MacroCall ) -> Option < SyntaxNode > {
316316 let sa = self . analyze_no_infer ( macro_call. syntax ( ) ) ?;
317317
318+ let macro_call = InFile :: new ( sa. file_id , macro_call) ;
319+ let file_id = if let Some ( call) =
320+ <ast:: MacroCall as crate :: semantics:: ToDef >:: to_def ( self , macro_call)
321+ {
322+ call. as_macro_file ( )
323+ } else {
324+ sa. expand ( self . db , macro_call) ?
325+ } ;
326+
327+ let node = self . parse_or_expand ( file_id. into ( ) ) ;
328+ Some ( node)
329+ }
330+
331+ pub fn expand_allowed_builtins ( & self , macro_call : & ast:: MacroCall ) -> Option < SyntaxNode > {
332+ let sa = self . analyze_no_infer ( macro_call. syntax ( ) ) ?;
333+
318334 let macro_call = InFile :: new ( sa. file_id , macro_call) ;
319335 let file_id = if let Some ( call) =
320336 <ast:: MacroCall as crate :: semantics:: ToDef >:: to_def ( self , macro_call)
Original file line number Diff line number Diff line change @@ -111,9 +111,10 @@ fn expand_macro_recur(
111111 macro_call : & ast:: Item ,
112112) -> Option < SyntaxNode > {
113113 let expanded = match macro_call {
114- item @ ast:: Item :: MacroCall ( macro_call) => {
115- sema. expand_attr_macro ( item) . or_else ( || sema. expand ( macro_call) ) ?. clone_for_update ( )
116- }
114+ item @ ast:: Item :: MacroCall ( macro_call) => sema
115+ . expand_attr_macro ( item)
116+ . or_else ( || sema. expand_allowed_builtins ( macro_call) ) ?
117+ . clone_for_update ( ) ,
117118 item => sema. expand_attr_macro ( item) ?. clone_for_update ( ) ,
118119 } ;
119120 expand ( sema, expanded)
You can’t perform that action at this time.
0 commit comments