mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Merge #2597
2597: Handle start imports in import groups r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
aee2eee362
3 changed files with 31 additions and 3 deletions
|
@ -5,6 +5,7 @@ test_utils::marks!(
|
||||||
name_res_works_for_broken_modules
|
name_res_works_for_broken_modules
|
||||||
can_import_enum_variant
|
can_import_enum_variant
|
||||||
glob_enum
|
glob_enum
|
||||||
|
glob_enum_group
|
||||||
glob_across_crates
|
glob_across_crates
|
||||||
std_prelude
|
std_prelude
|
||||||
macro_rules_from_other_crates_are_visible_with_macro_use
|
macro_rules_from_other_crates_are_visible_with_macro_use
|
||||||
|
|
|
@ -112,3 +112,24 @@ fn glob_enum() {
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn glob_enum_group() {
|
||||||
|
covers!(glob_enum_group);
|
||||||
|
let map = def_map(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
enum Foo {
|
||||||
|
Bar, Baz
|
||||||
|
}
|
||||||
|
use self::Foo::{*};
|
||||||
|
",
|
||||||
|
);
|
||||||
|
assert_snapshot!(map, @r###"
|
||||||
|
⋮crate
|
||||||
|
⋮Bar: t v
|
||||||
|
⋮Baz: t v
|
||||||
|
⋮Foo: t
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use hir_expand::{
|
||||||
name::{AsName, Name},
|
name::{AsName, Name},
|
||||||
};
|
};
|
||||||
use ra_syntax::ast::{self, NameOwner};
|
use ra_syntax::ast::{self, NameOwner};
|
||||||
|
use test_utils::tested_by;
|
||||||
|
|
||||||
use crate::path::{ModPath, PathKind};
|
use crate::path::{ModPath, PathKind};
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ pub(crate) fn lower_use_tree(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let alias = tree.alias().and_then(|a| a.name()).map(|a| a.as_name());
|
let alias = tree.alias().and_then(|a| a.name()).map(|a| a.as_name());
|
||||||
|
let is_glob = tree.has_star();
|
||||||
if let Some(ast_path) = tree.path() {
|
if let Some(ast_path) = tree.path() {
|
||||||
// Handle self in a path.
|
// Handle self in a path.
|
||||||
// E.g. `use something::{self, <...>}`
|
// E.g. `use something::{self, <...>}`
|
||||||
|
@ -48,11 +50,15 @@ pub(crate) fn lower_use_tree(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(path) = convert_path(prefix, ast_path, hygiene) {
|
if let Some(path) = convert_path(prefix, ast_path, hygiene) {
|
||||||
let is_glob = tree.has_star();
|
|
||||||
cb(path, &tree, is_glob, alias)
|
cb(path, &tree, is_glob, alias)
|
||||||
}
|
}
|
||||||
// FIXME: report errors somewhere
|
// FIXME: report errors somewhere
|
||||||
// We get here if we do
|
// We get here if we do
|
||||||
|
} else if is_glob {
|
||||||
|
tested_by!(glob_enum_group);
|
||||||
|
if let Some(prefix) = prefix {
|
||||||
|
cb(prefix, &tree, is_glob, None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue