mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Treat ast::Name
in field patterns as use
This commit is contained in:
parent
95c498d913
commit
210456aeaa
2 changed files with 119 additions and 43 deletions
|
@ -686,6 +686,52 @@ fn g() { f(); }
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_all_refs_struct_pat() {
|
||||
check(
|
||||
r#"
|
||||
struct S {
|
||||
field<|>: u8,
|
||||
}
|
||||
|
||||
fn f(s: S) {
|
||||
match s {
|
||||
S { field } => {}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 15..24 15..20 Other
|
||||
|
||||
FileId(0) 68..73 FieldShorthandForField Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_all_refs_enum_var_pat() {
|
||||
check(
|
||||
r#"
|
||||
enum En {
|
||||
Variant {
|
||||
field<|>: u8,
|
||||
}
|
||||
}
|
||||
|
||||
fn f(e: En) {
|
||||
match e {
|
||||
En::Variant { field } => {}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 32..41 32..37 Other
|
||||
|
||||
FileId(0) 102..107 FieldShorthandForField Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
check_with_scope(ra_fixture, None, expect)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue