@@ -54,7 +54,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5454use rustc_hir:: def_id:: { DefId , DefIdSet } ;
5555use rustc_hir:: Mutability ;
5656use rustc_middle:: middle:: stability;
57- use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
5857use rustc_middle:: ty:: TyCtxt ;
5958use rustc_span:: {
6059 symbol:: { sym, Symbol } ,
@@ -63,7 +62,6 @@ use rustc_span::{
6362use serde:: ser:: { SerializeMap , SerializeSeq } ;
6463use serde:: { Serialize , Serializer } ;
6564
66- use crate :: clean:: types:: TypeAliasItem ;
6765use crate :: clean:: { self , ItemId , RenderedLink , SelfTy } ;
6866use crate :: error:: Error ;
6967use crate :: formats:: cache:: Cache ;
@@ -1119,13 +1117,13 @@ pub(crate) fn render_all_impls(
11191117fn render_assoc_items < ' a , ' cx : ' a > (
11201118 cx : & ' a mut Context < ' cx > ,
11211119 containing_item : & ' a clean:: Item ,
1122- it : DefId ,
1120+ did : DefId ,
11231121 what : AssocItemRender < ' a > ,
11241122) -> impl fmt:: Display + ' a + Captures < ' cx > {
11251123 let mut derefs = DefIdSet :: default ( ) ;
1126- derefs. insert ( it ) ;
1124+ derefs. insert ( did ) ;
11271125 display_fn ( move |f| {
1128- render_assoc_items_inner ( f, cx, containing_item, it , what, & mut derefs) ;
1126+ render_assoc_items_inner ( f, cx, containing_item, did , what, & mut derefs) ;
11291127 Ok ( ( ) )
11301128 } )
11311129}
@@ -1134,46 +1132,16 @@ fn render_assoc_items_inner(
11341132 mut w : & mut dyn fmt:: Write ,
11351133 cx : & mut Context < ' _ > ,
11361134 containing_item : & clean:: Item ,
1137- it : DefId ,
1135+ did : DefId ,
11381136 what : AssocItemRender < ' _ > ,
11391137 derefs : & mut DefIdSet ,
11401138) {
11411139 info ! ( "Documenting associated items of {:?}" , containing_item. name) ;
11421140 let shared = Rc :: clone ( & cx. shared ) ;
1143- let cache = & shared. cache ;
1144- let tcx = cx. tcx ( ) ;
1145- let av = if let TypeAliasItem ( ait) = & * containing_item. kind &&
1146- let aliased_clean_type = ait. item_type . as_ref ( ) . unwrap_or ( & ait. type_ ) &&
1147- let Some ( aliased_type_defid) = aliased_clean_type. def_id ( cache) &&
1148- let Some ( mut av) = cache. impls . get ( & aliased_type_defid) . cloned ( ) &&
1149- let Some ( alias_def_id) = containing_item. item_id . as_def_id ( )
1150- {
1151- // This branch of the compiler compares types structually, but does
1152- // not check trait bounds. That's probably fine, since type aliases
1153- // don't normally constrain on them anyway.
1154- // https://github.com/rust-lang/rust/issues/21903
1155- //
1156- // FIXME(lazy_type_alias): Once the feature is complete or stable, rewrite this to use type unification.
1157- // Be aware of `tests/rustdoc/issue-112515-impl-ty-alias.rs` which might regress.
1158- let aliased_ty = tcx. type_of ( alias_def_id) . skip_binder ( ) ;
1159- let reject_cx = DeepRejectCtxt {
1160- treat_obligation_params : TreatParams :: AsCandidateKey ,
1161- } ;
1162- av. retain ( |impl_| {
1163- if let Some ( impl_def_id) = impl_. impl_item . item_id . as_def_id ( ) {
1164- reject_cx. types_may_unify ( aliased_ty, tcx. type_of ( impl_def_id) . skip_binder ( ) )
1165- } else {
1166- false
1167- }
1168- } ) ;
1169- av
1170- } else {
1171- Vec :: new ( )
1172- } ;
1173- let blank = Vec :: new ( ) ;
1174- let v = cache. impls . get ( & it) . unwrap_or ( & blank) ;
1175- let ( non_trait, traits) : ( Vec < _ > , _ ) =
1176- v. iter ( ) . chain ( & av[ ..] ) . partition ( |i| i. inner_impl ( ) . trait_ . is_none ( ) ) ;
1141+ let v = shared. all_impls_for_item ( containing_item, did) ;
1142+ let v = v. as_slice ( ) ;
1143+ let ( non_trait, traits) : ( Vec < & Impl > , _ ) =
1144+ v. iter ( ) . partition ( |i| i. inner_impl ( ) . trait_ . is_none ( ) ) ;
11771145 let mut saw_impls = FxHashSet :: default ( ) ;
11781146 if !non_trait. is_empty ( ) {
11791147 let mut tmp_buf = Buffer :: html ( ) ;
0 commit comments