This commit is contained in:
Anatol Ulrich 2021-10-27 04:42:58 +02:00
parent 95199ac30b
commit 2e0610e64e

View File

@ -36,9 +36,10 @@ pub(crate) fn prepare_rename(
let mut defs = find_definitions(&sema, syntax, position)?; let mut defs = find_definitions(&sema, syntax, position)?;
// TODO: // TODO:
// - empty case possible or already caught by `find_definitions`? // - is "No references found at position" the right error? (why does it not get caught by `find_definitions`... hmm)
// - is "just take the first" correct? If not, what do? // - is "just take the first `name_like`" correct? If not, what do?
let (name_like, _def) = defs.next().unwrap(); let (name_like, _def) =
defs.next().ok_or_else(|| format_err!("No references found at position"))?;
let frange = sema.original_range(name_like.syntax()); let frange = sema.original_range(name_like.syntax());
always!(frange.range.contains_inclusive(position.offset) && frange.file_id == position.file_id); always!(frange.range.contains_inclusive(position.offset) && frange.file_id == position.file_id);
Ok(RangeInfo::new(frange.range, ())) Ok(RangeInfo::new(frange.range, ()))