Use rewrite_assign_rhs when rewriting unit variant

This commit is contained in:
topecongiro 2017-10-25 01:08:32 +09:00
parent 560b054147
commit a67b8b0bbb
3 changed files with 14 additions and 15 deletions

View File

@ -537,21 +537,9 @@ impl<'a> FmtVisitor<'a> {
)?
}
ast::VariantData::Unit(..) => if let Some(ref expr) = field.node.disr_expr {
let one_line_width =
field.node.name.to_string().len() + self.snippet(expr.span).len() + 3;
if one_line_width <= shape.width {
format!("{} = {}", field.node.name, self.snippet(expr.span))
} else {
format!(
"{}\n{}{}",
field.node.name,
shape
.indent
.block_indent(self.config)
.to_string(self.config),
self.snippet(expr.span)
)
}
let lhs = format!("{} =", field.node.name);
// 1 = ','
rewrite_assign_rhs(&context, lhs, expr, shape.sub_width(1)?)?
} else {
String::from(field.node.name.to_string())
},

View File

@ -136,3 +136,8 @@ pub enum Entry<'a, K: 'a, V: 'a> {
OccupiedEntry<'a, K, V>,
),
}
// #2081
pub enum ForegroundColor {
CYAN = (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
}

View File

@ -173,3 +173,9 @@ pub enum Entry<'a, K: 'a, V: 'a> {
Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
}
// #2081
pub enum ForegroundColor {
CYAN =
(winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
}