minor: less ambiguous name

This commit is contained in:
Aleksey Kladov 2021-06-14 19:15:53 +03:00
parent da534bdd07
commit 94f7b63522
2 changed files with 7 additions and 5 deletions

View file

@ -32,8 +32,9 @@ pub(crate) fn prepare_rename(
let syntax = source_file.syntax();
let def = find_definition(&sema, syntax, position)?;
let frange =
def.rename_range(&sema).ok_or_else(|| format_err!("No references found at position"))?;
let frange = def
.range_for_rename(&sema)
.ok_or_else(|| format_err!("No references found at position"))?;
Ok(RangeInfo::new(frange.range, ()))
}

View file

@ -80,7 +80,7 @@ impl Definition {
/// Textual range of the identifier which will change when renaming this
/// `Definition`. Note that some definitions, like buitin types, can't be
/// renamed.
pub fn rename_range(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> {
pub fn range_for_rename(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> {
// FIXME: the `original_file_range` calls here are wrong -- they never fail,
// and _fall back_ to the entirety of the macro call. Such fall back is
// incorrect for renames. The safe behavior would be to return an error for
@ -412,8 +412,9 @@ fn source_edit_from_def(
def: Definition,
new_name: &str,
) -> Result<(FileId, TextEdit)> {
let frange =
def.rename_range(sema).ok_or_else(|| format_err!("No identifier available to rename"))?;
let frange = def
.range_for_rename(sema)
.ok_or_else(|| format_err!("No identifier available to rename"))?;
let mut replacement_text = String::new();
let mut repl_range = frange.range;