diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 138a7a7a9c..bbff5e81a4 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -200,7 +200,16 @@ fn runnable_action( _ => None, }, ModuleDef::Function(it) => { - runnable(&sema, it.source(sema.db).value.syntax().clone(), file_id) + let src = it.source(sema.db); + if src.file_id != file_id.into() { + // Don't try to find runnables in a macro generated code. + // See tests below: + // test_hover_macro_generated_struct_fn_doc_comment + // test_hover_macro_generated_struct_fn_doc_attr + return None; + } + + runnable(&sema, src.value.syntax().clone(), file_id) .map(|it| HoverAction::Runnable(it)) } _ => None,