@@ -22,7 +22,7 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
22
22
use rustc_middle:: middle:: resolve_lifetime as rl;
23
23
use rustc_middle:: ty:: fold:: TypeFolder ;
24
24
use rustc_middle:: ty:: InternalSubsts ;
25
- use rustc_middle:: ty:: { self , AdtKind , DefIdTree , EarlyBinder , Lift , Ty , TyCtxt } ;
25
+ use rustc_middle:: ty:: { self , AdtKind , DefIdTree , EarlyBinder , Lift , Ty , TyCtxt , TypeFoldable } ;
26
26
use rustc_middle:: { bug, span_bug} ;
27
27
use rustc_span:: hygiene:: { AstPass , MacroKind } ;
28
28
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -983,6 +983,8 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
983
983
) -> FnDecl {
984
984
let mut names = did. map_or ( & [ ] as & [ _ ] , |did| cx. tcx . fn_arg_names ( did) ) . iter ( ) ;
985
985
986
+ let sig = normalize ( cx, sig) . unwrap_or ( sig) ;
987
+
986
988
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
987
989
// but shouldn't change any code meaning.
988
990
let output = match clean_middle_ty ( sig. skip_binder ( ) . output ( ) , cx, None ) {
@@ -1552,33 +1554,22 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
1552
1554
}
1553
1555
1554
1556
/// Returns `None` if the type could not be normalized
1555
- fn normalize < ' tcx > ( cx : & mut DocContext < ' tcx > , ty : Ty < ' _ > ) -> Option < Ty < ' tcx > > {
1557
+ fn normalize < ' tcx , T : TypeFoldable < ' tcx > > ( cx : & mut DocContext < ' tcx > , value : T ) -> Option < T > {
1556
1558
// HACK: low-churn fix for #79459 while we wait for a trait normalization fix
1557
1559
if !cx. tcx . sess . opts . unstable_opts . normalize_docs {
1558
1560
return None ;
1559
1561
}
1560
1562
1561
- use crate :: rustc_trait_selection:: infer:: TyCtxtInferExt ;
1562
- use crate :: rustc_trait_selection:: traits:: query:: normalize:: AtExt ;
1563
- use rustc_middle:: traits:: ObligationCause ;
1563
+ if value. has_escaping_bound_vars ( ) {
1564
+ return None ;
1565
+ }
1566
+
1567
+ use rustc_trait_selection:: infer:: TyCtxtInferExt ;
1568
+ use rustc_trait_selection:: traits;
1564
1569
1565
1570
// Try to normalize `<X as Y>::T` to a type
1566
- let lifted = ty. lift_to_tcx ( cx. tcx ) . unwrap ( ) ;
1567
1571
let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
1568
- let normalized = infcx
1569
- . at ( & ObligationCause :: dummy ( ) , cx. param_env )
1570
- . normalize ( lifted)
1571
- . map ( |resolved| infcx. resolve_vars_if_possible ( resolved. value ) ) ;
1572
- match normalized {
1573
- Ok ( normalized_value) => {
1574
- debug ! ( "normalized {:?} to {:?}" , ty, normalized_value) ;
1575
- Some ( normalized_value)
1576
- }
1577
- Err ( err) => {
1578
- debug ! ( "failed to normalize {:?}: {:?}" , ty, err) ;
1579
- None
1580
- }
1581
- }
1572
+ traits:: fully_normalize ( & infcx, traits:: ObligationCause :: dummy ( ) , cx. param_env , value) . ok ( )
1582
1573
}
1583
1574
1584
1575
pub ( crate ) fn clean_middle_ty < ' tcx > (
0 commit comments