mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
fix: Check whether a parameter can be converted to a local
This commit is contained in:
parent
399559e597
commit
15e7112da3
3 changed files with 41 additions and 24 deletions
|
@ -219,8 +219,13 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
|
|||
let first_param = params
|
||||
.first()
|
||||
.ok_or_else(|| format_err!("Cannot rename local to self unless it is a parameter"))?;
|
||||
if first_param.as_local(sema.db) != local {
|
||||
bail!("Only the first parameter may be renamed to self");
|
||||
match first_param.as_local(sema.db) {
|
||||
Some(plocal) => {
|
||||
if plocal != local {
|
||||
bail!("Only the first parameter may be renamed to self");
|
||||
}
|
||||
}
|
||||
None => bail!("rename_to_self invoked on destructuring parameter"),
|
||||
}
|
||||
|
||||
let assoc_item = fn_def
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue