mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
add unit test to demonstrate struct fields/methods do not get ref match completions
This commit is contained in:
parent
8cd94900f7
commit
18c3fb2df5
1 changed files with 38 additions and 0 deletions
|
@ -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",
|
||||
},
|
||||
]
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue