aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/marks.rs1
-rw-r--r--crates/ra_hir_def/src/nameres/tests/globs.rs21
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs12
3 files changed, 31 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/marks.rs b/crates/ra_hir_def/src/marks.rs
index 65239ca0a..457ba4abe 100644
--- a/crates/ra_hir_def/src/marks.rs
+++ b/crates/ra_hir_def/src/marks.rs
@@ -5,6 +5,7 @@ test_utils::marks!(
5 name_res_works_for_broken_modules 5 name_res_works_for_broken_modules
6 can_import_enum_variant 6 can_import_enum_variant
7 glob_enum 7 glob_enum
8 glob_enum_group
8 glob_across_crates 9 glob_across_crates
9 std_prelude 10 std_prelude
10 macro_rules_from_other_crates_are_visible_with_macro_use 11 macro_rules_from_other_crates_are_visible_with_macro_use
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs
index 5b03fe365..5e24cb94d 100644
--- a/crates/ra_hir_def/src/nameres/tests/globs.rs
+++ b/crates/ra_hir_def/src/nameres/tests/globs.rs
@@ -112,3 +112,24 @@ fn glob_enum() {
112 "### 112 "###
113 ); 113 );
114} 114}
115
116#[test]
117fn glob_enum_group() {
118 covers!(glob_enum_group);
119 let map = def_map(
120 "
121 //- /lib.rs
122 enum Foo {
123 Bar, Baz
124 }
125 use self::Foo::{*};
126 ",
127 );
128 assert_snapshot!(map, @r###"
129 ⋮crate
130 ⋮Bar: t v
131 ⋮Baz: t v
132 ⋮Foo: t
133 "###
134 );
135}
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 062c02063..3218eaf0a 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -9,6 +9,7 @@ use hir_expand::{
9 name::{AsName, Name}, 9 name::{AsName, Name},
10}; 10};
11use ra_syntax::ast::{self, NameOwner}; 11use ra_syntax::ast::{self, NameOwner};
12use test_utils::tested_by;
12 13
13use crate::path::{ModPath, PathKind}; 14use crate::path::{ModPath, PathKind};
14 15
@@ -34,6 +35,7 @@ pub(crate) fn lower_use_tree(
34 } 35 }
35 } else { 36 } else {
36 let alias = tree.alias().and_then(|a| a.name()).map(|a| a.as_name()); 37 let alias = tree.alias().and_then(|a| a.name()).map(|a| a.as_name());
38 let is_glob = tree.has_star();
37 if let Some(ast_path) = tree.path() { 39 if let Some(ast_path) = tree.path() {
38 // Handle self in a path. 40 // Handle self in a path.
39 // E.g. `use something::{self, <...>}` 41 // E.g. `use something::{self, <...>}`
@@ -48,11 +50,15 @@ pub(crate) fn lower_use_tree(
48 } 50 }
49 } 51 }
50 if let Some(path) = convert_path(prefix, ast_path, hygiene) { 52 if let Some(path) = convert_path(prefix, ast_path, hygiene) {
51 let is_glob = tree.has_star();
52 cb(path, &tree, is_glob, alias) 53 cb(path, &tree, is_glob, alias)
53 } 54 }
54 // FIXME: report errors somewhere 55 // FIXME: report errors somewhere
55 // We get here if we do 56 // We get here if we do
57 } else if is_glob {
58 tested_by!(glob_enum_group);
59 if let Some(prefix) = prefix {
60 cb(prefix, &tree, is_glob, None)
61 }
56 } 62 }
57 } 63 }
58} 64}