Skip to content

or_fun_call false positive on enum variants with tuple fields #9608

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

Closed
AlexTMjugador opened this issue Oct 8, 2022 · 4 comments · Fixed by #9610
Closed

or_fun_call false positive on enum variants with tuple fields #9608

AlexTMjugador opened this issue Oct 8, 2022 · 4 comments · Fixed by #9610
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

@AlexTMjugador
Copy link

AlexTMjugador commented Oct 8, 2022

Summary

I maintain several Rust projects whose CI workflows run the latest nightly Clippy almost daily. As a result of that, I've discovered that yesterday's nightly, with a commit date of 2022-10-07, introduced a likely unintended behavior change on the or_fun_call lint when initializing enum variants with tuple fields:

False positive

Obviously, in this case no function is being called to initialize the fallback value, so it is a false positive.

Lint Name

or_fun_call

Reproducer

I tried this code:

https://github.com/OptiVorbis/OptiVorbis/archive/49ca18a55293bc5e74b09106c5b09ae56aba6148.zip (OptiVorbis source ZIP)

I saw this happen:

https://github.com/OptiVorbis/OptiVorbis/actions/runs/3209020234/jobs/5245395845 (workflow run logs. Notice the Clippy lints)

I expected to see this happen:

No new lints being triggered, or not new false positives

Version

rustc 1.66.0-nightly (8b0c05d9a 2022-10-07)
binary: rustc
commit-hash: 8b0c05d9ad7121cdb97600f261bcd5f04c8db20d
commit-date: 2022-10-07
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Additional Labels

No response

@AlexTMjugador AlexTMjugador 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 Oct 8, 2022
@kraktus
Copy link
Contributor

kraktus commented Oct 8, 2022

Thanks for reporting,

Do your enums have manual implementation of Drop? If so, this is intended: #9551

@AlexTMjugador
Copy link
Author

AlexTMjugador commented Oct 8, 2022

Thank you for your prompt response!

The affected enums, including the VorbisOptimizerError enum shown in the attached screenshot in particular, do not implement Drop: https://docs.rs/optivorbis/latest/optivorbis/enum.VorbisOptimizerError.html

@AlexTMjugador
Copy link
Author

AlexTMjugador commented Oct 13, 2022

Sadly, yesterday's nightly (c0983a9 2022-10-12) still outputs the described false positive for the same source code. I assume the fix PR made it to the nightly, so what's going on here?

AlexTMjugador added a commit to OptiVorbis/OptiVorbis that referenced this issue Oct 13, 2022
The latest Clippy nightlies introduced some regressions that are blocking
our builds. Ref:
rust-lang/rust-clippy#9608
AlexTMjugador added a commit to ComunidadAylas/PackSquash that referenced this issue Oct 13, 2022
The latest Clippy nightlies introduced some regressions that are blocking
our builds. Ref:
rust-lang/rust-clippy#9608
AlexTMjugador added a commit to ComunidadAylas/vorbis-rs that referenced this issue Oct 13, 2022
The latest Clippy nightlies introduced some regressions that are blocking
our builds. Ref:
rust-lang/rust-clippy#9608
@kraktus
Copy link
Contributor

kraktus commented Oct 13, 2022

Not every nightly ships a new clippy, will check on my side too

nightkr added a commit to nightkr/kube-rs that referenced this issue Oct 14, 2022
nightkr added a commit to nightkr/kube-rs that referenced this issue Oct 14, 2022
Clippy's stance here has changed.. see rust-lang/rust-clippy#9608

Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
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