about summary refs log tree commit diff
path: root/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-27 15:16:46 +0000
committerbors <bors@rust-lang.org>2023-12-27 15:16:46 +0000
commitc689d32a908377bdc92925275ef258060598e6a0 (patch)
treea98255cb8eba47abcdeddc34293371422b9e21e8 /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
parent677f8d8a3c70f852fec86fe56695b2b09e3fffdc (diff)
parent08d8ca9edd7a83f15a27012391fc9760ed30e408 (diff)
downloadrust-c689d32a908377bdc92925275ef258060598e6a0.tar.gz
rust-c689d32a908377bdc92925275ef258060598e6a0.zip
Auto merge of #11981 - y21:eager_int_transmute, r=llogiq
new lint: `eager_transmute`

A small but still hopefully useful lint that looks for patterns such as `(x < 5).then_some(transmute(x))`.
This is almost certainly wrong because it evaluates the transmute eagerly and can lead to surprises such as the check being completely removed and always evaluating to `Some` no matter what `x` is (it is UB after all when the integer is not a valid bitpattern for the transmuted-to type). [Example](https://godbolt.org/z/xoY34fPzh).
The user most likely meant to use `then` instead.

I can't remember where I saw this but this is inspired by a real bug that happened in practice.

This could probably be a correctness lint?

changelog: new lint: [`eager_int_transmute`]
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions