Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking to str::replacen from alloc crate docstring creates a broken link fragment #98941

Open
WilliamVenner opened this issue Jul 5, 2022 · 2 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@WilliamVenner
Copy link
Contributor

Hi, in my PR #97977 I was unable to link to str::replacen from the alloc crate in a docstring:

/// [`str::replacen(..., 1)`]: str::replacen

Rustbook (x86_64-unknown-linux-gnu) - embedded-book
Rustbook (x86_64-unknown-linux-gnu) - edition-guide
Building stage0 tool linkchecker (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.17s
alloc/string/struct.String.html:842: broken link fragment `#method.replacen` pointing to `core/primitive.str.html`
number of HTML files scanned: 32333
number of HTML redirects found: 10095
number of links checked: 2261468
number of links ignored due to external: 112628
@WilliamVenner WilliamVenner added the C-bug Category: This is a bug. label Jul 5, 2022
@WilliamVenner
Copy link
Contributor Author

@rustbot label T-rustdoc

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 5, 2022
@zachs18
Copy link
Contributor

zachs18 commented Apr 27, 2024

I don't think this is necessarily a rustdoc issue. Currently, the stdlib only has docs for primitive types in core and std, meaning that inherent methods on primitives that are defined in alloc (like str::replacen) are not documented in alloc (so they are not documented anywhere when building only alloc's docs).

One solution would be to also document (some) primitives in alloc, which would give a place for methods like str::replacen, str::into_string, str::into_boxed_bytes, slice::to_vec, slice::into_vec, etc to be documented without std.

Another "solution" (for the linked PR) is to hardcode the link to go to ../../std/primitive.str.html#method.replacen, so that the link will only be broken when alloc's docs are built without std (This is what I used in my rebased branch)

Another ""solution"" is to just ignore the "broken" link in alloc's docs, since the link is specifically only broken in alloc/string/struct.String.html, not std/string/struct.String.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants