diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-31 20:13:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-31 20:13:28 +0000 |
commit | 1a59f75cdaa730c16a694a4294eccf6dfe6fe0ad (patch) | |
tree | aad8fdee6b6308e41668052f61afff28d5023767 | |
parent | e6e93b3d1d8af018a6cb1fe3fd6c3f166c8a64f5 (diff) | |
parent | 999e020da2f08460ab0683409227ddd88097b336 (diff) |
Merge #7503
7503: Return inner attributes of outline mod declarations in `attrs_query` r=jonas-schievink a=Veykril
Co-authored-by: Lukas Wirth <[email protected]>
-rw-r--r-- | crates/hir_def/src/attr.rs | 10 | ||||
-rw-r--r-- | crates/ide/src/hover.rs | 16 |
2 files changed, 25 insertions, 1 deletions
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 { | |||
200 | let mod_data = &def_map[module.local_id]; | 200 | let mod_data = &def_map[module.local_id]; |
201 | match mod_data.declaration_source(db) { | 201 | match mod_data.declaration_source(db) { |
202 | Some(it) => { | 202 | Some(it) => { |
203 | RawAttrs::from_attrs_owner(db, it.as_ref().map(|it| it as &dyn AttrsOwner)) | 203 | let raw_attrs = RawAttrs::from_attrs_owner( |
204 | db, | ||
205 | it.as_ref().map(|it| it as &dyn AttrsOwner), | ||
206 | ); | ||
207 | match mod_data.definition_source(db) { | ||
208 | InFile { file_id, value: ModuleSource::SourceFile(file) } => raw_attrs | ||
209 | .merge(RawAttrs::from_attrs_owner(db, InFile::new(file_id, &file))), | ||
210 | _ => raw_attrs, | ||
211 | } | ||
204 | } | 212 | } |
205 | None => RawAttrs::from_attrs_owner( | 213 | None => RawAttrs::from_attrs_owner( |
206 | db, | 214 | 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<const LEN: usize> Foo<LEN$0> {} | |||
3444 | "#]], | 3444 | "#]], |
3445 | ); | 3445 | ); |
3446 | } | 3446 | } |
3447 | |||
3448 | #[test] | ||
3449 | fn hover_mod_def() { | ||
3450 | check( | ||
3451 | r#" | ||
3452 | //- /main.rs | ||
3453 | mod foo$0; | ||
3454 | //- /foo.rs | ||
3455 | //! For the horde! | ||
3456 | "#, | ||
3457 | expect![[r#" | ||
3458 | *foo* | ||
3459 | For the horde! | ||
3460 | "#]], | ||
3461 | ); | ||
3462 | } | ||
3447 | } | 3463 | } |