@@ -333,10 +333,11 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
333333 let res = if free. kind ( infcx. tcx ) . is_type ( ) {
334334 infcx. tcx . type_of ( free. def_id ) . instantiate ( infcx. tcx , free. args ) . fold_with ( self ) . into ( )
335335 } else {
336- // FIXME(mgca): once const items are actual aliases defined as equal to type system consts
337- // this should instead use that rather than evaluating.
338- super :: evaluate_const ( infcx, free. to_term ( infcx. tcx ) . expect_const ( ) , self . param_env )
339- . super_fold_with ( self )
336+ infcx
337+ . tcx
338+ . const_of_item ( free. def_id )
339+ . instantiate ( infcx. tcx , free. args )
340+ . fold_with ( self )
340341 . into ( )
341342 } ;
342343 self . depth -= 1 ;
@@ -436,51 +437,40 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
436437 return ct;
437438 }
438439
439- // Doing "proper" normalization of const aliases is inherently cyclic until const items
440- // are real aliases instead of having bodies. We gate proper const alias handling behind
441- // mgca to avoid breaking stable code, though this should become the "main" codepath long
442- // before mgca is stabilized.
443- //
444- // FIXME(BoxyUwU): Enabling this by default is blocked on a refactoring to how const items
445- // are represented.
446- if tcx. features ( ) . min_generic_const_args ( ) {
447- let uv = match ct. kind ( ) {
448- ty:: ConstKind :: Unevaluated ( uv) => uv,
449- _ => return ct. super_fold_with ( self ) ,
450- } ;
451-
452- let ct = match tcx. def_kind ( uv. def ) {
453- DefKind :: AssocConst => match tcx. def_kind ( tcx. parent ( uv. def ) ) {
454- DefKind :: Trait => self . normalize_trait_projection ( uv. into ( ) ) ,
455- DefKind :: Impl { of_trait : false } => {
456- self . normalize_inherent_projection ( uv. into ( ) )
457- }
458- kind => unreachable ! (
459- "unexpected `DefKind` for const alias' resolution's parent def: {:?}" ,
460- kind
461- ) ,
462- } ,
463- DefKind :: Const | DefKind :: AnonConst => self . normalize_free_alias ( uv. into ( ) ) ,
464- kind => {
465- unreachable ! ( "unexpected `DefKind` for const alias to resolve to: {:?}" , kind)
440+ let uv = match ct. kind ( ) {
441+ ty:: ConstKind :: Unevaluated ( uv) => uv,
442+ _ => return ct. super_fold_with ( self ) ,
443+ } ;
444+
445+ let ct = match tcx. def_kind ( uv. def ) {
446+ DefKind :: AssocConst => match tcx. def_kind ( tcx. parent ( uv. def ) ) {
447+ DefKind :: Trait => self . normalize_trait_projection ( uv. into ( ) ) . expect_const ( ) ,
448+ DefKind :: Impl { of_trait : false } => {
449+ self . normalize_inherent_projection ( uv. into ( ) ) . expect_const ( )
466450 }
467- } ;
451+ kind => unreachable ! (
452+ "unexpected `DefKind` for const alias' resolution's parent def: {:?}" ,
453+ kind
454+ ) ,
455+ } ,
456+ DefKind :: Const => self . normalize_free_alias ( uv. into ( ) ) . expect_const ( ) ,
457+ DefKind :: AnonConst => {
458+ let ct = ct. super_fold_with ( self ) ;
459+ super :: with_replaced_escaping_bound_vars (
460+ self . selcx . infcx ,
461+ & mut self . universes ,
462+ ct,
463+ |ct| super :: evaluate_const ( self . selcx . infcx , ct, self . param_env ) ,
464+ )
465+ }
466+ kind => {
467+ unreachable ! ( "unexpected `DefKind` for const alias to resolve to: {:?}" , kind)
468+ }
469+ } ;
468470
469- // We re-fold the normalized const as the `ty` field on `ConstKind::Value` may be
470- // unnormalized after const evaluation returns.
471- ct. expect_const ( ) . super_fold_with ( self )
472- } else {
473- let ct = ct. super_fold_with ( self ) ;
474- return super :: with_replaced_escaping_bound_vars (
475- self . selcx . infcx ,
476- & mut self . universes ,
477- ct,
478- |ct| super :: evaluate_const ( self . selcx . infcx , ct, self . param_env ) ,
479- )
480- . super_fold_with ( self ) ;
481- // We re-fold the normalized const as the `ty` field on `ConstKind::Value` may be
482- // unnormalized after const evaluation returns.
483- }
471+ // We re-fold the normalized const as the `ty` field on `ConstKind::Value` may be
472+ // unnormalized after const evaluation returns.
473+ ct. super_fold_with ( self )
484474 }
485475
486476 #[ inline]
0 commit comments