From 637360dfab4ff0d8f3b6506c78806c0386158ff1 Mon Sep 17 00:00:00 2001 From: anweiss <2326106+anweiss@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:37:55 -0400 Subject: [PATCH] fix wasm clippy errors --- Cargo.toml | 7 ++++--- src/ast.rs | 6 +++--- src/parser.rs | 4 ++-- src/token.rs | 4 ++-- src/validator/mod.rs | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6b4acf53..815126e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,21 +46,22 @@ crossterm = { version = "0.25.0", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook = "0.1.6" -wasm-bindgen = { version = "0.2.75", features = ["serde-serialize"], optional = true } +serde-wasm-bindgen = { version = "0.4", optional = true } +wasm-bindgen = { version = "0.2", optional = true } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.25" [features] default = ["std", "ast-span", "ast-comments", "json", "cbor", "additional-controls"] -std = ["base16/alloc", "base64/alloc", "serde_json", "ciborium", "serde", "chrono", "wasm-bindgen", "clap", "crossterm", "uriparse", "base64-url", "regex-syntax"] +std = ["base16/alloc", "base64/alloc", "serde_json", "ciborium", "serde", "chrono", "wasm-bindgen", "serde-wasm-bindgen", "clap", "crossterm", "uriparse", "base64-url", "regex-syntax"] lsp = ["std"] additional-controls = [] ast-span = [] ast-comments = [] json = ["std"] cbor = ["std"] -web = ["ast-span", "wasm-bindgen", "serde"] +web = ["ast-span", "wasm-bindgen", "serde-wasm-bindgen", "serde"] [[bin]] name = "cddl" diff --git a/src/ast.rs b/src/ast.rs index 75c98d0e..14f51b41 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -26,7 +26,7 @@ use alloc::{ pub type Span = (usize, usize, usize); #[cfg(feature = "ast-comments")] -#[derive(Default, Debug, PartialEq, Clone)] +#[derive(Default, Debug, PartialEq, Eq, Clone)] #[doc(hidden)] pub struct Comments<'a>(pub Vec<&'a str>); @@ -943,7 +943,7 @@ impl<'a> fmt::Display for Type1<'a> { /// ctlop = "." id /// ``` #[cfg_attr(target_arch = "wasm32", derive(Serialize))] -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum RangeCtlOp<'a> { /// Range operator RangeOp { @@ -2819,7 +2819,7 @@ impl<'a> fmt::Display for MemberKey<'a> { /// / "?" /// ``` #[cfg_attr(target_arch = "wasm32", derive(Serialize))] -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Occur { /// Occurrence indicator in the form n*m, where n is an optional lower limit /// and m is an optional upper limit diff --git a/src/parser.rs b/src/parser.rs index 9752d0aa..087f6481 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3529,11 +3529,11 @@ pub fn cddl_from_str(input: &str) -> result::Result { match Parser::new(input, Box::new(lexer::Lexer::new(input).iter())) { Ok(mut p) => match p.parse_cddl() { - Ok(c) => JsValue::from_serde(&c).map_err(|e| JsValue::from(e.to_string())), + Ok(c) => serde_wasm_bindgen::to_value(&c).map_err(|e| JsValue::from(e.to_string())), Err(Error::INCREMENTAL) => { if !p.errors.is_empty() { return Err( - JsValue::from_serde( + serde_wasm_bindgen::to_value( &p.errors .iter() .filter_map(|e| { diff --git a/src/token.rs b/src/token.rs index 12fab799..5910ef1b 100644 --- a/src/token.rs +++ b/src/token.rs @@ -404,7 +404,7 @@ impl<'a> From<&'a str> for Value<'a> { /// Byte string values #[cfg_attr(target_arch = "wasm32", derive(Serialize, Deserialize))] -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum ByteValue<'a> { /// Unprefixed byte string value UTF8(Cow<'a, [u8]>), @@ -438,7 +438,7 @@ impl<'a> fmt::Display for ByteValue<'a> { /// Socket/plug prefix #[cfg_attr(target_arch = "wasm32", derive(Serialize, Deserialize))] -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum SocketPlug { /// Type socket `$` TYPE, diff --git a/src/validator/mod.rs b/src/validator/mod.rs index 35d40a94..1f549f21 100644 --- a/src/validator/mod.rs +++ b/src/validator/mod.rs @@ -117,7 +117,7 @@ pub fn validate_json_from_str( let c = p.parse_cddl().map_err(|e| JsValue::from(e.to_string()))?; if !p.errors.is_empty() { return Err( - JsValue::from_serde( + serde_wasm_bindgen::to_value( &p.errors .iter() .filter_map(|e| { @@ -231,7 +231,7 @@ pub fn validate_cbor_from_slice( let c = p.parse_cddl().map_err(|e| JsValue::from(e.to_string()))?; if !p.errors.is_empty() { return Err( - JsValue::from_serde( + serde_wasm_bindgen::to_value( &p.errors .iter() .filter_map(|e| {