Files
rust/tests/ui
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
..
2021-01-07 18:54:12 -03:00
2019-01-08 21:46:39 +01:00
2019-09-27 18:01:04 +02:00
2020-11-08 18:32:12 -05:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-06-10 01:35:47 +00:00
2021-05-26 21:53:43 -05:00
2021-05-26 21:53:43 -05:00
2020-01-07 18:38:12 +09:00
2019-12-21 16:20:30 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2020-01-12 19:54:17 +08:00
2020-01-12 19:54:17 +08:00
2020-02-23 22:36:15 -08:00
2020-11-08 18:32:12 -05:00
2020-04-20 15:47:08 -04:00
2020-01-07 18:38:12 +09:00
2021-05-18 11:45:51 -04:00
2019-12-24 03:06:52 +07:00
2019-12-24 03:06:52 +07:00
2020-11-08 18:32:12 -05:00
2020-01-04 11:20:11 -06:00
2020-01-04 11:20:11 -06:00
2019-10-15 09:58:11 +02:00
2020-01-26 07:01:16 +09:00
2020-01-07 18:38:12 +09:00
2019-08-01 22:20:08 +09:00
2019-10-26 21:54:04 +02:00
2020-01-14 08:32:33 +09:00
2020-11-08 18:32:12 -05:00
2019-10-15 09:58:11 +02:00
2020-01-07 18:38:12 +09:00
2020-04-23 16:30:06 -07:00
2020-04-26 18:00:51 +03:00
2020-02-04 22:53:24 +01:00
2020-01-30 12:06:42 +09:00
2020-01-07 18:38:12 +09:00
2019-12-31 09:22:35 -08:00
2020-01-10 04:35:37 +09:00
2020-07-10 07:39:28 -04:00
2021-05-11 11:15:33 +02:00
2021-05-11 11:15:33 +02:00
2021-05-26 22:07:53 -05:00
2020-01-26 07:01:16 +09:00
2019-09-20 23:21:37 +09:00
2019-12-03 18:37:07 +01:00
2020-01-07 18:38:12 +09:00
2019-01-08 21:46:39 +01:00
2019-12-18 18:59:43 +02:00
2020-03-20 22:52:53 +00:00
2020-04-08 08:37:20 -07:00
2020-01-20 10:56:02 +09:00
2019-10-15 09:58:11 +02:00
2019-10-15 09:58:11 +02:00
2020-03-04 00:56:43 +01:00
2020-03-04 00:56:43 +01:00
2019-12-03 13:42:05 +01:00
2020-09-10 15:23:38 +02:00
2019-11-10 15:52:59 +02:00
2020-11-08 18:32:12 -05:00
2020-11-08 18:32:12 -05:00
2019-04-02 11:39:43 -03:00
2019-11-25 18:12:52 +03:00
2019-11-25 18:12:52 +03:00
2020-01-07 18:38:12 +09:00
2019-12-27 22:07:55 +09:00
2019-12-27 22:07:55 +09:00
2021-03-03 11:23:29 +01:00
2019-08-14 19:34:50 +02:00
2019-08-14 19:34:50 +02:00
2019-08-14 19:35:17 +02:00
2020-01-07 18:38:12 +09:00
2021-05-14 17:07:30 -07:00
2021-05-14 17:07:30 -07:00
2020-03-29 22:22:36 +02:00
2020-03-10 18:00:37 -04:00
2020-03-10 18:00:37 -04:00
2019-05-08 09:24:24 +02:00
2019-11-15 22:39:27 +01:00
2019-11-15 22:39:27 +01:00
2019-10-02 22:38:00 +07:00