From 999e020da2f08460ab0683409227ddd88097b336 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 31 Jan 2021 19:53:01 +0100 Subject: Return inner attributes of outline mod declarations in `attrs_query` --- crates/hir_def/src/attr.rs | 10 +++++++++- crates/ide/src/hover.rs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 6513daec8..fe4c3fa28 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -200,7 +200,15 @@ impl Attrs { let mod_data = &def_map[module.local_id]; match mod_data.declaration_source(db) { Some(it) => { - RawAttrs::from_attrs_owner(db, it.as_ref().map(|it| it as &dyn AttrsOwner)) + let raw_attrs = RawAttrs::from_attrs_owner( + db, + it.as_ref().map(|it| it as &dyn AttrsOwner), + ); + match mod_data.definition_source(db) { + InFile { file_id, value: ModuleSource::SourceFile(file) } => raw_attrs + .merge(RawAttrs::from_attrs_owner(db, InFile::new(file_id, &file))), + _ => raw_attrs, + } } None => RawAttrs::from_attrs_owner( db, diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index d47a4cb0f..5d2d072b1 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -3444,4 +3444,20 @@ impl Foo {} "#]], ); } + + #[test] + fn hover_mod_def() { + check( + r#" +//- /main.rs +mod foo$0; +//- /foo.rs +//! For the horde! +"#, + expect![[r#" + *foo* + For the horde! + "#]], + ); + } } -- cgit v1.2.3