@@ -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
} ;
@@ -290,43 +288,10 @@ fn sidebar_assoc_items<'a>(
290
288
) {
291
289
let did = it. item_id . expect_def_id ( ) ;
292
290
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
- } ;
326
291
327
292
let mut assoc_consts = Vec :: new ( ) ;
328
293
let mut methods = Vec :: new ( ) ;
329
- if !v . is_empty ( ) {
294
+ if let Some ( v ) = cache . impls . get ( & did ) {
330
295
let mut used_links = FxHashSet :: default ( ) ;
331
296
let mut id_map = IdMap :: new ( ) ;
332
297
@@ -362,7 +327,7 @@ fn sidebar_assoc_items<'a>(
362
327
cx,
363
328
& mut deref_methods,
364
329
impl_,
365
- v. iter ( ) . copied ( ) ,
330
+ v,
366
331
& mut derefs,
367
332
& mut used_links,
368
333
) ;
@@ -392,7 +357,7 @@ fn sidebar_deref_methods<'a>(
392
357
cx : & ' a Context < ' _ > ,
393
358
out : & mut Vec < LinkBlock < ' a > > ,
394
359
impl_ : & Impl ,
395
- v : impl Iterator < Item = & ' a Impl > ,
360
+ v : & [ Impl ] ,
396
361
derefs : & mut DefIdSet ,
397
362
used_links : & mut FxHashSet < String > ,
398
363
) {
@@ -417,7 +382,7 @@ fn sidebar_deref_methods<'a>(
417
382
// Avoid infinite cycles
418
383
return ;
419
384
}
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 ( ) ) ;
421
386
let inner_impl = target
422
387
. def_id ( c)
423
388
. or_else ( || {
@@ -468,7 +433,7 @@ fn sidebar_deref_methods<'a>(
468
433
cx,
469
434
out,
470
435
target_deref_impl,
471
- target_impls. iter ( ) ,
436
+ target_impls,
472
437
derefs,
473
438
used_links,
474
439
) ;
0 commit comments