Add clippy exceptions for needless_question_mark lint#2134
Add clippy exceptions for needless_question_mark lint#2134apoelstra merged 1 commit intorust-bitcoin:masterfrom
Conversation
|
I wouldn't say it's "semantically different". It's just that the original code would compile even when a function signature is changed, while Clippy's suggested code would not compile. Anyway concept ACK dropping the lint, I agree it's annoying and just adds fragility. |
|
I agree, though in practice I doubt there's going to be lots of "fragility" introduced this way, while 5 characters less while marginal, keep (not) being there. Just want to mention |
Unfortunately clippy ofter introduces multiple lints at once, and just |
|
I personally convey the intention by writing Do we really not want to get compile error when the signature changes? It can sometimes uncover problems. E.g. if we want to tighten the error type it may be that we need to change multiple functions, not just one. |
In theory, yes, but any use of @stevenroose BTW could you update this PR to change the comment? I think it's misleading to claim there's a "semantic difference" (which would be a clippy bug, even by the clippy authors' standards) when it's really more of a "difference in compiler behavior" if that. |
|
I think "delegate the remainder of the method call to the following function" is semantically different from "return the value returned by this function after error handling", no? I admit it's a subtle difference. I guess I can just remove the comment altogether as well, as we don't really have other comments on module-level compiler indications anyway. |
a3c9103 to
0bbf005
Compare
|
It seems like rustfmt doesn't allow me to leave a newline between different module-level compiler indications, so I added a pointless comment to separate the clippy line from the other module-level compiler indications. 👌 |
This lint only triggers on the last line of the function so both cases are "returning" a value. With your code you call |
|
@tcharding I'd like there to be some comment indicating why this was added. Even just referencing this issue would be fine. |
|
Did you mean to mention me? |
|
Oops, no, I meant to mention @stevenroose. |
0078dff to
4328ef2
Compare
|
Changed the comment |
tcharding
left a comment
There was a problem hiding this comment.
ACK 4328ef292400d30ed6ecbbb2e8fd06e0290f8a84
|
@stevenroose please indicate why this specific lint is a problem. Otherwise we are going to accumulate a pile of clippy exceptions and not remember what we were thinking, whether they have stopped being relevant or if we've changed our minds or what. It also helps the clippy developers who periodically scan crates.io for ignored lints and try to understand why people are doing this. It would be fine if the comment was a link to this PR and nothing else. (I can use |
|
done, also put everything in the same commit for easier git blame |
4328ef2 to
8755455
Compare
This lint forces you to write semantically different code that is in most cases inferior, just to save you 5 characters.
The reason why the code is inferior is because it doesn't do error conversion so it would break when either of the two function signatures changes while in the original code using the
?operator, nothing would break if the inner error can be converted into the outer error.