-
Notifications
You must be signed in to change notification settings - Fork 112
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
clippy: ignore result_large_err clippy lint for Tablet::from_raw_tablet #1095
Conversation
See: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err I justified this decision in the code: ``` // Ignore clippy lints here. Clippy suggests to // Box<> `Err`` variant, because it's too large. It does not // make much sense to do so, looking at the caller of this function. // Tablet returned in `Err` variant is used as if no error appeared. // The only difference is that we use node ids to emit some debug logs. ```
259788c
to
cebcb0c
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it should be ignored - Ok and Err variants differ only by 8 bytes I think.
Perhaps that it what the lint should look for: big size of Err compared to Ok.
I think the reason why big Err variants should be avoided is that Err are most commonly propagated, possibly through many layers. On each layer, stack variables must be copied, which implies |
Sure, but if your |
I see your point now, but your argument is only valid for one layer of propagation: that with big Now I also understood that our way of error handling, with error enums nested deep, can bring significant overhead. Stack memory is not that bad in terms of space waste, but a worse thing is reduced memory locality on stack due to large slots for errors in each function frame. |
Sure, but then in those higher layers:
We have nested enums, but we don't store a lot of data in them. Take |
I didn't know that! Awesome! |
Correct, I'm convinced now. |
With recent update of rust toolchain, new clippy lints were introduced -
result_large_err
being one of them.See: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
I decided to ignore the lint in
Tablet::from_raw_tablet
.I justified this decision in the code:
Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have provided docstrings for the public items that I want to introduce.[ ] I have adjusted the documentation in./docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.