In #53783, we document more precisely the rules for the various methods that can be used to access memory through raw pointers. In particular, we clarify that the pointer must be non-NULL and aligned even when the access has size 0.
This issue is about helping people find bugs in libstd by adding a debug_assert! to all these methods testing that condition, similar to what I did for from_raw_parts. I suggest to add a helper method to raw pointers to test this, and also use that for from_raw_parts and from_raw_parts_mut.
This may uncover issues in libstd, uncovering misuses of these methods. Those should then be fixed.
In #53783, we document more precisely the rules for the various methods that can be used to access memory through raw pointers. In particular, we clarify that the pointer must be non-NULL and aligned even when the access has size 0.
This issue is about helping people find bugs in libstd by adding a
debug_assert!to all these methods testing that condition, similar to what I did for from_raw_parts. I suggest to add a helper method to raw pointers to test this, and also use that forfrom_raw_partsandfrom_raw_parts_mut.This may uncover issues in libstd, uncovering misuses of these methods. Those should then be fixed.