rust/tests
bors dd0246813f Auto merge of #7326 - 1c3t3a:1c3t3a-issue-7324, r=flip1995
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.
2021-06-09 08:39:56 +00:00
..
auxiliary
cargo Merge commit '2f6439ae6a' into clippyup 2020-10-09 12:45:29 +02:00
ui Auto merge of #7326 - 1c3t3a:1c3t3a-issue-7324, r=flip1995 2021-06-09 08:39:56 +00:00
ui-cargo Merge commit 'b40ea209e7' into clippyup 2021-04-08 17:50:13 +02:00
ui-internal Show macro name in 'this error originates in macro' message 2021-05-12 19:03:06 -04:00
ui-toml Add avoid_breaking_exported_api config option 2021-05-26 16:35:22 -05:00
clippy.toml Add clippy.toml to project and tests 2021-05-26 16:53:13 -05:00
compile-test.rs Add clippy.toml to project and tests 2021-05-26 16:53:13 -05:00
dogfood.rs Adding the ability to invalidate caches to force metadata collection 2021-05-20 22:30:49 +02:00
fmt.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
integration.rs Merge commit '4911ab124c' into clippyup 2020-12-20 17:19:49 +01:00
lint_message_convention.rs Merge commit 'b40ea209e7' into clippyup 2021-04-08 17:50:13 +02:00
missing-test-files.rs Fix/allow non_fmt_panic in clippy tests. 2021-02-03 23:15:51 +01:00
versioncheck.rs Merge commit '6ed6f1e6a1' into clippyup 2021-03-12 15:30:50 +01:00