@@ -46,7 +46,9 @@ use rustc_hir::{LangItem, PredicateOrigin, find_attr};
4646use rustc_hir_analysis:: { lower_const_arg_for_rustdoc, lower_ty} ;
4747use rustc_middle:: metadata:: Reexport ;
4848use rustc_middle:: middle:: resolve_bound_vars as rbv;
49- use rustc_middle:: ty:: { self , AdtKind , GenericArgsRef , Ty , TyCtxt , TypeVisitableExt , TypingMode } ;
49+ use rustc_middle:: ty:: {
50+ self , AdtKind , GenericArgsRef , Ty , TyCtxt , TypeVisitableExt , TypingMode , Unnormalized ,
51+ } ;
5052use rustc_middle:: { bug, span_bug} ;
5153use rustc_span:: ExpnKind ;
5254use rustc_span:: hygiene:: { AstPass , MacroKind } ;
@@ -507,7 +509,8 @@ fn clean_hir_term<'tcx>(
507509 hir:: Term :: Ty ( ty) => Term :: Type ( clean_ty ( ty, cx) ) ,
508510 hir:: Term :: Const ( c) => {
509511 // FIXME(generic_const_items): this should instantiate with the alias item's args
510- let ty = cx. tcx . type_of ( assoc_item. unwrap ( ) ) . instantiate_identity ( ) ;
512+ let ty =
513+ cx. tcx . type_of ( assoc_item. unwrap ( ) ) . instantiate_identity ( ) . skip_normalization ( ) ;
511514 let ct = lower_const_arg_for_rustdoc ( cx. tcx , c, ty) ;
512515 Term :: Constant ( clean_middle_const ( ty:: Binder :: dummy ( ct) ) )
513516 }
@@ -590,7 +593,9 @@ fn clean_generic_param_def(
590593 && has_default
591594 {
592595 Some ( clean_middle_ty (
593- ty:: Binder :: dummy ( cx. tcx . type_of ( def. def_id ) . instantiate_identity ( ) ) ,
596+ ty:: Binder :: dummy (
597+ cx. tcx . type_of ( def. def_id ) . instantiate_identity ( ) . skip_normalization ( ) ,
598+ ) ,
594599 cx,
595600 Some ( def. def_id ) ,
596601 None ,
@@ -611,7 +616,9 @@ fn clean_generic_param_def(
611616 def. name ,
612617 GenericParamDefKind :: Const {
613618 ty : Box :: new ( clean_middle_ty (
614- ty:: Binder :: dummy ( cx. tcx . type_of ( def. def_id ) . instantiate_identity ( ) ) ,
619+ ty:: Binder :: dummy (
620+ cx. tcx . type_of ( def. def_id ) . instantiate_identity ( ) . skip_normalization ( ) ,
621+ ) ,
615622 cx,
616623 Some ( def. def_id ) ,
617624 None ,
@@ -620,7 +627,11 @@ fn clean_generic_param_def(
620627 && has_default
621628 {
622629 Some ( Box :: new (
623- cx. tcx . const_param_default ( def. def_id ) . instantiate_identity ( ) . to_string ( ) ,
630+ cx. tcx
631+ . const_param_default ( def. def_id )
632+ . instantiate_identity ( )
633+ . skip_normalization ( )
634+ . to_string ( ) ,
624635 ) )
625636 } else {
626637 None
@@ -1328,7 +1339,9 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
13281339 let kind = match assoc_item. kind {
13291340 ty:: AssocKind :: Const { .. } => {
13301341 let ty = clean_middle_ty (
1331- ty:: Binder :: dummy ( tcx. type_of ( assoc_item. def_id ) . instantiate_identity ( ) ) ,
1342+ ty:: Binder :: dummy (
1343+ tcx. type_of ( assoc_item. def_id ) . instantiate_identity ( ) . skip_normalization ( ) ,
1344+ ) ,
13321345 cx,
13331346 Some ( assoc_item. def_id ) ,
13341347 None ,
@@ -1363,13 +1376,18 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
13631376
13641377 if has_self {
13651378 let self_ty = match assoc_item. container {
1366- ty:: AssocContainer :: InherentImpl | ty:: AssocContainer :: TraitImpl ( _) => {
1367- tcx. type_of ( assoc_item. container_id ( tcx) ) . instantiate_identity ( )
1368- }
1379+ ty:: AssocContainer :: InherentImpl | ty:: AssocContainer :: TraitImpl ( _) => tcx
1380+ . type_of ( assoc_item. container_id ( tcx) )
1381+ . instantiate_identity ( )
1382+ . skip_normalization ( ) ,
13691383 ty:: AssocContainer :: Trait => tcx. types . self_param ,
13701384 } ;
1371- let self_param_ty =
1372- tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) . input ( 0 ) . skip_binder ( ) ;
1385+ let self_param_ty = tcx
1386+ . fn_sig ( assoc_item. def_id )
1387+ . instantiate_identity ( )
1388+ . skip_normalization ( )
1389+ . input ( 0 )
1390+ . skip_binder ( ) ;
13731391 if self_param_ty == self_ty {
13741392 item. decl . inputs [ 0 ] . type_ = SelfTy ;
13751393 } else if let ty:: Ref ( _, ty, _) = * self_param_ty. kind ( )
@@ -1423,7 +1441,10 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
14231441
14241442 let mut predicates = tcx. explicit_predicates_of ( assoc_item. def_id ) . predicates ;
14251443 if let ty:: AssocContainer :: Trait = assoc_item. container {
1426- let bounds = tcx. explicit_item_bounds ( assoc_item. def_id ) . iter_identity_copied ( ) ;
1444+ let bounds = tcx
1445+ . explicit_item_bounds ( assoc_item. def_id )
1446+ . iter_identity_copied ( )
1447+ . map ( Unnormalized :: skip_normalization) ;
14271448 predicates = tcx. arena . alloc_from_iter ( bounds. chain ( predicates. iter ( ) . copied ( ) ) ) ;
14281449 }
14291450 let mut generics = clean_ty_generics_inner (
@@ -1509,7 +1530,9 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
15091530 Box :: new ( TypeAlias {
15101531 type_ : clean_middle_ty (
15111532 ty:: Binder :: dummy (
1512- tcx. type_of ( assoc_item. def_id ) . instantiate_identity ( ) ,
1533+ tcx. type_of ( assoc_item. def_id )
1534+ . instantiate_identity ( )
1535+ . skip_normalization ( ) ,
15131536 ) ,
15141537 cx,
15151538 Some ( assoc_item. def_id ) ,
@@ -1529,7 +1552,9 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
15291552 Box :: new ( TypeAlias {
15301553 type_ : clean_middle_ty (
15311554 ty:: Binder :: dummy (
1532- tcx. type_of ( assoc_item. def_id ) . instantiate_identity ( ) ,
1555+ tcx. type_of ( assoc_item. def_id )
1556+ . instantiate_identity ( )
1557+ . skip_normalization ( ) ,
15331558 ) ,
15341559 cx,
15351560 Some ( assoc_item. def_id ) ,
@@ -2267,7 +2292,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
22672292 clean_middle_path ( cx, def_id, false , ThinVec :: new ( ) , bound_ty. rebind ( args) ) ;
22682293 Type :: Path { path }
22692294 } else {
2270- let ty = cx. tcx . type_of ( def_id) . instantiate ( cx. tcx , args) ;
2295+ let ty = cx. tcx . type_of ( def_id) . instantiate ( cx. tcx , args) . skip_normalization ( ) ;
22712296 clean_middle_ty ( bound_ty. rebind ( ty) , cx, None , None )
22722297 }
22732298 }
@@ -2330,6 +2355,7 @@ fn clean_middle_opaque_bounds<'tcx>(
23302355 . tcx
23312356 . explicit_item_bounds ( impl_trait_def_id)
23322357 . iter_instantiated_copied ( cx. tcx , args)
2358+ . map ( Unnormalized :: skip_normalization)
23332359 . collect ( ) ;
23342360
23352361 let mut bounds = bounds
@@ -2427,7 +2453,9 @@ pub(crate) fn clean_middle_field(field: &ty::FieldDef, cx: &mut DocContext<'_>)
24272453 field. did ,
24282454 field. name ,
24292455 clean_middle_ty (
2430- ty:: Binder :: dummy ( cx. tcx . type_of ( field. did ) . instantiate_identity ( ) ) ,
2456+ ty:: Binder :: dummy (
2457+ cx. tcx . type_of ( field. did ) . instantiate_identity ( ) . skip_normalization ( ) ,
2458+ ) ,
24312459 cx,
24322460 Some ( field. did ) ,
24332461 None ,
@@ -2491,7 +2519,8 @@ pub(crate) fn clean_variant_def_with_args<'tcx>(
24912519 . fields
24922520 . iter ( )
24932521 . map ( |field| {
2494- let ty = cx. tcx . type_of ( field. did ) . instantiate ( cx. tcx , args) ;
2522+ let ty =
2523+ cx. tcx . type_of ( field. did ) . instantiate ( cx. tcx , args) . skip_normalization ( ) ;
24952524
24962525 // normalize the type to only show concrete types
24972526 // note: we do not use try_normalize_erasing_regions since we
@@ -2516,7 +2545,8 @@ pub(crate) fn clean_variant_def_with_args<'tcx>(
25162545 . fields
25172546 . iter ( )
25182547 . map ( |field| {
2519- let ty = cx. tcx . type_of ( field. did ) . instantiate ( cx. tcx , args) ;
2548+ let ty =
2549+ cx. tcx . type_of ( field. did ) . instantiate ( cx. tcx , args) . skip_normalization ( ) ;
25202550
25212551 // normalize the type to only show concrete types
25222552 // note: we do not use try_normalize_erasing_regions since we
@@ -2860,7 +2890,7 @@ fn clean_maybe_renamed_item<'tcx>(
28602890 }
28612891 }
28622892
2863- let ty = cx. tcx . type_of ( def_id) . instantiate_identity ( ) ;
2893+ let ty = cx. tcx . type_of ( def_id) . instantiate_identity ( ) . skip_normalization ( ) ;
28642894
28652895 let mut ret = Vec :: new ( ) ;
28662896 let inner_type = clean_ty_alias_inner_type ( ty, cx, & mut ret) ;
@@ -2992,7 +3022,7 @@ fn clean_impl<'tcx>(
29923022 let type_alias =
29933023 for_. def_id ( & cx. cache ) . and_then ( |alias_def_id : DefId | match tcx. def_kind ( alias_def_id) {
29943024 DefKind :: TyAlias => Some ( clean_middle_ty (
2995- ty:: Binder :: dummy ( tcx. type_of ( def_id) . instantiate_identity ( ) ) ,
3025+ ty:: Binder :: dummy ( tcx. type_of ( def_id) . instantiate_identity ( ) . skip_normalization ( ) ) ,
29963026 cx,
29973027 Some ( def_id. to_def_id ( ) ) ,
29983028 None ,
0 commit comments