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

unnecessary closure used with bool::then in field definition #9485

Closed
xerenahmed opened this issue Sep 16, 2022 · 0 comments · Fixed by #9486
Closed

unnecessary closure used with bool::then in field definition #9485

xerenahmed opened this issue Sep 16, 2022 · 0 comments · Fixed by #9486
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

@xerenahmed
Copy link

Summary

....

Lint Name

unnecessary_lazy_evaluations

Reproducer

I tried this code:

// FromForm is from rocket (HTTP library)
#[derive(FromForm, Debug)]
pub struct CreateAlarm {
    pub label: String,
}

I saw this happen:

warning: unnecessary closure used with `bool::then`
  --> src/routes/alarm/create.rs:10:16
   |
10 |     pub label: String,
   |                ^^^^^^ help: use `then_some(..)` instead: `then_some(label)`
   |
   = note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations

I expected to see this happen: nothing

Version

rustc 1.65.0-nightly (29e4a9ee0 2022-08-10)
binary: rustc
commit-hash: 29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6
commit-date: 2022-08-10
host: aarch64-apple-darwin
release: 1.65.0-nightly
LLVM version: 14.0.6

Additional Labels

No response

@xerenahmed xerenahmed 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 16, 2022
@bors bors closed this as completed in 68408c5 Sep 30, 2022
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