Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit ba173b5

Browse files
committed
cargo-fmt
1 parent 021ebed commit ba173b5

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

failure_derive/src/lib.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,33 @@ fn fail_derive(s: synstructure::Structure) -> TokenStream {
3333
}
3434
});
3535

36-
let fail = s.unbound_impl(quote!(::failure::Fail), quote! {
37-
#[allow(unreachable_code)]
38-
fn cause(&self) -> ::failure::_core::option::Option<#make_dyn(::failure::Fail)> {
39-
match *self { #cause_body }
40-
None
41-
}
36+
let fail = s.unbound_impl(
37+
quote!(::failure::Fail),
38+
quote! {
39+
#[allow(unreachable_code)]
40+
fn cause(&self) -> ::failure::_core::option::Option<#make_dyn(::failure::Fail)> {
41+
match *self { #cause_body }
42+
None
43+
}
4244

43-
#[allow(unreachable_code)]
44-
fn backtrace(&self) -> ::failure::_core::option::Option<&::failure::Backtrace> {
45-
match *self { #bt_body }
46-
None
47-
}
48-
});
49-
let display = display_body(&s).map(|display_body| {
50-
s.unbound_impl(quote!(::failure::_core::fmt::Display), quote! {
5145
#[allow(unreachable_code)]
52-
fn fmt(&self, f: &mut ::failure::_core::fmt::Formatter) -> ::failure::_core::fmt::Result {
53-
match *self { #display_body }
54-
write!(f, "An error has occurred.")
46+
fn backtrace(&self) -> ::failure::_core::option::Option<&::failure::Backtrace> {
47+
match *self { #bt_body }
48+
None
5549
}
56-
})
50+
},
51+
);
52+
let display = display_body(&s).map(|display_body| {
53+
s.unbound_impl(
54+
quote!(::failure::_core::fmt::Display),
55+
quote! {
56+
#[allow(unreachable_code)]
57+
fn fmt(&self, f: &mut ::failure::_core::fmt::Formatter) -> ::failure::_core::fmt::Result {
58+
match *self { #display_body }
59+
write!(f, "An error has occurred.")
60+
}
61+
},
62+
)
5763
});
5864

5965
(quote! {

failure_derive/tests/custom_type_bounds.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#[macro_use] extern crate failure;
1+
#[macro_use]
2+
extern crate failure;
23

34
use std::fmt::Debug;
45

@@ -37,5 +38,8 @@ pub struct CustomBoundsGenericTupleError<T: NoDisplay>(T);
3738
fn custom_bounds_generic_tuple_error() {
3839
let error = CustomBoundsGenericTupleError("more details unavailable.");
3940
let s = format!("{}", error);
40-
assert_eq!(&s[..], "An error has occurred: \"more details unavailable.\"");
41+
assert_eq!(
42+
&s[..],
43+
"An error has occurred: \"more details unavailable.\""
44+
);
4145
}

0 commit comments

Comments
 (0)