@@ -30,7 +30,7 @@ use std::{
3030use la_arena:: { Arena , Idx , RawIdx } ;
3131use rustc_hash:: { FxBuildHasher , FxHashMap } ;
3232use syntax:: {
33- AstNode , AstPtr , SyntaxNode , SyntaxNodePtr ,
33+ AstNode , AstPtr , SyntaxKind , SyntaxNode , SyntaxNodePtr ,
3434 ast:: { self , HasName } ,
3535 match_ast,
3636} ;
@@ -92,6 +92,7 @@ impl fmt::Debug for ErasedFileAstId {
9292 Use ,
9393 Impl ,
9494 BlockExpr ,
95+ AsmExpr ,
9596 Fixup ,
9697 ) ;
9798 if f. alternate ( ) {
@@ -144,6 +145,10 @@ enum ErasedFileAstIdKind {
144145 Impl ,
145146 /// Associated with [`BlockExprFileAstId`].
146147 BlockExpr ,
148+ // `global_asm!()` is an item, so we need to give it an `AstId`. So we give to all inline asm
149+ // because incrementality is not a problem, they will always be the only item in the macro file,
150+ // and memory usage also not because they're rare.
151+ AsmExpr ,
147152 /// Keep this last.
148153 Root ,
149154}
@@ -204,14 +209,17 @@ impl ErasedFileAstId {
204209 . or_else ( || extern_block_ast_id ( node, index_map) )
205210 . or_else ( || use_ast_id ( node, index_map) )
206211 . or_else ( || impl_ast_id ( node, index_map) )
212+ . or_else ( || asm_expr_ast_id ( node, index_map) )
207213 }
208214
209215 fn should_alloc ( node : & SyntaxNode ) -> bool {
210- should_alloc_has_name ( node)
211- || should_alloc_assoc_item ( node)
212- || ast:: ExternBlock :: can_cast ( node. kind ( ) )
213- || ast:: Use :: can_cast ( node. kind ( ) )
214- || ast:: Impl :: can_cast ( node. kind ( ) )
216+ let kind = node. kind ( ) ;
217+ should_alloc_has_name ( kind)
218+ || should_alloc_assoc_item ( kind)
219+ || ast:: ExternBlock :: can_cast ( kind)
220+ || ast:: Use :: can_cast ( kind)
221+ || ast:: Impl :: can_cast ( kind)
222+ || ast:: AsmExpr :: can_cast ( kind)
215223 }
216224
217225 #[ inline]
@@ -331,6 +339,19 @@ fn use_ast_id(
331339 }
332340}
333341
342+ impl AstIdNode for ast:: AsmExpr { }
343+
344+ fn asm_expr_ast_id (
345+ node : & SyntaxNode ,
346+ index_map : & mut ErasedAstIdNextIndexMap ,
347+ ) -> Option < ErasedFileAstId > {
348+ if ast:: AsmExpr :: can_cast ( node. kind ( ) ) {
349+ Some ( index_map. new_id ( ErasedFileAstIdKind :: AsmExpr , ( ) ) )
350+ } else {
351+ None
352+ }
353+ }
354+
334355impl AstIdNode for ast:: Impl { }
335356
336357fn impl_ast_id (
@@ -449,8 +470,7 @@ macro_rules! register_has_name_ast_id {
449470 }
450471 }
451472
452- fn should_alloc_has_name( node: & SyntaxNode ) -> bool {
453- let kind = node. kind( ) ;
473+ fn should_alloc_has_name( kind: SyntaxKind ) -> bool {
454474 false $( || ast:: $ident:: can_cast( kind) ) *
455475 }
456476 } ;
@@ -501,8 +521,7 @@ macro_rules! register_assoc_item_ast_id {
501521 }
502522 }
503523
504- fn should_alloc_assoc_item( node: & SyntaxNode ) -> bool {
505- let kind = node. kind( ) ;
524+ fn should_alloc_assoc_item( kind: SyntaxKind ) -> bool {
506525 false $( || ast:: $ident:: can_cast( kind) ) *
507526 }
508527 } ;
0 commit comments