From 2c7a8c485710beb5700bb7a474cd152f0b075a0f Mon Sep 17 00:00:00 2001 From: Lukas Tobias Wirth Date: Wed, 19 May 2021 14:19:44 +0200 Subject: Fix prepare_rename failing for modules --- crates/ide/src/references/rename.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 2bf953305..01fe3a1a1 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -55,12 +55,14 @@ pub(crate) fn prepare_rename( match def { Definition::SelfType(_) => bail!("Cannot rename `Self`"), Definition::ModuleDef(ModuleDef::BuiltinType(_)) => bail!("Cannot rename builtin type"), - _ => {} + Definition::ModuleDef(ModuleDef::Module(_)) => (), + _ => { + let nav = def + .try_to_nav(sema.db) + .ok_or_else(|| format_err!("No references found at position"))?; + nav.focus_range.ok_or_else(|| format_err!("No identifier available to rename"))?; + } }; - let nav = - def.try_to_nav(sema.db).ok_or_else(|| format_err!("No references found at position"))?; - nav.focus_range.ok_or_else(|| format_err!("No identifier available to rename"))?; - let name_like = sema .find_node_at_offset_with_descend(&syntax, position.offset) .ok_or_else(|| format_err!("No references found at position"))?; -- cgit v1.2.3