diff options
| author | bors <bors@rust-lang.org> | 2022-12-24 23:33:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-24 23:33:13 +0000 |
| commit | e8703a0ce2e021a922b60455318e21e918940a62 (patch) | |
| tree | 8083bd80980f67c5a9a8a3b592fc958926ed669d /src/test/rustdoc-ui/coverage/enum-tuple.rs | |
| parent | e2a687da72266591354b9c7487044c7809adbf74 (diff) | |
| parent | d7b9e195c2df9e576abd2eba54f3fe6516619054 (diff) | |
| download | rust-e8703a0ce2e021a922b60455318e21e918940a62.tar.gz rust-e8703a0ce2e021a922b60455318e21e918940a62.zip | |
Auto merge of #10098 - lukaslueg:size_of_ref, r=Jarcho
Add size_of_ref lint This addresses #9995, which is likely raising a valid point about `std::mem::size_of_val()`: It's [very easy to use double-references as the argument](https://github.com/apache/arrow-datafusion/pull/4371#discussion_r1032385224), which the function will happily accept and give back the size of _the reference_, not the size of the value _behind_ the reference. In the worst case, if the value matches the programmer's expectation, this seems to work, while in fact, everything will go horribly wrong e.g. on a different platform. The size of a `&T` is independent of what `T` is, and people might want to use `std::mem::size_of_val()` to actually get the size of _any_ reference (e.g. via `&&()`). I would rather suggest that this is always bad behavior, though ([instead](https://doc.rust-lang.org/reference/type-layout.html#pointers-and-references-layout), [and](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.BITS)). I, therefore, put this lint into `correctness`. Since the problem is usually easily fixed by removing extra `&`, I went light on suggesting code. --- changelog: New lint: [`size_of_ref`] [#10098](https://github.com/rust-lang/rust-clippy/pull/10098) <!-- changelog_checked -->
Diffstat (limited to 'src/test/rustdoc-ui/coverage/enum-tuple.rs')
0 files changed, 0 insertions, 0 deletions
