diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-02 08:20:50 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-02 08:20:50 +0000 |
commit | da3802b2ce4796461a9fff22f4e9c6fd890879b2 (patch) | |
tree | b3df38ae7b749178d854be9f2e6b16070a373216 /crates/ra_hir/src/nameres.rs | |
parent | 4447019f4b5f24728bb7b91b161755ddb373c74c (diff) | |
parent | d8ef8acb47b1be92da97a2d5cd4334bceed5b919 (diff) |
Merge #725
725: Implement `use as` r=matklad a=flodiebold
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 7ec6512b6..04cc693b3 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -251,10 +251,14 @@ where | |||
251 | }; | 251 | }; |
252 | } | 252 | } |
253 | for (import_id, import_data) in input.imports.iter() { | 253 | for (import_id, import_data) in input.imports.iter() { |
254 | if let Some(segment) = import_data.path.segments.iter().last() { | 254 | if let Some(last_segment) = import_data.path.segments.iter().last() { |
255 | if !import_data.is_glob { | 255 | if !import_data.is_glob { |
256 | let name = import_data | ||
257 | .alias | ||
258 | .clone() | ||
259 | .unwrap_or_else(|| last_segment.name.clone()); | ||
256 | module_items.items.insert( | 260 | module_items.items.insert( |
257 | segment.name.clone(), | 261 | name, |
258 | Resolution { | 262 | Resolution { |
259 | def: PerNs::none(), | 263 | def: PerNs::none(), |
260 | import: Some(import_id), | 264 | import: Some(import_id), |
@@ -319,19 +323,18 @@ where | |||
319 | 323 | ||
320 | if reached_fixedpoint == ReachedFixedPoint::Yes { | 324 | if reached_fixedpoint == ReachedFixedPoint::Yes { |
321 | let last_segment = import.path.segments.last().unwrap(); | 325 | let last_segment = import.path.segments.last().unwrap(); |
326 | let name = import | ||
327 | .alias | ||
328 | .clone() | ||
329 | .unwrap_or_else(|| last_segment.name.clone()); | ||
330 | log::debug!("resolved import {:?} ({:?}) to {:?}", name, import, def,); | ||
322 | self.update(module_id, |items| { | 331 | self.update(module_id, |items| { |
323 | let res = Resolution { | 332 | let res = Resolution { |
324 | def, | 333 | def, |
325 | import: Some(import_id), | 334 | import: Some(import_id), |
326 | }; | 335 | }; |
327 | items.items.insert(last_segment.name.clone(), res); | 336 | items.items.insert(name, res); |
328 | }); | 337 | }); |
329 | log::debug!( | ||
330 | "resolved import {:?} ({:?}) cross-source root to {:?}", | ||
331 | last_segment.name, | ||
332 | import, | ||
333 | def, | ||
334 | ); | ||
335 | } | 338 | } |
336 | reached_fixedpoint | 339 | reached_fixedpoint |
337 | } | 340 | } |