The following functions have restrictions which (ideally) should be respected:
It would be nice to check these restrictions with debug asserts. The main blockers:
- stdlib is distributed with disabled debug assertions, so either implementation will have to use the same hack as in wrapping checks, or we'll have to distribute two versions of stdlib with enabled and disabled debug assertions, and teach
cargo to switch between them depending on a compilation profile.
- Some code in the stdlib (and probably in some external crates) consciously breaks those restrictions (e.g.
src/liballoc/vec.rs). Probably it should be rewritten in a more "correct" fashion.
See internals thread for additional discussion.