diff options
| author | Anatol Ulrich <anatol.ulrich@ferrous-systems.com> | 2021-10-27 04:42:58 +0200 |
|---|---|---|
| committer | Anatol Ulrich <anatol.ulrich@ferrous-systems.com> | 2021-10-27 04:42:58 +0200 |
| commit | 2e0610e64e7a573867eea29efcf59ae2fbad0251 (patch) | |
| tree | b0ea118a8d98f5d08ac1fcb70bbaffd6722594ad | |
| parent | 95199ac30bdc1a615ce3eb1b924183a18c7b1656 (diff) | |
| download | rust-2e0610e64e7a573867eea29efcf59ae2fbad0251.tar.gz rust-2e0610e64e7a573867eea29efcf59ae2fbad0251.zip | |
one down
| -rw-r--r-- | crates/ide/src/rename.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index 48d748fd198..51f6b5d133f 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs @@ -36,9 +36,10 @@ pub(crate) fn prepare_rename( let mut defs = find_definitions(&sema, syntax, position)?; // TODO: - // - empty case possible or already caught by `find_definitions`? - // - is "just take the first" correct? If not, what do? - let (name_like, _def) = defs.next().unwrap(); + // - is "No references found at position" the right error? (why does it not get caught by `find_definitions`... hmm) + // - is "just take the first `name_like`" correct? If not, what do? + let (name_like, _def) = + defs.next().ok_or_else(|| format_err!("No references found at position"))?; let frange = sema.original_range(name_like.syntax()); always!(frange.range.contains_inclusive(position.offset) && frange.file_id == position.file_id); Ok(RangeInfo::new(frange.range, ())) |
