@@ -155,14 +155,20 @@ mod tests {
155
155
use expect_test:: { expect, Expect } ;
156
156
157
157
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,
159
160
} ;
160
161
161
162
fn check ( ra_fixture : & str , expect : Expect ) {
162
163
let actual = completion_list_no_kw ( ra_fixture) ;
163
164
expect. assert_eq ( & actual) ;
164
165
}
165
166
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
+
166
172
fn check_with_private_editable ( ra_fixture : & str , expect : Expect ) {
167
173
let actual = completion_list_no_kw_with_private_editable ( ra_fixture) ;
168
174
expect. assert_eq ( & actual) ;
@@ -265,6 +271,32 @@ fn foo(a: A) { a.$0() }
265
271
) ;
266
272
}
267
273
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
+
268
300
#[ test]
269
301
fn test_visibility_filtering ( ) {
270
302
check (
0 commit comments