From 1a26af15ef190bf605d3a04005aea02664815fb0 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 8 Jun 2021 20:27:25 +0200 Subject: Add tests checking no value completion in type pos --- .../src/completions/qualified_path.rs | 30 ++++++++++++++++++++++ .../src/completions/unqualified_path.rs | 22 ++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'crates/ide_completion/src/completions') diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index d58745fb4..a5cba5938 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -198,6 +198,36 @@ mod tests { check(r#"use self::foo$0;"#, expect![[""]]); } + #[test] + fn dont_complete_values_in_type_pos() { + check( + r#" +const FOO: () = (); +static BAR: () = (); +struct Baz; +fn foo() { + let _: self::$0; +} +"#, + expect![[r#" + st Baz + "#]], + ); + } + + #[test] + fn dont_complete_enum_variants_in_type_pos() { + check( + r#" +enum Foo { Bar } +fn foo() { + let _: Foo::$0; +} +"#, + expect![[r#""#]], + ); + } + #[test] fn dont_complete_current_use_in_braces_with_glob() { check( diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index f370dbdf0..2105bb428 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -68,6 +68,28 @@ mod tests { expect.assert_eq(&actual) } + #[test] + fn dont_complete_values_in_type_pos() { + check( + r#" +const FOO: () = (); +static BAR: () = (); +enum Foo { + Bar +} +struct Baz; +fn foo() { + let local = (); + let _: $0; +} +"#, + expect![[r#" + en Foo + st Baz + "#]], + ); + } + #[test] fn only_completes_modules_in_import() { cov_mark::check!(only_completes_modules_in_import); -- cgit v1.2.3