You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like for unsafe blocks to be forced onto new lines, both before the unsafe and after the "unsafe {". (Possibly with an exception in simple let statements.)
The motivation for asking for this is that I have some rendering code that calls out to Vulkan. When I ran cargo fmt, I didn't like how the unsafe blocks got collapsed into a statement. I felt that it made it a bit less clear that there was unsafe code being called. There are lots of calls so it wouldn't be practical to decorate every call with #[rustfmt::skip].
Current Behavior
semaphors.push(unsafe{vkCreateSemaphore()});let x = unsafe{get_x()};
Desired Behavior
semaphors.push(unsafe{vkCreateSemaphore()});let x = unsafe{get_x()};
Rationale
I'd prefer that unsafe code is as conspicuous as possible. While IDEs can certainly highlight the unsafe keyword, code is rendered in places other than IDEs, and a structural change in code layout is an additional form of visual feedback.
I ended up avoiding this undesired formatting by using a temporary variable to simplify the statement, and maybe that's the best solution, but it gave me pause to using auto-formatting and seemed like something worth considering.
The text was updated successfully, but these errors were encountered:
I'd like for unsafe blocks to be forced onto new lines, both before the unsafe and after the "unsafe {". (Possibly with an exception in simple let statements.)
The motivation for asking for this is that I have some rendering code that calls out to Vulkan. When I ran cargo fmt, I didn't like how the unsafe blocks got collapsed into a statement. I felt that it made it a bit less clear that there was unsafe code being called. There are lots of calls so it wouldn't be practical to decorate every call with
#[rustfmt::skip]
.Current Behavior
Desired Behavior
Rationale
I'd prefer that unsafe code is as conspicuous as possible. While IDEs can certainly highlight the unsafe keyword, code is rendered in places other than IDEs, and a structural change in code layout is an additional form of visual feedback.
I ended up avoiding this undesired formatting by using a temporary variable to simplify the statement, and maybe that's the best solution, but it gave me pause to using auto-formatting and seemed like something worth considering.
The text was updated successfully, but these errors were encountered: