}
visitor.visit_block(block);
- if visitor.failed && shape.indent.alignment != 0 {
- block.rewrite(
- context,
- Shape::indented(shape.indent.block_only(), context.config),
- )
- } else {
- Some(format!("{}{}", prefix, visitor.buffer))
- }
+ Some(format!("{}{}", prefix, visitor.buffer))
}
impl Rewrite for ast::Block {
one_line_width,
args_max_width,
force_trailing_comma,
- ).or_else(|| if context.use_block_indent() {
- rewrite_call_args(
- context,
- args,
- args_span,
- Shape::indented(
- shape.block().indent.block_indent(context.config),
- context.config,
- ),
- 0,
- 0,
- force_trailing_comma,
- )
- } else {
- None
- })
- .ok_or(Ordering::Less)?;
+ ).ok_or(Ordering::Less)?;
if !context.use_block_indent() && need_block_indent(&list_str, nested_shape) && !extendable {
let mut new_context = context.clone();
// FIXME: use an RAII util or closure for indenting
pub block_indent: Indent,
pub config: &'a Config,
- pub failed: bool,
pub is_if_else_block: bool,
}
fn push_rewrite(&mut self, span: Span, rewrite: Option<String>) {
self.format_missing_with_indent(source!(self, span).lo);
- self.failed = match rewrite {
- Some(ref s)
- if s.rewrite(
- &self.get_context(),
- Shape::indented(self.block_indent, self.config),
- ).is_none() =>
- {
- true
- }
- None => true,
- _ => self.failed,
- };
let result = rewrite.unwrap_or_else(|| self.snippet(span));
self.buffer.push_str(&result);
self.last_pos = source!(self, span).hi;
last_pos: BytePos(0),
block_indent: Indent::empty(),
config: config,
- failed: false,
is_if_else_block: false,
}
}