gpui: Remove some unnecessary unsafe code (#40483)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -378,11 +378,9 @@ pub struct Entity<T> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
pub(crate) any_entity: AnyEntity,
|
||||
pub(crate) entity_type: PhantomData<T>,
|
||||
pub(crate) entity_type: PhantomData<fn(T) -> T>,
|
||||
}
|
||||
|
||||
unsafe impl<T> Send for Entity<T> {}
|
||||
unsafe impl<T> Sync for Entity<T> {}
|
||||
impl<T> Sealed for Entity<T> {}
|
||||
|
||||
impl<T: 'static> Entity<T> {
|
||||
@@ -657,7 +655,7 @@ pub struct WeakEntity<T> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
any_entity: AnyWeakEntity,
|
||||
entity_type: PhantomData<T>,
|
||||
entity_type: PhantomData<fn(T) -> T>,
|
||||
}
|
||||
|
||||
impl<T> std::fmt::Debug for WeakEntity<T> {
|
||||
@@ -669,9 +667,6 @@ impl<T> std::fmt::Debug for WeakEntity<T> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T> Send for WeakEntity<T> {}
|
||||
unsafe impl<T> Sync for WeakEntity<T> {}
|
||||
|
||||
impl<T> Clone for WeakEntity<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -888,7 +888,9 @@ impl VisualTestContext {
|
||||
// safety: on_quit will be called after the test has finished.
|
||||
// the executor will ensure that all tasks related to the test have stopped.
|
||||
// so there is no way for cx to be accessed after on_quit is called.
|
||||
let cx = Box::leak(unsafe { Box::from_raw(ptr) });
|
||||
// todo: This is unsound under stacked borrows (also tree borrows probably?)
|
||||
// the mutable reference invalidates `ptr` which is later used in the closure
|
||||
let cx = unsafe { &mut *ptr };
|
||||
cx.on_quit(move || unsafe {
|
||||
drop(Box::from_raw(ptr));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user