Skip to content

Commit

Permalink
Clean up pointer use in BundleSpawner/BundleInserter (bevyengine#12269)
Browse files Browse the repository at this point in the history
# Objective
Following bevyengine#10756, we're now using raw pointers in BundleInserter and
BundleSpawner. This is primarily to get around the need to split the
borrow on the World, but it leaves a lot to be desired in terms of
safety guarantees. There's no type level guarantee the code can't
dereference a null pointer, and it's restoring them to borrows fairly
liberally within the associated functions.

## Solution

* Replace the pointers with `NonNull` and a new `bevy_ptr::ConstNonNull`
that only allows conversion back to read-only borrows
* Remove the closure to avoid potentially aliasing through the closure
by restructuring the match expression.
* Move all conversions back into borrows as far up as possible to ensure
that the borrow checker is at least locally followed.
  • Loading branch information
james7132 authored Mar 6, 2024
1 parent d56e167 commit 4cd53cc
Show file tree
Hide file tree
Showing 2 changed files with 312 additions and 209 deletions.
Loading

0 comments on commit 4cd53cc

Please sign in to comment.