aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/generics.rs16
-rw-r--r--crates/hir_def/src/path.rs2
-rw-r--r--crates/hir_def/src/path/lower.rs2
3 files changed, 11 insertions, 9 deletions
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs
index 7c6cbff11..e02ac2c2f 100644
--- a/crates/hir_def/src/generics.rs
+++ b/crates/hir_def/src/generics.rs
@@ -18,6 +18,7 @@ use crate::{
18 child_by_source::ChildBySource, 18 child_by_source::ChildBySource,
19 db::DefDatabase, 19 db::DefDatabase,
20 dyn_map::DynMap, 20 dyn_map::DynMap,
21 intern::Interned,
21 keys, 22 keys,
22 src::{HasChildSource, HasSource}, 23 src::{HasChildSource, HasSource},
23 type_ref::{LifetimeRef, TypeBound, TypeRef}, 24 type_ref::{LifetimeRef, TypeBound, TypeRef},
@@ -29,7 +30,7 @@ use crate::{
29#[derive(Clone, PartialEq, Eq, Debug)] 30#[derive(Clone, PartialEq, Eq, Debug)]
30pub struct TypeParamData { 31pub struct TypeParamData {
31 pub name: Option<Name>, 32 pub name: Option<Name>,
32 pub default: Option<TypeRef>, 33 pub default: Option<Interned<TypeRef>>,
33 pub provenance: TypeParamProvenance, 34 pub provenance: TypeParamProvenance,
34} 35}
35 36
@@ -43,7 +44,7 @@ pub struct LifetimeParamData {
43#[derive(Clone, PartialEq, Eq, Debug)] 44#[derive(Clone, PartialEq, Eq, Debug)]
44pub struct ConstParamData { 45pub struct ConstParamData {
45 pub name: Name, 46 pub name: Name,
46 pub ty: TypeRef, 47 pub ty: Interned<TypeRef>,
47} 48}
48 49
49#[derive(Copy, Clone, PartialEq, Eq, Debug)] 50#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -75,7 +76,7 @@ pub enum WherePredicate {
75 76
76#[derive(Clone, PartialEq, Eq, Debug)] 77#[derive(Clone, PartialEq, Eq, Debug)]
77pub enum WherePredicateTypeTarget { 78pub enum WherePredicateTypeTarget {
78 TypeRef(TypeRef), 79 TypeRef(Interned<TypeRef>),
79 /// For desugared where predicates that can directly refer to a type param. 80 /// For desugared where predicates that can directly refer to a type param.
80 TypeParam(LocalTypeParamId), 81 TypeParam(LocalTypeParamId),
81} 82}
@@ -256,7 +257,8 @@ impl GenericParams {
256 for type_param in params.type_params() { 257 for type_param in params.type_params() {
257 let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); 258 let name = type_param.name().map_or_else(Name::missing, |it| it.as_name());
258 // FIXME: Use `Path::from_src` 259 // FIXME: Use `Path::from_src`
259 let default = type_param.default_type().map(|it| TypeRef::from_ast(lower_ctx, it)); 260 let default =
261 type_param.default_type().map(|it| Interned::new(TypeRef::from_ast(lower_ctx, it)));
260 let param = TypeParamData { 262 let param = TypeParamData {
261 name: Some(name.clone()), 263 name: Some(name.clone()),
262 default, 264 default,
@@ -280,7 +282,7 @@ impl GenericParams {
280 for const_param in params.const_params() { 282 for const_param in params.const_params() {
281 let name = const_param.name().map_or_else(Name::missing, |it| it.as_name()); 283 let name = const_param.name().map_or_else(Name::missing, |it| it.as_name());
282 let ty = const_param.ty().map_or(TypeRef::Error, |it| TypeRef::from_ast(lower_ctx, it)); 284 let ty = const_param.ty().map_or(TypeRef::Error, |it| TypeRef::from_ast(lower_ctx, it));
283 let param = ConstParamData { name, ty }; 285 let param = ConstParamData { name, ty: Interned::new(ty) };
284 let param_id = self.consts.alloc(param); 286 let param_id = self.consts.alloc(param);
285 sm.const_params.insert(param_id, const_param.clone()); 287 sm.const_params.insert(param_id, const_param.clone());
286 } 288 }
@@ -334,11 +336,11 @@ impl GenericParams {
334 (Either::Left(type_ref), bound) => match hrtb_lifetimes { 336 (Either::Left(type_ref), bound) => match hrtb_lifetimes {
335 Some(hrtb_lifetimes) => WherePredicate::ForLifetime { 337 Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
336 lifetimes: hrtb_lifetimes.clone(), 338 lifetimes: hrtb_lifetimes.clone(),
337 target: WherePredicateTypeTarget::TypeRef(type_ref), 339 target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)),
338 bound, 340 bound,
339 }, 341 },
340 None => WherePredicate::TypeBound { 342 None => WherePredicate::TypeBound {
341 target: WherePredicateTypeTarget::TypeRef(type_ref), 343 target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)),
342 bound, 344 bound,
343 }, 345 },
344 }, 346 },
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs
index a3e83e2cf..f9c8328f0 100644
--- a/crates/hir_def/src/path.rs
+++ b/crates/hir_def/src/path.rs
@@ -122,7 +122,7 @@ impl ModPath {
122pub struct Path { 122pub struct Path {
123 /// Type based path like `<T>::foo`. 123 /// Type based path like `<T>::foo`.
124 /// Note that paths like `<Type as Trait>::foo` are desugard to `Trait::<Self=Type>::foo`. 124 /// Note that paths like `<Type as Trait>::foo` are desugard to `Trait::<Self=Type>::foo`.
125 type_anchor: Option<Box<TypeRef>>, 125 type_anchor: Option<Interned<TypeRef>>,
126 mod_path: Interned<ModPath>, 126 mod_path: Interned<ModPath>,
127 /// Invariant: the same len as `self.mod_path.segments` 127 /// Invariant: the same len as `self.mod_path.segments`
128 generic_args: Vec<Option<Arc<GenericArgs>>>, 128 generic_args: Vec<Option<Arc<GenericArgs>>>,
diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs
index 28f6244da..7b29d9d4f 100644
--- a/crates/hir_def/src/path/lower.rs
+++ b/crates/hir_def/src/path/lower.rs
@@ -69,7 +69,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
69 match trait_ref { 69 match trait_ref {
70 // <T>::foo 70 // <T>::foo
71 None => { 71 None => {
72 type_anchor = Some(Box::new(self_type)); 72 type_anchor = Some(Interned::new(self_type));
73 kind = PathKind::Plain; 73 kind = PathKind::Plain;
74 } 74 }
75 // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo 75 // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo