File tree 5 files changed +198
-206
lines changed
crates/ide_completion/src
5 files changed +198
-206
lines changed Original file line number Diff line number Diff line change @@ -218,36 +218,6 @@ mod tests {
218
218
expect. assert_eq ( & actual) ;
219
219
}
220
220
221
- #[ test]
222
- fn dont_complete_values_in_type_pos ( ) {
223
- check (
224
- r#"
225
- const FOO: () = ();
226
- static BAR: () = ();
227
- struct Baz;
228
- fn foo() {
229
- let _: self::$0;
230
- }
231
- "# ,
232
- expect ! [ [ r#"
233
- st Baz
234
- "# ] ] ,
235
- ) ;
236
- }
237
-
238
- #[ test]
239
- fn dont_complete_enum_variants_in_type_pos ( ) {
240
- check (
241
- r#"
242
- enum Foo { Bar }
243
- fn foo() {
244
- let _: Foo::$0;
245
- }
246
- "# ,
247
- expect ! [ [ r#""# ] ] ,
248
- ) ;
249
- }
250
-
251
221
#[ test]
252
222
fn dont_complete_primitive_in_use ( ) {
253
223
check_builtin ( r#"use self::$0;"# , expect ! [ [ "" ] ] ) ;
@@ -258,32 +228,6 @@ fn foo() {
258
228
check_builtin ( r#"fn foo() { self::$0 }"# , expect ! [ [ "" ] ] ) ;
259
229
}
260
230
261
- #[ test]
262
- fn completes_primitives ( ) {
263
- check_builtin (
264
- r#"fn main() { let _: $0 = 92; }"# ,
265
- expect ! [ [ r#"
266
- bt u32
267
- bt bool
268
- bt u8
269
- bt isize
270
- bt u16
271
- bt u64
272
- bt u128
273
- bt f32
274
- bt i128
275
- bt i16
276
- bt str
277
- bt i64
278
- bt char
279
- bt f64
280
- bt i32
281
- bt i8
282
- bt usize
283
- "# ] ] ,
284
- ) ;
285
- }
286
-
287
231
#[ test]
288
232
fn completes_enum_variant ( ) {
289
233
check (
@@ -749,24 +693,4 @@ fn main() {
749
693
"# ] ] ,
750
694
) ;
751
695
}
752
-
753
- #[ test]
754
- fn completes_types_and_const_in_arg_list ( ) {
755
- check (
756
- r#"
757
- mod foo {
758
- pub const CONST: () = ();
759
- pub type Type = ();
760
- }
761
-
762
- struct Foo<T>(t);
763
-
764
- fn foo(_: Foo<foo::$0>) {}
765
- "# ,
766
- expect ! [ [ r#"
767
- ta Type
768
- ct CONST
769
- "# ] ] ,
770
- ) ;
771
- }
772
696
}
Original file line number Diff line number Diff line change @@ -112,28 +112,6 @@ mod tests {
112
112
expect. assert_eq ( & actual)
113
113
}
114
114
115
- #[ test]
116
- fn dont_complete_values_in_type_pos ( ) {
117
- check (
118
- r#"
119
- const FOO: () = ();
120
- static BAR: () = ();
121
- enum Foo {
122
- Bar
123
- }
124
- struct Baz;
125
- fn foo() {
126
- let local = ();
127
- let _: $0;
128
- }
129
- "# ,
130
- expect ! [ [ r#"
131
- en Foo
132
- st Baz
133
- "# ] ] ,
134
- ) ;
135
- }
136
-
137
115
#[ test]
138
116
fn completes_bindings_from_let ( ) {
139
117
check (
@@ -238,29 +216,6 @@ fn main() {
238
216
) ;
239
217
}
240
218
241
- #[ test]
242
- fn completes_generic_params_in_struct ( ) {
243
- check (
244
- r#"struct S<T> { x: $0}"# ,
245
- expect ! [ [ r#"
246
- sp Self
247
- tp T
248
- st S<…>
249
- "# ] ] ,
250
- ) ;
251
- }
252
-
253
- #[ test]
254
- fn completes_self_in_enum ( ) {
255
- check (
256
- r#"enum X { Y($0) }"# ,
257
- expect ! [ [ r#"
258
- sp Self
259
- en X
260
- "# ] ] ,
261
- ) ;
262
- }
263
-
264
219
#[ test]
265
220
fn completes_module_items ( ) {
266
221
check (
@@ -314,19 +269,6 @@ mod m {
314
269
) ;
315
270
}
316
271
317
- #[ test]
318
- fn completes_return_type ( ) {
319
- check (
320
- r#"
321
- struct Foo;
322
- fn x() -> $0
323
- "# ,
324
- expect ! [ [ r#"
325
- st Foo
326
- "# ] ] ,
327
- ) ;
328
- }
329
-
330
272
#[ test]
331
273
fn dont_show_both_completions_for_shadowing ( ) {
332
274
check (
@@ -508,19 +450,6 @@ fn foo() { $0 }
508
450
) ;
509
451
}
510
452
511
- #[ test]
512
- fn completes_macros_as_type ( ) {
513
- check (
514
- r#"
515
- macro_rules! foo { () => {} }
516
- fn main() { let x: $0 }
517
- "# ,
518
- expect ! [ [ r#"
519
- ma foo!(…) macro_rules! foo
520
- "# ] ] ,
521
- ) ;
522
- }
523
-
524
453
#[ test]
525
454
fn completes_macros_as_stmt ( ) {
526
455
check (
@@ -666,30 +595,4 @@ fn f() {}
666
595
expect ! [ [ "" ] ] ,
667
596
)
668
597
}
669
-
670
- #[ test]
671
- fn completes_types_and_const_in_arg_list ( ) {
672
- check (
673
- r#"
674
- enum Bar {
675
- Baz
676
- }
677
- trait Foo {
678
- type Bar;
679
- }
680
-
681
- const CONST: () = ();
682
-
683
- fn foo<T: Foo<$0>, const CONST_PARAM: usize>(_: T) {}
684
- "# ,
685
- expect ! [ [ r#"
686
- ta Bar = type Bar;
687
- tp T
688
- cp CONST_PARAM
689
- tt Foo
690
- en Bar
691
- ct CONST
692
- "# ] ] ,
693
- ) ;
694
- }
695
598
}
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ mod item_list;
8
8
mod use_tree;
9
9
mod items;
10
10
mod pattern;
11
+ mod type_pos;
12
+
13
+ use std:: mem;
11
14
12
15
use hir:: { PrefixKind , Semantics } ;
13
16
use ide_db:: {
@@ -46,7 +49,16 @@ pub(crate) fn completion_list(code: &str) -> String {
46
49
}
47
50
48
51
fn completion_list_with_config ( config : CompletionConfig , code : & str ) -> String {
49
- render_completion_list ( get_all_items ( config, code) )
52
+ // filter out all but one builtintype completion for smaller test outputs
53
+ let items = get_all_items ( config, code) ;
54
+ let mut bt_seen = false ;
55
+ let items = items
56
+ . into_iter ( )
57
+ . filter ( |it| {
58
+ it. completion_kind != CompletionKind :: BuiltinType || !mem:: replace ( & mut bt_seen, true )
59
+ } )
60
+ . collect ( ) ;
61
+ render_completion_list ( items)
50
62
}
51
63
52
64
/// Creates analysis from a multi-file fixture, returns positions marked with $0.
Original file line number Diff line number Diff line change @@ -35,22 +35,6 @@ impl Tra$0
35
35
ma foo!(…) #[macro_export] macro_rules! foo
36
36
ma foo!(…) #[macro_export] macro_rules! foo
37
37
bt u32
38
- bt bool
39
- bt u8
40
- bt isize
41
- bt u16
42
- bt u64
43
- bt u128
44
- bt f32
45
- bt i128
46
- bt i16
47
- bt str
48
- bt i64
49
- bt char
50
- bt f64
51
- bt i32
52
- bt i8
53
- bt usize
54
38
"## ] ] ,
55
39
)
56
40
}
@@ -69,22 +53,6 @@ impl Trait for Str$0
69
53
ma foo!(…) #[macro_export] macro_rules! foo
70
54
ma foo!(…) #[macro_export] macro_rules! foo
71
55
bt u32
72
- bt bool
73
- bt u8
74
- bt isize
75
- bt u16
76
- bt u64
77
- bt u128
78
- bt f32
79
- bt i128
80
- bt i16
81
- bt str
82
- bt i64
83
- bt char
84
- bt f64
85
- bt i32
86
- bt i8
87
- bt usize
88
56
"## ] ] ,
89
57
)
90
58
}
You can’t perform that action at this time.
0 commit comments