Skip to content

Commit ff1addb

Browse files
committed
Run cargo fmt
1 parent 5ebfa27 commit ff1addb

File tree

12 files changed

+93
-48
lines changed

12 files changed

+93
-48
lines changed

crates/backend/src/codegen.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,13 @@ impl ToTokens for ast::ImportType {
588588
}
589589
};
590590

591-
let is_type_of = self.is_type_of.as_ref().map(|is_type_of| quote! {
592-
#[inline]
593-
fn is_type_of(val: &JsValue) -> bool {
594-
let is_type_of: fn(&JsValue) -> bool = #is_type_of;
595-
is_type_of(val)
591+
let is_type_of = self.is_type_of.as_ref().map(|is_type_of| {
592+
quote! {
593+
#[inline]
594+
fn is_type_of(val: &JsValue) -> bool {
595+
let is_type_of: fn(&JsValue) -> bool = #is_type_of;
596+
is_type_of(val)
597+
}
596598
}
597599
});
598600

@@ -1447,10 +1449,7 @@ impl<'a, T: ToTokens> ToTokens for Descriptor<'a, T> {
14471449
}
14481450
}
14491451

1450-
fn respan(
1451-
input: TokenStream,
1452-
span: &dyn ToTokens,
1453-
) -> TokenStream {
1452+
fn respan(input: TokenStream, span: &dyn ToTokens) -> TokenStream {
14541453
let mut first_span = Span::call_site();
14551454
let mut last_span = Span::call_site();
14561455
let mut spans = TokenStream::new();

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
340340
Descriptor::Char => {
341341
self.js_arguments
342342
.push((name.clone(), "string | undefined".to_string()));
343-
self.rust_arguments
344-
.push(format!("isLikeNone({0}) ? 0xFFFFFF : {0}.codePointAt(0)", name));
343+
self.rust_arguments.push(format!(
344+
"isLikeNone({0}) ? 0xFFFFFF : {0}.codePointAt(0)",
345+
name
346+
));
345347
}
346348
Descriptor::Enum { hole } => {
347349
self.js_arguments
@@ -630,7 +632,8 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
630632
self.ret_expr = "
631633
const ret = RET;
632634
return ret === 0xFFFFFF ? undefined : String.fromCodePoint(ret);
633-
".to_string();
635+
"
636+
.to_string();
634637
return Ok(self);
635638
}
636639
Descriptor::Enum { hole } => {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
215215
return Ok(());
216216
}
217217
Descriptor::Char => {
218-
self.js_arguments
219-
.push(format!("{0} === 0xFFFFFF ? undefined : String.fromCodePoint({0})", abi));
218+
self.js_arguments.push(format!(
219+
"{0} === 0xFFFFFF ? undefined : String.fromCodePoint({0})",
220+
abi
221+
));
220222
return Ok(());
221223
}
222224
Descriptor::RustStruct(ref class) => {

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,17 @@ fn rmain() -> Result<(), Error> {
106106
// Gracefully handle requests to execute only node or only web tests.
107107
if env::var_os("WASM_BINDGEN_TEST_ONLY_NODE").is_some() {
108108
if !node {
109-
println!("this test suite is only configured to run in a browser, \
110-
but we're only testing node.js tests so skipping");
109+
println!(
110+
"this test suite is only configured to run in a browser, \
111+
but we're only testing node.js tests so skipping"
112+
);
111113
return Ok(());
112114
}
113115
}
114116
if env::var_os("WASM_BINDGEN_TEST_ONLY_WEB").is_some() {
115117
if node {
116-
println!("\
118+
println!(
119+
"\
117120
This test suite is only configured to run in node.js, but we're only running
118121
browser tests so skipping. If you'd like to run the tests in a browser
119122
include this in your crate when testing:
@@ -122,7 +125,8 @@ include this in your crate when testing:
122125
123126
You'll likely want to put that in a `#[cfg(test)]` module or at the top of an
124127
integration test.\
125-
");
128+
"
129+
);
126130
return Ok(());
127131
}
128132
}

crates/js-sys/src/lib.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,15 +2360,27 @@ pub mod Reflect {
23602360
///
23612361
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
23622362
#[wasm_bindgen(js_namespace = Reflect, catch)]
2363-
pub fn set(target: &JsValue, property_key: &JsValue, value: &JsValue) -> Result<bool, JsValue>;
2363+
pub fn set(
2364+
target: &JsValue,
2365+
property_key: &JsValue,
2366+
value: &JsValue,
2367+
) -> Result<bool, JsValue>;
23642368

23652369
/// The same as [`Reflect::set`](#method.set) except the key is an `f64`, which is slightly faster.
23662370
#[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
2367-
pub fn set_f64(target: &JsValue, property_key: f64, value: &JsValue) -> Result<bool, JsValue>;
2371+
pub fn set_f64(
2372+
target: &JsValue,
2373+
property_key: f64,
2374+
value: &JsValue,
2375+
) -> Result<bool, JsValue>;
23682376

23692377
/// The same as [`Reflect::set`](#method.set) except the key is a `u32`, which is slightly faster.
23702378
#[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
2371-
pub fn set_u32(target: &JsValue, property_key: u32, value: &JsValue) -> Result<bool, JsValue>;
2379+
pub fn set_u32(
2380+
target: &JsValue,
2381+
property_key: u32,
2382+
value: &JsValue,
2383+
) -> Result<bool, JsValue>;
23722384

23732385
/// The static `Reflect.set()` method works like setting a
23742386
/// property on an object.
@@ -3100,7 +3112,10 @@ pub mod JSON {
31003112
///
31013113
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
31023114
#[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
3103-
pub fn stringify_with_replacer(obj: &JsValue, replacer: &JsValue) -> Result<JsString, JsValue>;
3115+
pub fn stringify_with_replacer(
3116+
obj: &JsValue,
3117+
replacer: &JsValue,
3118+
) -> Result<JsString, JsValue>;
31043119

31053120
/// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
31063121
///

crates/macro-support/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'a> ConvertToAst<BindgenAttrs> for &'a mut syn::ItemStruct {
324324
assert_not_variadic(&attrs)?;
325325
if attrs.skip().is_some() {
326326
attrs.check_used()?;
327-
continue
327+
continue;
328328
}
329329

330330
let comments = extract_doc_comments(&field.attrs);

crates/webidl-tests/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pub mod dictionary;
1010
pub mod enums;
1111
pub mod global;
1212
pub mod namespace;
13+
pub mod no_interface;
1314
pub mod simple;
1415
pub mod throws;
15-
pub mod no_interface;

crates/webidl/src/first_pass.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ impl<'src> FirstPass<'src, ()> for weedle::InterfaceDefinition<'src> {
310310
interface_data.definition_attributes = self.attributes.as_ref();
311311
interface_data.deprecated =
312312
util::get_rust_deprecated(&self.attributes).map(|s| s.to_string());
313-
interface_data.has_interface =
314-
!util::is_no_interface_object(&self.attributes);
313+
interface_data.has_interface = !util::is_no_interface_object(&self.attributes);
315314
if let Some(attrs) = &self.attributes {
316315
for attr in attrs.body.list.iter() {
317316
process_interface_attribute(record, self.identifier.0, attr);

crates/webidl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl<'src> FirstPassRecord<'src> {
517517
is_type_of: if data.has_interface {
518518
None
519519
} else {
520-
Some(syn::parse_quote!{ |_| false })
520+
Some(syn::parse_quote! { |_| false })
521521
},
522522
extends: Vec::new(),
523523
vendor_prefixes: Vec::new(),

src/convert/closures.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use core::mem;
22

33
use crate::convert::slices::WasmSlice;
4-
use crate::convert::{FromWasmAbi, GlobalStack, IntoWasmAbi, ReturnWasmAbi, Stack};
54
use crate::convert::RefFromWasmAbi;
5+
use crate::convert::{FromWasmAbi, GlobalStack, IntoWasmAbi, ReturnWasmAbi, Stack};
66
use crate::describe::{inform, WasmDescribe, FUNCTION};
77
use crate::throw_str;
88

@@ -120,15 +120,19 @@ stack_closures! {
120120
}
121121

122122
impl<'a, 'b, A, R> IntoWasmAbi for &'a (Fn(&A) -> R + 'b)
123-
where A: RefFromWasmAbi,
124-
R: ReturnWasmAbi
123+
where
124+
A: RefFromWasmAbi,
125+
R: ReturnWasmAbi,
125126
{
126127
type Abi = WasmSlice;
127128

128129
fn into_abi(self, _extra: &mut Stack) -> WasmSlice {
129130
unsafe {
130131
let (a, b): (usize, usize) = mem::transmute(self);
131-
WasmSlice { ptr: a as u32, len: b as u32 }
132+
WasmSlice {
133+
ptr: a as u32,
134+
len: b as u32,
135+
}
132136
}
133137
}
134138
}
@@ -154,8 +158,9 @@ unsafe extern "C" fn invoke1_ref<A: RefFromWasmAbi, R: ReturnWasmAbi>(
154158
}
155159

156160
impl<'a, A, R> WasmDescribe for Fn(&A) -> R + 'a
157-
where A: RefFromWasmAbi,
158-
R: ReturnWasmAbi,
161+
where
162+
A: RefFromWasmAbi,
163+
R: ReturnWasmAbi,
159164
{
160165
fn describe() {
161166
inform(FUNCTION);
@@ -167,15 +172,19 @@ impl<'a, A, R> WasmDescribe for Fn(&A) -> R + 'a
167172
}
168173

169174
impl<'a, 'b, A, R> IntoWasmAbi for &'a mut (FnMut(&A) -> R + 'b)
170-
where A: RefFromWasmAbi,
171-
R: ReturnWasmAbi
175+
where
176+
A: RefFromWasmAbi,
177+
R: ReturnWasmAbi,
172178
{
173179
type Abi = WasmSlice;
174180

175181
fn into_abi(self, _extra: &mut Stack) -> WasmSlice {
176182
unsafe {
177183
let (a, b): (usize, usize) = mem::transmute(self);
178-
WasmSlice { ptr: a as u32, len: b as u32 }
184+
WasmSlice {
185+
ptr: a as u32,
186+
len: b as u32,
187+
}
179188
}
180189
}
181190
}
@@ -201,8 +210,9 @@ unsafe extern "C" fn invoke1_mut_ref<A: RefFromWasmAbi, R: ReturnWasmAbi>(
201210
}
202211

203212
impl<'a, A, R> WasmDescribe for FnMut(&A) -> R + 'a
204-
where A: RefFromWasmAbi,
205-
R: ReturnWasmAbi
213+
where
214+
A: RefFromWasmAbi,
215+
R: ReturnWasmAbi,
206216
{
207217
fn describe() {
208218
inform(FUNCTION);

tests/wasm/classes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub struct PublicFields {
275275
pub c: f64,
276276
pub d: i32,
277277
#[wasm_bindgen(skip)]
278-
pub skipped: u32
278+
pub skipped: u32,
279279
}
280280

281281
#[wasm_bindgen]
@@ -475,7 +475,6 @@ mod works_in_module {
475475
WorksInModule(1)
476476
}
477477

478-
pub fn foo(&self) {
479-
}
478+
pub fn foo(&self) {}
480479
}
481480
}

tests/wasm/math.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ fn auto_bind_math() {
8787
}
8888

8989
macro_rules! t_roundtrip {
90-
($f:ident($e:expr)) => (assert_eq!($f($e), $e as f64))
90+
($f:ident($e:expr)) => {
91+
assert_eq!($f($e), $e as f64)
92+
};
9193
}
9294

9395
#[wasm_bindgen_test]
@@ -114,15 +116,27 @@ fn limits_correct() {
114116
test_js_roundtrip();
115117

116118
#[wasm_bindgen]
117-
pub fn rust_roundtrip_i8(a: i8) -> i8 { a }
119+
pub fn rust_roundtrip_i8(a: i8) -> i8 {
120+
a
121+
}
118122
#[wasm_bindgen]
119-
pub fn rust_roundtrip_i16(a: i16) -> i16 { a }
123+
pub fn rust_roundtrip_i16(a: i16) -> i16 {
124+
a
125+
}
120126
#[wasm_bindgen]
121-
pub fn rust_roundtrip_i32(a: i32) -> i32 { a }
127+
pub fn rust_roundtrip_i32(a: i32) -> i32 {
128+
a
129+
}
122130
#[wasm_bindgen]
123-
pub fn rust_roundtrip_u8(a: u8) -> u8 { a }
131+
pub fn rust_roundtrip_u8(a: u8) -> u8 {
132+
a
133+
}
124134
#[wasm_bindgen]
125-
pub fn rust_roundtrip_u16(a: u16) -> u16 { a }
135+
pub fn rust_roundtrip_u16(a: u16) -> u16 {
136+
a
137+
}
126138
#[wasm_bindgen]
127-
pub fn rust_roundtrip_u32(a: u32) -> u32 { a }
139+
pub fn rust_roundtrip_u32(a: u32) -> u32 {
140+
a
141+
}
128142
}

0 commit comments

Comments
 (0)