diff --git a/crates/ide-completion/src/tests/type_pos.rs b/crates/ide-completion/src/tests/type_pos.rs index 6369f31788c..31ff9cf956e 100644 --- a/crates/ide-completion/src/tests/type_pos.rs +++ b/crates/ide-completion/src/tests/type_pos.rs @@ -715,8 +715,8 @@ struct Foo { #[test] fn completes_const_and_type_generics_separately() { - let type_completion_cases = [ - // Function + // Function generic params + check( r#" struct Foo; const X: usize = 0; @@ -725,7 +725,41 @@ fn main() { foo::(); } "#, - // Method + expect![[r#" + en Enum + ma makro!(…) macro_rules! makro + md module + st Foo + st Record + st Tuple + st Unit + tt Trait + un Union + bt u32 + kw crate:: + kw self:: + "#]], + ); + check( + r#" +struct Foo; +const X: usize = 0; +fn foo() {} +fn main() { + foo::<_, $0>(); +} + "#, + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Method generic params + check( r#" const X: usize = 0; struct Foo; @@ -734,28 +768,40 @@ fn main() { Foo.bar::<_, $0>(); } "#, - ]; - - for case in type_completion_cases { - check( - case, - expect![[r#" - en Enum - ma makro!(…) macro_rules! makro - md module - st Foo - st Record - st Tuple - st Unit - tt Trait - un Union - bt u32 - kw crate:: - kw self:: - "#]], - ) - } + expect![[r#" + en Enum + ma makro!(…) macro_rules! makro + md module + st Foo + st Record + st Tuple + st Unit + tt Trait + un Union + bt u32 + kw crate:: + kw self:: + "#]], + ); + check( + r#" +const X: usize = 0; +struct Foo; +impl Foo { fn bar(self) {} } +fn main() { + Foo.bar::(); +} + "#, + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + // Associated type generic params check( r#" const X: usize = 0; @@ -781,27 +827,7 @@ fn foo(_: impl Bar = ()>) {} kw self:: "#]], ); - - let const_completion_cases = [ - // Function params - r#" -struct Foo; -const X: usize = 0; -fn foo() {} -fn main() { - foo::<_, $0>(); -} - "#, - // Method params - r#" -const X: usize = 0; -struct Foo; -impl Foo { fn bar(self) {} } -fn main() { - Foo.bar::(); -} - "#, - // Associated type params + check( r#" const X: usize = 0; struct Foo; @@ -810,7 +836,17 @@ trait Bar { } fn foo = ()>>() {} "#, - // Type params + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Type generic params + check( r#" const X: usize = 0; struct Foo(T); @@ -818,7 +854,17 @@ fn main() { let _: Foo::<_, $0> = Foo(()); } "#, - // Enum variant params + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Type alias generic params + check( r#" const X: usize = 0; struct Foo(T); @@ -827,6 +873,17 @@ fn main() { let _: Bar:: = Bar(()); } "#, + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Enum variant params + check( r#" const X: usize = 0; enum Foo { A(T), B } @@ -834,13 +891,33 @@ fn main() { Foo::B::<(), $0>; } "#, - // Trait params + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Trait params + check( r#" const X: usize = 0; trait Foo {} impl Foo<(), $0> for () {} "#, - // Trait alias params + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); + + // Trait alias params + check( r#" #![feature(trait_alias)] const X: usize = 0; @@ -848,18 +925,12 @@ trait Foo {} trait Bar = Foo; fn foo>() {} "#, - ]; - - for case in const_completion_cases { - check( - case, - expect![[r#" - ct CONST - ct X - ma makro!(…) macro_rules! makro - kw crate:: - kw self:: - "#]], - ); - } + expect![[r#" + ct CONST + ct X + ma makro!(…) macro_rules! makro + kw crate:: + kw self:: + "#]], + ); }