@@ -378,6 +378,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
378
378
term : projected_term,
379
379
obligations : mut projected_obligations,
380
380
} ) ) => {
381
+ debug ! ( "opt_normalize_projection_type: progress" ) ;
381
382
// if projection succeeded, then what we get out of this
382
383
// is also non-normalized (consider: it was derived from
383
384
// an impl, where-clause etc) and hence we must
@@ -408,6 +409,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
408
409
Ok ( Some ( result. value ) )
409
410
}
410
411
Ok ( Projected :: NoProgress ( projected_ty) ) => {
412
+ debug ! ( "opt_normalize_projection_type: no progress" ) ;
411
413
let result =
412
414
Normalized { value : projected_ty, obligations : PredicateObligations :: new ( ) } ;
413
415
infcx. inner . borrow_mut ( ) . projection_cache ( ) . insert_term ( cache_key, result. clone ( ) ) ;
@@ -621,8 +623,17 @@ struct Progress<'tcx> {
621
623
}
622
624
623
625
impl < ' 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 ( ) }
626
637
}
627
638
628
639
fn with_addl_obligations ( mut self , mut obligations : PredicateObligations < ' tcx > ) -> Self {
@@ -650,7 +661,11 @@ fn project<'cx, 'tcx>(
650
661
}
651
662
652
663
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
+ ) ) ) ;
654
669
}
655
670
656
671
let mut candidates = ProjectionCandidateSet :: None ;
@@ -1965,7 +1980,13 @@ fn confirm_impl_candidate<'cx, 'tcx>(
1965
1980
let param_env = obligation. param_env ;
1966
1981
let assoc_term = match specialization_graph:: assoc_def ( tcx, impl_def_id, assoc_item_id) {
1967
1982
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
+ }
1969
1990
} ;
1970
1991
1971
1992
// This means that the impl is missing a definition for the
0 commit comments