Closed
Description
What it does
This is the same as both semicolon-inside-block and semicolon-outside-block, but decides which one to use based on whether the block is singleline or multiline.
Lint Name
semicolon-inside-block-if-multiline or semicolon-outside-block-if-singleline (I prefer this one)
Category
restriction
Advantage
- rustfmt will make an unsafe block containing only one expression multiline if the semicolon is inside the block, but won't if it's on the outside. Adding this lint will allow swapping the location to allow rustfmt to make it a singleline, while also encouraging some consistency.
- Some may find outside cleaner only in the case that it's singleline.
Drawbacks
- The descriptions of both semicolon-inside-block and semicolon-outside-block suggest consistency, so this may contradict that.
- If rustfmt is invoked, what was previously fine could become a warning (or an error if a library author is a bit zealous about warnings). This may be unexpected.
Example
unsafe {
WriteProcessMemory(
self.inner,
base as _,
bytes.as_ptr() as _,
bytes.len(),
None,
)
};
unsafe {
ExitProcess(0i32);
}
Could be written as:
unsafe {
WriteProcessMemory(
self.inner,
base as _,
bytes.as_ptr() as _,
bytes.len(),
None,
);
}
unsafe { ExitProcess(0i32) };