aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model_api.rs6
-rw-r--r--crates/ra_hir/src/expr/scope.rs2
-rw-r--r--crates/ra_hir/src/ids.rs16
-rw-r--r--crates/ra_hir/src/nameres.rs2
-rw-r--r--crates/ra_hir/src/nameres/lower.rs2
-rw-r--r--crates/ra_hir/src/path.rs2
6 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 94a08aa63..2ac05c836 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -134,7 +134,7 @@ impl Module {
134 134
135 /// Topmost parent of this module. Every module has a `crate_root`, but some 135 /// Topmost parent of this module. Every module has a `crate_root`, but some
136 /// might be missing `krate`. This can happen if a module's file is not included 136 /// might be missing `krate`. This can happen if a module's file is not included
137 /// in the module tree of any target in Cargo.toml. 137 /// in the module tree of any target in `Cargo.toml`.
138 pub fn crate_root(&self, db: &impl PersistentHirDatabase) -> Module { 138 pub fn crate_root(&self, db: &impl PersistentHirDatabase) -> Module {
139 self.crate_root_impl(db) 139 self.crate_root_impl(db)
140 } 140 }
@@ -351,7 +351,7 @@ impl Enum {
351 db.type_for_def((*self).into()) 351 db.type_for_def((*self).into())
352 } 352 }
353 353
354 // TODO move to a more general type 354 // TODO: move to a more general type
355 /// Builds a resolver for type references inside this struct. 355 /// Builds a resolver for type references inside this struct.
356 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { 356 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
357 // take the outer scope... 357 // take the outer scope...
@@ -495,7 +495,7 @@ impl Function {
495 db.generic_params((*self).into()) 495 db.generic_params((*self).into())
496 } 496 }
497 497
498 // TODO move to a more general type for 'body-having' items 498 // TODO: move to a more general type for 'body-having' items
499 /// Builds a resolver for code inside this item. 499 /// Builds a resolver for code inside this item.
500 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { 500 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
501 // take the outer scope... 501 // take the outer scope...
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs
index 44d5c2429..bb8d50db8 100644
--- a/crates/ra_hir/src/expr/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -84,7 +84,7 @@ impl ExprScopes {
84 fn add_bindings(&mut self, body: &Body, scope: ScopeId, pat: PatId) { 84 fn add_bindings(&mut self, body: &Body, scope: ScopeId, pat: PatId) {
85 match &body[pat] { 85 match &body[pat] {
86 Pat::Bind { name, .. } => { 86 Pat::Bind { name, .. } => {
87 // bind can have a subpattern, but it's actually not allowed 87 // bind can have a sub pattern, but it's actually not allowed
88 // to bind to things in there 88 // to bind to things in there
89 let entry = ScopeEntry { name: name.clone(), pat }; 89 let entry = ScopeEntry { name: name.clone(), pat };
90 self.scopes[scope].entries.push(entry) 90 self.scopes[scope].entries.push(entry)
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());
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 261ebdf97..ffb20d564 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -490,7 +490,7 @@ impl ItemMap {
490 None => { 490 None => {
491 // we still have path segments left, but the path so far 491 // we still have path segments left, but the path so far
492 // didn't resolve in the types namespace => no resolution 492 // didn't resolve in the types namespace => no resolution
493 // (don't break here because curr_per_ns might contain 493 // (don't break here because `curr_per_ns` might contain
494 // something in the value namespace, and it would be wrong 494 // something in the value namespace, and it would be wrong
495 // to return that) 495 // to return that)
496 return (PerNs::none(), ReachedFixedPoint::No); 496 return (PerNs::none(), ReachedFixedPoint::No);
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs
index 7e9a3de2b..3cd496d7f 100644
--- a/crates/ra_hir/src/nameres/lower.rs
+++ b/crates/ra_hir/src/nameres/lower.rs
@@ -208,7 +208,7 @@ impl LoweredModule {
208 } 208 }
209 } 209 }
210 ast::ModuleItemKind::Module(_) => { 210 ast::ModuleItemKind::Module(_) => {
211 // modules are handled separately direclty by nameres 211 // modules are handled separately directly by name res
212 } 212 }
213 }; 213 };
214 } 214 }
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 6a24c8aa7..8ed54607a 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -97,7 +97,7 @@ impl Path {
97 return Some(q); 97 return Some(q);
98 } 98 }
99 // TODO: this bottom up traversal is not too precise. 99 // TODO: this bottom up traversal is not too precise.
100 // Should we handle do a top-down analysiss, recording results? 100 // Should we handle do a top-down analysis, recording results?
101 let use_tree_list = path.syntax().ancestors().find_map(ast::UseTreeList::cast)?; 101 let use_tree_list = path.syntax().ancestors().find_map(ast::UseTreeList::cast)?;
102 let use_tree = use_tree_list.parent_use_tree(); 102 let use_tree = use_tree_list.parent_use_tree();
103 use_tree.path() 103 use_tree.path()