From b00266b79f0e2c2a5e332b30f7e6aba83b5e6e5a Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 1 Apr 2021 19:46:43 +0200 Subject: Global TypeRef/TraitRef interning --- crates/hir/src/display.rs | 2 +- crates/hir/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index 97a78ca25..ab04c55bc 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -91,7 +91,7 @@ impl HirDisplay for Function { let ret_type = if !qual.is_async { &data.ret_type } else { - match &data.ret_type { + match &*data.ret_type { TypeRef::ImplTrait(bounds) => match &bounds[0] { TypeBound::Path(path) => { path.segments().iter().last().unwrap().args_and_bindings.unwrap().bindings diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 97f162315..06fd6542d 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -957,7 +957,7 @@ impl SelfParam { func_data .params .first() - .map(|param| match *param { + .map(|param| match &**param { TypeRef::Reference(.., mutability) => match mutability { hir_def::type_ref::Mutability::Shared => Access::Shared, hir_def::type_ref::Mutability::Mut => Access::Exclusive, @@ -1011,7 +1011,7 @@ impl Const { } pub fn type_ref(self, db: &dyn HirDatabase) -> TypeRef { - db.const_data(self.id).type_ref.clone() + db.const_data(self.id).type_ref.as_ref().clone() } } @@ -1101,7 +1101,7 @@ impl TypeAlias { } pub fn type_ref(self, db: &dyn HirDatabase) -> Option { - db.type_alias_data(self.id).type_ref.clone() + db.type_alias_data(self.id).type_ref.as_deref().cloned() } pub fn ty(self, db: &dyn HirDatabase) -> Type { @@ -1615,7 +1615,7 @@ impl Impl { // FIXME: the return type is wrong. This should be a hir version of // `TraitRef` (ie, resolved `TypeRef`). pub fn trait_(self, db: &dyn HirDatabase) -> Option { - db.impl_data(self.id).target_trait.clone() + db.impl_data(self.id).target_trait.as_deref().cloned() } pub fn self_ty(self, db: &dyn HirDatabase) -> Type { -- cgit v1.2.3