Use rewrite instead of visitor for attributes
This commit is contained in:
parent
272b0b6f49
commit
9df1509d19
1 changed files with 4 additions and 11 deletions
15
src/expr.rs
15
src/expr.rs
|
@ -1321,20 +1321,13 @@ impl Rewrite for ast::Arm {
|
||||||
ref body,
|
ref body,
|
||||||
} = self;
|
} = 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() {
|
let attr_str = if !attrs.is_empty() {
|
||||||
// We only use this visitor for the attributes, should we use it for
|
if contains_skip(attrs) {
|
||||||
// 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.
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
attr_visitor.format_missing(pats[0].span.lo);
|
format!("{}\n{}",
|
||||||
attr_visitor.buffer.to_string()
|
try_opt!(attrs.rewrite(context, shape)),
|
||||||
|
shape.indent.to_string(context.config))
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue