@@ -59,7 +59,7 @@ use hir_def::{
5959 Lookup , MacroExpander , MacroId , ModuleId , StaticId , StructId , TraitAliasId , TraitId ,
6060 TypeAliasId , TypeOrConstParamId , TypeParamId , UnionId ,
6161} ;
62- use hir_expand:: { name:: name, MacroCallKind } ;
62+ use hir_expand:: { attrs :: collect_attrs , name:: name, MacroCallKind } ;
6363use hir_ty:: {
6464 all_super_traits, autoderef, check_orphan_rules,
6565 consteval:: { try_const_usize, unknown_const_as_generic, ConstEvalError , ConstExt } ,
@@ -81,7 +81,7 @@ use once_cell::unsync::Lazy;
8181use rustc_hash:: FxHashSet ;
8282use stdx:: { impl_from, never} ;
8383use syntax:: {
84- ast:: { self , HasAttrs as _, HasDocComments , HasName } ,
84+ ast:: { self , HasAttrs as _, HasName } ,
8585 AstNode , AstPtr , SmolStr , SyntaxNode , SyntaxNodePtr , TextRange , T ,
8686} ;
8787use triomphe:: Arc ;
@@ -974,10 +974,9 @@ fn precise_macro_call_location(
974974 // Compute the precise location of the macro name's token in the derive
975975 // list.
976976 let token = ( || {
977- let derive_attr = node
978- . doc_comments_and_attrs ( )
977+ let derive_attr = collect_attrs ( & node)
979978 . nth ( derive_attr_index. ast_index ( ) )
980- . and_then ( Either :: left) ?;
979+ . and_then ( |x| Either :: left ( x . 1 ) ) ?;
981980 let token_tree = derive_attr. meta ( ) ?. token_tree ( ) ?;
982981 let group_by = token_tree
983982 . syntax ( )
@@ -1002,10 +1001,9 @@ fn precise_macro_call_location(
10021001 }
10031002 MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
10041003 let node = ast_id. to_node ( db. upcast ( ) ) ;
1005- let attr = node
1006- . doc_comments_and_attrs ( )
1004+ let attr = collect_attrs ( & node)
10071005 . nth ( invoc_attr_index. ast_index ( ) )
1008- . and_then ( Either :: left)
1006+ . and_then ( |x| Either :: left ( x . 1 ) )
10091007 . unwrap_or_else ( || {
10101008 panic ! ( "cannot find attribute #{}" , invoc_attr_index. ast_index( ) )
10111009 } ) ;
0 commit comments