@@ -545,10 +545,22 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>(
545545 ) ) ;
546546 }
547547
548- let term: Term < ' tcx > = if alias_term. kind ( tcx) . is_type ( ) {
549- tcx. type_of ( alias_term. def_id ) . instantiate ( tcx, args) . into ( )
550- } else {
551- tcx. const_of_item ( alias_term. def_id ) . instantiate ( tcx, args) . into ( )
548+ let term: Term < ' tcx > = match alias_term. kind ( tcx) {
549+ ty:: AliasTermKind :: InherentTy => {
550+ tcx. type_of ( alias_term. def_id ) . instantiate ( tcx, args) . into ( )
551+ }
552+ ty:: AliasTermKind :: InherentConst { is_type_const : true } => {
553+ tcx. const_of_item ( alias_term. def_id ) . instantiate ( tcx, args) . into ( )
554+ }
555+ ty:: AliasTermKind :: InherentConst { is_type_const : false } => {
556+ // FIXME(gca): This is dead code at the moment. It should eventually call
557+ // super::evaluate_const like projected consts do in confirm_impl_candidate in this
558+ // file. However, how generic args are represented for IACs is up in the air right now.
559+ // Will super::evaluate_const eventually take the inherent_args or the impl_args form of
560+ // args? It might be either.
561+ panic ! ( "References to inherent associated consts should have been blocked" ) ;
562+ }
563+ kind => panic ! ( "expected inherent alias, found {kind:?}" ) ,
552564 } ;
553565
554566 let mut term = selcx. infcx . resolve_vars_if_possible ( term) ;
@@ -2046,12 +2058,6 @@ fn confirm_impl_candidate<'cx, 'tcx>(
20462058 let args = obligation. predicate . args . rebase_onto ( tcx, trait_def_id, args) ;
20472059 let args = translate_args ( selcx. infcx , param_env, impl_def_id, args, assoc_term. defining_node ) ;
20482060
2049- let term = if obligation. predicate . kind ( tcx) . is_type ( ) {
2050- tcx. type_of ( assoc_term. item . def_id ) . map_bound ( |ty| ty. into ( ) )
2051- } else {
2052- tcx. const_of_item ( assoc_term. item . def_id ) . map_bound ( |ct| ct. into ( ) )
2053- } ;
2054-
20552061 let progress = if !tcx. check_args_compatible ( assoc_term. item . def_id , args) {
20562062 let msg = "impl item and trait item have different parameters" ;
20572063 let span = obligation. cause . span ;
@@ -2063,7 +2069,23 @@ fn confirm_impl_candidate<'cx, 'tcx>(
20632069 Progress { term : err, obligations : nested }
20642070 } else {
20652071 assoc_term_own_obligations ( selcx, obligation, & mut nested) ;
2066- Progress { term : term. instantiate ( tcx, args) , obligations : nested }
2072+
2073+ let term = match obligation. predicate . kind ( tcx) {
2074+ ty:: AliasTermKind :: ProjectionTy => {
2075+ tcx. type_of ( assoc_term. item . def_id ) . instantiate ( tcx, args) . into ( )
2076+ }
2077+ ty:: AliasTermKind :: ProjectionConst { is_type_const : true } => {
2078+ tcx. const_of_item ( assoc_term. item . def_id ) . instantiate ( tcx, args) . into ( )
2079+ }
2080+ ty:: AliasTermKind :: ProjectionConst { is_type_const : false } => {
2081+ let uv = ty:: UnevaluatedConst :: new ( assoc_term. item . def_id , args) ;
2082+ let ct = ty:: Const :: new_unevaluated ( tcx, uv) ;
2083+ super :: evaluate_const ( selcx. infcx , ct, param_env) . into ( )
2084+ }
2085+ kind => panic ! ( "expected projection alias, found {kind:?}" ) ,
2086+ } ;
2087+
2088+ Progress { term, obligations : nested }
20672089 } ;
20682090 Ok ( Projected :: Progress ( progress) )
20692091}
0 commit comments