-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Send
and Sync
from wasmer
types backed by JavaScript objects
#4157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,7 @@ pub struct Table { | |
pub(crate) handle: VMTable, | ||
} | ||
|
||
// Table can't be Send in js because it dosen't support `structuredClone` | ||
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone | ||
// unsafe impl Send for Table {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep a comment on all |
||
assert_not_implemented!(Table: !Send + !Sync); | ||
|
||
fn set_table_item(table: &VMTable, item_index: u32, item: &Function) -> Result<(), RuntimeError> { | ||
table.table.set(item_index, item).map_err(|e| e.into()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// Assert that a type does **not** implement a set of traits. | ||
macro_rules! assert_not_implemented { | ||
($t:ty : !$first:ident $(+ !$rest:ident)*) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a small nit: |
||
const _: fn() = || { | ||
// Generic trait with a blanket impl over `()` for all types. | ||
trait AmbiguousIfImpl<A> { | ||
// Required for actually being able to reference the trait. | ||
fn some_item() {} | ||
} | ||
|
||
impl<T: ?Sized> AmbiguousIfImpl<()> for T {} | ||
|
||
// Creates multiple scoped `Invalid` types for each trait, | ||
// over which a specialized `AmbiguousIfImpl<Invalid>` is | ||
// implemented for every type that implements the trait. | ||
#[allow(dead_code)] | ||
struct InvalidFirst; | ||
impl<T: ?Sized + $first> AmbiguousIfImpl<InvalidFirst> for T {} | ||
|
||
$({ | ||
#[allow(dead_code)] | ||
struct Invalid; | ||
impl<T: ?Sized + $rest> AmbiguousIfImpl<Invalid> for T {} | ||
})* | ||
|
||
// If there is only one specialized trait impl, type inference | ||
// with `_` can be resolved and this can compile. Fails to | ||
// compile if `$t` implements any `AmbiguousIfImpl<Invalid>`. | ||
let _ = <$t as AmbiguousIfImpl<_>>::some_item; | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ mod lib { | |
} | ||
} | ||
|
||
#[macro_use] | ||
mod macros; | ||
|
||
mod as_js; | ||
pub(crate) mod engine; | ||
pub(crate) mod errors; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: should't clippy have required a Safety: ... comment here?