-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement RFC 2585: unsafe blocks in unsafe fn #71862
Implement RFC 2585: unsafe blocks in unsafe fn #71862
Conversation
I'm afraid I cannot review this, the code is way outside my comfort zone. |
Cc @matthewjasper maybe you can help with review? |
Maybe @hanna-kruppe (who reviewed another PR I had on the same part of the code), if you have some time? |
Sorry, I don't have the time. |
No problem, thanks for answering! |
src/test/ui/feature-gates/feature-gate-unsafe_block_in_unsafe_fn.rs
Outdated
Show resolved
Hide resolved
src/test/ui/feature-gates/feature-gate-unsafe_block_in_unsafe_fn.rs
Outdated
Show resolved
Hide resolved
f4858b1
to
a6bb96c
Compare
@RalfJung -- it looks like you've found a bunch of things to work on, can you maybe ping me when the PR is ready for me to take a look? I can assign to you in the meantime..? |
I can review the tests, but that's about it. Sure, I'll re-assign to you once those look good to me. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@RalfJung Sorry if I've been inactive lately... I pushed a commit which should address your review. Could you confirm that the test for the RFC looks good now? |
@LeSeulArtichaut it's okay, we are not in a rush. :) The tests look much better now, thanks! Could you also test some other unsafe operations besides calling an unsafe function... let's say, dereferencing a raw pointer. Also taking a reference to a packed field is notorious (#27060), it is a warning instead of a hard error, so we should probably test that that interacts properly with the new lint. |
@RalfJung I pushed 15ec7fd5ff3c5ec92f1155bad202ee00f80e111b, which includes dereferencing a raw pointer, using a static mut and borrowing a packed field. Should I add other stuff, e.g. using a union or doing inline assembly? |
e0d57bc
to
db684be
Compare
Pushed a commit to fix rustdoc failures, and this time I tested it :D |
@nikomatsakis CI passes now 🎉 In the meantime, I opened #72694 for the feature-gated lints. I developed my implementation plan there and I think I could do it pretty easily. But at the same time I think it might be a good first issue for a new contributor, which I can probably "mentor" (rather guide them in the documentation 😄). Please tell me if the implementation plan seems good and whether I should do it or let someone else do it. |
@bors r Thanks for seeing this through, @LeSeulArtichaut! I'll check out #72694 |
📌 Commit 0e3b31c has been approved by |
…afe-fn, r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: rust-lang#71668 r? @RalfJung cc @nikomatsakis
…afe-fn, r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: rust-lang#71668 r? @RalfJung cc @nikomatsakis
…afe-fn, r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: rust-lang#71668 r? @RalfJung cc @nikomatsakis
…afe-fn, r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: rust-lang#71668 r? @RalfJung cc @nikomatsakis
Rollup of 9 pull requests Successful merges: - rust-lang#67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes) - rust-lang#71095 (impl From<[T; N]> for Box<[T]>) - rust-lang#71500 (Make pointer offset methods/intrinsics const) - rust-lang#71804 (linker: Support `-static-pie` and `-static -shared`) - rust-lang#71862 (Implement RFC 2585: unsafe blocks in unsafe fn) - rust-lang#72103 (borrowck `DefId` -> `LocalDefId`) - rust-lang#72407 (Various minor improvements to Ipv6Addr::Display) - rust-lang#72413 (impl Step for char (make Range*<char> iterable)) - rust-lang#72439 (NVPTX support for new asm!) Failed merges: r? @ghost
…nikomatsakis `#[deny(unsafe_op_in_unsafe_fn)]` in liballoc This PR proposes to make use of the new `unsafe_op_in_unsafe_fn` lint, i.e. no longer consider the body of an unsafe function as an unsafe block and require explicit unsafe block to perform unsafe operations. This has been first (partly) suggested by @Mark-Simulacrum in rust-lang#69245 (comment) Tracking issue for the feature: rust-lang#71668. ~~Blocked on rust-lang#71862.~~ r? @Mark-Simulacrum cc @nikomatsakis can you confirm that those changes are desirable? Should I restrict it to only BTree for the moment?
Tracking issue: #71668
r? @RalfJung cc @nikomatsakis