-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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_wraps is too strict #6427
Comments
Or instead of heuristics based on name, when the function is passed as a callback that expects an For example: fn my_callback_opt() -> Option<usize> { Some(0) }
fn my_callback() -> usize { 0 }
fn takes_callback<F>(_: F) where F: Fn() -> Option<usize> {}
fn main() {
takes_callback(my_callback_opt);
// rather than:
takes_callback(|| { Some(my_callback()) });
} Sometimes the functions taking the callback are from foreign crates, or really do need an |
@rustbot modify labels: +L-enhancement |
I bumped on this issue today when using nightly. The doc says:
But that's not okay because the callee is an external crate to the project. The function signature might have to be this way. Related to IMI-eRnD-Be/wasm-run#27 |
It's also not recognized in the
|
This now hit stable. |
I didn't see any improvement in my case.
Is it supposed to be in stable 1.50? @jan-auer |
What am I testing... 🤔 Ok nevermind my comment. I mixed up 2 different issues. |
The recently introduced
unnecessary_wraps
lint is quite strict, and sometimes the affected function cannot be refactored. An example is when the function is used for#[serde(default)]
:It is a bit unfortunate having to allow the clippy lint explicitly. I was wondering if you would consider to add a function naming pattern that ignores the lint, such as an
_opt
suffix or atry_
prefix.The text was updated successfully, but these errors were encountered: