Skip to content

Commit 908fc61

Browse files
committed
cli-support: cargo fmt
1 parent 5f90951 commit 908fc61

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

crates/cli-support/src/js/mod.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,10 @@ impl<'a> Context<'a> {
465465
};
466466

467467
let default_module_path = match self.config.mode {
468-
OutputMode::Web => {
469-
"\
468+
OutputMode::Web => "\
470469
if (typeof module === 'undefined') {
471470
module = import.meta.url.replace(/\\.js$/, '_bg.wasm');
472-
}"
473-
}
471+
}",
474472
_ => "",
475473
};
476474

@@ -872,21 +870,30 @@ impl<'a> Context<'a> {
872870

873871
match self.config.encode_into {
874872
EncodeInto::Always if !shared => {
875-
self.global(&format!("
873+
self.global(&format!(
874+
"
876875
const encodeString = {};
877-
", encode_into));
876+
",
877+
encode_into
878+
));
878879
}
879880
EncodeInto::Test if !shared => {
880-
self.global(&format!("
881+
self.global(&format!(
882+
"
881883
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
882884
? {}
883885
: {});
884-
", encode_into, encode));
886+
",
887+
encode_into, encode
888+
));
885889
}
886890
_ => {
887-
self.global(&format!("
891+
self.global(&format!(
892+
"
888893
const encodeString = {};
889-
", encode));
894+
",
895+
encode
896+
));
890897
}
891898
}
892899

@@ -1080,7 +1087,6 @@ impl<'a> Context<'a> {
10801087
fields: Vec::new(),
10811088
})?;
10821089
self.global(&format!("let cached{} = new {}{};", s, name, args));
1083-
10841090
} else if !self.config.mode.always_run_in_browser() {
10851091
self.global(&format!(
10861092
"
@@ -1090,7 +1096,6 @@ impl<'a> Context<'a> {
10901096
s
10911097
));
10921098
self.global(&format!("let cached{0} = new l{0}{1};", s, args));
1093-
10941099
} else {
10951100
self.global(&format!("let cached{0} = new {0}{1};", s, args));
10961101
}

crates/cli-support/src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ impl Bindgen {
337337
// the webidl bindings proposal) as well as an auxiliary section for all
338338
// sorts of miscellaneous information and features #[wasm_bindgen]
339339
// supports that aren't covered by WebIDL bindings.
340-
webidl::process(&mut module, self.anyref, self.wasm_interface_types, self.emit_start)?;
340+
webidl::process(
341+
&mut module,
342+
self.anyref,
343+
self.wasm_interface_types,
344+
self.emit_start,
345+
)?;
341346

342347
// Now that we've got type information from the webidl processing pass,
343348
// touch up the output of rustc to insert anyref shims where necessary.
@@ -563,16 +568,14 @@ impl Output {
563568
} else {
564569
format!("{}_bg", self.stem)
565570
};
566-
let wasm_path = out_dir
567-
.join(wasm_name)
568-
.with_extension("wasm");
571+
let wasm_path = out_dir.join(wasm_name).with_extension("wasm");
569572
fs::create_dir_all(out_dir)?;
570573
let wasm_bytes = self.module.emit_wasm();
571574
fs::write(&wasm_path, wasm_bytes)
572575
.with_context(|_| format!("failed to write `{}`", wasm_path.display()))?;
573576

574577
if self.wasm_interface_types {
575-
return Ok(())
578+
return Ok(());
576579
}
577580

578581
// Write out all local JS snippets to the final destination now that

crates/cli-support/src/webidl/standard.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ fn extract_incoming(
453453
exprs.push(e.clone());
454454
continue;
455455
}
456-
NonstandardIncoming::Int64 { .. } => "64-bit integer",
456+
NonstandardIncoming::Int64 { .. } => "64-bit integer",
457457
NonstandardIncoming::AllocCopyInt64 { .. } => "64-bit integer array",
458458
NonstandardIncoming::AllocCopyAnyrefArray { .. } => "array of JsValue",
459459
NonstandardIncoming::MutableSlice { .. } => "mutable slice",
@@ -472,7 +472,10 @@ fn extract_incoming(
472472
NonstandardIncoming::Char { .. } => "character",
473473
NonstandardIncoming::BorrowedAnyref { .. } => "borrowed anyref",
474474
};
475-
bail!("cannot represent {} with a standard bindings expression", desc);
475+
bail!(
476+
"cannot represent {} with a standard bindings expression",
477+
desc
478+
);
476479
}
477480
Ok(exprs)
478481
}
@@ -525,7 +528,10 @@ fn extract_outgoing(
525528
NonstandardOutgoing::OptionRustType { .. } => "optional rust type",
526529
NonstandardOutgoing::StackClosure { .. } => "closures",
527530
};
528-
bail!("cannot represent {} with a standard bindings expression", desc);
531+
bail!(
532+
"cannot represent {} with a standard bindings expression",
533+
desc
534+
);
529535
}
530536
Ok(exprs)
531537
}

0 commit comments

Comments
 (0)