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

clippy::cast-possible-truncation generates warnings #121

Closed
LPardue opened this issue Aug 16, 2019 · 2 comments · Fixed by #122
Closed

clippy::cast-possible-truncation generates warnings #121

LPardue opened this issue Aug 16, 2019 · 2 comments · Fixed by #122

Comments

@LPardue
Copy link
Contributor

LPardue commented Aug 16, 2019

We don't normally run the rule -W clippy::cast-possible-truncation but if I try we see a few messages such as :

warning: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
   --> src/lib.rs:950:13
    |
950 |             config.local_transport_params.initial_max_streams_bidi as usize,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-W clippy::cast-possible-truncation` implied by `-W clippy::pedantic`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation

warning: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
   --> src/lib.rs:954:13
    |
954 |             config.local_transport_params.initial_max_streams_uni as usize,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation

warning: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
    --> src/lib.rs:1173:13
     |
1173 |             b.get_varint()? as usize
     |             ^^^^^^^^^^^^^^^^^^^^^^^^
@ghedo
Copy link
Member

ghedo commented Aug 17, 2019

There's probably a lot of those messages, and in most cases they don't indicate bugs (which is why the lint is not enabled by default).

Though the first two examples you mentioned are probably bugs, so I made #122 to fix them.

@LPardue
Copy link
Contributor Author

LPardue commented Aug 17, 2019

Cool yeah clippy pedantic is pretty spammy and I dont think we should respect all of its moaning. I suspect some of them are from the recent 32bit changes but will assume that these changes fix possible problems.

ghedo added a commit that referenced this issue Aug 17, 2019
ghedo added a commit that referenced this issue Aug 17, 2019
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 a pull request may close this issue.

2 participants