diff options
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/display.rs | 7 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 7 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 18 |
4 files changed, 22 insertions, 18 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 21291ddda..378c951c5 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -319,7 +319,10 @@ impl HirDisplay for Ty { | |||
319 | TyKind::Dyn(predicates) if predicates.len() > 1 => { | 319 | TyKind::Dyn(predicates) if predicates.len() > 1 => { |
320 | Cow::Borrowed(predicates.as_ref()) | 320 | Cow::Borrowed(predicates.as_ref()) |
321 | } | 321 | } |
322 | &TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, ref parameters })) => { | 322 | &TyKind::Alias(AliasTy::Opaque(OpaqueTy { |
323 | opaque_ty_id, | ||
324 | substitution: ref parameters, | ||
325 | })) => { | ||
323 | let impl_trait_id = f.db.lookup_intern_impl_trait_id(opaque_ty_id.into()); | 326 | let impl_trait_id = f.db.lookup_intern_impl_trait_id(opaque_ty_id.into()); |
324 | if let ImplTraitId::ReturnTypeImplTrait(func, idx) = impl_trait_id { | 327 | if let ImplTraitId::ReturnTypeImplTrait(func, idx) = impl_trait_id { |
325 | datas = | 328 | datas = |
@@ -579,7 +582,7 @@ impl HirDisplay for Ty { | |||
579 | let data = (*datas) | 582 | let data = (*datas) |
580 | .as_ref() | 583 | .as_ref() |
581 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 584 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
582 | let bounds = data.subst(&opaque_ty.parameters); | 585 | let bounds = data.subst(&opaque_ty.substitution); |
583 | write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?; | 586 | write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?; |
584 | } | 587 | } |
585 | ImplTraitId::AsyncBlockTypeImplTrait(..) => { | 588 | ImplTraitId::AsyncBlockTypeImplTrait(..) => { |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index bc7a7369a..484652073 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -66,7 +66,7 @@ pub enum Lifetime { | |||
66 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 66 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
67 | pub struct OpaqueTy { | 67 | pub struct OpaqueTy { |
68 | pub opaque_ty_id: OpaqueTyId, | 68 | pub opaque_ty_id: OpaqueTyId, |
69 | pub parameters: Substs, | 69 | pub substitution: Substs, |
70 | } | 70 | } |
71 | 71 | ||
72 | /// A "projection" type corresponds to an (unnormalized) | 72 | /// A "projection" type corresponds to an (unnormalized) |
@@ -903,7 +903,7 @@ impl Ty { | |||
903 | let data = (*it) | 903 | let data = (*it) |
904 | .as_ref() | 904 | .as_ref() |
905 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 905 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
906 | data.subst(&opaque_ty.parameters) | 906 | data.subst(&opaque_ty.substitution) |
907 | }) | 907 | }) |
908 | } | 908 | } |
909 | // It always has an parameter for Future::Output type. | 909 | // It always has an parameter for Future::Output type. |
@@ -1059,7 +1059,7 @@ impl TypeWalk for Ty { | |||
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | TyKind::Alias(AliasTy::Opaque(o_ty)) => { | 1061 | TyKind::Alias(AliasTy::Opaque(o_ty)) => { |
1062 | for t in o_ty.parameters.iter() { | 1062 | for t in o_ty.substitution.iter() { |
1063 | t.walk(f); | 1063 | t.walk(f); |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
@@ -1094,7 +1094,7 @@ impl TypeWalk for Ty { | |||
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | TyKind::Alias(AliasTy::Opaque(o_ty)) => { | 1096 | TyKind::Alias(AliasTy::Opaque(o_ty)) => { |
1097 | o_ty.parameters.walk_mut_binders(f, binders); | 1097 | o_ty.substitution.walk_mut_binders(f, binders); |
1098 | } | 1098 | } |
1099 | _ => { | 1099 | _ => { |
1100 | if let Some(substs) = self.substs_mut() { | 1100 | if let Some(substs) = self.substs_mut() { |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 76b2124af..d026310f4 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -230,8 +230,11 @@ impl<'a> TyLoweringContext<'a> { | |||
230 | let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); | 230 | let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); |
231 | let generics = generics(self.db.upcast(), func.into()); | 231 | let generics = generics(self.db.upcast(), func.into()); |
232 | let parameters = Substs::bound_vars(&generics, self.in_binders); | 232 | let parameters = Substs::bound_vars(&generics, self.in_binders); |
233 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters })) | 233 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { |
234 | .intern(&Interner) | 234 | opaque_ty_id, |
235 | substitution: parameters, | ||
236 | })) | ||
237 | .intern(&Interner) | ||
235 | } | 238 | } |
236 | ImplTraitLoweringMode::Param => { | 239 | ImplTraitLoweringMode::Param => { |
237 | let idx = self.impl_trait_counter.get(); | 240 | let idx = self.impl_trait_counter.get(); |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 1a6fca611..05a4bf0df 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -87,6 +87,13 @@ impl ToChalk for Ty { | |||
87 | .cast(&Interner) | 87 | .cast(&Interner) |
88 | .intern(&Interner) | 88 | .intern(&Interner) |
89 | } | 89 | } |
90 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { | ||
91 | let opaque_ty_id = opaque_ty.opaque_ty_id; | ||
92 | let substitution = opaque_ty.substitution.to_chalk(db); | ||
93 | chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { opaque_ty_id, substitution }) | ||
94 | .cast(&Interner) | ||
95 | .intern(&Interner) | ||
96 | } | ||
90 | TyKind::Placeholder(idx) => idx.to_ty::<Interner>(&Interner), | 97 | TyKind::Placeholder(idx) => idx.to_ty::<Interner>(&Interner), |
91 | TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), | 98 | TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), |
92 | TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), | 99 | TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), |
@@ -101,15 +108,6 @@ impl ToChalk for Ty { | |||
101 | }; | 108 | }; |
102 | chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) | 109 | chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) |
103 | } | 110 | } |
104 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { | ||
105 | let opaque_ty_id = opaque_ty.opaque_ty_id; | ||
106 | let substitution = opaque_ty.parameters.to_chalk(db); | ||
107 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { | ||
108 | opaque_ty_id, | ||
109 | substitution, | ||
110 | })) | ||
111 | .intern(&Interner) | ||
112 | } | ||
113 | TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner), | 111 | TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner), |
114 | } | 112 | } |
115 | } | 113 | } |
@@ -129,7 +127,7 @@ impl ToChalk for Ty { | |||
129 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { | 127 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { |
130 | let opaque_ty_id = opaque_ty.opaque_ty_id; | 128 | let opaque_ty_id = opaque_ty.opaque_ty_id; |
131 | let parameters = from_chalk(db, opaque_ty.substitution); | 129 | let parameters = from_chalk(db, opaque_ty.substitution); |
132 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters })) | 130 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, substitution: parameters })) |
133 | } | 131 | } |
134 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 132 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { |
135 | num_binders, | 133 | num_binders, |