mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
tests: suggesting names in completions for let_stmt and fn_param
This commit is contained in:
parent
492e66ceab
commit
35ed65a513
1 changed files with 73 additions and 0 deletions
|
@ -198,6 +198,7 @@ fn foo(a$0: Tuple) {
|
||||||
st Unit
|
st Unit
|
||||||
bn Record {…} Record { field$1 }$0
|
bn Record {…} Record { field$1 }$0
|
||||||
bn Tuple(…) Tuple($1)$0
|
bn Tuple(…) Tuple($1)$0
|
||||||
|
bn tuple
|
||||||
kw mut
|
kw mut
|
||||||
kw ref
|
kw ref
|
||||||
"#]],
|
"#]],
|
||||||
|
@ -850,3 +851,75 @@ fn foo() {
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn suggest_name_for_pattern() {
|
||||||
|
check_edit(
|
||||||
|
"s1",
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let $0 = S1;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let s1 = S1;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_edit(
|
||||||
|
"s1",
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo(s$0: S1) {
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo(s1: S1) {
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Tests for &adt
|
||||||
|
check_edit(
|
||||||
|
"s1",
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let $0 = &S1;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct S1;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let s1 = &S1;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do not suggest reserved keywords
|
||||||
|
check_empty(
|
||||||
|
r#"
|
||||||
|
struct Struct;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let $0 = Struct;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
st Struct
|
||||||
|
kw mut
|
||||||
|
kw ref
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue