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 reports size_of_in_element_count lint errors in the generated code from derive_ReprC macro #137

Open
pan93412 opened this issue Sep 3, 2022 · 2 comments

Comments

@pan93412
Copy link

pan93412 commented Sep 3, 2022

截圖 2022-09-03 下午10 54 34

The link of this lint rule is https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count.

Not sure if this is supposed to do, as the documentation of std::slice::from_raw_parts indicates that the len parameter of it is the number of elements, not the number of bytes.

If it is supposed to do, how about to allow this lint rule with #[allow(clippy::size_of_in_element_count)]?

@pan93412
Copy link
Author

pan93412 commented Sep 8, 2022

cc @danielhenrymantilla

@danielhenrymantilla
Copy link
Collaborator

The code linted by this is really debugging code (correct code ought never to run into it); while the lint itself is a false positive (I'll have it silenced before the next release), it is true that it does something unorthodox: it reinterprets a type as its raw bytes, potentially exposing padding or uninit bytes, which is not great. So, all in all, I guess I could (default) feature-gate this snippet so that people can disable it

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

No branches or pull requests

2 participants