@@ -804,7 +804,17 @@ impl Alias {
804804 alias_ty : & ty:: AliasTy < ' tcx > ,
805805 ) -> TyKind {
806806 let tcx = s. base ( ) . tcx ;
807+ let typing_env = s. typing_env ( ) ;
807808 use rustc_type_ir:: AliasTyKind as RustAliasKind ;
809+
810+ // Try to normalize the alias first.
811+ let ty = ty:: Ty :: new_alias ( tcx, * alias_kind, * alias_ty) ;
812+ let ty = crate :: traits:: normalize ( tcx, typing_env, ty) ;
813+ let ty:: Alias ( alias_kind, alias_ty) = ty. kind ( ) else {
814+ let ty: Ty = ty. sinto ( s) ;
815+ return ty. kind ( ) . clone ( ) ;
816+ } ;
817+
808818 let kind = match alias_kind {
809819 RustAliasKind :: Projection => {
810820 let trait_ref = alias_ty. trait_ref ( tcx) ;
@@ -820,7 +830,7 @@ impl Alias {
820830 // yet we dont have a binder around (could even be several). Binding this correctly
821831 // is therefore difficult. Since our trait resolution ignores lifetimes anyway, we
822832 // just erase them. See also https://github.com/hacspec/hax/issues/747.
823- let trait_ref = crate :: traits:: erase_and_norm ( tcx, s . typing_env ( ) , trait_ref) ;
833+ let trait_ref = crate :: traits:: erase_free_regions ( tcx, trait_ref) ;
824834 AliasKind :: Projection {
825835 assoc_item : tcx. associated_item ( alias_ty. def_id ) . sinto ( s) ,
826836 impl_expr : solve_trait ( s, ty:: Binder :: dummy ( trait_ref) ) ,
0 commit comments