-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Exclamation ! return type not respected in unwrap_or_else #94418
Comments
I think this is a bug in clippy rather than in rust. Rust cannot implicitly coerce a function even though the return type is coercable, and this isn't limited to
And this code also trips clippy for the same warning. Clippy doesn't take the coercion at function return position into account, and provides a wrong suggestion |
Clippy side issue: rust-lang/rust-clippy#7812 |
Ah, thanks for pointing that out. Closing this issue. @wwylele while I have you, could you answer one last question (not clippy related)? When I remove the
So clearly |
|
I often write a function that logs an error in a custom way and then panics afterwards, e.g.
This has worked for me for a long time, but I recently noticed this clippy warning:
I'd like to catch all clippy warnings in CI pipelines and just adding
#[allow(clippy::redundant_closure)]
everywhere I call that function is suboptimal, but when I try to fix it as clippy suggests I get this compiler error instead:Consider me confused. Isn't the
!
return type supposed to indicate that it's a diverging function? What makes this not work in aunwrap_or_else
?Meta
rustc --version --verbose
:(found same behaviour on nightly)
The text was updated successfully, but these errors were encountered: