aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index d3fa7d266..8d81d5ebf 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -46,24 +46,24 @@ impl HirInterner {
46/// This module defines a bunch of ids we are using. The most important ones are 46/// This module defines a bunch of ids we are using. The most important ones are
47/// probably `HirFileId` and `DefId`. 47/// probably `HirFileId` and `DefId`.
48 48
49/// Input to the analyzer is a set of files, where each file is indentified by 49/// Input to the analyzer is a set of files, where each file is identified by
50/// `FileId` and contains source code. However, another source of source code in 50/// `FileId` and contains source code. However, another source of source code in
51/// Rust are macros: each macro can be thought of as producing a "temporary 51/// Rust are macros: each macro can be thought of as producing a "temporary
52/// file". To assign an id to such a file, we use the id of the macro call that 52/// file". To assign an id to such a file, we use the id of the macro call that
53/// produced the file. So, a `HirFileId` is either a `FileId` (source code 53/// produced the file. So, a `HirFileId` is either a `FileId` (source code
54/// written by user), or a `MacroCallId` (source code produced by macro). 54/// written by user), or a `MacroCallId` (source code produced by macro).
55/// 55///
56/// What is a `MacroCallId`? Simplifying, it's a `HirFileId` of a file containin 56/// What is a `MacroCallId`? Simplifying, it's a `HirFileId` of a file
57/// the call plus the offset of the macro call in the file. Note that this is a 57/// containing the call plus the offset of the macro call in the file. Note that
58/// recursive definition! However, the size_of of `HirFileId` is finite 58/// this is a recursive definition! However, the size_of of `HirFileId` is
59/// (because everything bottoms out at the real `FileId`) and small 59/// finite (because everything bottoms out at the real `FileId`) and small
60/// (`MacroCallId` uses the location interner). 60/// (`MacroCallId` uses the location interner).
61#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 61#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
62pub struct HirFileId(HirFileIdRepr); 62pub struct HirFileId(HirFileIdRepr);
63 63
64impl HirFileId { 64impl HirFileId {
65 /// For macro-expansion files, returns the file original source file the 65 /// For macro-expansion files, returns the file original source file the
66 /// expansionoriginated from. 66 /// expansion originated from.
67 pub fn original_file(self, db: &impl PersistentHirDatabase) -> FileId { 67 pub fn original_file(self, db: &impl PersistentHirDatabase) -> FileId {
68 match self.0 { 68 match self.0 {
69 HirFileIdRepr::File(file_id) => file_id, 69 HirFileIdRepr::File(file_id) => file_id,
@@ -324,9 +324,9 @@ impl SourceFileItems {
324 324
325 fn init(&mut self, source_file: &SourceFile) { 325 fn init(&mut self, source_file: &SourceFile) {
326 // By walking the tree in bread-first order we make sure that parents 326 // By walking the tree in bread-first order we make sure that parents
327 // get lower ids then children. That is, addding a new child does not 327 // get lower ids then children. That is, adding a new child does not
328 // change parent's id. This means that, say, adding a new function to a 328 // change parent's id. This means that, say, adding a new function to a
329 // trait does not chage ids of top-level items, which helps caching. 329 // trait does not change ids of top-level items, which helps caching.
330 bfs(source_file.syntax(), |it| { 330 bfs(source_file.syntax(), |it| {
331 if let Some(module_item) = ast::ModuleItem::cast(it) { 331 if let Some(module_item) = ast::ModuleItem::cast(it) {
332 self.alloc(module_item.syntax()); 332 self.alloc(module_item.syntax());