diff options
author | Aleksey Kladov <[email protected]> | 2019-01-15 16:15:01 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-15 16:15:01 +0000 |
commit | 490112dea10d476e9b5829499bc6670f03f7d138 (patch) | |
tree | 2c02cf513feeb85054e68a04f28c16e516c54653 /crates/ra_hir/src/code_model_impl | |
parent | 18e9a710cd2f2ced84fde19e88d0b967dcb5939e (diff) |
remove Cancelable from nameres
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 331b0500e..04301ae53 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -114,18 +114,13 @@ impl Module { | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /// Returns a `ModuleScope`: a set of items, visible in this module. | 116 | /// Returns a `ModuleScope`: a set of items, visible in this module. |
117 | pub fn scope_impl(&self, db: &impl HirDatabase) -> Cancelable<ModuleScope> { | 117 | pub fn scope_impl(&self, db: &impl HirDatabase) -> ModuleScope { |
118 | let loc = self.def_id.loc(db); | 118 | let loc = self.def_id.loc(db); |
119 | let item_map = db.item_map(loc.source_root_id)?; | 119 | let item_map = db.item_map(loc.source_root_id); |
120 | let res = item_map.per_module[&loc.module_id].clone(); | 120 | item_map.per_module[&loc.module_id].clone() |
121 | Ok(res) | ||
122 | } | 121 | } |
123 | 122 | ||
124 | pub fn resolve_path_impl( | 123 | pub fn resolve_path_impl(&self, db: &impl HirDatabase, path: &Path) -> PerNs<DefId> { |
125 | &self, | ||
126 | db: &impl HirDatabase, | ||
127 | path: &Path, | ||
128 | ) -> Cancelable<PerNs<DefId>> { | ||
129 | let mut curr_per_ns = PerNs::types( | 124 | let mut curr_per_ns = PerNs::types( |
130 | match path.kind { | 125 | match path.kind { |
131 | PathKind::Crate => self.crate_root(db), | 126 | PathKind::Crate => self.crate_root(db), |
@@ -134,7 +129,7 @@ impl Module { | |||
134 | if let Some(p) = self.parent(db) { | 129 | if let Some(p) = self.parent(db) { |
135 | p | 130 | p |
136 | } else { | 131 | } else { |
137 | return Ok(PerNs::none()); | 132 | return PerNs::none(); |
138 | } | 133 | } |
139 | } | 134 | } |
140 | } | 135 | } |
@@ -146,7 +141,7 @@ impl Module { | |||
146 | let curr = if let Some(r) = curr_per_ns.as_ref().take_types() { | 141 | let curr = if let Some(r) = curr_per_ns.as_ref().take_types() { |
147 | r | 142 | r |
148 | } else { | 143 | } else { |
149 | return Ok(PerNs::none()); | 144 | return PerNs::none(); |
150 | }; | 145 | }; |
151 | let module = match curr.resolve(db) { | 146 | let module = match curr.resolve(db) { |
152 | Def::Module(it) => it, | 147 | Def::Module(it) => it, |
@@ -157,28 +152,28 @@ impl Module { | |||
157 | e.variants(db).into_iter().find(|(n, _variant)| n == name); | 152 | e.variants(db).into_iter().find(|(n, _variant)| n == name); |
158 | 153 | ||
159 | if let Some((_n, variant)) = matching_variant { | 154 | if let Some((_n, variant)) = matching_variant { |
160 | return Ok(PerNs::both(variant.def_id(), e.def_id())); | 155 | return PerNs::both(variant.def_id(), e.def_id()); |
161 | } else { | 156 | } else { |
162 | return Ok(PerNs::none()); | 157 | return PerNs::none(); |
163 | } | 158 | } |
164 | } else if segments.len() == idx { | 159 | } else if segments.len() == idx { |
165 | // enum | 160 | // enum |
166 | return Ok(PerNs::types(e.def_id())); | 161 | return PerNs::types(e.def_id()); |
167 | } else { | 162 | } else { |
168 | // malformed enum? | 163 | // malformed enum? |
169 | return Ok(PerNs::none()); | 164 | return PerNs::none(); |
170 | } | 165 | } |
171 | } | 166 | } |
172 | _ => return Ok(PerNs::none()), | 167 | _ => return PerNs::none(), |
173 | }; | 168 | }; |
174 | let scope = module.scope(db)?; | 169 | let scope = module.scope(db); |
175 | curr_per_ns = if let Some(r) = scope.get(&name) { | 170 | curr_per_ns = if let Some(r) = scope.get(&name) { |
176 | r.def_id | 171 | r.def_id |
177 | } else { | 172 | } else { |
178 | return Ok(PerNs::none()); | 173 | return PerNs::none(); |
179 | }; | 174 | }; |
180 | } | 175 | } |
181 | Ok(curr_per_ns) | 176 | curr_per_ns |
182 | } | 177 | } |
183 | 178 | ||
184 | pub fn problems_impl( | 179 | pub fn problems_impl( |