@@ -22,7 +22,7 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
2222use rustc_middle:: middle:: resolve_lifetime as rl;
2323use rustc_middle:: ty:: fold:: TypeFolder ;
2424use 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 } ;
2626use rustc_middle:: { bug, span_bug} ;
2727use rustc_span:: hygiene:: { AstPass , MacroKind } ;
2828use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -983,6 +983,8 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
983983) -> FnDecl {
984984 let mut names = did. map_or ( & [ ] as & [ _ ] , |did| cx. tcx . fn_arg_names ( did) ) . iter ( ) ;
985985
986+ let sig = normalize ( cx, sig) . unwrap_or ( sig) ;
987+
986988 // We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
987989 // but shouldn't change any code meaning.
988990 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
15521554}
15531555
15541556/// 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 > {
15561558 // HACK: low-churn fix for #79459 while we wait for a trait normalization fix
15571559 if !cx. tcx . sess . opts . unstable_opts . normalize_docs {
15581560 return None ;
15591561 }
15601562
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;
15641569
15651570 // Try to normalize `<X as Y>::T` to a type
1566- let lifted = ty. lift_to_tcx ( cx. tcx ) . unwrap ( ) ;
15671571 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 ( )
15821573}
15831574
15841575pub ( crate ) fn clean_middle_ty < ' tcx > (
0 commit comments