tkaitchuck / aHash

aHash is a non-cryptographic hashing algorithm that uses the AES hardware instruction
https://crates.io/crates/ahash
Apache License 2.0
986 stars 94 forks source link

`set_random_source` never returns `Err(false)` #230

Open y21 opened 3 months ago

y21 commented 3 months ago

https://github.com/tkaitchuck/aHash/blob/7778357cf9a684b06aaada11788ac1cd796dc5b8/src/random_state.rs#L192

This looks like it's calling .type_id() on a Box<dyn RandomSource> (not on the underlying trait object), and as a result always returns the fixed TypeId of the box. Therefore this function can never return Err(false). The documentation for it however says:

If the source has already been specified Err is returned with a bool indicating if the set failed because method was previously invoked (true) or if the default source is already being used (false).

I'm currently working on improving clippy's type_id_on_box lint and it found this instance