@@ -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} ;
@@ -282,43 +280,10 @@ fn sidebar_assoc_items<'a>(
282280) {
283281 let did = it. item_id . expect_def_id ( ) ;
284282 let cache = cx. cache ( ) ;
285- let tcx = cx. tcx ( ) ;
286- let mut v: Vec < & Impl > =
287- cache. impls . get ( & did) . map ( Vec :: as_slice) . unwrap_or ( & [ ] ) . iter ( ) . collect ( ) ;
288- if let TypeAliasItem ( ait) = & * it. kind &&
289- let aliased_clean_type = ait. item_type . as_ref ( ) . unwrap_or ( & ait. type_ ) &&
290- let Some ( aliased_type_defid) = aliased_clean_type. def_id ( cache) &&
291- let Some ( av) = cache. impls . get ( & aliased_type_defid) &&
292- let Some ( alias_def_id) = it. item_id . as_def_id ( )
293- {
294- // This branch of the compiler compares types structually, but does
295- // not check trait bounds. That's probably fine, since type aliases
296- // don't normally constrain on them anyway.
297- // https://github.com/rust-lang/rust/issues/21903
298- //
299- // FIXME(lazy_type_alias): Once the feature is complete or stable, rewrite this to use type unification.
300- // Be aware of `tests/rustdoc/issue-112515-impl-ty-alias.rs` which might regress.
301- let aliased_ty = tcx. type_of ( alias_def_id) . skip_binder ( ) ;
302- let reject_cx = DeepRejectCtxt {
303- treat_obligation_params : TreatParams :: AsCandidateKey ,
304- } ;
305- v. extend ( av. iter ( ) . filter ( |impl_| {
306- if let Some ( impl_def_id) = impl_. impl_item . item_id . as_def_id ( ) {
307- reject_cx. types_may_unify ( aliased_ty, tcx. type_of ( impl_def_id) . skip_binder ( ) )
308- } else {
309- false
310- }
311- } ) ) ;
312- }
313- let v = {
314- let mut saw_impls = FxHashSet :: default ( ) ;
315- v. retain ( |i| saw_impls. insert ( i. def_id ( ) ) ) ;
316- v. as_slice ( )
317- } ;
318283
319284 let mut assoc_consts = Vec :: new ( ) ;
320285 let mut methods = Vec :: new ( ) ;
321- if !v . is_empty ( ) {
286+ if let Some ( v ) = cache . impls . get ( & did ) {
322287 let mut used_links = FxHashSet :: default ( ) ;
323288 let mut id_map = IdMap :: new ( ) ;
324289
@@ -354,7 +319,7 @@ fn sidebar_assoc_items<'a>(
354319 cx,
355320 & mut deref_methods,
356321 impl_,
357- v. iter ( ) . copied ( ) ,
322+ v,
358323 & mut derefs,
359324 & mut used_links,
360325 ) ;
@@ -384,7 +349,7 @@ fn sidebar_deref_methods<'a>(
384349 cx : & ' a Context < ' _ > ,
385350 out : & mut Vec < LinkBlock < ' a > > ,
386351 impl_ : & Impl ,
387- v : impl Iterator < Item = & ' a Impl > ,
352+ v : & [ Impl ] ,
388353 derefs : & mut DefIdSet ,
389354 used_links : & mut FxHashSet < String > ,
390355) {
@@ -409,7 +374,7 @@ fn sidebar_deref_methods<'a>(
409374 // Avoid infinite cycles
410375 return ;
411376 }
412- let deref_mut = { v } . any ( |i| i. trait_did ( ) == cx. tcx ( ) . lang_items ( ) . deref_mut_trait ( ) ) ;
377+ let deref_mut = v . iter ( ) . any ( |i| i. trait_did ( ) == cx. tcx ( ) . lang_items ( ) . deref_mut_trait ( ) ) ;
413378 let inner_impl = target
414379 . def_id ( c)
415380 . or_else ( || {
@@ -460,7 +425,7 @@ fn sidebar_deref_methods<'a>(
460425 cx,
461426 out,
462427 target_deref_impl,
463- target_impls. iter ( ) ,
428+ target_impls,
464429 derefs,
465430 used_links,
466431 ) ;
0 commit comments