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

Docs: clarify that certain intrinsics are not unsafe #86308

Merged
merged 1 commit into from
Jul 2, 2021

Conversation

bstrie
Copy link
Contributor

@bstrie bstrie commented Jun 14, 2021

As determined by the hardcoded list at

sym::abort
| sym::size_of
| sym::min_align_of
| sym::needs_drop
| sym::caller_location
| sym::add_with_overflow
| sym::sub_with_overflow
| sym::mul_with_overflow
| sym::wrapping_add
| sym::wrapping_sub
| sym::wrapping_mul
| sym::saturating_add
| sym::saturating_sub
| sym::rotate_left
| sym::rotate_right
| sym::ctpop
| sym::ctlz
| sym::cttz
| sym::bswap
| sym::bitreverse
| sym::discriminant_value
| sym::type_id
| sym::likely
| sym::unlikely
| sym::ptr_guaranteed_eq
| sym::ptr_guaranteed_ne
| sym::minnumf32
| sym::minnumf64
| sym::maxnumf32
| sym::rustc_peek
| sym::maxnumf64
| sym::type_name
| sym::forget
| sym::variant_count => hir::Unsafety::Normal,

@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 14, 2021
@RalfJung
Copy link
Member

Maybe add a comment in rustc_typeck/src/check/intrinsic.rs telling people to also update the docs when adding more items to that list?

@lqd
Copy link
Member

lqd commented Jun 15, 2021

Btw: #86327 will fix the rustdoc issue which made these intrinsics' signatures appear unsafe to call in the libcore/libstd docs.

@bstrie
Copy link
Contributor Author

bstrie commented Jun 16, 2021

Btw: #86327 will fix the rustdoc issue which made these intrinsics' signatures appear unsafe to call in the libcore/libstd docs.

Great to hear that the rustdoc bug is fixed. I still think that this PR would be useful, since the idea of any safe function declared inside an extern block is surprising, and users used to the normal semantics of extern blocks could just as easily assume that the lack of a visible unsafe in the docs is a bug in rustdoc. :P

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me! It's a bit unfortunate that we have to write a lot of the same comments but it should be fine for now.

@JohnTitor
Copy link
Member

r? @JohnTitor @bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 2, 2021

📌 Commit 16168dd has been approved by JohnTitor

@rust-highfive rust-highfive assigned JohnTitor and unassigned kennytm Jul 2, 2021
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#84029 (add `track_path::path` fn for usage in `proc_macro`s)
 - rust-lang#85001 (Merge `sys_common::bytestring` back into `os_str_bytes`)
 - rust-lang#86308 (Docs: clarify that certain intrinsics are not unsafe)
 - rust-lang#86796 (Add a regression test for issue-70703)
 - rust-lang#86803 (Remove & from Command::args calls in documentation)
 - rust-lang#86807 (Fix double import in wasm thread )
 - rust-lang#86813 (Add a help message to `unused_doc_comments` lint)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7fb3c29 into rust-lang:master Jul 2, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants