aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs65
1 files changed, 60 insertions, 5 deletions
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index 8ff76688e..e33fc4b78 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -97,7 +97,7 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
97 .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind) 97 .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind)
98 .into_iter() 98 .into_iter()
99 .map(|import| { 99 .map(|import| {
100 let proposed_def = match import.item_to_import() { 100 let proposed_def = match import.item_to_display() {
101 hir::ItemInNs::Types(id) => ScopeDef::ModuleDef(id.into()), 101 hir::ItemInNs::Types(id) => ScopeDef::ModuleDef(id.into()),
102 hir::ItemInNs::Values(id) => ScopeDef::ModuleDef(id.into()), 102 hir::ItemInNs::Values(id) => ScopeDef::ModuleDef(id.into()),
103 hir::ItemInNs::Macros(id) => ScopeDef::MacroDef(id.into()), 103 hir::ItemInNs::Macros(id) => ScopeDef::MacroDef(id.into()),
@@ -809,7 +809,7 @@ fn main() {
809 #[test] 809 #[test]
810 fn unresolved_assoc_item_container() { 810 fn unresolved_assoc_item_container() {
811 check_edit( 811 check_edit(
812 "Item", 812 "TEST_ASSOC",
813 r#" 813 r#"
814mod foo { 814mod foo {
815 pub struct Item; 815 pub struct Item;
@@ -820,7 +820,7 @@ mod foo {
820} 820}
821 821
822fn main() { 822fn main() {
823 Item::TEST_A$0; 823 Item::TEST_A$0
824} 824}
825"#, 825"#,
826 r#" 826 r#"
@@ -844,7 +844,7 @@ fn main() {
844 #[test] 844 #[test]
845 fn unresolved_assoc_item_container_with_path() { 845 fn unresolved_assoc_item_container_with_path() {
846 check_edit( 846 check_edit(
847 "Item", 847 "TEST_ASSOC",
848 r#" 848 r#"
849mod foo { 849mod foo {
850 pub mod bar { 850 pub mod bar {
@@ -857,7 +857,7 @@ mod foo {
857} 857}
858 858
859fn main() { 859fn main() {
860 bar::Item::TEST_A$0; 860 bar::Item::TEST_A$0
861} 861}
862"#, 862"#,
863 r#" 863 r#"
@@ -879,4 +879,59 @@ fn main() {
879"#, 879"#,
880 ); 880 );
881 } 881 }
882
883 #[test]
884 fn unresolved_assoc_item_container_and_trait_with_path() {
885 check_edit(
886 "TEST_ASSOC",
887 r#"
888mod foo {
889 pub mod bar {
890 pub trait SomeTrait {
891 const TEST_ASSOC: usize;
892 }
893 }
894
895 pub mod baz {
896 use super::bar::SomeTrait;
897
898 pub struct Item;
899
900 impl SomeTrait for Item {
901 const TEST_ASSOC: usize = 3;
902 }
903 }
904}
905
906fn main() {
907 baz::Item::TEST_A$0
908}
909"#,
910 r#"
911use foo::{bar::SomeTrait, baz};
912
913mod foo {
914 pub mod bar {
915 pub trait SomeTrait {
916 const TEST_ASSOC: usize;
917 }
918 }
919
920 pub mod baz {
921 use super::bar::SomeTrait;
922
923 pub struct Item;
924
925 impl SomeTrait for Item {
926 const TEST_ASSOC: usize = 3;
927 }
928 }
929}
930
931fn main() {
932 baz::Item::TEST_ASSOC
933}
934"#,
935 );
936 }
882} 937}