chore; Add some explanatory comments on allow(unused_unsafe) annotations

This commit is contained in:
Christoph Herzog
2023-01-17 00:20:36 +01:00
parent 4c5b773dd7
commit e9edb7e8e6
5 changed files with 15 additions and 0 deletions

View File

@@ -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())