In Rust there are several unchecked operations, but no unchecked_ilog2: the compiler will always insert a test that leads to panic if the argument is zero. Replacing unchecked_ilog2 with the bit width minus leading_zeros minus 1 does not help either because the compiler inserts a test to give a result equal to the bit width if the argument is zero.
Essentially: is there a clean way to access the BSR instruction without incurring in a check when one is sure that the argument will be nonzero?
When Rust inserts checks like these, you can usually get them optimized out by making the same check yourself before the call.
This lets you handle the check how you want it, which could be return that's cheaper than a panic, or even the unsafe unreachable_unchecked() that will get that code and identical checks following it removed.
I went exactly through this entire line of reasoning more than a year ago when writing the invariant macro and I unconditionally erased the whole thing from my mind.