From 18c3fb2df549da2d51104d74107d3b8cd27ee996 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Mon, 22 Mar 2021 20:34:02 -0700 Subject: add unit test to demonstrate struct fields/methods do not get ref match completions --- crates/ide_completion/src/render.rs | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates/ide_completion/src/render.rs') diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index a0432b806..9ce49074f 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -1315,4 +1315,42 @@ fn main() { "#]], ) } + + #[test] + fn struct_field_method_ref() { + check( + r#" +struct Foo { bar: u32 } +impl Foo { fn baz(&self) -> u32 { 0 } } + +fn foo(f: Foo) { let _: &u32 = f.b$0 } +"#, + // FIXME + // Ideally we'd also suggest &f.bar and &f.baz() as exact + // type matches. See #8058. + expect![[r#" + [ + CompletionItem { + label: "bar", + source_range: 98..99, + delete: 98..99, + insert: "bar", + kind: SymbolKind( + Field, + ), + detail: "u32", + }, + CompletionItem { + label: "baz()", + source_range: 98..99, + delete: 98..99, + insert: "baz()$0", + kind: Method, + lookup: "baz", + detail: "fn(&self) -> u32", + }, + ] + "#]], + ); + } } -- cgit v1.2.3