Skip to content

Commit 513285f

Browse files
committed
Run rustfmt
1 parent a20dd26 commit 513285f

File tree

13 files changed

+100
-69
lines changed

13 files changed

+100
-69
lines changed

crates/backend/src/codegen.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,7 @@ impl TryToTokens for ast::Export {
456456
},
457457
)
458458
} else {
459-
(
460-
quote! { #syn_ret },
461-
quote! { #ret },
462-
)
459+
(quote! { #syn_ret }, quote! { #ret })
463460
};
464461
let projection = quote! { <#ret_ty as wasm_bindgen::convert::ReturnWasmAbi> };
465462
let convert_ret = quote! { #projection::return_abi(#ret_expr) };

crates/backend/src/encode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn shared_function<'a>(func: &'a ast::Function, _intern: &'a Interner) -> Functi
198198
.enumerate()
199199
.map(|(idx, arg)| {
200200
if let syn::Pat::Ident(x) = &*arg.pat {
201-
return x.ident.to_string()
201+
return x.ident.to_string();
202202
}
203203
format!("arg{}", idx)
204204
})

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ fn check_standard_import(import: &AuxImport) -> Result<(), Error> {
520520
| AuxImport::Value(AuxValue::ClassSetter(js, name)) => {
521521
format!("field access of `{}` for {}", name, desc_js(js))
522522
}
523-
AuxImport::ValueWithThis(js, method) => {
524-
format!("method `{}.{}`", desc_js(js), method)
525-
}
523+
AuxImport::ValueWithThis(js, method) => format!("method `{}.{}`", desc_js(js), method),
526524
AuxImport::Instanceof(js) => format!("instance of check of {}", desc_js(js)),
527525
AuxImport::Static(js) => format!("static js value {}", desc_js(js)),
528526
AuxImport::StructuralMethod(name) => format!("structural method `{}`", name),

crates/js-sys/tests/wasm/Array.rs

+14-26
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,37 @@ fn to_rust(arr: &Array) -> Vec<JsValue> {
2929
#[wasm_bindgen_test]
3030
fn from_iter() {
3131
assert_eq!(
32-
to_rust(&vec![
33-
JsValue::from("a"),
34-
JsValue::from("b"),
35-
JsValue::from("c"),
36-
].into_iter().collect()),
32+
to_rust(
33+
&vec![JsValue::from("a"), JsValue::from("b"), JsValue::from("c"),]
34+
.into_iter()
35+
.collect()
36+
),
3737
vec!["a", "b", "c"],
3838
);
3939

4040
assert_eq!(
41-
to_rust(&vec![
42-
JsValue::from("a"),
43-
JsValue::from("b"),
44-
JsValue::from("c"),
45-
].iter().collect()),
41+
to_rust(
42+
&vec![JsValue::from("a"), JsValue::from("b"), JsValue::from("c"),]
43+
.iter()
44+
.collect()
45+
),
4646
vec!["a", "b", "c"],
4747
);
4848

4949
let array = js_array![1u32, 2u32, 3u32];
5050

5151
assert_eq!(
52-
to_rust(&vec![
53-
array.clone(),
54-
].into_iter().collect()),
52+
to_rust(&vec![array.clone(),].into_iter().collect()),
5553
vec![JsValue::from(array.clone())],
5654
);
5755

5856
assert_eq!(
59-
to_rust(&vec![
60-
array.clone(),
61-
].iter().collect()),
57+
to_rust(&vec![array.clone(),].iter().collect()),
6258
vec![JsValue::from(array)],
6359
);
6460

6561
assert_eq!(
66-
to_rust(&vec![
67-
5,
68-
10,
69-
20,
70-
].into_iter().map(JsValue::from).collect()),
62+
to_rust(&vec![5, 10, 20,].into_iter().map(JsValue::from).collect()),
7163
vec![5, 10, 20],
7264
);
7365

@@ -80,11 +72,7 @@ fn from_iter() {
8072
vec!["a", "b", "c"],
8173
);
8274

83-
let v = vec![
84-
"a",
85-
"b",
86-
"c",
87-
];
75+
let v = vec!["a", "b", "c"];
8876

8977
assert_eq!(
9078
to_rust(&Array::from_iter(v.into_iter().map(|s| JsValue::from(s)))),

crates/macro-support/src/parser.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -1019,18 +1019,16 @@ impl MacroParse<()> for syn::ItemEnum {
10191019
attrs: _,
10201020
lit: syn::Lit::Int(int_lit),
10211021
}),
1022-
)) => {
1023-
match int_lit.base10_digits().parse::<u32>() {
1024-
Ok(v) => v,
1025-
Err(_) => {
1026-
bail_span!(
1027-
int_lit,
1028-
"enums with #[wasm_bindgen] can only support \
1029-
numbers that can be represented as u32"
1030-
);
1031-
}
1022+
)) => match int_lit.base10_digits().parse::<u32>() {
1023+
Ok(v) => v,
1024+
Err(_) => {
1025+
bail_span!(
1026+
int_lit,
1027+
"enums with #[wasm_bindgen] can only support \
1028+
numbers that can be represented as u32"
1029+
);
10321030
}
1033-
}
1031+
},
10341032
None => i as u32,
10351033
Some((_, expr)) => bail_span!(
10361034
expr,

crates/test/sample/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use js_sys::Promise;
2-
use std::task::{Poll, Context};
2+
use std::future::Future;
33
use std::pin::Pin;
4+
use std::task::{Context, Poll};
45
use std::time::Duration;
56
use wasm_bindgen::prelude::*;
6-
use std::future::Future;
77
use wasm_bindgen_futures::JsFuture;
88

99
pub struct Timeout {

crates/test/sample/tests/common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::time::Duration;
21
use sample::Timeout;
2+
use std::time::Duration;
33
use wasm_bindgen_test::*;
44

55
#[wasm_bindgen_test]

crates/web-sys/tests/wasm/html_element.rs

+47-9
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,58 @@ fn test_html_element() {
3333
element.set_hidden(true);
3434
assert!(element.hidden(), "Should be hidden");
3535

36-
assert_eq!(element.class_list().get(0), None, "Shouldn't have class at index 0");
36+
assert_eq!(
37+
element.class_list().get(0),
38+
None,
39+
"Shouldn't have class at index 0"
40+
);
3741
element.class_list().add_2("a", "b").unwrap();
38-
assert_eq!(element.class_list().get(0).unwrap(), "a", "Should have class at index 0");
39-
assert_eq!(element.class_list().get(1).unwrap(), "b", "Should have class at index 1");
40-
assert_eq!(element.class_list().get(2), None, "Shouldn't have class at index 2");
42+
assert_eq!(
43+
element.class_list().get(0).unwrap(),
44+
"a",
45+
"Should have class at index 0"
46+
);
47+
assert_eq!(
48+
element.class_list().get(1).unwrap(),
49+
"b",
50+
"Should have class at index 1"
51+
);
52+
assert_eq!(
53+
element.class_list().get(2),
54+
None,
55+
"Shouldn't have class at index 2"
56+
);
4157

4258
assert_eq!(element.dataset().get("id"), None, "Shouldn't have data-id");
4359
element.dataset().set("id", "123").unwrap();
44-
assert_eq!(element.dataset().get("id").unwrap(), "123", "Should have data-id");
60+
assert_eq!(
61+
element.dataset().get("id").unwrap(),
62+
"123",
63+
"Should have data-id"
64+
);
4565

46-
assert_eq!(element.style().get(0), None, "Shouldn't have style property name at index 0");
47-
element.style().set_property("background-color", "red").unwrap();
48-
assert_eq!(element.style().get(0).unwrap(), "background-color", "Should have style property at index 0");
49-
assert_eq!(element.style().get_property_value("background-color").unwrap(), "red", "Should have style property");
66+
assert_eq!(
67+
element.style().get(0),
68+
None,
69+
"Shouldn't have style property name at index 0"
70+
);
71+
element
72+
.style()
73+
.set_property("background-color", "red")
74+
.unwrap();
75+
assert_eq!(
76+
element.style().get(0).unwrap(),
77+
"background-color",
78+
"Should have style property at index 0"
79+
);
80+
assert_eq!(
81+
element
82+
.style()
83+
.get_property_value("background-color")
84+
.unwrap(),
85+
"red",
86+
"Should have style property"
87+
);
5088

5189
// TODO add a click handler here
5290
element.click();

crates/web-sys/tests/wasm/rtc_rtp_transceiver_direction.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,19 @@ async fn exchange_sdps(
6262
) -> (RtcPeerConnection, RtcPeerConnection) {
6363
let offer = JsFuture::from(p1.create_offer()).await.unwrap();
6464
let offer = offer.unchecked_into::<RtcSessionDescriptionInit>();
65-
JsFuture::from(p1.set_local_description(&offer)).await.unwrap();
66-
JsFuture::from(p2.set_remote_description(&offer)).await.unwrap();
65+
JsFuture::from(p1.set_local_description(&offer))
66+
.await
67+
.unwrap();
68+
JsFuture::from(p2.set_remote_description(&offer))
69+
.await
70+
.unwrap();
6771
let answer = JsFuture::from(p2.create_answer()).await.unwrap();
6872
let answer = answer.unchecked_into::<RtcSessionDescriptionInit>();
69-
JsFuture::from(p2.set_local_description(&answer)).await.unwrap();
70-
JsFuture::from(p1.set_remote_description(&answer)).await.unwrap();
73+
JsFuture::from(p2.set_local_description(&answer))
74+
.await
75+
.unwrap();
76+
JsFuture::from(p1.set_remote_description(&answer))
77+
.await
78+
.unwrap();
7179
(p1, p2)
7280
}

crates/webidl/src/util.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,13 @@ impl<'src> FirstPassRecord<'src> {
585585
// otherwise be marked with catch).
586586
match ret_ty {
587587
IdlType::Nullable(_) => ret_ty,
588-
ref ty @ _ => if catch {
589-
ret_ty
590-
} else {
591-
IdlType::Nullable(Box::new(ty.clone()))
592-
},
588+
ref ty @ _ => {
589+
if catch {
590+
ret_ty
591+
} else {
592+
IdlType::Nullable(Box::new(ty.clone()))
593+
}
594+
}
593595
}
594596
} else {
595597
ret_ty

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ pub fn function_table() -> JsValue {
820820

821821
#[doc(hidden)]
822822
pub mod __rt {
823+
use crate::JsValue;
823824
use core::cell::{Cell, UnsafeCell};
824825
use core::ops::{Deref, DerefMut};
825-
use crate::JsValue;
826826

827827
pub extern crate core;
828828
#[cfg(feature = "std")]

tests/wasm/futures.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ extern "C" {
88

99
#[wasm_bindgen_test]
1010
async fn smoke() {
11-
wasm_bindgen_futures::JsFuture::from(call_exports()).await.unwrap();
11+
wasm_bindgen_futures::JsFuture::from(call_exports())
12+
.await
13+
.unwrap();
1214
}
1315

1416
#[wasm_bindgen]

tests/wasm/simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use wasm_bindgen::prelude::*;
2-
use wasm_bindgen::{JsCast, intern, unintern};
2+
use wasm_bindgen::{intern, unintern, JsCast};
33
use wasm_bindgen_test::*;
44

55
#[wasm_bindgen(module = "tests/wasm/simple.js")]

0 commit comments

Comments
 (0)