-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix missing block for unsafe code #10809
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
Conversation
r? @Jarcho (rustbot has picked a reviewer for you, use r? to override) |
These unit tests generate non-compilable code. I did NOT `bless` them on purpose because the stderr output is not good. I'm surprised we don't auto-compile the suggestions here - is this something that can be easily enabled? See rust-lang#10808
I wouldn't worry too much about formatting since most people will be running a formatter anyways. As long as it works and isn't atrocious.
Adding |
@Jarcho thx, fixed |
Thank you. @bors r+ |
Fix missing block for unsafe code If a block is declared as unsafe, it needs an extra layer of curly braces around it. Fixes #10808 This code adds handling for `UnsafeSource::UserProvided` block, i.e. `unsafe { ... }`. Note that we do not handle the `UnsafeSource::CompilerGenerated` as it seems to not be possible to generate that with the user code (?), or at least doesn't seem to be needed to be handled explicitly. There is an issue with this code: it does not add an extra indentation for the unsafe blocks. I think this is a relatively minor concern for such an edge case, and should probably be done by a separate PR (fixing compile bug is more important than getting styling perfect especially when `rustfmt` will fix it anyway) ```rust // original code unsafe { ... } // code that is now generated by this PR { unsafe { ... } } // what we would ideally like to get { unsafe { ... } } ```
💔 Test failed - checks-action_test |
@bors retry |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
If a block is declared as unsafe, it needs an extra layer of curly braces around it.
Fixes #10808
This code adds handling for
UnsafeSource::UserProvided
block, i.e.unsafe { ... }
. Note that we do not handle theUnsafeSource::CompilerGenerated
as it seems to not be possible to generate that with the user code (?), or at least doesn't seem to be needed to be handled explicitly.There is an issue with this code: it does not add an extra indentation for the unsafe blocks. I think this is a relatively minor concern for such an edge case, and should probably be done by a separate PR (fixing compile bug is more important than getting styling perfect especially when
rustfmt
will fix it anyway)changelog:
single_match
: Fix suggestion forunsafe
blocks