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

Reexported intrinsics show up in rustdoc intra-doc links instead of their proper paths #131676

Closed
theemathas opened this issue Oct 14, 2024 · 7 comments · Fixed by #135043 or #135171
Closed
Labels
A-rustdoc-search Area: Rustdoc's search feature C-bug Category: This is a bug. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Comments

@theemathas
Copy link
Contributor

The following functions appear to be intrinsics that are re-exported at a different path (see also: #113387):

  • intrinsics::transmute -> mem::transmute
  • intrinsics::copy -> ptr::copy
  • intrinsics::copy_nonoverlapping -> ptr::copy_nonoverlapping
  • intrinsics::write_bytes -> ptr::write_bytes

Searching for these only finds the functions in std::intrinsics. (And for specifically transmute, it also shows core::mem::transmute for some reason.) The search result should ideally show the functions in std::mem/ptr. See below screenshots obtained by searching for transmute and searching for copy_nonoverlapping

Image
Image

@theemathas theemathas added the C-bug Category: This is a bug. label Oct 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 14, 2024
@lolbinarycat lolbinarycat added A-rustdoc-search Area: Rustdoc's search feature T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 14, 2024
@kpreid
Copy link
Contributor

kpreid commented Oct 15, 2024

Possibly related: intra-doc links to std::mem::transmute or core::mem::transmute also end up linking to the intrinsic page.

@RalfJung
Copy link
Member

RalfJung commented Dec 12, 2024

Ouch, yes we should not push more people towards these accidentally-stable names. rustdoc should treat #[rustc_allowed_through_unstable_modules] functions in a pub module like pub fn in a private module.

Cc @rust-lang/rustdoc

@workingjubilee
Copy link
Member

I wonder if we should just move the intrinsic defs to their reexport site and then reexport them from core::intrinsics.

@RalfJung
Copy link
Member

RalfJung commented Jan 1, 2025

If #135003 lands, we will start emitting a deprecation lint for std::intrinsics::transmute -- would be better if we didn't at the same time have rustdoc recommend exactly that deprecated path.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 3, 2025
…h-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez

rustdoc: treat `allowed_through_unstable_modules` as deprecation

This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable.

Fixes rust-lang#131676

Related to rust-lang#135003

r? `@GuillaumeGomez`

`@RalfJung` `@workingjubilee`
@bors bors closed this as completed in f0c03f6 Jan 4, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 4, 2025
Rollup merge of rust-lang#135043 - notriddle:notriddle/allowed-through-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez

rustdoc: treat `allowed_through_unstable_modules` as deprecation

This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable.

Fixes rust-lang#131676

Related to rust-lang#135003

r? ``@GuillaumeGomez``

``@RalfJung`` ``@workingjubilee``
@theemathas
Copy link
Contributor Author

Intra-doc links still link to the wrong place. For example, the link at https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.from_raw points to the transmute intrinsic.

@RalfJung
Copy link
Member

RalfJung commented Jan 6, 2025

Hm yeah that is confusing -- it points to https://doc.rust-lang.org/nightly/std/intrinsics/fn.transmute.html which looks as if transmute itself is deprecated.

@RalfJung RalfJung reopened this Jan 6, 2025
@RalfJung RalfJung changed the title Reexported intrinsics show up in rustdoc search instead of their proper paths Reexported intrinsics show up in rustdoc intra-doc links instead of their proper paths Jan 6, 2025
@RalfJung
Copy link
Member

RalfJung commented Jan 6, 2025

Note that the doc comment explicitly uses the std::mem path, and still rustdoc chooses the std::intrinsics path.

For private items that are re-exported publicly, rustdoc must have some logic that prints the public path rather than the private one. Could we make rustdoc consider the unstable path "private" and hence pretend it does not exist, therefore insisting on the proper stable path everywhere?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 7, 2025
…-better, r=GuillaumeGomez

rustdoc: use stable paths as preferred canonical paths

This accomplishes something like 16a4ad7, but with the `rustc_allowed_through_unstable_modules` attribute instead of the path length.

Fixes rust-lang#131676
@bors bors closed this as completed in 0e48e96 Jan 8, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2025
Rollup merge of rust-lang#135171 - notriddle:notriddle/stable-path-is-better, r=GuillaumeGomez

rustdoc: use stable paths as preferred canonical paths

This accomplishes something like 16a4ad7, but with the `rustc_allowed_through_unstable_modules` attribute instead of the path length.

Fixes rust-lang#131676
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-bug Category: This is a bug. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
6 participants