Skip to content
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

Fix newly added clippy warnings #32

Merged
merged 2 commits into from
Dec 2, 2022
Merged

Fix newly added clippy warnings #32

merged 2 commits into from
Dec 2, 2022

Conversation

taiki-e
Copy link

@taiki-e taiki-e commented Dec 2, 2022

No description provided.

```
error: the `Err`-variant returned from this function is very large
  --> src/tf_broadcaster.rs:45:59
   |
45 |     pub fn send_transform(&self, tf: TransformStamped) -> Result<(), TfError> {
   |                                                           ^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 136 bytes
   |
   = note: `-D clippy::result-large-err` implied by `-D warnings`
   = help: try reducing the size of `tf_error::TfError`, for example by boxing large elements or replacing it with `Box<tf_error::TfError>`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
```
```
error: this block may be rewritten with the `?` operator
   --> src/tf_buffer.rs:186:9
    |
186 | /         if let Err(x) = tf1 {
187 | |             return Err(x);
188 | |         }
    | |_________^ help: replace it with: `tf1?;`
    |
    = note: `-D clippy::question-mark` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

error: this block may be rewritten with the `?` operator
   --> src/tf_buffer.rs:189:9
    |
189 | /         if let Err(x) = tf2 {
190 | |             return Err(x);
191 | |         }
    | |_________^ help: replace it with: `tf2?;`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
```
@taiki-e taiki-e requested a review from OTL December 2, 2022 08:32
@@ -60,12 +60,12 @@ impl TfIndividualTransformChain {
if x == 0 {
return Err(TfError::AttemptedLookupInPast(
time,
self.transform_chain.first().unwrap().clone(),
Box::new(self.transform_chain.first().unwrap().clone()),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to know why we need box here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

A Result is at least as large as the Err-variant. While we expect that variant to be seldomly used, the compiler needs to reserve and move that much memory every single time.

@taiki-e taiki-e merged commit b7d1c93 into main Dec 2, 2022
@taiki-e taiki-e deleted the taiki-e/clippy branch December 2, 2022 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants