@@ -59,7 +59,7 @@ use hir_def::{
59
59
Lookup , MacroExpander , MacroId , ModuleId , StaticId , StructId , TraitAliasId , TraitId ,
60
60
TypeAliasId , TypeOrConstParamId , TypeParamId , UnionId ,
61
61
} ;
62
- use hir_expand:: { name:: name, MacroCallKind } ;
62
+ use hir_expand:: { attrs :: collect_attrs , name:: name, MacroCallKind } ;
63
63
use hir_ty:: {
64
64
all_super_traits, autoderef, check_orphan_rules,
65
65
consteval:: { try_const_usize, unknown_const_as_generic, ConstEvalError , ConstExt } ,
@@ -81,7 +81,7 @@ use once_cell::unsync::Lazy;
81
81
use rustc_hash:: FxHashSet ;
82
82
use stdx:: { impl_from, never} ;
83
83
use syntax:: {
84
- ast:: { self , HasAttrs as _, HasDocComments , HasName } ,
84
+ ast:: { self , HasAttrs as _, HasName } ,
85
85
AstNode , AstPtr , SmolStr , SyntaxNode , SyntaxNodePtr , TextRange , T ,
86
86
} ;
87
87
use triomphe:: Arc ;
@@ -974,10 +974,9 @@ fn precise_macro_call_location(
974
974
// Compute the precise location of the macro name's token in the derive
975
975
// list.
976
976
let token = ( || {
977
- let derive_attr = node
978
- . doc_comments_and_attrs ( )
977
+ let derive_attr = collect_attrs ( & node)
979
978
. nth ( derive_attr_index. ast_index ( ) )
980
- . and_then ( Either :: left) ?;
979
+ . and_then ( |x| Either :: left ( x . 1 ) ) ?;
981
980
let token_tree = derive_attr. meta ( ) ?. token_tree ( ) ?;
982
981
let group_by = token_tree
983
982
. syntax ( )
@@ -1002,10 +1001,9 @@ fn precise_macro_call_location(
1002
1001
}
1003
1002
MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
1004
1003
let node = ast_id. to_node ( db. upcast ( ) ) ;
1005
- let attr = node
1006
- . doc_comments_and_attrs ( )
1004
+ let attr = collect_attrs ( & node)
1007
1005
. nth ( invoc_attr_index. ast_index ( ) )
1008
- . and_then ( Either :: left)
1006
+ . and_then ( |x| Either :: left ( x . 1 ) )
1009
1007
. unwrap_or_else ( || {
1010
1008
panic ! ( "cannot find attribute #{}" , invoc_attr_index. ast_index( ) )
1011
1009
} ) ;
0 commit comments