mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
chore; Add some explanatory comments on allow(unused_unsafe) annotations
This commit is contained in:
1
lib/api/src/js/externals/function.rs
vendored
1
lib/api/src/js/externals/function.rs
vendored
@@ -399,6 +399,7 @@ impl Function {
|
||||
store: &mut impl AsStoreMut,
|
||||
params: &[Value],
|
||||
) -> Result<Box<[Value]>, RuntimeError> {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
let params: Vec<_> = unsafe {
|
||||
params
|
||||
|
||||
1
lib/api/src/js/externals/memory.rs
vendored
1
lib/api/src/js/externals/memory.rs
vendored
@@ -92,6 +92,7 @@ impl Memory {
|
||||
|
||||
pub(crate) fn new_internal(ty: MemoryType) -> Result<js_sys::WebAssembly::Memory, MemoryError> {
|
||||
let descriptor = js_sys::Object::new();
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
js_sys::Reflect::set(&descriptor, &"initial".into(), &ty.minimum.0.into()).unwrap();
|
||||
|
||||
@@ -171,12 +171,14 @@ impl Imports {
|
||||
for (ns, exports) in namespaces.into_iter() {
|
||||
let import_namespace = js_sys::Object::new();
|
||||
for (name, ext) in exports {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
js_sys::Reflect::set(&import_namespace, &name.into(), &ext.as_jsvalue(store))
|
||||
.expect("Error while setting into the js namespace object");
|
||||
}
|
||||
}
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
js_sys::Reflect::set(&imports, &ns.into(), &import_namespace.into())
|
||||
@@ -238,6 +240,7 @@ impl Imports {
|
||||
}
|
||||
|
||||
impl AsJs for Imports {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
fn as_jsvalue(&self, store: &impl AsStoreRef) -> wasm_bindgen::JsValue {
|
||||
let imports_object = js_sys::Object::new();
|
||||
@@ -245,6 +248,8 @@ impl AsJs for Imports {
|
||||
let val = unsafe { js_sys::Reflect::get(&imports_object, &namespace.into()).unwrap() };
|
||||
if !val.is_undefined() {
|
||||
// If the namespace is already set
|
||||
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
js_sys::Reflect::set(
|
||||
|
||||
@@ -118,6 +118,7 @@ impl Instance {
|
||||
.map(|export_type| {
|
||||
let name = export_type.name();
|
||||
let extern_type = export_type.ty().clone();
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
let js_export = unsafe {
|
||||
js_sys::Reflect::get(&instance_exports, &name.into())
|
||||
|
||||
@@ -232,6 +232,7 @@ impl Module {
|
||||
/// validation of the Module.
|
||||
pub fn validate(_store: &impl AsStoreRef, binary: &[u8]) -> Result<(), CompileError> {
|
||||
let js_bytes = unsafe { Uint8Array::view(binary) };
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
match WebAssembly::validate(&js_bytes.into()) {
|
||||
@@ -267,6 +268,7 @@ impl Module {
|
||||
let mut import_externs: Vec<Extern> = vec![];
|
||||
for import_type in self.imports() {
|
||||
let resolved_import = imports.get_export(import_type.module(), import_type.name());
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_variables)]
|
||||
if let wasmer_types::ExternType::Memory(mem_ty) = import_type.ty() {
|
||||
if resolved_import.is_some() {
|
||||
@@ -282,6 +284,7 @@ impl Module {
|
||||
);
|
||||
}
|
||||
}
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
if let Some(import) = resolved_import {
|
||||
@@ -468,6 +471,7 @@ impl Module {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(move |(i, val)| {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
let module = Reflect::get(val.as_ref(), &"module".into())
|
||||
@@ -530,6 +534,7 @@ impl Module {
|
||||
return Err("The exports length must match the type hints lenght".to_owned());
|
||||
}
|
||||
for (i, val) in exports.iter().enumerate() {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
let kind = unsafe {
|
||||
Reflect::get(val.as_ref(), &"kind".into())
|
||||
@@ -582,6 +587,7 @@ impl Module {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(move |(i, val)| {
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
let field = unsafe {
|
||||
Reflect::get(val.as_ref(), &"name".into())
|
||||
@@ -589,6 +595,7 @@ impl Module {
|
||||
.as_string()
|
||||
.unwrap()
|
||||
};
|
||||
// Annotation is here to prevent spurious IDE warnings.
|
||||
#[allow(unused_unsafe)]
|
||||
let kind = unsafe {
|
||||
Reflect::get(val.as_ref(), &"kind".into())
|
||||
|
||||
Reference in New Issue
Block a user