-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Don't mark #[target_feature]
safe fns as unsafe in rustdoc JSON.
#143555
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
base: master
Are you sure you want to change the base?
Don't mark #[target_feature]
safe fns as unsafe in rustdoc JSON.
#143555
Conversation
These commits modify Please ensure that if you've changed the output:
|
While reading up on the overall context, I noticed that @oli-obk had considered changing the I'm not qualified to decide whether refactoring |
src/librustdoc/json/conversions.rs
Outdated
let is_unsafe = | ||
header.is_unsafe() && !matches!(header.safety, HeaderSafety::SafeTargetFeatures); |
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.
Make this an exhaustive match on header.safety
(not not header.safety()
!).
Tho long term I think we'll want to change the rustdoc::json::FunctionHeader
to just fully have the header safety information. Even normal rustdoc rendering should probably distinguish between safe functions and safe-in-some-contexts functions and have appropriate hints somewhere.
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.
Sounds good, thanks Oli!
src/librustdoc/json/conversions.rs
Outdated
// The type system's internal implementation details consider | ||
// safe functions with the `#[target_feature]` attribute as analogous to unsafe functions. | ||
// `header.is_unsafe()` returns `true` for them. But that's not the right decision | ||
// for rustdoc, so we specifically exclude that case. |
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.
NIT: It might be nice to link back to #142655 here
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.
Done inside the exhaustive match's HeaderSafety::SafeTargetFeatures
arm.
Thanks! r=me with oli's match thing changed. (You don't need to handle my nit). @bors delegate+ |
✌️ @obi1kenobi, you can now approve this pull request! If @aDotInTheVoid told you to " |
239f472
to
7170412
Compare
@bors r=aDotInTheVoid |
…nsafe-rustdoc-json, r=aDotInTheVoid Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON. Fixes rust-lang#142655 by explicitly checking whether functions are safe but using `#[target_feature]`, instead of relying on the `FnHeader::is_unsafe()` method which considers such functions unsafe. I don't believe this merits a bump of the rustdoc JSON `FORMAT_VERSION` constant, since the format is unchanged and this is just a small bugfix. r? aDotInTheVoid
Rollup of 6 pull requests Successful merges: - #134628 (Make `Default` const and add some `const Default` impls) - #143555 (Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.) - #143600 (Update intro blurb in `wasm32-wasip1` docs) - #143603 (Clarify the meaning of `AttributeOrder::KeepFirst` and `AttributeOrder::KeepLast`) - #143620 (fix: Remove newline from multiple crate versions note) - #143622 (Add target maintainer information for mips64-unknown-linux-muslabi64) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #142655 by explicitly checking whether functions are safe but using
#[target_feature]
, instead of relying on theFnHeader::is_unsafe()
method which considers such functions unsafe.I don't believe this merits a bump of the rustdoc JSON
FORMAT_VERSION
constant, since the format is unchanged and this is just a small bugfix.r? aDotInTheVoid