diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-18 22:51:34 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-18 22:51:34 +0000 |
commit | 0e1c01cdb8e6b346edd5d68d9cc72cbce1ce9793 (patch) | |
tree | bba7163aa81ceba1dfb26f481b8fd974421aaa8b /crates/ra_hir/src/module.rs | |
parent | 9664fbcac5e53d725c6e438ffba2194921321b76 (diff) | |
parent | 1c5ce7a8682c9e14ce726388b88897644721b19b (diff) |
Merge #291
291: File module source does not depend on syntax r=matklad a=matklad
Fixes this problem: https://github.com/rust-analyzer/rust-analyzer/pull/289#issuecomment-448398571
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/module.rs')
-rw-r--r-- | crates/ra_hir/src/module.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_hir/src/module.rs b/crates/ra_hir/src/module.rs index c6bb76d56..d5866f6ef 100644 --- a/crates/ra_hir/src/module.rs +++ b/crates/ra_hir/src/module.rs | |||
@@ -271,15 +271,13 @@ pub struct ModuleData { | |||
271 | 271 | ||
272 | impl ModuleSource { | 272 | impl ModuleSource { |
273 | // precondition: item_id **must** point to module | 273 | // precondition: item_id **must** point to module |
274 | fn new(file_id: FileId, item_id: SourceFileItemId) -> ModuleSource { | 274 | fn new(file_id: FileId, item_id: Option<SourceFileItemId>) -> ModuleSource { |
275 | let source_item_id = SourceItemId { file_id, item_id }; | 275 | let source_item_id = SourceItemId { file_id, item_id }; |
276 | ModuleSource(source_item_id) | 276 | ModuleSource(source_item_id) |
277 | } | 277 | } |
278 | 278 | ||
279 | pub(crate) fn new_file(db: &impl HirDatabase, file_id: FileId) -> ModuleSource { | 279 | pub(crate) fn new_file(file_id: FileId) -> ModuleSource { |
280 | let file_items = db.file_items(file_id); | 280 | ModuleSource::new(file_id, None) |
281 | let item_id = file_items.id_of_source_file(); | ||
282 | ModuleSource::new(file_id, item_id) | ||
283 | } | 281 | } |
284 | 282 | ||
285 | pub(crate) fn new_inline( | 283 | pub(crate) fn new_inline( |
@@ -290,7 +288,7 @@ impl ModuleSource { | |||
290 | assert!(!m.has_semi()); | 288 | assert!(!m.has_semi()); |
291 | let file_items = db.file_items(file_id); | 289 | let file_items = db.file_items(file_id); |
292 | let item_id = file_items.id_of(file_id, m.syntax()); | 290 | let item_id = file_items.id_of(file_id, m.syntax()); |
293 | ModuleSource::new(file_id, item_id) | 291 | ModuleSource::new(file_id, Some(item_id)) |
294 | } | 292 | } |
295 | 293 | ||
296 | pub fn file_id(self) -> FileId { | 294 | pub fn file_id(self) -> FileId { |