Skip to content

Commit 4cee507

Browse files
committed
Auto merge of #11988 - jonas-schievink:expand-glob, r=jonas-schievink
minor: reenable simplify glob import test
2 parents 5620d25 + 72dcfe6 commit 4cee507

File tree

1 file changed

+33
-42
lines changed

1 file changed

+33
-42
lines changed

crates/ide_assists/src/handlers/expand_glob_import.rs

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext) -> Opti
5252
let current_scope = ctx.sema.scope(&star.parent()?)?;
5353
let current_module = current_scope.module();
5454

55-
let refs_in_target = find_refs_in_mod(ctx, target_module, Some(current_module))?;
55+
let refs_in_target = find_refs_in_mod(ctx, target_module, current_module)?;
5656
let imported_defs = find_imported_defs(ctx, star)?;
5757

5858
let target = parent.either(|n| n.syntax().clone(), |n| n.syntax().clone());
@@ -168,18 +168,12 @@ impl Refs {
168168
}
169169
}
170170

171-
fn find_refs_in_mod(
172-
ctx: &AssistContext,
173-
module: Module,
174-
visible_from: Option<Module>,
175-
) -> Option<Refs> {
176-
if let Some(from) = visible_from {
177-
if !is_mod_visible_from(ctx, module, from) {
178-
return None;
179-
}
171+
fn find_refs_in_mod(ctx: &AssistContext, module: Module, visible_from: Module) -> Option<Refs> {
172+
if !is_mod_visible_from(ctx, module, visible_from) {
173+
return None;
180174
}
181175

182-
let module_scope = module.scope(ctx.db(), visible_from);
176+
let module_scope = module.scope(ctx.db(), Some(visible_from));
183177
let refs = module_scope.into_iter().filter_map(|(n, d)| Ref::from_scope_def(n, d)).collect();
184178
Some(Refs(refs))
185179
}
@@ -729,37 +723,34 @@ fn qux(bar: Bar, baz: Baz) {
729723

730724
#[test]
731725
fn expanding_glob_import_with_macro_defs() {
732-
// FIXME: this is currently fails because `Definition::find_usages` ignores macros
733-
// https://github.com/rust-analyzer/rust-analyzer/issues/3484
734-
//
735-
// check_assist(
736-
// expand_glob_import,
737-
// r"
738-
// //- /lib.rs crate:foo
739-
// #[macro_export]
740-
// macro_rules! bar {
741-
// () => ()
742-
// }
743-
744-
// pub fn baz() {}
745-
746-
// //- /main.rs crate:main deps:foo
747-
// use foo::*$0;
748-
749-
// fn main() {
750-
// bar!();
751-
// baz();
752-
// }
753-
// ",
754-
// r"
755-
// use foo::{bar, baz};
756-
757-
// fn main() {
758-
// bar!();
759-
// baz();
760-
// }
761-
// ",
762-
// )
726+
check_assist(
727+
expand_glob_import,
728+
r#"
729+
//- /lib.rs crate:foo
730+
#[macro_export]
731+
macro_rules! bar {
732+
() => ()
733+
}
734+
735+
pub fn baz() {}
736+
737+
//- /main.rs crate:main deps:foo
738+
use foo::*$0;
739+
740+
fn main() {
741+
bar!();
742+
baz();
743+
}
744+
"#,
745+
r#"
746+
use foo::{bar, baz};
747+
748+
fn main() {
749+
bar!();
750+
baz();
751+
}
752+
"#,
753+
);
763754
}
764755

765756
#[test]

0 commit comments

Comments
 (0)