Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

use std::ops::Deref;
use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

mod app;
mod main_schedule;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![forbid(unsafe_op_in_unsafe_fn)]

pub mod io;
pub mod meta;
pub mod processor;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl ReflectAsset {
handle: UntypedHandle,
) -> Option<&'w mut dyn Reflect> {
// SAFETY: requirements are deferred to the caller
(self.get_unchecked_mut)(world, handle)
unsafe { (self.get_unchecked_mut)(world, handle) }
}

/// Equivalent of [`Assets::add`]
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]
//! This crate provides core functionality for Bevy Engine.

mod name;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

pub mod blit;
pub mod bloom;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

extern crate proc_macro;

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_diagnostic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

mod diagnostic;
mod entity_count_diagnostics_plugin;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_dylib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![allow(clippy::single_component_path_imports)]
#![forbid(unsafe_op_in_unsafe_fn)]

//! Forces dynamic linking of Bevy.
//!
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_dynamic_plugin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::type_complexity)]
#![forbid(unsafe_op_in_unsafe_fn)]

mod loader;

Expand Down
15 changes: 9 additions & 6 deletions crates/bevy_dynamic_plugin/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ pub enum DynamicPluginLoadError {
pub unsafe fn dynamically_load_plugin<P: AsRef<OsStr>>(
path: P,
) -> Result<(Library, Box<dyn Plugin>), DynamicPluginLoadError> {
let lib = Library::new(path).map_err(DynamicPluginLoadError::Library)?;
let func: Symbol<CreatePlugin> = lib
.get(b"_bevy_create_plugin")
.map_err(DynamicPluginLoadError::Plugin)?;
let plugin = Box::from_raw(func());
// SAFETY: the caller must uphold the safety contract for `new`.
let lib = unsafe { Library::new(path) }.map_err(DynamicPluginLoadError::Library)?;
// SAFETY: the caller must uphold the safety contract for `get`.
let func: Symbol<CreatePlugin> =
unsafe { lib.get(b"_bevy_create_plugin") }.map_err(DynamicPluginLoadError::Plugin)?;
// SAFETY: the caller must uphold the safety contract for `from_raw`.
let plugin = unsafe { Box::from_raw(func()) };
Ok((lib, plugin))
}

Expand All @@ -41,7 +43,8 @@ pub trait DynamicPluginExt {

impl DynamicPluginExt for App {
unsafe fn load_plugin<P: AsRef<OsStr>>(&mut self, path: P) -> &mut Self {
let (lib, plugin) = dynamically_load_plugin(path).unwrap();
// SAFETY: the caller must uphold the safety contract for `dynamically_load_plugin`.
let (lib, plugin) = unsafe { dynamically_load_plugin(path) }.unwrap();
std::mem::forget(lib); // Ensure that the library is not automatically unloaded
plugin.build(self);
self
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl BundleComponentStatus for AddBundle {
#[inline]
unsafe fn get_status(&self, index: usize) -> ComponentStatus {
// SAFETY: caller has ensured index is a valid bundle index for this bundle
*self.bundle_status.get_unchecked(index)
unsafe { *self.bundle_status.get_unchecked(index) }
}
}

Expand Down
Loading