diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index e6a7aaee07a..2f42f877ca5 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -43,11 +43,11 @@ pub enum PathResolution { } impl PathResolution { - fn in_type_ns(self) -> Option { + fn in_type_ns(&self) -> Option { match self { - PathResolution::Def(ModuleDef::Adt(adt)) => Some(TypeNs::AdtId(adt.into())), + PathResolution::Def(ModuleDef::Adt(adt)) => Some(TypeNs::AdtId((*adt).into())), PathResolution::Def(ModuleDef::BuiltinType(builtin)) => { - Some(TypeNs::BuiltinType(builtin)) + Some(TypeNs::BuiltinType(*builtin)) } PathResolution::Def(ModuleDef::Const(_)) => None, PathResolution::Def(ModuleDef::EnumVariant(_)) => None, @@ -56,16 +56,16 @@ fn in_type_ns(self) -> Option { PathResolution::Def(ModuleDef::Static(_)) => None, PathResolution::Def(ModuleDef::Trait(_)) => None, PathResolution::Def(ModuleDef::TypeAlias(alias)) => { - Some(TypeNs::TypeAliasId(alias.into())) + Some(TypeNs::TypeAliasId((*alias).into())) } PathResolution::Local(_) => None, - PathResolution::TypeParam(param) => Some(TypeNs::GenericParam(param.into())), - PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType(impl_def.into())), + PathResolution::TypeParam(param) => Some(TypeNs::GenericParam((*param).into())), + PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType((*impl_def).into())), PathResolution::Macro(_) => None, PathResolution::AssocItem(AssocItem::Const(_)) => None, PathResolution::AssocItem(AssocItem::Function(_)) => None, PathResolution::AssocItem(AssocItem::TypeAlias(alias)) => { - Some(TypeNs::TypeAliasId(alias.into())) + Some(TypeNs::TypeAliasId((*alias).into())) } } } @@ -77,7 +77,7 @@ pub fn assoc_type_shorthand_candidates( db: &dyn HirDatabase, mut cb: impl FnMut(TypeAlias) -> Option, ) -> Option { - if let Some(res) = self.clone().in_type_ns() { + if let Some(res) = self.in_type_ns() { associated_type_shorthand_candidates(db, res, |_, _, id| cb(id.into())) } else { None