diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 5b1d6ead62e..6a7bba55c61 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -465,12 +465,10 @@ impl<'a> Context<'a> { }; let default_module_path = match self.config.mode { - OutputMode::Web => { - "\ + OutputMode::Web => "\ if (typeof module === 'undefined') { module = import.meta.url.replace(/\\.js$/, '_bg.wasm'); - }" - } + }", _ => "", }; @@ -872,21 +870,30 @@ impl<'a> Context<'a> { match self.config.encode_into { EncodeInto::Always if !shared => { - self.global(&format!(" + self.global(&format!( + " const encodeString = {}; - ", encode_into)); + ", + encode_into + )); } EncodeInto::Test if !shared => { - self.global(&format!(" + self.global(&format!( + " const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? {} : {}); - ", encode_into, encode)); + ", + encode_into, encode + )); } _ => { - self.global(&format!(" + self.global(&format!( + " const encodeString = {}; - ", encode)); + ", + encode + )); } } @@ -1080,7 +1087,6 @@ impl<'a> Context<'a> { fields: Vec::new(), })?; self.global(&format!("let cached{} = new {}{};", s, name, args)); - } else if !self.config.mode.always_run_in_browser() { self.global(&format!( " @@ -1090,7 +1096,6 @@ impl<'a> Context<'a> { s )); self.global(&format!("let cached{0} = new l{0}{1};", s, args)); - } else { self.global(&format!("let cached{0} = new {0}{1};", s, args)); } diff --git a/crates/cli-support/src/lib.rs b/crates/cli-support/src/lib.rs index 4ee99c1bddd..666f52dd4e3 100755 --- a/crates/cli-support/src/lib.rs +++ b/crates/cli-support/src/lib.rs @@ -337,7 +337,12 @@ impl Bindgen { // the webidl bindings proposal) as well as an auxiliary section for all // sorts of miscellaneous information and features #[wasm_bindgen] // supports that aren't covered by WebIDL bindings. - webidl::process(&mut module, self.anyref, self.wasm_interface_types, self.emit_start)?; + webidl::process( + &mut module, + self.anyref, + self.wasm_interface_types, + self.emit_start, + )?; // Now that we've got type information from the webidl processing pass, // touch up the output of rustc to insert anyref shims where necessary. @@ -563,16 +568,14 @@ impl Output { } else { format!("{}_bg", self.stem) }; - let wasm_path = out_dir - .join(wasm_name) - .with_extension("wasm"); + let wasm_path = out_dir.join(wasm_name).with_extension("wasm"); fs::create_dir_all(out_dir)?; let wasm_bytes = self.module.emit_wasm(); fs::write(&wasm_path, wasm_bytes) .with_context(|_| format!("failed to write `{}`", wasm_path.display()))?; if self.wasm_interface_types { - return Ok(()) + return Ok(()); } // Write out all local JS snippets to the final destination now that diff --git a/crates/cli-support/src/webidl/standard.rs b/crates/cli-support/src/webidl/standard.rs index 936b8d36963..e3ef0b10808 100644 --- a/crates/cli-support/src/webidl/standard.rs +++ b/crates/cli-support/src/webidl/standard.rs @@ -453,7 +453,7 @@ fn extract_incoming( exprs.push(e.clone()); continue; } - NonstandardIncoming::Int64 { .. } => "64-bit integer", + NonstandardIncoming::Int64 { .. } => "64-bit integer", NonstandardIncoming::AllocCopyInt64 { .. } => "64-bit integer array", NonstandardIncoming::AllocCopyAnyrefArray { .. } => "array of JsValue", NonstandardIncoming::MutableSlice { .. } => "mutable slice", @@ -472,7 +472,10 @@ fn extract_incoming( NonstandardIncoming::Char { .. } => "character", NonstandardIncoming::BorrowedAnyref { .. } => "borrowed anyref", }; - bail!("cannot represent {} with a standard bindings expression", desc); + bail!( + "cannot represent {} with a standard bindings expression", + desc + ); } Ok(exprs) } @@ -525,7 +528,10 @@ fn extract_outgoing( NonstandardOutgoing::OptionRustType { .. } => "optional rust type", NonstandardOutgoing::StackClosure { .. } => "closures", }; - bail!("cannot represent {} with a standard bindings expression", desc); + bail!( + "cannot represent {} with a standard bindings expression", + desc + ); } Ok(exprs) }