@@ -378,6 +378,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
378378 term : projected_term,
379379 obligations : mut projected_obligations,
380380 } ) ) => {
381+ debug ! ( "opt_normalize_projection_type: progress" ) ;
381382 // if projection succeeded, then what we get out of this
382383 // is also non-normalized (consider: it was derived from
383384 // an impl, where-clause etc) and hence we must
@@ -408,6 +409,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
408409 Ok ( Some ( result. value ) )
409410 }
410411 Ok ( Projected :: NoProgress ( projected_ty) ) => {
412+ debug ! ( "opt_normalize_projection_type: no progress" ) ;
411413 let result =
412414 Normalized { value : projected_ty, obligations : PredicateObligations :: new ( ) } ;
413415 infcx. inner . borrow_mut ( ) . projection_cache ( ) . insert_term ( cache_key, result. clone ( ) ) ;
@@ -621,8 +623,17 @@ struct Progress<'tcx> {
621623}
622624
623625impl < ' tcx > Progress < ' tcx > {
624- fn error ( tcx : TyCtxt < ' tcx > , guar : ErrorGuaranteed ) -> Self {
625- Progress { term : Ty :: new_error ( tcx, guar) . into ( ) , obligations : PredicateObligations :: new ( ) }
626+ fn error_for_term (
627+ tcx : TyCtxt < ' tcx > ,
628+ alias_term : ty:: AliasTerm < ' tcx > ,
629+ guar : ErrorGuaranteed ,
630+ ) -> Self {
631+ let err_term = if alias_term. kind ( tcx) . is_type ( ) {
632+ Ty :: new_error ( tcx, guar) . into ( )
633+ } else {
634+ ty:: Const :: new_error ( tcx, guar) . into ( )
635+ } ;
636+ Progress { term : err_term, obligations : PredicateObligations :: new ( ) }
626637 }
627638
628639 fn with_addl_obligations ( mut self , mut obligations : PredicateObligations < ' tcx > ) -> Self {
@@ -650,7 +661,11 @@ fn project<'cx, 'tcx>(
650661 }
651662
652663 if let Err ( guar) = obligation. predicate . error_reported ( ) {
653- return Ok ( Projected :: Progress ( Progress :: error ( selcx. tcx ( ) , guar) ) ) ;
664+ return Ok ( Projected :: Progress ( Progress :: error_for_term (
665+ selcx. tcx ( ) ,
666+ obligation. predicate ,
667+ guar,
668+ ) ) ) ;
654669 }
655670
656671 let mut candidates = ProjectionCandidateSet :: None ;
@@ -1965,7 +1980,13 @@ fn confirm_impl_candidate<'cx, 'tcx>(
19651980 let param_env = obligation. param_env ;
19661981 let assoc_term = match specialization_graph:: assoc_def ( tcx, impl_def_id, assoc_item_id) {
19671982 Ok ( assoc_term) => assoc_term,
1968- Err ( guar) => return Ok ( Projected :: Progress ( Progress :: error ( tcx, guar) ) ) ,
1983+ Err ( guar) => {
1984+ return Ok ( Projected :: Progress ( Progress :: error_for_term (
1985+ tcx,
1986+ obligation. predicate ,
1987+ guar,
1988+ ) ) ) ;
1989+ }
19691990 } ;
19701991
19711992 // This means that the impl is missing a definition for the
0 commit comments