Stream: rustdoc

Topic: Trying to get rustdoc to generate redirects


view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:02):

@Dániel Buga I'm trying to reproduce the issue you saw on https://github.com/deadlinks/cargo-deadlinks/issues/120 with something smaller than all of embedded-text. Do you know what causes that redirect page to be generated? I tried

mod inner {
    pub struct S;
}

pub use inner::S;

pub mod prelude {
    // This generates a redirect link.
    pub use crate::S;
}

but that caused S to be inlined in both prelude and the crate root.

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:02):

(I have a fix btw, just trying to write the test)

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:06):

I hope this isn't related to cross-crate links :/

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:08):

I found https://github.com/rust-lang/rust/blob/6340607acaab10eed3cf11ef7ad3564db58ec981/src/librustdoc/html/render/mod.rs#L1597 and https://github.com/rust-lang/rust/blob/6340607acaab10eed3cf11ef7ad3564db58ec981/src/librustdoc/html/render/mod.rs#L683, I think I'll just go with the macro one since it's easier to replicate

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:08):

ah hmm but macros don't have associated items, gah

view this post on Zulip Dániel Buga (Dec 18 2020 at 19:09):

I don't know, but I can check in a bit.

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:10):

618: self.render_redirect_pages = item.is_stripped();

oh boy

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:12):

aha, got it - this happens when the module is private but contains a public item that's linked to from elsewhere

view this post on Zulip Joshua Nelson (Dec 18 2020 at 19:13):

so to replicate I need to link to inner/struct.S.html, which redirects to the place it was inlined:

7:    <p>Redirecting to <a href="../../simple_project/struct.S.html">../../simple_project/struct.S.html</a>...</p>

Last updated: Oct 11 2021 at 22:34 UTC