Skip to content

Commit a69e15c

Browse files
committed
Remove the side channel
Hooray! It was no longer used, so it can just be deleted.
1 parent 54a14e8 commit a69e15c

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+11-44
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use smallvec::{smallvec, SmallVec};
2525
use pulldown_cmark::LinkType;
2626

2727
use std::borrow::Cow;
28-
use std::cell::Cell;
2928
use std::convert::{TryFrom, TryInto};
3029
use std::fmt::Write;
3130
use std::mem;
@@ -48,12 +47,8 @@ crate const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
4847
};
4948

5049
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() };
5752
collector.visit_crate(&krate);
5853
krate
5954
}
@@ -319,7 +314,6 @@ struct DiagnosticInfo<'a> {
319314
#[derive(Clone, Debug, Hash)]
320315
struct CachedLink {
321316
pub res: (Res, Option<UrlFragment>),
322-
pub side_channel: Option<(DefKind, DefId)>,
323317
}
324318

325319
struct LinkCollector<'a, 'tcx> {
@@ -329,10 +323,6 @@ struct LinkCollector<'a, 'tcx> {
329323
/// The last module will be used if the parent scope of the current item is
330324
/// unknown.
331325
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)>>,
336326
/// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link.
337327
/// The link will be `None` if it could not be resolved (i.e. the error was cached).
338328
visited_links: FxHashMap<ResolutionInfo, Option<CachedLink>>,
@@ -430,7 +420,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
430420
prim_ty: PrimitiveType,
431421
ns: Namespace,
432422
item_name: Symbol,
433-
) -> Option<(Res, UrlFragment, Option<(DefKind, DefId)>)> {
423+
) -> Option<(Res, UrlFragment)> {
434424
let tcx = self.cx.tcx;
435425

436426
prim_ty.impls(tcx).into_iter().find_map(|&impl_| {
@@ -439,7 +429,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
439429
.map(|item| {
440430
let kind = item.kind;
441431
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)
443433
})
444434
})
445435
}
@@ -580,15 +570,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
580570
resolve_primitive(&path_root, TypeNS)
581571
.or_else(|| self.resolve_path(&path_root, TypeNS, module_id))
582572
.and_then(|ty_res| {
583-
let (res, fragment, side_channel) =
573+
let (res, fragment) =
584574
self.resolve_associated_item(ty_res, item_name, ns, module_id)?;
585575

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-
}
592576
Some(Ok((res, Some(fragment))))
593577
})
594578
.unwrap_or_else(|| {
@@ -686,7 +670,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
686670
item_name: Symbol,
687671
ns: Namespace,
688672
module_id: DefId,
689-
) -> Option<(Res, UrlFragment, Option<(DefKind, DefId)>)> {
673+
) -> Option<(Res, UrlFragment)> {
690674
let tcx = self.cx.tcx;
691675

692676
match root_res {
@@ -702,10 +686,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
702686
assoc_item.map(|item| {
703687
let kind = item.kind;
704688
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)
709690
})
710691
})
711692
}
@@ -756,10 +737,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
756737
if let Some(item) = assoc_item {
757738
let kind = item.kind;
758739
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));
763741
}
764742

765743
if ns != Namespace::ValueNS {
@@ -790,11 +768,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
790768
.fields
791769
.iter()
792770
.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)))
798772
}
799773
Res::Def(DefKind::Trait, did) => tcx
800774
.associated_items(did)
@@ -806,7 +780,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
806780
!item.defaultness.has_value(),
807781
);
808782
let res = Res::Def(item.kind.as_def_kind(), item.def_id);
809-
(res, fragment, None)
783+
(res, fragment)
810784
}),
811785
_ => None,
812786
}
@@ -1436,7 +1410,6 @@ impl LinkCollector<'_, '_> {
14361410
if let Some(ref cached) = self.visited_links.get(&key) {
14371411
match cached {
14381412
Some(cached) => {
1439-
self.kind_side_channel.set(cached.side_channel);
14401413
return Some(cached.res.clone());
14411414
}
14421415
None if cache_resolution_failure => return None,
@@ -1453,13 +1426,7 @@ impl LinkCollector<'_, '_> {
14531426
// Cache only if resolved successfully - don't silence duplicate errors
14541427
if let Some(res) = res {
14551428
// 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() }));
14631430

14641431
Some(res)
14651432
} else {

0 commit comments

Comments
 (0)