From b3fa50db7320aa23e94ec15d774ad47c856757b5 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Wed, 7 Mar 2018 10:51:28 +0900 Subject: [PATCH] Use nested_shape for indenting types of lazy_static --- src/macros.rs | 2 +- tests/source/lazy_static.rs | 8 ++++++++ tests/target/lazy_static.rs | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/macros.rs b/src/macros.rs index e7238a314fc..6be6a1f2664 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -916,7 +916,7 @@ fn format_lazy_static(context: &RewriteContext, shape: Shape, ts: &TokenStream) "{}static ref {}: {} =", vis, id, - ty.rewrite(context, shape)? + ty.rewrite(context, nested_shape)? )); result.push_str(&::expr::rewrite_assign_rhs( context, diff --git a/tests/source/lazy_static.rs b/tests/source/lazy_static.rs index c1c74fb8307..38fefbcbef5 100644 --- a/tests/source/lazy_static.rs +++ b/tests/source/lazy_static.rs @@ -35,3 +35,11 @@ let ptr = :: remacs_sys :: xmalloc ( remacs_sys :: Lisp_Subr ; :: std :: ptr :: copy_nonoverlapping ( & subr , ptr , 1 ) ; :: std :: mem :: forget ( subr ) ; :: lisp :: ExternalPtr :: new ( ptr ) } } ; } + + +lazy_static! { +static ref FOO: HashMap Result, Either> +),> = HashMap::new(); +} diff --git a/tests/target/lazy_static.rs b/tests/target/lazy_static.rs index edce6e7b894..0aed6d38ccf 100644 --- a/tests/target/lazy_static.rs +++ b/tests/target/lazy_static.rs @@ -37,3 +37,13 @@ lazy_static! { } }; } + +lazy_static! { + static ref FOO: HashMap< + String, + ( + &'static str, + fn(Foo) -> Result, Either> + ), + > = HashMap::new(); +}