aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2021-03-23 03:34:02 +0000
committerJosh Mcguigan <[email protected]>2021-03-23 03:34:02 +0000
commit18c3fb2df549da2d51104d74107d3b8cd27ee996 (patch)
treede830248d81791b47599ed047f13e20c77dce80d /crates
parent8cd94900f7e0806bfdf4e6cb6f0bb868f7673d7d (diff)
add unit test to demonstrate struct fields/methods do not get ref match completions
Diffstat (limited to 'crates')
-rw-r--r--crates/ide_completion/src/render.rs38
1 files changed, 38 insertions, 0 deletions
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() {
1315 "#]], 1315 "#]],
1316 ) 1316 )
1317 } 1317 }
1318
1319 #[test]
1320 fn struct_field_method_ref() {
1321 check(
1322 r#"
1323struct Foo { bar: u32 }
1324impl Foo { fn baz(&self) -> u32 { 0 } }
1325
1326fn foo(f: Foo) { let _: &u32 = f.b$0 }
1327"#,
1328 // FIXME
1329 // Ideally we'd also suggest &f.bar and &f.baz() as exact
1330 // type matches. See #8058.
1331 expect![[r#"
1332 [
1333 CompletionItem {
1334 label: "bar",
1335 source_range: 98..99,
1336 delete: 98..99,
1337 insert: "bar",
1338 kind: SymbolKind(
1339 Field,
1340 ),
1341 detail: "u32",
1342 },
1343 CompletionItem {
1344 label: "baz()",
1345 source_range: 98..99,
1346 delete: 98..99,
1347 insert: "baz()$0",
1348 kind: Method,
1349 lookup: "baz",
1350 detail: "fn(&self) -> u32",
1351 },
1352 ]
1353 "#]],
1354 );
1355 }
1318} 1356}