@@ -25,7 +25,6 @@ use smallvec::{smallvec, SmallVec};
25
25
use pulldown_cmark:: LinkType ;
26
26
27
27
use std:: borrow:: Cow ;
28
- use std:: cell:: Cell ;
29
28
use std:: convert:: { TryFrom , TryInto } ;
30
29
use std:: fmt:: Write ;
31
30
use std:: mem;
@@ -48,12 +47,8 @@ crate const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
48
47
} ;
49
48
50
49
fn collect_intra_doc_links ( krate : Crate , cx : & mut DocContext < ' _ > ) -> Crate {
51
- let mut collector = LinkCollector {
52
- cx,
53
- mod_ids : Vec :: new ( ) ,
54
- kind_side_channel : Cell :: new ( None ) ,
55
- visited_links : FxHashMap :: default ( ) ,
56
- } ;
50
+ let mut collector =
51
+ LinkCollector { cx, mod_ids : Vec :: new ( ) , visited_links : FxHashMap :: default ( ) } ;
57
52
collector. visit_crate ( & krate) ;
58
53
krate
59
54
}
@@ -319,7 +314,6 @@ struct DiagnosticInfo<'a> {
319
314
#[ derive( Clone , Debug , Hash ) ]
320
315
struct CachedLink {
321
316
pub res : ( Res , Option < UrlFragment > ) ,
322
- pub side_channel : Option < ( DefKind , DefId ) > ,
323
317
}
324
318
325
319
struct LinkCollector < ' a , ' tcx > {
@@ -329,10 +323,6 @@ struct LinkCollector<'a, 'tcx> {
329
323
/// The last module will be used if the parent scope of the current item is
330
324
/// unknown.
331
325
mod_ids : Vec < DefId > ,
332
- /// This is used to store the kind of associated items,
333
- /// because `clean` and the disambiguator code expect them to be different.
334
- /// See the code for associated items on inherent impls for details.
335
- kind_side_channel : Cell < Option < ( DefKind , DefId ) > > ,
336
326
/// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link.
337
327
/// The link will be `None` if it could not be resolved (i.e. the error was cached).
338
328
visited_links : FxHashMap < ResolutionInfo , Option < CachedLink > > ,
@@ -430,7 +420,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
430
420
prim_ty : PrimitiveType ,
431
421
ns : Namespace ,
432
422
item_name : Symbol ,
433
- ) -> Option < ( Res , UrlFragment , Option < ( DefKind , DefId ) > ) > {
423
+ ) -> Option < ( Res , UrlFragment ) > {
434
424
let tcx = self . cx . tcx ;
435
425
436
426
prim_ty. impls ( tcx) . into_iter ( ) . find_map ( |& impl_| {
@@ -439,7 +429,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
439
429
. map ( |item| {
440
430
let kind = item. kind ;
441
431
let fragment = UrlFragment :: from_assoc_item ( item. def_id , kind, false ) ;
442
- ( Res :: Primitive ( prim_ty) , fragment, Some ( ( kind . as_def_kind ( ) , item . def_id ) ) )
432
+ ( Res :: Primitive ( prim_ty) , fragment)
443
433
} )
444
434
} )
445
435
}
@@ -580,15 +570,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
580
570
resolve_primitive ( & path_root, TypeNS )
581
571
. or_else ( || self . resolve_path ( & path_root, TypeNS , module_id) )
582
572
. and_then ( |ty_res| {
583
- let ( res, fragment, side_channel ) =
573
+ let ( res, fragment) =
584
574
self . resolve_associated_item ( ty_res, item_name, ns, module_id) ?;
585
575
586
- // HACK(jynelson): `clean` expects the type, not the associated item
587
- // but the disambiguator logic expects the associated item.
588
- // Store the kind in a side channel so that only the disambiguator logic looks at it.
589
- if let Some ( ( kind, id) ) = side_channel {
590
- self . kind_side_channel . set ( Some ( ( kind, id) ) ) ;
591
- }
592
576
Some ( Ok ( ( res, Some ( fragment) ) ) )
593
577
} )
594
578
. unwrap_or_else ( || {
@@ -686,7 +670,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
686
670
item_name : Symbol ,
687
671
ns : Namespace ,
688
672
module_id : DefId ,
689
- ) -> Option < ( Res , UrlFragment , Option < ( DefKind , DefId ) > ) > {
673
+ ) -> Option < ( Res , UrlFragment ) > {
690
674
let tcx = self . cx . tcx ;
691
675
692
676
match root_res {
@@ -702,10 +686,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
702
686
assoc_item. map ( |item| {
703
687
let kind = item. kind ;
704
688
let fragment = UrlFragment :: from_assoc_item ( item. def_id , kind, false ) ;
705
- // HACK(jynelson): `clean` expects the type, not the associated item
706
- // but the disambiguator logic expects the associated item.
707
- // Store the kind in a side channel so that only the disambiguator logic looks at it.
708
- ( root_res, fragment, Some ( ( kind. as_def_kind ( ) , item. def_id ) ) )
689
+ ( root_res, fragment)
709
690
} )
710
691
} )
711
692
}
@@ -756,10 +737,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
756
737
if let Some ( item) = assoc_item {
757
738
let kind = item. kind ;
758
739
let fragment = UrlFragment :: from_assoc_item ( item. def_id , kind, false ) ;
759
- // HACK(jynelson): `clean` expects the type, not the associated item
760
- // but the disambiguator logic expects the associated item.
761
- // Store the kind in a side channel so that only the disambiguator logic looks at it.
762
- return Some ( ( root_res, fragment, Some ( ( kind. as_def_kind ( ) , item. def_id ) ) ) ) ;
740
+ return Some ( ( root_res, fragment) ) ;
763
741
}
764
742
765
743
if ns != Namespace :: ValueNS {
@@ -790,11 +768,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
790
768
. fields
791
769
. iter ( )
792
770
. find ( |item| item. ident . name == item_name) ?;
793
- Some ( (
794
- root_res,
795
- UrlFragment :: Def ( FragmentKind :: StructField , field. did ) ,
796
- Some ( ( DefKind :: Field , field. did ) ) ,
797
- ) )
771
+ Some ( ( root_res, UrlFragment :: Def ( FragmentKind :: StructField , field. did ) ) )
798
772
}
799
773
Res :: Def ( DefKind :: Trait , did) => tcx
800
774
. associated_items ( did)
@@ -806,7 +780,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
806
780
!item. defaultness . has_value ( ) ,
807
781
) ;
808
782
let res = Res :: Def ( item. kind . as_def_kind ( ) , item. def_id ) ;
809
- ( res, fragment, None )
783
+ ( res, fragment)
810
784
} ) ,
811
785
_ => None ,
812
786
}
@@ -1436,7 +1410,6 @@ impl LinkCollector<'_, '_> {
1436
1410
if let Some ( ref cached) = self . visited_links . get ( & key) {
1437
1411
match cached {
1438
1412
Some ( cached) => {
1439
- self . kind_side_channel . set ( cached. side_channel ) ;
1440
1413
return Some ( cached. res . clone ( ) ) ;
1441
1414
}
1442
1415
None if cache_resolution_failure => return None ,
@@ -1453,13 +1426,7 @@ impl LinkCollector<'_, '_> {
1453
1426
// Cache only if resolved successfully - don't silence duplicate errors
1454
1427
if let Some ( res) = res {
1455
1428
// Store result for the actual namespace
1456
- self . visited_links . insert (
1457
- key,
1458
- Some ( CachedLink {
1459
- res : res. clone ( ) ,
1460
- side_channel : self . kind_side_channel . clone ( ) . into_inner ( ) ,
1461
- } ) ,
1462
- ) ;
1429
+ self . visited_links . insert ( key, Some ( CachedLink { res : res. clone ( ) } ) ) ;
1463
1430
1464
1431
Some ( res)
1465
1432
} else {
0 commit comments