Skip to content

Commit 82bde8d

Browse files
committed
Format with rustfmt 2019-03-27
1 parent 465392b commit 82bde8d

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

serde_derive/src/de.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream
6161
}
6262
};
6363

64-
Ok(dummy::wrap_in_const(cont.attrs.custom_serde_path(), "DESERIALIZE", ident, impl_block))
64+
Ok(dummy::wrap_in_const(
65+
cont.attrs.custom_serde_path(),
66+
"DESERIALIZE",
67+
ident,
68+
impl_block,
69+
))
6570
}
6671

6772
fn precondition(cx: &Ctxt, cont: &Container) {

serde_derive/src/dummy.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@ use proc_macro2::{Ident, Span, TokenStream};
33
use syn;
44
use try;
55

6-
pub fn wrap_in_const(serde_path: Option<&syn::Path>, trait_: &str, ty: &Ident, code: TokenStream) -> TokenStream {
6+
pub fn wrap_in_const(
7+
serde_path: Option<&syn::Path>,
8+
trait_: &str,
9+
ty: &Ident,
10+
code: TokenStream,
11+
) -> TokenStream {
712
let try_replacement = try::replacement();
813

914
let dummy_const = Ident::new(
1015
&format!("_IMPL_{}_FOR_{}", trait_, unraw(ty)),
1116
Span::call_site(),
1217
);
1318

14-
let use_serde = serde_path.map(|path| {
15-
quote!(use #path as _serde;)
16-
}).unwrap_or_else(|| {
17-
quote! {
18-
#[allow(unknown_lints)]
19-
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
20-
#[allow(rust_2018_idioms)]
21-
extern crate serde as _serde;
22-
}
23-
});
19+
let use_serde = serde_path
20+
.map(|path| {
21+
quote! {
22+
use #path as _serde;
23+
}
24+
})
25+
.unwrap_or_else(|| {
26+
quote! {
27+
#[allow(unknown_lints)]
28+
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
29+
#[allow(rust_2018_idioms)]
30+
extern crate serde as _serde;
31+
}
32+
});
2433

2534
quote! {
2635
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]

serde_derive/src/ser.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<TokenStream,
5252
}
5353
};
5454

55-
Ok(dummy::wrap_in_const(cont.attrs.custom_serde_path(), "SERIALIZE", ident, impl_block))
55+
Ok(dummy::wrap_in_const(
56+
cont.attrs.custom_serde_path(),
57+
"SERIALIZE",
58+
ident,
59+
impl_block,
60+
))
5661
}
5762

5863
fn precondition(cx: &Ctxt, cont: &Container) {

test_suite/tests/test_gen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn test_gen() {
265265
#[cfg(feature = "unstable")]
266266
#[derive(Serialize, Deserialize)]
267267
struct NonAsciiIdents {
268-
σ: f64,
268+
σ: f64,
269269
}
270270

271271
#[derive(Serialize, Deserialize)]

test_suite/tests/test_serde_path.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ mod fake_serde {
1919
where
2020
T: Serialize,
2121
T: for<'a> Deserialize<'a>,
22-
{}
22+
{
23+
}
2324

2425
pub trait Serialize {
2526
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>;

0 commit comments

Comments
 (0)