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.
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.
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.
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
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
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
…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 8 pull requests Successful merges: - #143402 (Port several linking (linkage?) related attributes the new attribute system ) - #143555 (Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.) - #143593 (Port #[rustc_dummy]) - #143600 (Update intro blurb in `wasm32-wasip1` docs) - #143603 (Clarify the meaning of `AttributeOrder::KeepFirst` and `AttributeOrder::KeepLast`) - #143606 (configure.py: Write last key in each section) - #143620 (fix: Remove newline from multiple crate versions note) - #143622 (Add target maintainer information for mips64-unknown-linux-muslabi64) Failed merges: - #143403 (Port several trait/coherence-related attributes the new attribute system) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - #143402 (Port several linking (linkage?) related attributes the new attribute system ) - #143555 (Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.) - #143593 (Port #[rustc_dummy]) - #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) Failed merges: - #143403 (Port several trait/coherence-related attributes the new attribute system) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #143555 - obi1kenobi:pg/target-feature-not-unsafe-rustdoc-json, r=aDotInTheVoid Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON. Fixes #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
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_VERSIONconstant, since the format is unchanged and this is just a small bugfix.r? aDotInTheVoid