mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Properly handle shorthands in destructure patterns when renaming
This commit is contained in:
parent
e55a44a831
commit
924eecf4af
2 changed files with 68 additions and 5 deletions
|
@ -110,14 +110,23 @@ pub(crate) fn find_all_refs(
|
|||
.filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind)
|
||||
.collect();
|
||||
|
||||
let decl_range = def.try_to_nav(sema.db)?.focus_or_full_range();
|
||||
let nav = def.try_to_nav(sema.db)?;
|
||||
let decl_range = nav.focus_or_full_range();
|
||||
|
||||
let declaration = Declaration {
|
||||
nav: def.try_to_nav(sema.db)?,
|
||||
kind: ReferenceKind::Other,
|
||||
access: decl_access(&def, &syntax, decl_range),
|
||||
let mut kind = ReferenceKind::Other;
|
||||
if let Definition::Local(local) = def {
|
||||
if let either::Either::Left(pat) = local.source(sema.db).value {
|
||||
if matches!(
|
||||
pat.syntax().parent().and_then(ast::RecordPatField::cast),
|
||||
Some(pat_field) if pat_field.name_ref().is_none()
|
||||
) {
|
||||
kind = ReferenceKind::FieldShorthandForLocal;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let declaration = Declaration { nav, kind, access: decl_access(&def, &syntax, decl_range) };
|
||||
|
||||
Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references }))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue