-
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
false positives and crazy suggestsiong for unit_arg lint #6015
Comments
It looks like this lint is working as intended to me. Are you saying that |
ok i misundertood what it says, I read it as saying it could be reduced to Ok(()). THe text is not clear. Having said that, I disagree with the lint. As the code stands the intent is very clear -> 'Okize' the result of calling this function. You dont have to look at set_word to see if it returns something that I am choosing to ignore, also the intent is 100% clear. And its very concise. In clippy's approved version one is left wondering about that function call. I have a long series of small functions that are proxying non Result returning functions and upscaling them to be Result returners. The fact that some of them return () as opposed to i32 or string is not relevant. Having said that I must say that clippy is awesome. It found some real bugs. I ported c++ code that uses octal literals a lot (a PDP 11 emulator) and clippy found some literals I had not added 'o' to. Ty v much. |
FYI there's a PR that will be merged soon that improves the suggestion (#5931). About your use case, to be fair the lint help mentions functions, so the fact that enum constructors are included may be an oversight in the implementation and could be special cased. I'm adding the "needs-discussion" tag to hopefully have more eyes on this, as I think it's debatable. |
also note that the message says line 475 should say Ok(()) thats why its confusing |
improve the suggestion of the lint `unit-arg` Fixes #5823 Fixes #6015 Changes ``` help: move the expression in front of the call... | 3 | g(); | help: ...and use a unit literal instead | 3 | o.map_or((), |i| f(i)) | ``` into ``` help: move the expression in front of the call and replace it with the unit literal `()` | 3 | g(); | o.map_or((), |i| f(i)) | ``` changelog: improve the suggestion of the lint `unit-arg`
I have this code:
ExcResult is Result<(), Exception>
clippy says
which is clearly not right.
I have half a dozen similar errors when calling functions that return ()
Meta
clippy 0.0.212 (04488afe3 2020-08-24)
cargo 1.46.0 (149022b1d 2020-07-17)
rustc 1.46.0 (04488afe3 2020-08-24)
The text was updated successfully, but these errors were encountered: