@@ -3,12 +3,10 @@ use std::{borrow::Cow, rc::Rc};
33use askama:: Template ;
44use rustc_data_structures:: fx:: FxHashSet ;
55use rustc_hir:: { def:: CtorKind , def_id:: DefIdSet } ;
6- use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
76use rustc_middle:: ty:: { self , TyCtxt } ;
87
98use crate :: {
109 clean,
11- clean:: types:: TypeAliasItem ,
1210 formats:: { item_type:: ItemType , Impl } ,
1311 html:: { format:: Buffer , markdown:: IdMap } ,
1412} ;
@@ -290,43 +288,10 @@ fn sidebar_assoc_items<'a>(
290288) {
291289 let did = it. item_id . expect_def_id ( ) ;
292290 let cache = cx. cache ( ) ;
293- let tcx = cx. tcx ( ) ;
294- let mut v: Vec < & Impl > =
295- cache. impls . get ( & did) . map ( Vec :: as_slice) . unwrap_or ( & [ ] ) . iter ( ) . collect ( ) ;
296- if let TypeAliasItem ( ait) = & * it. kind &&
297- let aliased_clean_type = ait. item_type . as_ref ( ) . unwrap_or ( & ait. type_ ) &&
298- let Some ( aliased_type_defid) = aliased_clean_type. def_id ( cache) &&
299- let Some ( av) = cache. impls . get ( & aliased_type_defid) &&
300- let Some ( alias_def_id) = it. item_id . as_def_id ( )
301- {
302- // This branch of the compiler compares types structually, but does
303- // not check trait bounds. That's probably fine, since type aliases
304- // don't normally constrain on them anyway.
305- // https://github.com/rust-lang/rust/issues/21903
306- //
307- // FIXME(lazy_type_alias): Once the feature is complete or stable, rewrite this to use type unification.
308- // Be aware of `tests/rustdoc/issue-112515-impl-ty-alias.rs` which might regress.
309- let aliased_ty = tcx. type_of ( alias_def_id) . skip_binder ( ) ;
310- let reject_cx = DeepRejectCtxt {
311- treat_obligation_params : TreatParams :: AsCandidateKey ,
312- } ;
313- v. extend ( av. iter ( ) . filter ( |impl_| {
314- if let Some ( impl_def_id) = impl_. impl_item . item_id . as_def_id ( ) {
315- reject_cx. types_may_unify ( aliased_ty, tcx. type_of ( impl_def_id) . skip_binder ( ) )
316- } else {
317- false
318- }
319- } ) ) ;
320- }
321- let v = {
322- let mut saw_impls = FxHashSet :: default ( ) ;
323- v. retain ( |i| saw_impls. insert ( i. def_id ( ) ) ) ;
324- v. as_slice ( )
325- } ;
326291
327292 let mut assoc_consts = Vec :: new ( ) ;
328293 let mut methods = Vec :: new ( ) ;
329- if !v . is_empty ( ) {
294+ if let Some ( v ) = cache . impls . get ( & did ) {
330295 let mut used_links = FxHashSet :: default ( ) ;
331296 let mut id_map = IdMap :: new ( ) ;
332297
@@ -362,7 +327,7 @@ fn sidebar_assoc_items<'a>(
362327 cx,
363328 & mut deref_methods,
364329 impl_,
365- v. iter ( ) . copied ( ) ,
330+ v,
366331 & mut derefs,
367332 & mut used_links,
368333 ) ;
@@ -392,7 +357,7 @@ fn sidebar_deref_methods<'a>(
392357 cx : & ' a Context < ' _ > ,
393358 out : & mut Vec < LinkBlock < ' a > > ,
394359 impl_ : & Impl ,
395- v : impl Iterator < Item = & ' a Impl > ,
360+ v : & [ Impl ] ,
396361 derefs : & mut DefIdSet ,
397362 used_links : & mut FxHashSet < String > ,
398363) {
@@ -417,7 +382,7 @@ fn sidebar_deref_methods<'a>(
417382 // Avoid infinite cycles
418383 return ;
419384 }
420- let deref_mut = { v } . any ( |i| i. trait_did ( ) == cx. tcx ( ) . lang_items ( ) . deref_mut_trait ( ) ) ;
385+ let deref_mut = v . iter ( ) . any ( |i| i. trait_did ( ) == cx. tcx ( ) . lang_items ( ) . deref_mut_trait ( ) ) ;
421386 let inner_impl = target
422387 . def_id ( c)
423388 . or_else ( || {
@@ -468,7 +433,7 @@ fn sidebar_deref_methods<'a>(
468433 cx,
469434 out,
470435 target_deref_impl,
471- target_impls. iter ( ) ,
436+ target_impls,
472437 derefs,
473438 used_links,
474439 ) ;
0 commit comments