std::slice::get_unchecked is always unchecked, but its use in yaxpeax-x86 is as an optimization, not for load-bearing correctness. it would be helpful to panic if the expectation is violated in debug builds, instead of veering off into unknown states. the same applies for uses of unreachable_unchecked() in yaxpeax-x86.
for both hints, it would be good to have a wrapper that panics in debug builds, but is just the hint for release builds. maybe a debug_assert, maybe an cfg_if between two impls, either should be fine. but yaxpeax-x86 is well at the point that these unsafe hints should be designed to be caught by tests or fuzzing if they become erroneous.
std::slice::get_unchecked
is always unchecked, but its use inyaxpeax-x86
is as an optimization, not for load-bearing correctness. it would be helpful to panic if the expectation is violated in debug builds, instead of veering off into unknown states. the same applies for uses ofunreachable_unchecked()
inyaxpeax-x86
.for both hints, it would be good to have a wrapper that panics in debug builds, but is just the hint for release builds. maybe a
debug_assert
, maybe ancfg_if
between two impls, either should be fine. butyaxpeax-x86
is well at the point that these unsafe hints should be designed to be caught by tests or fuzzing if they become erroneous.