|
3 | 3 | use std::{fmt::Display, iter};
|
4 | 4 |
|
5 | 5 | use crate::{
|
6 |
| - consteval::usize_const, db::HirDatabase, display::HirDisplay, infer::PointerCast, |
7 |
| - lang_items::is_box, mapping::ToChalk, CallableDefId, ClosureId, Const, ConstScalar, |
8 |
| - InferenceResult, Interner, MemoryMap, Substitution, Ty, TyKind, |
| 6 | + consteval::usize_const, |
| 7 | + db::HirDatabase, |
| 8 | + display::HirDisplay, |
| 9 | + infer::{normalize, PointerCast}, |
| 10 | + lang_items::is_box, |
| 11 | + mapping::ToChalk, |
| 12 | + CallableDefId, ClosureId, Const, ConstScalar, InferenceResult, Interner, MemoryMap, |
| 13 | + Substitution, TraitEnvironment, Ty, TyKind, |
9 | 14 | };
|
10 | 15 | use base_db::CrateId;
|
11 | 16 | use chalk_ir::Mutability;
|
@@ -34,6 +39,7 @@ pub use monomorphization::{
|
34 | 39 | };
|
35 | 40 | use smallvec::{smallvec, SmallVec};
|
36 | 41 | use stdx::{impl_from, never};
|
| 42 | +use triomphe::Arc; |
37 | 43 |
|
38 | 44 | use super::consteval::{intern_const_scalar, try_const_usize};
|
39 | 45 |
|
@@ -131,11 +137,19 @@ pub enum ProjectionElem<V, T> {
|
131 | 137 | impl<V, T> ProjectionElem<V, T> {
|
132 | 138 | pub fn projected_ty(
|
133 | 139 | &self,
|
134 |
| - base: Ty, |
| 140 | + mut base: Ty, |
135 | 141 | db: &dyn HirDatabase,
|
136 | 142 | closure_field: impl FnOnce(ClosureId, &Substitution, usize) -> Ty,
|
137 | 143 | krate: CrateId,
|
138 | 144 | ) -> Ty {
|
| 145 | + if matches!(base.data(Interner).kind, TyKind::Alias(_) | TyKind::AssociatedType(..)) { |
| 146 | + base = normalize( |
| 147 | + db, |
| 148 | + // FIXME: we should get this from caller |
| 149 | + Arc::new(TraitEnvironment::empty(krate)), |
| 150 | + base, |
| 151 | + ); |
| 152 | + } |
139 | 153 | match self {
|
140 | 154 | ProjectionElem::Deref => match &base.data(Interner).kind {
|
141 | 155 | TyKind::Raw(_, inner) | TyKind::Ref(_, _, inner) => inner.clone(),
|
|
0 commit comments