diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 3e0af3a43..7929e8b7c 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -48,17 +48,11 @@ pub(crate) enum Scope { | |||
48 | pub enum Resolution { | 48 | pub enum Resolution { |
49 | // FIXME make these tuple variants | 49 | // FIXME make these tuple variants |
50 | /// An item | 50 | /// An item |
51 | Def { | 51 | Def(ModuleDef), |
52 | def: ModuleDef, | ||
53 | }, | ||
54 | /// A local binding (only value namespace) | 52 | /// A local binding (only value namespace) |
55 | LocalBinding { | 53 | LocalBinding(PatId), |
56 | pat: PatId, | ||
57 | }, | ||
58 | /// A generic parameter | 54 | /// A generic parameter |
59 | GenericParam { | 55 | GenericParam(u32), |
60 | idx: u32, | ||
61 | }, | ||
62 | SelfType(ImplBlock), | 56 | SelfType(ImplBlock), |
63 | } | 57 | } |
64 | 58 | ||
@@ -85,7 +79,7 @@ impl Resolver { | |||
85 | _ => return PerNs::none(), | 79 | _ => return PerNs::none(), |
86 | }; | 80 | }; |
87 | let module_res = item_map.resolve_path(db, module, path); | 81 | let module_res = item_map.resolve_path(db, module, path); |
88 | module_res.map(|def| Resolution::Def { def }) | 82 | module_res.map(|def| Resolution::Def(def)) |
89 | } | 83 | } |
90 | } | 84 | } |
91 | 85 | ||
@@ -157,18 +151,16 @@ impl Scope { | |||
157 | match self { | 151 | match self { |
158 | Scope::ModuleScope(m) => { | 152 | Scope::ModuleScope(m) => { |
159 | if let Some(KnownName::SelfParam) = name.as_known_name() { | 153 | if let Some(KnownName::SelfParam) = name.as_known_name() { |
160 | PerNs::types(Resolution::Def { | 154 | PerNs::types(Resolution::Def(m.module.into())) |
161 | def: m.module.into(), | ||
162 | }) | ||
163 | } else { | 155 | } else { |
164 | match m.item_map[m.module.module_id].get(name) { | 156 | match m.item_map[m.module.module_id].get(name) { |
165 | Some(res) => res.def.map(|def| Resolution::Def { def }), | 157 | Some(res) => res.def.map(Resolution::Def), |
166 | None => PerNs::none(), | 158 | None => PerNs::none(), |
167 | } | 159 | } |
168 | } | 160 | } |
169 | } | 161 | } |
170 | Scope::GenericParams(gp) => match gp.find_by_name(name) { | 162 | Scope::GenericParams(gp) => match gp.find_by_name(name) { |
171 | Some(gp) => PerNs::types(Resolution::GenericParam { idx: gp.idx }), | 163 | Some(gp) => PerNs::types(Resolution::GenericParam(gp.idx)), |
172 | None => PerNs::none(), | 164 | None => PerNs::none(), |
173 | }, | 165 | }, |
174 | Scope::ImplBlockScope(i) => { | 166 | Scope::ImplBlockScope(i) => { |
@@ -185,7 +177,7 @@ impl Scope { | |||
185 | .iter() | 177 | .iter() |
186 | .find(|entry| entry.name() == name); | 178 | .find(|entry| entry.name() == name); |
187 | match entry { | 179 | match entry { |
188 | Some(e) => PerNs::values(Resolution::LocalBinding { pat: e.pat() }), | 180 | Some(e) => PerNs::values(Resolution::LocalBinding(e.pat())), |
189 | None => PerNs::none(), | 181 | None => PerNs::none(), |
190 | } | 182 | } |
191 | } | 183 | } |
@@ -205,14 +197,14 @@ impl Scope { | |||
205 | m.item_map[m.module.module_id] | 197 | m.item_map[m.module.module_id] |
206 | .entries() | 198 | .entries() |
207 | .for_each(|(name, res)| { | 199 | .for_each(|(name, res)| { |
208 | f(name.clone(), res.def.map(|def| Resolution::Def { def })); | 200 | f(name.clone(), res.def.map(Resolution::Def)); |
209 | }) | 201 | }) |
210 | } | 202 | } |
211 | Scope::GenericParams(gp) => { | 203 | Scope::GenericParams(gp) => { |
212 | for param in &gp.params { | 204 | for param in &gp.params { |
213 | f( | 205 | f( |
214 | param.name.clone(), | 206 | param.name.clone(), |
215 | PerNs::types(Resolution::GenericParam { idx: param.idx }), | 207 | PerNs::types(Resolution::GenericParam(param.idx)), |
216 | ) | 208 | ) |
217 | } | 209 | } |
218 | } | 210 | } |
@@ -226,7 +218,7 @@ impl Scope { | |||
226 | e.expr_scopes.entries(e.scope_id).iter().for_each(|e| { | 218 | e.expr_scopes.entries(e.scope_id).iter().for_each(|e| { |
227 | f( | 219 | f( |
228 | e.name().clone(), | 220 | e.name().clone(), |
229 | PerNs::values(Resolution::LocalBinding { pat: e.pat() }), | 221 | PerNs::values(Resolution::LocalBinding(e.pat())), |
230 | ); | 222 | ); |
231 | }); | 223 | }); |
232 | } | 224 | } |