@@ -3,12 +3,10 @@ use std::{borrow::Cow, rc::Rc};
3
3
use askama:: Template ;
4
4
use rustc_data_structures:: fx:: FxHashSet ;
5
5
use rustc_hir:: { def:: CtorKind , def_id:: DefIdSet } ;
6
- use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
7
6
use rustc_middle:: ty:: { self , TyCtxt } ;
8
7
9
8
use crate :: {
10
9
clean,
11
- clean:: types:: TypeAliasItem ,
12
10
formats:: { item_type:: ItemType , Impl } ,
13
11
html:: { format:: Buffer , markdown:: IdMap } ,
14
12
} ;
@@ -282,43 +280,10 @@ fn sidebar_assoc_items<'a>(
282
280
) {
283
281
let did = it. item_id . expect_def_id ( ) ;
284
282
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
- } ;
318
283
319
284
let mut assoc_consts = Vec :: new ( ) ;
320
285
let mut methods = Vec :: new ( ) ;
321
- if !v . is_empty ( ) {
286
+ if let Some ( v ) = cache . impls . get ( & did ) {
322
287
let mut used_links = FxHashSet :: default ( ) ;
323
288
let mut id_map = IdMap :: new ( ) ;
324
289
@@ -354,7 +319,7 @@ fn sidebar_assoc_items<'a>(
354
319
cx,
355
320
& mut deref_methods,
356
321
impl_,
357
- v. iter ( ) . copied ( ) ,
322
+ v,
358
323
& mut derefs,
359
324
& mut used_links,
360
325
) ;
@@ -384,7 +349,7 @@ fn sidebar_deref_methods<'a>(
384
349
cx : & ' a Context < ' _ > ,
385
350
out : & mut Vec < LinkBlock < ' a > > ,
386
351
impl_ : & Impl ,
387
- v : impl Iterator < Item = & ' a Impl > ,
352
+ v : & [ Impl ] ,
388
353
derefs : & mut DefIdSet ,
389
354
used_links : & mut FxHashSet < String > ,
390
355
) {
@@ -409,7 +374,7 @@ fn sidebar_deref_methods<'a>(
409
374
// Avoid infinite cycles
410
375
return ;
411
376
}
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 ( ) ) ;
413
378
let inner_impl = target
414
379
. def_id ( c)
415
380
. or_else ( || {
@@ -460,7 +425,7 @@ fn sidebar_deref_methods<'a>(
460
425
cx,
461
426
out,
462
427
target_deref_impl,
463
- target_impls. iter ( ) ,
428
+ target_impls,
464
429
derefs,
465
430
used_links,
466
431
) ;
0 commit comments