@@ -22,6 +22,7 @@ pub mod span;
2222pub mod files;
2323mod fixup;
2424
25+ use attrs:: collect_attrs;
2526use triomphe:: Arc ;
2627
2728use std:: { fmt, hash:: Hash } ;
@@ -32,7 +33,7 @@ use base_db::{
3233} ;
3334use either:: Either ;
3435use syntax:: {
35- ast:: { self , AstNode , HasDocComments } ,
36+ ast:: { self , AstNode } ,
3637 SyntaxNode , SyntaxToken , TextRange , TextSize ,
3738} ;
3839
@@ -438,9 +439,9 @@ impl MacroCallLoc {
438439 MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
439440 // FIXME: handle `cfg_attr`
440441 ast_id. with_value ( ast_id. to_node ( db) ) . map ( |it| {
441- it . doc_comments_and_attrs ( )
442+ collect_attrs ( & it )
442443 . nth ( derive_attr_index. ast_index ( ) )
443- . and_then ( |it| match it {
444+ . and_then ( |it| match it. 1 {
444445 Either :: Left ( attr) => Some ( attr. syntax ( ) . clone ( ) ) ,
445446 Either :: Right ( _) => None ,
446447 } )
@@ -451,9 +452,9 @@ impl MacroCallLoc {
451452 if self . def . is_attribute_derive ( ) {
452453 // FIXME: handle `cfg_attr`
453454 ast_id. with_value ( ast_id. to_node ( db) ) . map ( |it| {
454- it . doc_comments_and_attrs ( )
455+ collect_attrs ( & it )
455456 . nth ( invoc_attr_index. ast_index ( ) )
456- . and_then ( |it| match it {
457+ . and_then ( |it| match it. 1 {
457458 Either :: Left ( attr) => Some ( attr. syntax ( ) . clone ( ) ) ,
458459 Either :: Right ( _) => None ,
459460 } )
@@ -549,24 +550,24 @@ impl MacroCallKind {
549550 MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
550551 // FIXME: should be the range of the macro name, not the whole derive
551552 // FIXME: handle `cfg_attr`
552- ast_id
553- . to_node ( db)
554- . doc_comments_and_attrs ( )
553+ collect_attrs ( & ast_id. to_node ( db) )
555554 . nth ( derive_attr_index. ast_index ( ) )
556555 . expect ( "missing derive" )
556+ . 1
557557 . expect_left ( "derive is a doc comment?" )
558558 . syntax ( )
559559 . text_range ( )
560560 }
561561 // FIXME: handle `cfg_attr`
562- MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => ast_id
563- . to_node ( db)
564- . doc_comments_and_attrs ( )
565- . nth ( invoc_attr_index. ast_index ( ) )
566- . expect ( "missing attribute" )
567- . expect_left ( "attribute macro is a doc comment?" )
568- . syntax ( )
569- . text_range ( ) ,
562+ MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
563+ collect_attrs ( & ast_id. to_node ( db) )
564+ . nth ( invoc_attr_index. ast_index ( ) )
565+ . expect ( "missing attribute" )
566+ . 1
567+ . expect_left ( "attribute macro is a doc comment?" )
568+ . syntax ( )
569+ . text_range ( )
570+ }
570571 } ;
571572
572573 FileRange { range, file_id }
@@ -737,11 +738,9 @@ impl ExpansionInfo {
737738 let attr_input_or_mac_def = def. or_else ( || match loc. kind {
738739 MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
739740 // FIXME: handle `cfg_attr`
740- let tt = ast_id
741- . to_node ( db)
742- . doc_comments_and_attrs ( )
741+ let tt = collect_attrs ( & ast_id. to_node ( db) )
743742 . nth ( invoc_attr_index. ast_index ( ) )
744- . and_then ( Either :: left) ?
743+ . and_then ( |x| Either :: left ( x . 1 ) ) ?
745744 . token_tree ( ) ?;
746745 Some ( InFile :: new ( ast_id. file_id , tt) )
747746 }
0 commit comments