@@ -151,7 +151,7 @@ pub fn expand_speculative(
151
151
let span_map = RealSpanMap :: absolute ( FileId :: BOGUS ) ;
152
152
let span_map = SpanMapRef :: RealSpanMap ( & span_map) ;
153
153
154
- let ( _, _, span) = db. macro_arg ( actual_macro_call) ;
154
+ let ( _, _, span) = db. macro_arg_considering_derives ( actual_macro_call, & loc . kind ) ;
155
155
156
156
// Build the subtree and token mapping for the speculative args
157
157
let ( mut tt, undo_info) = match loc. kind {
@@ -346,8 +346,6 @@ pub(crate) fn parse_with_map(
346
346
}
347
347
}
348
348
349
- /// Imagine the word smart in quotes.
350
- ///
351
349
/// This resolves the [MacroCallId] to check if it is a derive macro if so get the [macro_arg] for the derive.
352
350
/// Other wise return the [macro_arg] for the macro_call_id.
353
351
///
@@ -435,20 +433,9 @@ fn macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
435
433
}
436
434
return ( Arc :: new ( tt) , SyntaxFixupUndoInfo :: NONE , span) ;
437
435
}
438
-
439
436
// 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`" )
452
439
}
453
440
MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
454
441
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 {
637
624
638
625
fn expand_proc_macro ( db : & dyn ExpandDatabase , id : MacroCallId ) -> ExpandResult < Arc < tt:: Subtree > > {
639
626
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 ) ;
641
628
642
629
let ( expander, ast) = match loc. def . kind {
643
630
MacroDefKind :: ProcMacro ( expander, _, ast) => ( expander, ast) ,
0 commit comments