cli-support: cargo fmt

This commit is contained in:
Nick Fitzgerald 2019-09-10 11:20:19 -07:00
parent 5f90951441
commit 908fc614c0
3 changed files with 34 additions and 20 deletions

View File

@ -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));
}

View File

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

View File

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