@@ -7,6 +7,7 @@ use mbe::{syntax_node_to_token_tree, ValueResult};
7
7
use rustc_hash:: FxHashSet ;
8
8
use span:: { AstIdMap , SyntaxContextData , SyntaxContextId } ;
9
9
use syntax:: { ast, AstNode , Parse , SyntaxElement , SyntaxError , SyntaxNode , SyntaxToken , T } ;
10
+ use tracing:: debug;
10
11
use triomphe:: Arc ;
11
12
12
13
use crate :: {
@@ -345,7 +346,13 @@ fn smart_macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
345
346
// FIXME: We called lookup_intern_macro_call twice.
346
347
match loc. kind {
347
348
// Get the macro arg for the derive macro
348
- MacroCallKind :: Derive { derive_macro_id, .. } => db. macro_arg ( derive_macro_id) ,
349
+ MacroCallKind :: Derive { derive_macro_id, .. } => {
350
+ debug ! (
351
+ ?loc,
352
+ "{id:?} is a derive macro. Using the derive macro, id: {derive_macro_id:?}, attribute as the macro arg."
353
+ ) ;
354
+ db. macro_arg ( derive_macro_id)
355
+ }
349
356
// Normal macro arg
350
357
_ => db. macro_arg ( id) ,
351
358
}
@@ -455,7 +462,12 @@ fn macro_arg(
455
462
}
456
463
MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
457
464
let node = ast_id. to_ptr ( db) . to_node ( & root) ;
458
- ( censor_attr_input ( invoc_attr_index, & node) , node)
465
+ if loc. def . is_attribute_derive ( ) && ast:: Adt :: can_cast ( node. syntax ( ) . kind ( ) ) {
466
+ let node = ast:: Adt :: cast ( node. syntax ( ) . clone ( ) ) . unwrap ( ) ;
467
+ ( censor_derive_input ( invoc_attr_index, & node) , node. into ( ) )
468
+ } else {
469
+ ( censor_attr_input ( invoc_attr_index, & node) , node)
470
+ }
459
471
}
460
472
} ;
461
473
0 commit comments