Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semicolon_if_nothing_returned FP on let-else statements #7912

Closed
dswij opened this issue Nov 2, 2021 · 1 comment · Fixed by #7955
Closed

semicolon_if_nothing_returned FP on let-else statements #7912

dswij opened this issue Nov 2, 2021 · 1 comment · Fixed by #7955
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dswij
Copy link
Member

dswij commented Nov 2, 2021

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)

@dswij dswij added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Nov 2, 2021
@dswij
Copy link
Member Author

dswij commented Nov 9, 2021

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant