diff options
Diffstat (limited to 'crates/hir_def/src/attr.rs')
-rw-r--r-- | crates/hir_def/src/attr.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 1b09ff816..fe4c3fa28 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -196,17 +196,26 @@ impl Attrs { | |||
196 | pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs { | 196 | pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs { |
197 | let raw_attrs = match def { | 197 | let raw_attrs = match def { |
198 | AttrDefId::ModuleId(module) => { | 198 | AttrDefId::ModuleId(module) => { |
199 | let def_map = db.crate_def_map(module.krate); | 199 | let def_map = module.def_map(db); |
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, |
207 | mod_data.definition_source(db).as_ref().map(|src| match src { | 215 | mod_data.definition_source(db).as_ref().map(|src| match src { |
208 | ModuleSource::SourceFile(file) => file as &dyn AttrsOwner, | 216 | ModuleSource::SourceFile(file) => file as &dyn AttrsOwner, |
209 | ModuleSource::Module(module) => module as &dyn AttrsOwner, | 217 | ModuleSource::Module(module) => module as &dyn AttrsOwner, |
218 | ModuleSource::BlockExpr(block) => block as &dyn AttrsOwner, | ||
210 | }), | 219 | }), |
211 | ), | 220 | ), |
212 | } | 221 | } |