summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/Cargo.toml3
-rw-r--r--crates/types/src/archive.rs22
-rw-r--r--crates/types/src/instructions.rs1
-rw-r--r--crates/types/src/lib.rs5
4 files changed, 4 insertions, 27 deletions
diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml
index 76e5679..33271d5 100644
--- a/crates/types/Cargo.toml
+++ b/crates/types/Cargo.toml
@@ -13,8 +13,7 @@ rkyv={version="0.7", optional=true, default-features=false, features=["size_32",
bytecheck={version="0.7", optional=true}
[features]
-default=["std", "logging", "archive", "unsafe"]
+default=["std", "logging", "archive"]
std=["rkyv?/std"]
archive=["dep:rkyv", "dep:bytecheck"]
logging=["dep:log"]
-unsafe=[]
diff --git a/crates/types/src/archive.rs b/crates/types/src/archive.rs
index 9bf095b..52146e7 100644
--- a/crates/types/src/archive.rs
+++ b/crates/types/src/archive.rs
@@ -65,18 +65,6 @@ impl TinyWasmModule {
Ok(root.deserialize(&mut rkyv::Infallible).unwrap())
}
- #[cfg(feature = "unsafe")]
- #[allow(unsafe_code)]
- /// Creates a TinyWasmModule from a slice of bytes.
- ///
- /// # Safety
- /// This function is only safe to call if the bytes have been created by
- /// a trusted source. Otherwise, it may cause undefined behavior.
- pub unsafe fn from_twasm_unchecked(wasm: &[u8]) -> Self {
- let len = validate_magic(wasm).unwrap();
- rkyv::archived_root::<TinyWasmModule>(&wasm[len..]).deserialize(&mut rkyv::Infallible).unwrap()
- }
-
/// Serializes the TinyWasmModule into a vector of bytes.
/// AlignedVec can be deferenced as a slice of bytes and
/// implements io::Write when the `std` feature is enabled.
@@ -101,14 +89,4 @@ mod tests {
let wasm2 = TinyWasmModule::from_twasm(&twasm).unwrap();
assert_eq!(wasm, wasm2);
}
-
- #[cfg(feature = "unsafe")]
- #[test]
- fn test_serialize_unchecked() {
- let wasm = TinyWasmModule::default();
- let twasm = wasm.serialize_twasm();
- #[allow(unsafe_code)]
- let wasm2 = unsafe { TinyWasmModule::from_twasm_unchecked(&twasm) };
- assert_eq!(wasm, wasm2);
- }
}
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs
index ee624bd..6290bb4 100644
--- a/crates/types/src/instructions.rs
+++ b/crates/types/src/instructions.rs
@@ -85,6 +85,7 @@ pub enum ConstInstruction {
#[cfg_attr(feature = "archive", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize), archive(check_bytes))]
// should be kept as small as possible (16 bytes max)
#[rustfmt::skip]
+#[non_exhaustive]
pub enum Instruction {
// > Custom Instructions
BrLabel(LabelAddr),
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index c5c8071..5e38bfc 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -4,8 +4,7 @@
))]
#![warn(missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
#![no_std]
-#![cfg_attr(not(feature = "unsafe"), forbid(unsafe_code))]
-#![cfg_attr(feature = "unsafe", deny(unused_unsafe))]
+#![forbid(unsafe_code)]
//! Types used by [`tinywasm`](https://docs.rs/tinywasm) and [`tinywasm_parser`](https://docs.rs/tinywasm_parser).
@@ -95,7 +94,7 @@ pub struct TinyWasmModule {
/// A WebAssembly External Kind.
///
/// See <https://webassembly.github.io/spec/core/syntax/types.html#external-types>
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "archive", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize), archive(check_bytes))]
pub enum ExternalKind {
/// A WebAssembly Function.