4 ms·
The big questions is why clippy (standard linter) didn't catch this. It will complain about expensive expressions in a `.then_some()` because it's eager, why no
by 3836293648 3y ago
The big questions is why clippy (standard linter) didn't catch this. It will complain about expensive expressions in a `.then_some()` because it's eager, why not unsafe?
- lifthrasiir 3y agoClippy would only complain about expensive expressions when it can prove that the alternative would be always better than the original (for example, `or_fun_call` [1]). It is not impossible to measure the cost of given expression to suggest that, but that would increase a risk of false positives. The OP has the same challenge---this kind of range analysis can only occur (and currently does occur) much later than Clippy. [1] https://rust-lang.github.io/rust-clippy/master/index.html#/or_fun_call https://rust-lang.github.io/rust-clippy/master/index.html#/o...
- Ygg2 3y agoYou want miri, not clippy. Clippy is for minor issues in code, miri is for finding UB in Rust.
- 3836293648 3y agoIn testing I want miri, but knowing that there already is a very similar lint, I want that expanded
- SpaghettiCthulu 3y agoI believe the parent wants the lint to trigger for any unsafe code in the argument to `then_some`. This would not require any real analysis of the expression.