- // Format macro invocation as array literal.
- let extra_offset = macro_name.len();
- let shape = try_opt!(shape.shrink_left(extra_offset));
- let rewrite =
- try_opt!(rewrite_array(expr_vec.iter().map(|x| &**x),
- mk_sp(context.codemap.span_after(mac.span,
- original_style.opener()),
- mac.span.hi - BytePos(1)),
- context,
- shape));
-
- Some(format!("{}{}", macro_name, rewrite))
+ let mac_shape = try_opt!(shape.shrink_left(macro_name.len()));
+ // Handle special case: `vec![expr; expr]`
+ if vec_with_semi {
+ let (lbr, rbr) = if context.config.spaces_within_square_brackets {
+ ("[ ", " ]")
+ } else {
+ ("[", "]")
+ };
+ rewrite_pair(&*expr_vec[0],
+ &*expr_vec[1],
+ lbr,
+ "; ",
+ rbr,
+ context,
+ mac_shape)
+ .map(|s| format!("{}{}", macro_name, s))
+ } else {
+ // Format macro invocation as array literal.
+ let rewrite =
+ try_opt!(rewrite_array(expr_vec.iter().map(|x| &**x),
+ mk_sp(context.codemap.span_after(mac.span,
+ original_style
+ .opener()),
+ mac.span.hi - BytePos(1)),
+ context,
+ mac_shape));
+
+ Some(format!("{}{}", macro_name, rewrite))
+ }