Skip to content

Commit d723291

Browse files
remove 'unused' unsafe blocks until rust-lang/rust#100081 lands
1 parent e0a6c71 commit d723291

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

crates/bevy_ecs/src/world/entity_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'w> EntityRef<'w> {
149149
) -> Option<MutUntyped<'w>> {
150150
self.world.components().get_info(component_id)?;
151151
// SAFETY: entity_location is valid, component_id is valid as checked by the line above, world access is promised by the caller
152-
unsafe { get_mut_by_id(self.world, self.entity, self.location, component_id) }
152+
get_mut_by_id(self.world, self.entity, self.location, component_id)
153153
}
154154
}
155155

crates/bevy_ecs/src/world/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1427,20 +1427,19 @@ impl World {
14271427

14281428
let column = self.get_populated_resource_column(component_id)?;
14291429

1430-
// SAFETY: get_data_ptr requires that the mutability rules are not violated, and the caller promises
1431-
// to only modify the resource while the mutable borrow of the world is valid
14321430
let ticks = Ticks {
14331431
// SAFETY:
14341432
// - index is in-bounds because the column is initialized and non-empty
14351433
// - no other reference to the ticks of the same row can exist at the same time
1436-
component_ticks: unsafe { &mut *column.get_ticks_unchecked(0).get() },
1434+
component_ticks: &mut *column.get_ticks_unchecked(0).get(),
14371435
last_change_tick: self.last_change_tick(),
14381436
change_tick: self.read_change_tick(),
14391437
};
14401438

14411439
Some(MutUntyped {
1442-
// SAFETY: world access is unique, so no other reference can exist at the same time
1443-
value: unsafe { column.get_data_ptr().assert_unique() },
1440+
// SAFETY: get_data_ptr requires that the mutability rules are not violated, and the caller promises
1441+
// to only modify the resource while the mutable borrow of the world is valid
1442+
value: column.get_data_ptr().assert_unique(),
14441443
ticks,
14451444
})
14461445
}

0 commit comments

Comments
 (0)