about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2018-09-11 15:50:13 +1200
committerGitHub <noreply@github.com>2018-09-11 15:50:13 +1200
commit77824a24ef9ced4bcda52c5238e8c5b07d098e7b (patch)
treefa5c38e0b31f780a7dbfa15be3e6fd3ae5f93406 /src
parent29df2179b7b390d196c4db39db77a445ff73a05d (diff)
parent54f8bcb5a2c5aca77e4c941365e04582ba97f9a8 (diff)
Merge pull request #2988 from YaLTeR/fix-issue-2922
Use correct indent in rewrite_bare_fn with Visual style
Diffstat (limited to 'src')
-rw-r--r--src/types.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/types.rs b/src/types.rs
index 3ab639a1ac3..3a30f40a591 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -298,6 +298,8 @@ where
     <I as Iterator>::Item: Deref,
     <I::Item as Deref>::Target: Rewrite + Spanned + 'a,
 {
+    debug!("format_function_type {:#?}", shape);
+
     // Code for handling variadics is somewhat duplicated for items, but they
     // are different enough to need some serious refactoring to share code.
     enum ArgumentKind<T>
@@ -706,6 +708,8 @@ fn rewrite_bare_fn(
     context: &RewriteContext,
     shape: Shape,
 ) -> Option<String> {
+    debug!("rewrite_bare_fn {:#?}", shape);
+
     let mut result = String::with_capacity(128);
 
     if let Some(ref lifetime_str) = rewrite_lifetime_param(context, shape, &bare_fn.generic_params)
@@ -728,7 +732,11 @@ fn rewrite_bare_fn(
 
     result.push_str("fn");
 
-    let func_ty_shape = shape.offset_left(result.len())?;
+    let func_ty_shape = if context.use_block_indent() {
+        shape.offset_left(result.len())?
+    } else {
+        shape.visual_indent(result.len()).sub_width(result.len())?
+    };
 
     let rewrite = format_function_type(
         bare_fn.decl.inputs.iter(),