-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Lint name:semicolon_if_nothing_returned
I tried this code:
#![feature(let_else)]
#![warn(clippy::semicolon_if_nothing_returned)]
fn fn_returning_option() -> Option<i32> {
Some(1)
}
fn main() {
let Some(_) = fn_returning_option() else { return; };
}
I expected to see this happen: nothing
Instead, this happened: semicolon_if_nothing_returned
fires and suggests adding another colon after closing braces
Checking playground v0.0.1 (/playground)
warning: consider adding a `;` to the last statement for consistent formatting
--> src/main.rs:9:5
|
9 | let Some(_) = fn_returning_option() else { return; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `let Some(_) = fn_returning_option() else { return; };;`
|
note: the lint level is defined here
--> src/main.rs:2:9
|
2 | #![warn(clippy::semicolon_if_nothing_returned)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
Meta
playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7dd2867755b28e12cad7ba9b01f67eae
related: #7877 (comment)
fmease and dylni
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have