-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Generate a documentation page for core::mem::transmute. #57848
Conversation
…ransmute. In #[no_std] environments, std::mem::transmute is unavailable. Searching for transmute in libcore only pulls up core::intrinsics::transmute, which is behind the (unstable) core_intrinsics feature flag. Users wishing to use transmute in #[no_std] environments typically should use core::mem::transmute instead, as it is stable. This documentation makes core::mem::transmute discoverable.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @shepmaster (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
And (unfortunately in this case), the I think this is fine, but I'd wonder how it would look for |
Now, does this new fancy thing work yet... r? @rust-lang/docs |
No, it does not. |
Actually, the one we want (
Unfortunately, the recommendation does show up in |
Hm. It's because Lines 17 to 18 in 19f8958
|
You can (will be able to) filter your search (currently not in stable, only in nightly and beta...) so you won't have the search issue anymore. However, I approve the precision add! |
src/libcore/intrinsics.rs
Outdated
@@ -729,6 +729,10 @@ extern "rust-intrinsic" { | |||
/// cause [undefined behavior][ub] with this function. `transmute` should be | |||
/// the absolute last resort. | |||
/// | |||
/// `transmute` is re-exported by [core::mem](../mem/index.html) as | |||
/// `core::mem::transmute`, which may be used without the `core_intrinsics` | |||
/// feature flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs are going to show up for all four of {core|std}::{mem|intrinsics}::transmute
, right? It might be worth pointing at both mem
locations, in that case.
A better solution than adding the extra blurb in the docs is to apply |
|
Actually, the doc for the intrinsic is going to be the same in all four places it's available, because it's just re-exported around. There's no way to fix that, since rustdoc doesn't let you add different docs to a re-export. |
Thank you! I'll give that a try -- it sounds like a much better solution. |
…::mem::transmute, create documentation pages for them. This renders them discoverable via search. I removed the mention of the exports in the transmute documentation, but can re-add it if desired.
I added the doc page for core::mem::transmute. For my own use cases, this change would've been plenty, so I removed the additional paragraph from the doc comment. I can replace the comment if others feel that transmute is sufficiently unique to deserve a "recommended exports of" comment. |
Sorry for letting this sit for so long! Let's get this merged! @bors r+ rollup |
📌 Commit 1c8c94a has been approved by |
…ietMisdreavus Generate a documentation page for core::mem::transmute. In `#[no_std]` environments, `std::mem::transmute` is unavailable. Searching for "core transmute" online only pulls up `core::intrinsics::transmute`, which is behind the (unstable) `core_intrinsics` feature flag. Users wishing to use transmute in `#[no_std]` environments typically should use `core::mem::transmute` instead, as it is stable. This documentation makes `core::mem::transmute` discoverable.
Rollup of 11 pull requests Successful merges: - #57504 (Re-enable history api on file:// protocol) - #57848 (Generate a documentation page for core::mem::transmute.) - #57884 (Update minifier version) - #57954 (rustdoc: remove blank unstable spans) - #58028 (Fix image link in the settings menu) - #58033 (rustdoc: wrap stability tags in colored spans) - #58086 ([rustdoc] Improve file list display) - #58143 (Sort elements in the sidebar) - #58146 (Prevent automatic collapse of methods impl blocks) - #58150 (Don't apply impl block collapse rules to trait impls) - #58185 (Remove images' url to make it work even without internet connection) Failed merges: r? @ghost
In
#[no_std]
environments,std::mem::transmute
is unavailable. Searching for "core transmute" online only pulls upcore::intrinsics::transmute
, which is behind the (unstable)core_intrinsics
feature flag. Users wishing to use transmute in#[no_std]
environments typically should usecore::mem::transmute
instead, as it is stable. This documentation makescore::mem::transmute
discoverable.