From 9df1509d1913865303844728de1b24d4495e9a4f Mon Sep 17 00:00:00 2001 From: topecongiro Date: Mon, 12 Jun 2017 17:25:07 +0900 Subject: [PATCH] Use rewrite instead of visitor for attributes --- src/expr.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index aa5913e5f0f..e6889991b07 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1321,20 +1321,13 @@ impl Rewrite for ast::Arm { ref body, } = self; - // FIXME this is all a bit grotty, would be nice to abstract out the - // treatment of attributes. let attr_str = if !attrs.is_empty() { - // We only use this visitor for the attributes, should we use it for - // more? - let mut attr_visitor = FmtVisitor::from_codemap(context.parse_session, context.config); - attr_visitor.block_indent = shape.indent.block_only(); - attr_visitor.last_pos = attrs[0].span.lo; - if attr_visitor.visit_attrs(attrs) { - // Attributes included a skip instruction. + if contains_skip(attrs) { return None; } - attr_visitor.format_missing(pats[0].span.lo); - attr_visitor.buffer.to_string() + format!("{}\n{}", + try_opt!(attrs.rewrite(context, shape)), + shape.indent.to_string(context.config)) } else { String::new() };