diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs index 11b22b6520..2b9ed86e41 100644 --- a/crates/ide-assists/src/handlers/inline_call.rs +++ b/crates/ide-assists/src/handlers/inline_call.rs @@ -107,6 +107,9 @@ pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext<'_>) -> let call_infos: Vec<_> = name_refs .into_iter() .filter_map(CallInfo::from_name_ref) + // FIXME: do not handle callsites in macros' parameters, because + // directly inlining into macros may cause errors. + .filter(|call_info| !ctx.sema.hir_file_for(call_info.node.syntax()).is_macro()) .map(|call_info| { let mut_node = builder.make_syntax_mut(call_info.node.syntax().clone()); (call_info, mut_node) @@ -1795,4 +1798,26 @@ fn _hash2(self_: &u64, state: &mut u64) { "#, ) } + + #[test] + fn inline_into_callers_in_macros_not_applicable() { + check_assist_not_applicable( + inline_into_callers, + r#" +fn foo() -> u32 { + 42 +} + +macro_rules! bar { + ($x:expr) => { + $x + }; +} + +fn f() { + bar!(foo$0()); +} +"#, + ); + } }