@@ -287,7 +287,8 @@ mod tests {
287287 } ;
288288
289289 use crate :: tests:: {
290- check_assist, check_assist_not_applicable, check_assist_target, TEST_CONFIG ,
290+ check_assist, check_assist_by_label, check_assist_not_applicable, check_assist_target,
291+ TEST_CONFIG ,
291292 } ;
292293
293294 fn check_auto_import_order ( before : & str , order : & [ & str ] ) {
@@ -739,7 +740,44 @@ fn main() {
739740
740741 #[ test]
741742 fn associated_trait_function ( ) {
742- check_assist (
743+ check_assist_by_label (
744+ auto_import,
745+ r"
746+ mod test_mod {
747+ pub trait TestTrait {
748+ fn test_function();
749+ }
750+ pub struct TestStruct {}
751+ impl TestTrait for TestStruct {
752+ fn test_function() {}
753+ }
754+ }
755+
756+ fn main() {
757+ test_mod::TestStruct::test_function$0
758+ }
759+ " ,
760+ r"
761+ use test_mod::TestTrait;
762+
763+ mod test_mod {
764+ pub trait TestTrait {
765+ fn test_function();
766+ }
767+ pub struct TestStruct {}
768+ impl TestTrait for TestStruct {
769+ fn test_function() {}
770+ }
771+ }
772+
773+ fn main() {
774+ test_mod::TestStruct::test_function
775+ }
776+ " ,
777+ "Import `test_mod::TestTrait`" ,
778+ ) ;
779+
780+ check_assist_by_label (
743781 auto_import,
744782 r"
745783 mod test_mod {
@@ -773,6 +811,7 @@ fn main() {
773811 test_mod::TestStruct::test_function
774812 }
775813 " ,
814+ "Import `test_mod::TestTrait as _`" ,
776815 ) ;
777816 }
778817
@@ -810,7 +849,7 @@ fn main() {
810849
811850 #[ test]
812851 fn associated_trait_const ( ) {
813- check_assist (
852+ check_assist_by_label (
814853 auto_import,
815854 r"
816855 mod test_mod {
@@ -844,6 +883,44 @@ fn main() {
844883 test_mod::TestStruct::TEST_CONST
845884 }
846885 " ,
886+ "Import `test_mod::TestTrait as _`" ,
887+ ) ;
888+
889+ check_assist_by_label (
890+ auto_import,
891+ r"
892+ mod test_mod {
893+ pub trait TestTrait {
894+ const TEST_CONST: u8;
895+ }
896+ pub struct TestStruct {}
897+ impl TestTrait for TestStruct {
898+ const TEST_CONST: u8 = 42;
899+ }
900+ }
901+
902+ fn main() {
903+ test_mod::TestStruct::TEST_CONST$0
904+ }
905+ " ,
906+ r"
907+ use test_mod::TestTrait;
908+
909+ mod test_mod {
910+ pub trait TestTrait {
911+ const TEST_CONST: u8;
912+ }
913+ pub struct TestStruct {}
914+ impl TestTrait for TestStruct {
915+ const TEST_CONST: u8 = 42;
916+ }
917+ }
918+
919+ fn main() {
920+ test_mod::TestStruct::TEST_CONST
921+ }
922+ " ,
923+ "Import `test_mod::TestTrait`" ,
847924 ) ;
848925 }
849926
@@ -881,7 +958,7 @@ fn main() {
881958
882959 #[ test]
883960 fn trait_method ( ) {
884- check_assist (
961+ check_assist_by_label (
885962 auto_import,
886963 r"
887964 mod test_mod {
@@ -917,12 +994,52 @@ fn main() {
917994 test_struct.test_method()
918995 }
919996 " ,
997+ "Import `test_mod::TestTrait as _`" ,
998+ ) ;
999+
1000+ check_assist_by_label (
1001+ auto_import,
1002+ r"
1003+ mod test_mod {
1004+ pub trait TestTrait {
1005+ fn test_method(&self);
1006+ }
1007+ pub struct TestStruct {}
1008+ impl TestTrait for TestStruct {
1009+ fn test_method(&self) {}
1010+ }
1011+ }
1012+
1013+ fn main() {
1014+ let test_struct = test_mod::TestStruct {};
1015+ test_struct.test_meth$0od()
1016+ }
1017+ " ,
1018+ r"
1019+ use test_mod::TestTrait;
1020+
1021+ mod test_mod {
1022+ pub trait TestTrait {
1023+ fn test_method(&self);
1024+ }
1025+ pub struct TestStruct {}
1026+ impl TestTrait for TestStruct {
1027+ fn test_method(&self) {}
1028+ }
1029+ }
1030+
1031+ fn main() {
1032+ let test_struct = test_mod::TestStruct {};
1033+ test_struct.test_method()
1034+ }
1035+ " ,
1036+ "Import `test_mod::TestTrait`" ,
9201037 ) ;
9211038 }
9221039
9231040 #[ test]
9241041 fn trait_method_cross_crate ( ) {
925- check_assist (
1042+ check_assist_by_label (
9261043 auto_import,
9271044 r"
9281045 //- /main.rs crate:main deps:dep
@@ -949,12 +1066,43 @@ fn main() {
9491066 test_struct.test_method()
9501067 }
9511068 " ,
1069+ "Import `dep::test_mod::TestTrait as _`" ,
1070+ ) ;
1071+
1072+ check_assist_by_label (
1073+ auto_import,
1074+ r"
1075+ //- /main.rs crate:main deps:dep
1076+ fn main() {
1077+ let test_struct = dep::test_mod::TestStruct {};
1078+ test_struct.test_meth$0od()
1079+ }
1080+ //- /dep.rs crate:dep
1081+ pub mod test_mod {
1082+ pub trait TestTrait {
1083+ fn test_method(&self);
1084+ }
1085+ pub struct TestStruct {}
1086+ impl TestTrait for TestStruct {
1087+ fn test_method(&self) {}
1088+ }
1089+ }
1090+ " ,
1091+ r"
1092+ use dep::test_mod::TestTrait;
1093+
1094+ fn main() {
1095+ let test_struct = dep::test_mod::TestStruct {};
1096+ test_struct.test_method()
1097+ }
1098+ " ,
1099+ "Import `dep::test_mod::TestTrait`" ,
9521100 ) ;
9531101 }
9541102
9551103 #[ test]
9561104 fn assoc_fn_cross_crate ( ) {
957- check_assist (
1105+ check_assist_by_label (
9581106 auto_import,
9591107 r"
9601108 //- /main.rs crate:main deps:dep
@@ -979,12 +1127,41 @@ fn main() {
9791127 dep::test_mod::TestStruct::test_function
9801128 }
9811129 " ,
1130+ "Import `dep::test_mod::TestTrait as _`" ,
1131+ ) ;
1132+
1133+ check_assist_by_label (
1134+ auto_import,
1135+ r"
1136+ //- /main.rs crate:main deps:dep
1137+ fn main() {
1138+ dep::test_mod::TestStruct::test_func$0tion
1139+ }
1140+ //- /dep.rs crate:dep
1141+ pub mod test_mod {
1142+ pub trait TestTrait {
1143+ fn test_function();
1144+ }
1145+ pub struct TestStruct {}
1146+ impl TestTrait for TestStruct {
1147+ fn test_function() {}
1148+ }
1149+ }
1150+ " ,
1151+ r"
1152+ use dep::test_mod::TestTrait;
1153+
1154+ fn main() {
1155+ dep::test_mod::TestStruct::test_function
1156+ }
1157+ " ,
1158+ "Import `dep::test_mod::TestTrait`" ,
9821159 ) ;
9831160 }
9841161
9851162 #[ test]
9861163 fn assoc_const_cross_crate ( ) {
987- check_assist (
1164+ check_assist_by_label (
9881165 auto_import,
9891166 r"
9901167 //- /main.rs crate:main deps:dep
@@ -1009,6 +1186,35 @@ fn main() {
10091186 dep::test_mod::TestStruct::CONST
10101187 }
10111188 " ,
1189+ "Import `dep::test_mod::TestTrait as _`" ,
1190+ ) ;
1191+
1192+ check_assist_by_label (
1193+ auto_import,
1194+ r"
1195+ //- /main.rs crate:main deps:dep
1196+ fn main() {
1197+ dep::test_mod::TestStruct::CONST$0
1198+ }
1199+ //- /dep.rs crate:dep
1200+ pub mod test_mod {
1201+ pub trait TestTrait {
1202+ const CONST: bool;
1203+ }
1204+ pub struct TestStruct {}
1205+ impl TestTrait for TestStruct {
1206+ const CONST: bool = true;
1207+ }
1208+ }
1209+ " ,
1210+ r"
1211+ use dep::test_mod::TestTrait;
1212+
1213+ fn main() {
1214+ dep::test_mod::TestStruct::CONST
1215+ }
1216+ " ,
1217+ "Import `dep::test_mod::TestTrait`" ,
10121218 ) ;
10131219 }
10141220
0 commit comments