Skip to content

Commit e1c7ed7

Browse files
committed
Removed unsound Send + Sync
1 parent 7dfe64e commit e1c7ed7

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ edition = "2021"
1414
rquickjs = { version = "0.8.1", features = ["loader"] }
1515

1616
[dev-dependencies]
17-
rquickjs = { version = "0.8.1", features = ["futures", "macro"] }
17+
rquickjs = { version = "0.8.1", features = ["futures", "macro", "parallel"] }
1818
tokio = { version = "1", features = ["full"] }

src/loader/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl ModuleLoaderBuilder {
5252
#[must_use]
5353
pub fn with_module<O, M, R>(mut self, module: M) -> Self
5454
where
55-
for<'js> O: JsLifetime<'js> + 'static,
55+
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
5656
R: ModuleDef + ModuleMeta,
5757
M: IntoModule<O, R>,
5858
{
@@ -63,7 +63,7 @@ impl ModuleLoaderBuilder {
6363
#[must_use]
6464
pub fn with_module_named<O, M, R>(mut self, module: M, name: &'static str) -> Self
6565
where
66-
for<'js> O: JsLifetime<'js> + 'static,
66+
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
6767
R: ModuleDef + ModuleMeta,
6868
M: IntoModule<O, R>,
6969
{
@@ -73,7 +73,7 @@ impl ModuleLoaderBuilder {
7373

7474
pub fn add_module<O, M, R>(&mut self, module: M) -> &mut Self
7575
where
76-
for<'js> O: JsLifetime<'js> + 'static,
76+
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
7777
R: ModuleDef + ModuleMeta,
7878
M: IntoModule<O, R>,
7979
{
@@ -82,7 +82,7 @@ impl ModuleLoaderBuilder {
8282

8383
pub fn add_module_named<O, M, R>(&mut self, module: M, name: &'static str) -> &mut Self
8484
where
85-
for<'js> O: JsLifetime<'js> + 'static,
85+
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
8686
R: ModuleDef + ModuleMeta,
8787
M: IntoModule<O, R>,
8888
{
@@ -91,7 +91,7 @@ impl ModuleLoaderBuilder {
9191

9292
fn process_module<O, M, R>(&mut self, module: M, name: Option<&'static str>) -> &mut Self
9393
where
94-
for<'js> O: JsLifetime<'js> + 'static,
94+
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
9595
R: ModuleDef + ModuleMeta,
9696
M: IntoModule<O, R>,
9797
{

src/loader/global.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ pub struct GlobalInitializer {
66
globals: Vec<GlobalLoadFn>,
77
}
88

9-
unsafe impl Send for GlobalInitializer {}
10-
unsafe impl Sync for GlobalInitializer {}
11-
129
impl GlobalInitializer {
1310
pub(crate) fn new(globals: Vec<GlobalLoadFn>) -> Self {
1411
Self { globals }

src/loader/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod builder;
1010
mod global;
1111
mod resolver;
1212

13-
type GlobalLoadFn = Box<dyn for<'js> FnOnce(&Ctx<'js>, &Object<'js>) -> Result<()>>;
13+
type GlobalLoadFn = Box<dyn for<'js> FnOnce(&Ctx<'js>, &Object<'js>) -> Result<()> + Send + Sync>;
1414
type ModuleLoadFn = for<'js> fn(Ctx<'js>, Vec<u8>) -> Result<Module<'js>>;
1515

1616
/// Loader for Rust modules defined using [`crate::ModuleDefExt`].

0 commit comments

Comments
 (0)