@@ -151,7 +151,7 @@ pub fn expand_speculative(
151151 let span_map = RealSpanMap :: absolute ( FileId :: BOGUS ) ;
152152 let span_map = SpanMapRef :: RealSpanMap ( & span_map) ;
153153
154- let ( _, _, span) = db. macro_arg ( actual_macro_call) ;
154+ let ( _, _, span) = db. macro_arg_considering_derives ( actual_macro_call, & loc . kind ) ;
155155
156156 // Build the subtree and token mapping for the speculative args
157157 let ( mut tt, undo_info) = match loc. kind {
@@ -346,8 +346,6 @@ pub(crate) fn parse_with_map(
346346 }
347347}
348348
349- /// Imagine the word smart in quotes.
350- ///
351349/// This resolves the [MacroCallId] to check if it is a derive macro if so get the [macro_arg] for the derive.
352350/// Other wise return the [macro_arg] for the macro_call_id.
353351///
@@ -435,20 +433,9 @@ fn macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
435433 }
436434 return ( Arc :: new ( tt) , SyntaxFixupUndoInfo :: NONE , span) ;
437435 }
438-
439436 // MacroCallKind::Derive should not be here. As we are getting the argument for the derive macro
440- MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
441- let node = ast_id. to_ptr ( db) . to_node ( & root) ;
442- let censor_derive_input = censor_derive_input ( derive_attr_index, & node) ;
443- let item_node = node. into ( ) ;
444- let attr_source = attr_source ( derive_attr_index, & item_node) ;
445- // FIXME: This is wrong, this should point to the path of the derive attribute`
446- let span =
447- map. span_for_range ( attr_source. as_ref ( ) . and_then ( |it| it. path ( ) ) . map_or_else (
448- || item_node. syntax ( ) . text_range ( ) ,
449- |it| it. syntax ( ) . text_range ( ) ,
450- ) ) ;
451- ( censor_derive_input, item_node, span)
437+ MacroCallKind :: Derive { .. } => {
438+ unreachable ! ( "`ExpandDatabase::macro_arg` called with `MacroCallKind::Derive`" )
452439 }
453440 MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
454441 let node = ast_id. to_ptr ( db) . to_node ( & root) ;
@@ -637,7 +624,7 @@ fn proc_macro_span(db: &dyn ExpandDatabase, ast: AstId<ast::Fn>) -> Span {
637624
638625fn expand_proc_macro ( db : & dyn ExpandDatabase , id : MacroCallId ) -> ExpandResult < Arc < tt:: Subtree > > {
639626 let loc = db. lookup_intern_macro_call ( id) ;
640- let ( macro_arg, undo_info, span) = db. macro_arg_considering_derives ( id, & loc. kind . clone ( ) ) ;
627+ let ( macro_arg, undo_info, span) = db. macro_arg_considering_derives ( id, & loc. kind ) ;
641628
642629 let ( expander, ast) = match loc. def . kind {
643630 MacroDefKind :: ProcMacro ( expander, _, ast) => ( expander, ast) ,
0 commit comments