@@ -688,8 +688,11 @@ impl MacroCallKind {
688688
689689 /// Returns the original file range that best describes the location of this macro call.
690690 ///
691- /// Unlike `MacroCallKind::original_call_range`, this also spans the item of attributes and derives.
692- pub fn original_call_range_with_body ( self , db : & dyn ExpandDatabase ) -> FileRange {
691+ /// This spans the entire macro call, including its input. That is for
692+ /// - fn_like! {}, it spans the path and token tree
693+ /// - #\[derive], it spans the `#[derive(...)]` attribute and the annotated item
694+ /// - #\[attr], it spans the `#[attr(...)]` attribute and the annotated item
695+ pub fn original_call_range_with_input ( self , db : & dyn ExpandDatabase ) -> FileRange {
693696 let mut kind = self ;
694697 let file_id = loop {
695698 match kind. file_id ( ) {
@@ -712,8 +715,8 @@ impl MacroCallKind {
712715 /// Returns the original file range that best describes the location of this macro call.
713716 ///
714717 /// Here we try to roughly match what rustc does to improve diagnostics: fn-like macros
715- /// get the whole `ast::MacroCall`, attribute macros get the attribute's range, and derives
716- /// get only the specific derive that is being referred to.
718+ /// get the macro path (rustc shows the whole `ast::MacroCall`) , attribute macros get the
719+ /// attribute's range, and derives get only the specific derive that is being referred to.
717720 pub fn original_call_range ( self , db : & dyn ExpandDatabase ) -> FileRange {
718721 let mut kind = self ;
719722 let file_id = loop {
@@ -726,7 +729,14 @@ impl MacroCallKind {
726729 } ;
727730
728731 let range = match kind {
729- MacroCallKind :: FnLike { ast_id, .. } => ast_id. to_ptr ( db) . text_range ( ) ,
732+ MacroCallKind :: FnLike { ast_id, .. } => {
733+ let node = ast_id. to_node ( db) ;
734+ node. path ( )
735+ . unwrap ( )
736+ . syntax ( )
737+ . text_range ( )
738+ . cover ( node. excl_token ( ) . unwrap ( ) . text_range ( ) )
739+ }
730740 MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
731741 // FIXME: should be the range of the macro name, not the whole derive
732742 // FIXME: handle `cfg_attr`
0 commit comments