From ee0037a31eb4ed6b7cdd11492f68537ea44e5c23 Mon Sep 17 00:00:00 2001 From: MultisampledNight Date: Sat, 30 Apr 2022 10:01:06 +0200 Subject: [PATCH] Fix undefined behavior There's no guarantee that the lock is being held by the main thread at that moment, so the unsafe block violated the safety contract. --- src/settings/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/settings/mod.rs b/src/settings/mod.rs index 1b98390..f761489 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -69,9 +69,6 @@ impl Settings { pub fn set(&self, t: &T) { let type_id: TypeId = TypeId::of::(); let t: T = (*t).clone(); - unsafe { - self.settings.force_unlock_write(); - } let mut write_lock = self.settings.write(); write_lock.insert(type_id, Box::new(t)); }