Improve documentation for intra-doc links computation
This commit is contained in:
parent
d540e7285c
commit
2b9e41c128
@ -288,14 +288,16 @@ pub(crate) struct LinkCollector<'a, 'tcx> {
|
|||||||
/// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link.
|
/// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link.
|
||||||
/// The link will be `None` if it could not be resolved (i.e. the error was cached).
|
/// The link will be `None` if it could not be resolved (i.e. the error was cached).
|
||||||
pub(crate) visited_links: FxHashMap<ResolutionInfo, Option<(Res, Option<UrlFragment>)>>,
|
pub(crate) visited_links: FxHashMap<ResolutionInfo, Option<(Res, Option<UrlFragment>)>>,
|
||||||
/// These links are ambiguous. We need for the cache to have its paths filled. Unfortunately,
|
/// According to `rustc_resolve`, these links are ambiguous.
|
||||||
/// if we run the `LinkCollector` pass after `Cache::populate`, a lot of items that we need
|
|
||||||
/// to go through will be removed, making a lot of intra-doc links to not be inferred.
|
|
||||||
///
|
///
|
||||||
/// So instead, we store the ambiguous links and we wait for cache paths to be filled before
|
/// However, we cannot link to an item that has been stripped from the documentation. If all
|
||||||
/// inferring them (if possible).
|
/// but one of the "possibilities" are stripped, then there is no real ambiguity. To determine
|
||||||
|
/// if an ambiguity is real, we delay resolving them until after `Cache::populate`, then filter
|
||||||
|
/// every item that doesn't have a cached path.
|
||||||
///
|
///
|
||||||
/// Key is `(item ID, path str)`.
|
/// We could get correct results by simply delaying everything. This would have fewer happy
|
||||||
|
/// codepaths, but we want to distinguish different kinds of error conditions, and this is easy
|
||||||
|
/// to do by resolving links as soon as possible.
|
||||||
pub(crate) ambiguous_links: FxIndexMap<(ItemId, String), Vec<AmbiguousLinks>>,
|
pub(crate) ambiguous_links: FxIndexMap<(ItemId, String), Vec<AmbiguousLinks>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1187,9 +1189,7 @@ pub(crate) fn resolve_ambiguities(&mut self) {
|
|||||||
report_diagnostic(
|
report_diagnostic(
|
||||||
self.cx.tcx,
|
self.cx.tcx,
|
||||||
BROKEN_INTRA_DOC_LINKS,
|
BROKEN_INTRA_DOC_LINKS,
|
||||||
format!(
|
format!("all items matching `{path_str}` are private or doc(hidden)"),
|
||||||
"all items matching `{path_str}` are either private or doc(hidden)"
|
|
||||||
),
|
|
||||||
&diag_info,
|
&diag_info,
|
||||||
|diag, sp, _| {
|
|diag, sp, _| {
|
||||||
if let Some(sp) = sp {
|
if let Some(sp) = sp {
|
||||||
|
@ -11,5 +11,5 @@ pub struct Thing {}
|
|||||||
pub fn Thing() {}
|
pub fn Thing() {}
|
||||||
|
|
||||||
/// Do stuff with [`Thing`].
|
/// Do stuff with [`Thing`].
|
||||||
//~^ ERROR all items matching `Thing` are either private or doc(hidden)
|
//~^ ERROR all items matching `Thing` are private or doc(hidden)
|
||||||
pub fn repro(_: Thing) {}
|
pub fn repro(_: Thing) {}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: all items matching `Thing` are either private or doc(hidden)
|
error: all items matching `Thing` are private or doc(hidden)
|
||||||
--> $DIR/filter-out-private-2.rs:13:21
|
--> $DIR/filter-out-private-2.rs:13:21
|
||||||
|
|
|
|
||||||
LL | /// Do stuff with [`Thing`].
|
LL | /// Do stuff with [`Thing`].
|
||||||
|
Loading…
Reference in New Issue
Block a user