Skip to content

Commit 7deba43

Browse files
committed
fix: normalize thrust::Model::Ty
1 parent a6fe81e commit 7deba43

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/refine/template.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,32 @@ impl<'tcx> TypeBuilder<'tcx> {
170170
}
171171

172172
fn resolve_model_ty(&self, orig_ty: mir_ty::Ty<'tcx>) -> mir_ty::Ty<'tcx> {
173+
tracing::debug!("attempting to resolve the type {:#?}.", orig_ty);
173174
let ty = self.replace_closure_model(orig_ty);
174175

175176
let Some(model_ty_def_id) = self.def_ids.model_ty() else {
176177
return ty;
177178
};
178179
let args = self.tcx.mk_args(&[ty.into()]);
180+
tracing::debug!("generic args are {:#?}.", args);
179181
let projection_ty = mir_ty::Ty::new_projection(self.tcx, model_ty_def_id, args);
180182
if let Ok(normalized_ty) = self
181183
.tcx
182184
.try_normalize_erasing_regions(self.typing_env, projection_ty)
183185
{
184-
return normalized_ty;
186+
tracing::debug!("the type {:#?} is resolved as the type {:#?}.", orig_ty, ty);
187+
let contains_model_ty_alias = normalized_ty.walk().any(|arg| {
188+
if let mir_ty::GenericArgKind::Type(t) = arg.kind() {
189+
matches!(t.kind(), mir_ty::TyKind::Alias(_, alias_ty) if alias_ty.def_id == model_ty_def_id)
190+
} else {
191+
false
192+
}
193+
});
194+
if !contains_model_ty_alias {
195+
return normalized_ty;
196+
}
185197
}
198+
tracing::debug!("the type {:#?} is replaced as the {:#?}.", orig_ty, ty);
186199
ty
187200
}
188201

0 commit comments

Comments
 (0)