Skip to content

Commit 2e0610e

Browse files
author
Anatol Ulrich
committed
one down
1 parent 95199ac commit 2e0610e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/ide/src/rename.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ pub(crate) fn prepare_rename(
3636
let mut defs = find_definitions(&sema, syntax, position)?;
3737

3838
// TODO:
39-
// - empty case possible or already caught by `find_definitions`?
40-
// - is "just take the first" correct? If not, what do?
41-
let (name_like, _def) = defs.next().unwrap();
39+
// - is "No references found at position" the right error? (why does it not get caught by `find_definitions`... hmm)
40+
// - is "just take the first `name_like`" correct? If not, what do?
41+
let (name_like, _def) =
42+
defs.next().ok_or_else(|| format_err!("No references found at position"))?;
4243
let frange = sema.original_range(name_like.syntax());
4344
always!(frange.range.contains_inclusive(position.offset) && frange.file_id == position.file_id);
4445
Ok(RangeInfo::new(frange.range, ()))

0 commit comments

Comments
 (0)