@@ -458,7 +458,6 @@ impl<'a> AssocItemCollector<'a> {
458
458
def_map : module_id. def_map ( db) ,
459
459
container,
460
460
expander : Expander :: new ( db, file_id, module_id) ,
461
-
462
461
items : Vec :: new ( ) ,
463
462
attr_calls : Vec :: new ( ) ,
464
463
}
@@ -473,6 +472,7 @@ impl<'a> AssocItemCollector<'a> {
473
472
}
474
473
}
475
474
475
+ // FIXME: proc-macro diagnostics
476
476
fn collect ( & mut self , tree_id : TreeId , assoc_items : & [ AssocItem ] ) {
477
477
let item_tree = tree_id. item_tree ( self . db ) ;
478
478
@@ -482,7 +482,7 @@ impl<'a> AssocItemCollector<'a> {
482
482
continue ;
483
483
}
484
484
485
- for attr in & * attrs {
485
+ ' attrs : for attr in & * attrs {
486
486
let ast_id =
487
487
AstId :: new ( self . expander . current_file_id ( ) , item. ast_id ( & item_tree) . upcast ( ) ) ;
488
488
let ast_id_with_path = AstIdWithPath { path : ( * attr. path ) . clone ( ) , ast_id } ;
@@ -494,9 +494,17 @@ impl<'a> AssocItemCollector<'a> {
494
494
attr,
495
495
) {
496
496
self . attr_calls . push ( ( ast_id, call_id) ) ;
497
- let res = self . expander . enter_expand_id ( self . db , call_id) ;
498
- self . collect_macro_items ( res) ;
499
- continue ' items;
497
+ // If proc attribute macro expansion is disabled, skip expanding it here
498
+ if !self . db . enable_proc_attr_macros ( ) {
499
+ continue ' attrs;
500
+ }
501
+ match self . expander . enter_expand_id ( self . db , call_id) {
502
+ ExpandResult { value : Some ( ( mark, mac) ) , .. } => {
503
+ self . collect_macro_items ( mark, mac) ;
504
+ continue ' items;
505
+ }
506
+ ExpandResult { .. } => { }
507
+ }
500
508
}
501
509
}
502
510
@@ -537,25 +545,23 @@ impl<'a> AssocItemCollector<'a> {
537
545
stdx:: panic_context:: enter ( format ! ( "collect_items MacroCall: {}" , call) ) ;
538
546
let res = self . expander . enter_expand ( self . db , call) ;
539
547
540
- if let Ok ( res ) = res {
541
- self . collect_macro_items ( res ) ;
548
+ if let Ok ( ExpandResult { value : Some ( ( mark , mac ) ) , .. } ) = res {
549
+ self . collect_macro_items ( mark , mac ) ;
542
550
}
543
551
}
544
552
}
545
553
}
546
554
}
547
555
548
- fn collect_macro_items ( & mut self , res : ExpandResult < Option < ( Mark , ast:: MacroItems ) > > ) {
549
- if let Some ( ( mark, mac) ) = res. value {
550
- let src: InFile < ast:: MacroItems > = self . expander . to_source ( mac) ;
551
- let tree_id = item_tree:: TreeId :: new ( src. file_id , None ) ;
552
- let item_tree = tree_id. item_tree ( self . db ) ;
553
- let iter: Vec < _ > =
554
- item_tree. top_level_items ( ) . iter ( ) . filter_map ( ModItem :: as_assoc_item) . collect ( ) ;
556
+ fn collect_macro_items ( & mut self , mark : Mark , mac : ast:: MacroItems ) {
557
+ let src: InFile < ast:: MacroItems > = self . expander . to_source ( mac) ;
558
+ let tree_id = item_tree:: TreeId :: new ( src. file_id , None ) ;
559
+ let item_tree = tree_id. item_tree ( self . db ) ;
560
+ let iter: Vec < _ > =
561
+ item_tree. top_level_items ( ) . iter ( ) . filter_map ( ModItem :: as_assoc_item) . collect ( ) ;
555
562
556
- self . collect ( tree_id, & iter) ;
563
+ self . collect ( tree_id, & iter) ;
557
564
558
- self . expander . exit ( self . db , mark) ;
559
- }
565
+ self . expander . exit ( self . db , mark) ;
560
566
}
561
567
}
0 commit comments