mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Add tests checking no value completion in type pos
This commit is contained in:
parent
1d74ef1d98
commit
1a26af15ef
3 changed files with 55 additions and 0 deletions
|
@ -204,6 +204,9 @@ impl Completions {
|
|||
variant: hir::Variant,
|
||||
local_name: Option<hir::Name>,
|
||||
) {
|
||||
if ctx.expects_type() {
|
||||
return;
|
||||
}
|
||||
let item = render_variant(RenderContext::new(ctx), None, local_name, variant, None);
|
||||
self.add(item);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue