Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail to compile on 16-bit platforms (bevyengine#4736)
# Objective `bevy_ecs` assumes that `u32 as usize` is a lossless operation and in a few cases relies on this for soundness and correctness. The only platforms that Rust compiles to where this invariant is broken are 16-bit systems. A very clear example of this behavior is in the SparseSetIndex impl for Entity, where it converts a u32 into a usize to act as an index. If usize is 16-bit, the conversion will overflow and provide the caller with the wrong index. This can easily result in previously unforseen aliased mutable borrows (i.e. Query::get_many_mut). ## Solution Explicitly fail compilation on 16-bit platforms instead of introducing UB. Properly supporting 16-bit systems will likely need a workable use case first. --- ## Changelog Removed: Ability to compile `bevy_ecs` on 16-bit platforms. ## Migration Guide `bevy_ecs` will now explicitly fail to compile on 16-bit platforms. If this is required, there is currently no alternative. Please file an issue (https://github.com/bevyengine/bevy/issues) to help detail your use case.
- Loading branch information