Run cargo fmt --all

This commit is contained in:
Alex Crichton 2019-06-13 08:30:06 -07:00
parent 3aa803c55c
commit 83a3f5d44a
5 changed files with 58 additions and 45 deletions

View File

@ -1174,7 +1174,8 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
// //
// But for now, we just bounce wasm -> js -> wasm because it is // But for now, we just bounce wasm -> js -> wasm because it is
// easy. // easy.
self.cx.require_internal_export("__wbindgen_anyref_heap_live_count_impl")?; self.cx
.require_internal_export("__wbindgen_anyref_heap_live_count_impl")?;
"wasm.__wbindgen_anyref_heap_live_count_impl()".into() "wasm.__wbindgen_anyref_heap_live_count_impl()".into()
} else { } else {
self.cx.expose_global_heap(); self.cx.expose_global_heap();

View File

@ -11,9 +11,9 @@ use walrus::Module;
mod anyref; mod anyref;
mod decode; mod decode;
mod intrinsic;
mod descriptor; mod descriptor;
mod descriptors; mod descriptors;
mod intrinsic;
mod js; mod js;
pub mod wasm2es6js; pub mod wasm2es6js;
mod webidl; mod webidl;
@ -337,7 +337,10 @@ impl Bindgen {
let (js, ts) = { let (js, ts) = {
let mut cx = js::Context::new(&mut module, self)?; let mut cx = js::Context::new(&mut module, self)?;
let aux = cx.module.customs.delete_typed::<webidl::WasmBindgenAux>() let aux = cx
.module
.customs
.delete_typed::<webidl::WasmBindgenAux>()
.expect("aux section should be present"); .expect("aux section should be present");
cx.generate(&aux)?; cx.generate(&aux)?;
@ -346,10 +349,7 @@ impl Bindgen {
for (identifier, list) in aux.snippets.iter() { for (identifier, list) in aux.snippets.iter() {
for (i, js) in list.iter().enumerate() { for (i, js) in list.iter().enumerate() {
let name = format!("inline{}.js", i); let name = format!("inline{}.js", i);
let path = out_dir let path = out_dir.join("snippets").join(identifier).join(name);
.join("snippets")
.join(identifier)
.join(name);
fs::create_dir_all(path.parent().unwrap())?; fs::create_dir_all(path.parent().unwrap())?;
fs::write(&path, js) fs::write(&path, js)
.with_context(|_| format!("failed to write `{}`", path.display()))?; .with_context(|_| format!("failed to write `{}`", path.display()))?;

View File

@ -71,7 +71,8 @@ fn rmain() -> Result<(), Error> {
// that any exported function with the prefix `__wbg_test` is a test we need // that any exported function with the prefix `__wbg_test` is a test we need
// to execute. // to execute.
let wasm = fs::read(&wasm_file_to_test).context("failed to read wasm file")?; let wasm = fs::read(&wasm_file_to_test).context("failed to read wasm file")?;
let mut wasm = walrus::Module::from_buffer(&wasm).context("failed to deserialize wasm module")?; let mut wasm =
walrus::Module::from_buffer(&wasm).context("failed to deserialize wasm module")?;
let mut tests = Vec::new(); let mut tests = Vec::new();
for export in wasm.exports.iter() { for export in wasm.exports.iter() {

View File

@ -1,7 +1,12 @@
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
#[wasm_bindgen] #[wasm_bindgen]
pub struct ColorWithGetter { r: f64, _g: f64, _b: f64, _a: u8 } pub struct ColorWithGetter {
r: f64,
_g: f64,
_b: f64,
_a: u8,
}
#[wasm_bindgen] #[wasm_bindgen]
impl ColorWithGetter { impl ColorWithGetter {
@ -12,7 +17,12 @@ impl ColorWithGetter {
} }
#[wasm_bindgen] #[wasm_bindgen]
pub struct ColorWithSetter { r: f64, _g: f64, _b: f64, a: u8 } pub struct ColorWithSetter {
r: f64,
_g: f64,
_b: f64,
a: u8,
}
#[wasm_bindgen] #[wasm_bindgen]
impl ColorWithSetter { impl ColorWithSetter {
@ -21,18 +31,21 @@ impl ColorWithSetter {
self.r = r; self.r = r;
self.a = if self.r > 1.0 { self.a = if self.r > 1.0 {
255 255
} } else if self.r < 0.0 {
else if self.r < 0.0 {
0 0
} } else {
else {
(self.r * 255.0) as u8 (self.r * 255.0) as u8
}; };
} }
} }
#[wasm_bindgen] #[wasm_bindgen]
pub struct ColorWithGetterAndSetter { r: f64, _g: f64, _b: f64, a: u8 } pub struct ColorWithGetterAndSetter {
r: f64,
_g: f64,
_b: f64,
a: u8,
}
#[wasm_bindgen] #[wasm_bindgen]
impl ColorWithGetterAndSetter { impl ColorWithGetterAndSetter {
@ -46,11 +59,9 @@ impl ColorWithGetterAndSetter {
self.r = r; self.r = r;
self.a = if self.r > 1.0 { self.a = if self.r > 1.0 {
255 255
} } else if self.r < 0.0 {
else if self.r < 0.0 {
0 0
} } else {
else {
(self.r * 255.0) as u8 (self.r * 255.0) as u8
}; };
} }

View File

@ -1080,7 +1080,7 @@ pub mod __rt {
pub fn take_last_exception() -> Result<(), super::JsValue> { pub fn take_last_exception() -> Result<(), super::JsValue> {
unsafe { unsafe {
let ret = if GLOBAL_EXNDATA[0] == 1 { let ret = if GLOBAL_EXNDATA[0] == 1 {
Err(super::JsValue:: _new(GLOBAL_EXNDATA[1])) Err(super::JsValue::_new(GLOBAL_EXNDATA[1]))
} else { } else {
Ok(()) Ok(())
}; };