]> git.lizzy.rs Git - rust.git/blobdiff - src/types.rs
Remove BlockIndentStyle::Inherit
[rust.git] / src / types.rs
index 574def6d7c47331d17d118e311886f9fe1149acf..0162ac851f3833b73d5de3ce1e15842edbb88f36 100644 (file)
@@ -87,8 +87,6 @@ pub fn rewrite_path(context: &RewriteContext,
         span_lo = qself.ty.span.hi + BytePos(1);
     }
 
-    let extra_offset = extra_offset(&result, shape);
-    let shape = try_opt!(shape.shrink_left(extra_offset));
     rewrite_path_segments(path_context,
                           result,
                           path.segments.iter().skip(skip_count),
@@ -160,12 +158,15 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
             SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
             SegmentParam::Type(ty) => ty.rewrite(context, shape),
             SegmentParam::Binding(binding) => {
-                let mut result = format!("{} = ", binding.ident);
+                let mut result = match context.config.type_punctuation_density {
+                    TypeDensity::Wide => format!("{} = ", binding.ident),
+                    TypeDensity::Compressed => format!("{}=", binding.ident),
+                };
                 let budget = try_opt!(shape.width.checked_sub(result.len()));
-                let rewrite =
-                    try_opt!(binding.ty
-                                 .rewrite(context,
-                                          Shape::legacy(budget, shape.indent + result.len())));
+                let rewrite = try_opt!(binding.ty.rewrite(context,
+                                                          Shape::legacy(budget,
+                                                                        shape.indent +
+                                                                        result.len())));
                 result.push_str(&rewrite);
                 Some(result)
             }
@@ -205,7 +206,10 @@ fn rewrite_segment(path_context: PathContext,
                     .chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
                     .collect::<Vec<_>>();
 
-                let next_span_lo = param_list.last().unwrap().get_span().hi + BytePos(1);
+                let next_span_lo = param_list.last()
+                    .unwrap()
+                    .get_span()
+                    .hi + BytePos(1);
                 let list_lo = context.codemap.span_after(codemap::mk_sp(*span_lo, span_hi), "<");
                 let separator = if path_context == PathContext::Expr {
                     "::"
@@ -442,9 +446,8 @@ fn rewrite_bounded_lifetime<'b, I>(lt: &ast::Lifetime,
     if bounds.len() == 0 {
         Some(result)
     } else {
-        let appendix: Vec<_> = try_opt!(bounds.into_iter()
-                                            .map(|b| b.rewrite(context, shape))
-                                            .collect());
+        let appendix: Vec<_> =
+            try_opt!(bounds.into_iter().map(|b| b.rewrite(context, shape)).collect());
         let colon = type_bound_colon(context);
         let result = format!("{}{}{}", result, colon, appendix.join(" + "));
         wrap_str(result, context.config.max_width, shape)
@@ -482,9 +485,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
             TypeDensity::Compressed => "+",
             TypeDensity::Wide => " + ",
         };
-        let strs: Vec<_> = try_opt!(self.iter()
-                                        .map(|b| b.rewrite(context, shape))
-                                        .collect());
+        let strs: Vec<_> = try_opt!(self.iter().map(|b| b.rewrite(context, shape)).collect());
         wrap_str(strs.join(joiner), context.config.max_width, shape)
     }
 }
@@ -540,10 +541,10 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
             // 6 is "for<> ".len()
             let extra_offset = lifetime_str.len() + 6;
             let max_path_width = try_opt!(shape.width.checked_sub(extra_offset));
-            let path_str = try_opt!(self.trait_ref
-                                        .rewrite(context,
-                                                 Shape::legacy(max_path_width,
-                                                               shape.indent + extra_offset)));
+            let path_str = try_opt!(self.trait_ref.rewrite(context,
+                                                           Shape::legacy(max_path_width,
+                                                                         shape.indent +
+                                                                         extra_offset)));
 
             Some(if context.config.spaces_within_angle_brackets && lifetime_str.len() > 0 {
                      format!("for< {} > {}", lifetime_str, path_str)
@@ -589,11 +590,10 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                     format!("&{} {}{}",
                             lt_str,
                             mut_str,
-                            try_opt!(mt.ty
-                                         .rewrite(context,
-                                                  Shape::legacy(budget,
-                                                                shape.indent + 2 + mut_len +
-                                                                lt_len))))
+                            try_opt!(mt.ty.rewrite(context,
+                                                   Shape::legacy(budget,
+                                                                 shape.indent + 2 + mut_len +
+                                                                 lt_len))))
                 }
                          None => {
                     let budget = try_opt!(shape.width.checked_sub(1 + mut_len));
@@ -675,9 +675,9 @@ fn rewrite_bare_fn(bare_fn: &ast::BareFnTy,
         result.push_str(&try_opt!(bare_fn.lifetimes
                                       .iter()
                                       .map(|l| {
-            l.rewrite(context,
+                                               l.rewrite(context,
                       Shape::legacy(try_opt!(shape.width.checked_sub(6)), shape.indent + 4))
-        })
+                                           })
                                       .intersperse(Some(", ".to_string()))
                                       .collect::<Option<String>>()));
         result.push_str("> ");