@@ -52,7 +52,7 @@ pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext) -> Opti
52
52
let current_scope = ctx. sema . scope ( & star. parent ( ) ?) ?;
53
53
let current_module = current_scope. module ( ) ;
54
54
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) ?;
56
56
let imported_defs = find_imported_defs ( ctx, star) ?;
57
57
58
58
let target = parent. either ( |n| n. syntax ( ) . clone ( ) , |n| n. syntax ( ) . clone ( ) ) ;
@@ -168,18 +168,12 @@ impl Refs {
168
168
}
169
169
}
170
170
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 ;
180
174
}
181
175
182
- let module_scope = module. scope ( ctx. db ( ) , visible_from) ;
176
+ let module_scope = module. scope ( ctx. db ( ) , Some ( visible_from) ) ;
183
177
let refs = module_scope. into_iter ( ) . filter_map ( |( n, d) | Ref :: from_scope_def ( n, d) ) . collect ( ) ;
184
178
Some ( Refs ( refs) )
185
179
}
@@ -729,37 +723,34 @@ fn qux(bar: Bar, baz: Baz) {
729
723
730
724
#[ test]
731
725
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
+ ) ;
763
754
}
764
755
765
756
#[ test]
0 commit comments