Stream: rustdoc

Topic: Populating cache before intra-doc links


view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:06):

I want to populate the cache before running intra-doc links (for https://github.com/rust-lang/rust/pull/82014). Right now that breaks links to traits:

> diff /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/test/rustdoc/intra-doc/trait-impl.nightly/foo/trait.MyTrait.html /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/test/rustdoc/intra-doc/trait-impl/foo/trait.MyTrait.html
128c128
<               <a href="../foo/struct.MyStruct.html#associatedtype.AssoType"><code>AssoType</code></a>
---
>               <a href="MyStruct::AssoType"><code>AssoType</code></a>
136c136
<               <a href="../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST"><code>ASSO_CONST</code></a>
---
>               <a href="MyStruct::ASSO_CONST"><code>ASSO_CONST</code></a>
144c144
<               <a href="../foo/struct.MyStruct.html#method.trait_fn"><code>trait_fn</code></a>
---
>               <a href="MyStruct::trait_fn"><code>trait_fn</code></a>

I think this is happening because intra-doc links themselves fill out parts of the cache: https://github.com/rust-lang/rust/blob/a118ee2c13cc96ceb27bd5030c1cca1052377604/src/librustdoc/passes/collect_intra_doc_links.rs#L1245.

There are two issues here:

I guess my questions are

Maybe it would be easier to move this check out of intra-doc links altogether ...

view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:09):

@GuillaumeGomez would be interested in your thoughts :)

view this post on Zulip GuillaumeGomez (Feb 12 2021 at 18:28):

Anything cache-related isn't behaving the same depending at which phase we are and it's a bit problematic. If you know what the issue is, you can always try to work around and identify clearly what shouldn't have access to the cache. At least it's how I do it generally. It got simpler lately so if we continue like that, we might even be able to use the cache everywhere without worrying.

view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:37):

well I don't know if intra-doc links shouldn't have access to the cache is the issue

view this post on Zulip GuillaumeGomez (Feb 12 2021 at 18:43):

I don't see why it shouldn't. But does the cache provides information you can't get otherwise?

view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:43):

yes, specifically I want to know if an item will have documentation generated

view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:44):

which I do currently by calling href(def_id).is_some(), which breaks because the cache is still being constructed

view this post on Zulip Joshua Nelson (Feb 12 2021 at 18:47):

if there's an easier way to do that I'm all ears :)

view this post on Zulip GuillaumeGomez (Feb 12 2021 at 21:02):

I'd say: construct the cache first? XD

view this post on Zulip Joshua Nelson (Feb 12 2021 at 23:03):

GuillaumeGomez said:

I'd say: construct the cache first? XD

this isn't possible AFAICT because there are some items that are only used if intra-doc links link to them


Last updated: Oct 11 2021 at 22:34 UTC