diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/rename.rs | 5 | ||||
-rw-r--r-- | crates/ide_db/src/rename.rs | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index 41689a939..8096dfa0e 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs | |||
@@ -32,8 +32,9 @@ pub(crate) fn prepare_rename( | |||
32 | let syntax = source_file.syntax(); | 32 | let syntax = source_file.syntax(); |
33 | 33 | ||
34 | let def = find_definition(&sema, syntax, position)?; | 34 | let def = find_definition(&sema, syntax, position)?; |
35 | let frange = | 35 | let frange = def |
36 | def.rename_range(&sema).ok_or_else(|| format_err!("No references found at position"))?; | 36 | .range_for_rename(&sema) |
37 | .ok_or_else(|| format_err!("No references found at position"))?; | ||
37 | Ok(RangeInfo::new(frange.range, ())) | 38 | Ok(RangeInfo::new(frange.range, ())) |
38 | } | 39 | } |
39 | 40 | ||
diff --git a/crates/ide_db/src/rename.rs b/crates/ide_db/src/rename.rs index d77602453..82855725f 100644 --- a/crates/ide_db/src/rename.rs +++ b/crates/ide_db/src/rename.rs | |||
@@ -80,7 +80,7 @@ impl Definition { | |||
80 | /// Textual range of the identifier which will change when renaming this | 80 | /// Textual range of the identifier which will change when renaming this |
81 | /// `Definition`. Note that some definitions, like buitin types, can't be | 81 | /// `Definition`. Note that some definitions, like buitin types, can't be |
82 | /// renamed. | 82 | /// renamed. |
83 | pub fn rename_range(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> { | 83 | pub fn range_for_rename(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> { |
84 | // FIXME: the `original_file_range` calls here are wrong -- they never fail, | 84 | // FIXME: the `original_file_range` calls here are wrong -- they never fail, |
85 | // and _fall back_ to the entirety of the macro call. Such fall back is | 85 | // and _fall back_ to the entirety of the macro call. Such fall back is |
86 | // incorrect for renames. The safe behavior would be to return an error for | 86 | // incorrect for renames. The safe behavior would be to return an error for |
@@ -412,8 +412,9 @@ fn source_edit_from_def( | |||
412 | def: Definition, | 412 | def: Definition, |
413 | new_name: &str, | 413 | new_name: &str, |
414 | ) -> Result<(FileId, TextEdit)> { | 414 | ) -> Result<(FileId, TextEdit)> { |
415 | let frange = | 415 | let frange = def |
416 | def.rename_range(sema).ok_or_else(|| format_err!("No identifier available to rename"))?; | 416 | .range_for_rename(sema) |
417 | .ok_or_else(|| format_err!("No identifier available to rename"))?; | ||
417 | 418 | ||
418 | let mut replacement_text = String::new(); | 419 | let mut replacement_text = String::new(); |
419 | let mut repl_range = frange.range; | 420 | let mut repl_range = frange.range; |