@@ -297,7 +297,7 @@ pub enum PermitVariants {
297297
298298#[ derive( Debug , Clone , Copy ) ]
299299enum TypeRelativePath < ' tcx > {
300- AssocItem ( DefId , GenericArgsRef < ' tcx > ) ,
300+ AssocItem ( ty :: AliasTerm < ' tcx > ) ,
301301 Variant { adt : Ty < ' tcx > , variant_did : DefId } ,
302302 Ctor { ctor_def_id : DefId , args : GenericArgsRef < ' tcx > } ,
303303}
@@ -1356,15 +1356,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13561356 span,
13571357 LowerTypeRelativePathMode :: Type ( permit_variants) ,
13581358 ) ? {
1359- TypeRelativePath :: AssocItem ( def_id, args) => {
1360- let alias_ty = ty:: AliasTy :: new_from_args (
1361- tcx,
1362- ty:: AliasTyKind :: new_from_def_id ( tcx, def_id) ,
1363- args,
1364- ) ;
1365- let ty = Ty :: new_alias ( tcx, alias_ty) ;
1359+ TypeRelativePath :: AssocItem ( alias_term) => {
1360+ let ty = alias_term. expect_ty ( ) . to_ty ( tcx) ;
13661361 let ty = self . check_param_uses_if_mcg ( ty, span, false ) ;
1367- Ok ( ( ty, tcx. def_kind ( def_id) , def_id) )
1362+ Ok ( ( ty, tcx. def_kind ( alias_term . def_id ( ) ) , alias_term . def_id ( ) ) )
13681363 }
13691364 TypeRelativePath :: Variant { adt, variant_did } => {
13701365 let adt = self . check_param_uses_if_mcg ( adt, span, false ) ;
@@ -1396,16 +1391,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13961391 span,
13971392 LowerTypeRelativePathMode :: Const ,
13981393 ) ? {
1399- TypeRelativePath :: AssocItem ( def_id, args) => {
1400- self . require_type_const_attribute ( def_id, span) ?;
1401- let ct = Const :: new_unevaluated (
1402- tcx,
1403- ty:: UnevaluatedConst :: new (
1404- tcx,
1405- ty:: UnevaluatedConstKind :: new_from_def_id ( tcx, def_id) ,
1406- args,
1407- ) ,
1408- ) ;
1394+ TypeRelativePath :: AssocItem ( alias_term) => {
1395+ self . require_type_const_attribute ( alias_term. def_id ( ) , span) ?;
1396+ let ct = Const :: new_unevaluated ( tcx, alias_term. expect_ct ( ) ) ;
14091397 let ct = self . check_param_uses_if_mcg ( ct, span, false ) ;
14101398 Ok ( ct)
14111399 }
@@ -1487,15 +1475,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14871475 }
14881476
14891477 // FIXME(inherent_associated_types, #106719): Support self types other than ADTs.
1490- if let Some ( ( did , args ) ) = self . probe_inherent_assoc_item (
1478+ if let Some ( alias_term ) = self . probe_inherent_assoc_item (
14911479 segment,
14921480 adt_def. did ( ) ,
14931481 self_ty,
14941482 qpath_hir_id,
14951483 span,
14961484 mode. assoc_tag ( ) ,
14971485 ) ? {
1498- return Ok ( TypeRelativePath :: AssocItem ( did , args ) ) ;
1486+ return Ok ( TypeRelativePath :: AssocItem ( alias_term ) ) ;
14991487 }
15001488 }
15011489
@@ -1529,7 +1517,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
15291517 ) ;
15301518 }
15311519
1532- Ok ( TypeRelativePath :: AssocItem ( item_def_id, args) )
1520+ Ok ( TypeRelativePath :: AssocItem ( ty :: AliasTerm :: new_from_def_id ( tcx , item_def_id, args) ) )
15331521 }
15341522
15351523 /// Resolve a [type-relative](hir::QPath::TypeRelative) (and type-level) path.
@@ -1609,7 +1597,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
16091597 block : HirId ,
16101598 span : Span ,
16111599 assoc_tag : ty:: AssocTag ,
1612- ) -> Result < Option < ( DefId , GenericArgsRef < ' tcx > ) > , ErrorGuaranteed > {
1600+ ) -> Result < Option < ty :: AliasTerm < ' tcx > > , ErrorGuaranteed > {
16131601 let tcx = self . tcx ( ) ;
16141602
16151603 if !tcx. features ( ) . inherent_associated_types ( ) {
@@ -1692,7 +1680,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
16921680 . chain ( args. into_iter ( ) . skip ( parent_args. len ( ) ) ) ,
16931681 ) ;
16941682
1695- Ok ( Some ( ( assoc_item, args) ) )
1683+ let kind = match assoc_tag {
1684+ ty:: AssocTag :: Type => ty:: AliasTermKind :: InherentTy { def_id : assoc_item } ,
1685+ ty:: AssocTag :: Const => {
1686+ // FIXME(mgca): drop once `InherentConst` accepts IAC-shaped args (issue #156181)
1687+ // without this, `new_from_args` errors (#155341).
1688+ self . require_type_const_attribute ( assoc_item, span) ?;
1689+ ty:: AliasTermKind :: InherentConst { def_id : assoc_item }
1690+ }
1691+ ty:: AssocTag :: Fn => unreachable ! ( ) ,
1692+ } ;
1693+
1694+ Ok ( Some ( ty:: AliasTerm :: new_from_args ( tcx, kind, args) ) )
16961695 }
16971696
16981697 /// Given name and kind search for the assoc item in the provided scope and check if it's accessible[^1].
0 commit comments