@@ -155,14 +155,20 @@ mod tests {
155155 use expect_test:: { expect, Expect } ;
156156
157157 use crate :: tests:: {
158- check_edit, completion_list_no_kw, completion_list_no_kw_with_private_editable,
158+ check_edit, completion_list_exact_order, completion_list_no_kw,
159+ completion_list_no_kw_with_private_editable,
159160 } ;
160161
161162 fn check ( ra_fixture : & str , expect : Expect ) {
162163 let actual = completion_list_no_kw ( ra_fixture) ;
163164 expect. assert_eq ( & actual) ;
164165 }
165166
167+ fn check_exact_order ( ra_fixture : & str , expect : Expect ) {
168+ let actual = completion_list_exact_order ( ra_fixture) ;
169+ expect. assert_eq ( & actual) ;
170+ }
171+
166172 fn check_with_private_editable ( ra_fixture : & str , expect : Expect ) {
167173 let actual = completion_list_no_kw_with_private_editable ( ra_fixture) ;
168174 expect. assert_eq ( & actual) ;
@@ -265,6 +271,32 @@ fn foo(a: A) { a.$0() }
265271 ) ;
266272 }
267273
274+ #[ test]
275+ fn test_usable_types_first ( ) {
276+ check_exact_order (
277+ r#"
278+ struct A;
279+ impl A {
280+ fn foo(&self) {}
281+ fn new_1(input: u32) -> Self { A }
282+ fn new_2() -> A { A }
283+ }
284+
285+ fn test() {
286+ let a = A::$0;
287+ }
288+ "# ,
289+ // preference:
290+ // fn with no param that returns itself
291+ // fn with param that returns itself
292+ expect ! [ [ r#"
293+ fn new_2() fn() -> A
294+ fn new_1(…) fn(u32) -> A
295+ me foo(…) fn(&self)
296+ "# ] ] ,
297+ ) ;
298+ }
299+
268300 #[ test]
269301 fn test_visibility_filtering ( ) {
270302 check (
0 commit comments