aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path/lower
diff options
context:
space:
mode:
authorzombiefungus <[email protected]>2020-01-31 04:14:20 +0000
committerzombiefungus <[email protected]>2020-02-02 13:04:24 +0000
commit7d527159457420d55f1ee2f70615098a10176b91 (patch)
treef64ef8face72a68e5904bc6e4ddbb2c27ce5a5cd /crates/ra_hir_def/src/path/lower
parentdce7dc44be948bb6b73b79ce284ec2eb83811ae8 (diff)
add new ImportAlias enum to differentiate no alias from an _ alias
Diffstat (limited to 'crates/ra_hir_def/src/path/lower')
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index 531878174..f693cefbc 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -4,20 +4,18 @@
4use std::iter; 4use std::iter;
5 5
6use either::Either; 6use either::Either;
7use hir_expand::{ 7use hir_expand::{hygiene::Hygiene, name::AsName};
8 hygiene::Hygiene,
9 name::{AsName, Name},
10};
11use ra_syntax::ast::{self, NameOwner}; 8use ra_syntax::ast::{self, NameOwner};
12use test_utils::tested_by; 9use test_utils::tested_by;
13 10
11use crate::nameres::raw::ImportAlias;
14use crate::path::{ModPath, PathKind}; 12use crate::path::{ModPath, PathKind};
15 13
16pub(crate) fn lower_use_tree( 14pub(crate) fn lower_use_tree(
17 prefix: Option<ModPath>, 15 prefix: Option<ModPath>,
18 tree: ast::UseTree, 16 tree: ast::UseTree,
19 hygiene: &Hygiene, 17 hygiene: &Hygiene,
20 cb: &mut dyn FnMut(ModPath, &ast::UseTree, bool, Option<Name>), 18 cb: &mut dyn FnMut(ModPath, &ast::UseTree, bool, ImportAlias),
21) { 19) {
22 if let Some(use_tree_list) = tree.use_tree_list() { 20 if let Some(use_tree_list) = tree.use_tree_list() {
23 let prefix = match tree.path() { 21 let prefix = match tree.path() {
@@ -34,7 +32,9 @@ pub(crate) fn lower_use_tree(
34 lower_use_tree(prefix.clone(), child_tree, hygiene, cb); 32 lower_use_tree(prefix.clone(), child_tree, hygiene, cb);
35 } 33 }
36 } else { 34 } else {
37 let alias = tree.alias().and_then(|a| a.name()).map(|a| a.as_name()); 35 let alias = tree.alias().map_or(ImportAlias::NoAlias, |a| {
36 a.name().map(|it| it.as_name()).map_or(ImportAlias::Unnamed, |a| ImportAlias::Alias(a))
37 });
38 let is_glob = tree.has_star(); 38 let is_glob = tree.has_star();
39 if let Some(ast_path) = tree.path() { 39 if let Some(ast_path) = tree.path() {
40 // Handle self in a path. 40 // Handle self in a path.
@@ -57,7 +57,7 @@ pub(crate) fn lower_use_tree(
57 } else if is_glob { 57 } else if is_glob {
58 tested_by!(glob_enum_group); 58 tested_by!(glob_enum_group);
59 if let Some(prefix) = prefix { 59 if let Some(prefix) = prefix {
60 cb(prefix, &tree, is_glob, None) 60 cb(prefix, &tree, is_glob, ImportAlias::NoAlias)
61 } 61 }
62 } 62 }
63 } 63 }