-
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
Enable rustdoc to document safe wasm intrinsics #85982
Conversation
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
// | ||
// Note that this is also allowed if `actually_rustdoc` so | ||
// if a target is documenting some wasm-specific code then | ||
// it's not spuriously denied. |
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.
I really am not a fan of continuing to special-case rustdoc ... is there any way to avoid calling codegen_fn_attrs
in rustdoc itself? Rustdoc shouldn't care what they are, right?
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.
No, the codegen_fn_attrs
query is forced in the check attr pass which ensures that many attributes are valid. Otherwise cargo check
would completely ignore it and cargo build
would ignore it for functions that aren't codegened.
Please add a test for this. |
50e7161
to
8123570
Compare
Sure, I've added a test. As for whether we can avoid calling the function, I don't know. I'm trying to basically just continue how target features are already handled differently for rustdoc. |
@davidtwco are you ok reviewing this? I can try to find someone else if you're busy? Or @jyn514 would you be up for reviewing? |
Do you happen to know where in the codebase that's handled? I'm not familiar with target_feature. |
Sure yeah, that happens here --
|
Thanks! I'm not super happy about that special casing either, but it makes sense to keep them consistent. @bors r+ |
📌 Commit 8123570141f7ce1a57e69cd57a5e5c8acbe631d2 has been approved by |
Oh wait hold on, that test doesn't actually test anything. You need to either add a @Has check (see https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#dotting-is-and-crossing-ts) or move it to rustdoc-ui with a // check-pass annotation. Maybe there should be a tidy lint for rustdoc tests without @Has checks? @bors r- |
This commit fixes an issue not found during rust-lang#84988 where rustdoc is used to document cross-platform intrinsics but it was requiring that functions which use `#[target_feature]` are `unsafe` erroneously, even if they're WebAssembly specific. Rustdoc today, for example, already has a special case where it enables annotations like `#[target_feature(enable = "simd128")]` on platforms other than WebAssembly. The purpose of this commit is to relax the "require all `#[target_feature]` functions are `unsafe`" requirement for all targets whenever rustdoc is running, enabling all targets to fully document other targets, such as WebAssembly, where intrinsics functions aren't always `unsafe`.
8123570
to
aba85ff
Compare
@bors: r=jyn514 Oh oops, moved. Thanks for reviewing! |
📌 Commit aba85ff has been approved by |
No problem, thanks for the fix :) |
Rollup of 11 pull requests Successful merges: - rust-lang#85676 (Fix documentation style inconsistencies for IP addresses) - rust-lang#85715 (Document `From` impls in string.rs) - rust-lang#85791 (Add `Ipv6Addr::is_unicast`) - rust-lang#85957 (Display defaults on const params- rustdoc ) - rust-lang#85982 (Enable rustdoc to document safe wasm intrinsics) - rust-lang#86121 (Forwarding implementation for Seek trait's stream_position method) - rust-lang#86124 (Include macro name in 'local ambiguity' error) - rust-lang#86128 (Refactor: Extract render_summary from render_impl.) - rust-lang#86142 (Simplify proc_macro code using Bound::cloned().) - rust-lang#86158 (Update books) - rust-lang#86159 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit fixes an issue not found during #84988 where rustdoc is used
to document cross-platform intrinsics but it was requiring that
functions which use
#[target_feature]
areunsafe
erroneously, evenif they're WebAssembly specific. Rustdoc today, for example, already has
a special case where it enables annotations like
#[target_feature(enable = "simd128")]
on platforms other thanWebAssembly. The purpose of this commit is to relax the "require all
#[target_feature]
functions areunsafe
" requirement for all targetswhenever rustdoc is running, enabling all targets to fully document
other targets, such as WebAssembly, where intrinsics functions aren't
always
unsafe
.