mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
dd0246813f
Fix false positive on `semicolon_if_nothing_returned` Currently the [`semicolon_if_nothing_returned`](https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned) lint fires in unwanted situations where a block only spans one line. An example of this was given in #7324. This code: ```rust use std::mem::MaybeUninit; use std::ptr; fn main() { let mut s = MaybeUninit::<String>::uninit(); let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) }; } ``` yields the following clippy error: ``` error: consider adding a `;` to the last statement for consistent formatting --> src/main.rs:6:26 | 6 | let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` | = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D clippy::pedantic` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned ``` I updated the lint to check if the statement is inside an `unsafe` block, a closure or a normal block and if the block only spans one line, in that case the lint is not emitted. This closes #7324. changelog: enhanced semicolon if nothing returned according to #7324. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |