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

needless_return misfires in a let-else statement (RFC 3137) #7637

Closed
yvt opened this issue Sep 5, 2021 · 1 comment · Fixed by #7685
Closed

needless_return misfires in a let-else statement (RFC 3137) #7637

yvt opened this issue Sep 5, 2021 · 1 comment · Fixed by #7685
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

@yvt
Copy link

yvt commented Sep 5, 2021

Lint name: needless_return

I tried this code:

#![feature(let_else)]
pub fn hoge(x: Option<u32>) {
    let Some(x) = x else { return; };
    dbg!(x);
}

I expected to see this happen: No warnings emitted

Instead, this happened:

    Checking playground v0.0.1 (/playground)
warning: unneeded `return` statement
 --> src/lib.rs:3:28
  |
3 |     let Some(x) = x else { return; };
  |                            ^^^^^^^ help: remove `return`
  |
  = note: `#[warn(clippy::needless_return)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

Meta

Rust version (rustc -Vv):

rustc 1.56.0-nightly (50171c310 2021-09-01)
binary: rustc
commit-hash: 50171c310cd15e1b2d3723766ce64e2e4d6696fc
commit-date: 2021-09-01
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0
@yvt yvt 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 Sep 5, 2021
@rustbot

This comment has been minimized.

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.

2 participants