Merge pull request #379 from marcusklaas/enum-quik-fix

Fix variant name duplication on rewrite failure
This commit is contained in:
Nick Cameron 2015-09-28 07:51:09 +13:00
commit 9139a8040c
2 changed files with 7 additions and 9 deletions

View File

@ -606,10 +606,7 @@ impl<'a> FmtVisitor<'a> {
let result = match field.node.kind {
ast::VariantKind::TupleVariantKind(ref types) => {
let name = field.node.name.to_string();
self.buffer.push_str(&name);
let mut result = String::new();
let mut result = field.node.name.to_string();
if !types.is_empty() {
let items = itemize_list(self.codemap,
@ -662,11 +659,6 @@ impl<'a> FmtVisitor<'a> {
result.push_str(" = ");
let expr_snippet = self.snippet(expr.span);
result.push_str(&expr_snippet);
// Make sure we do not exceed column limit
assert!(self.config.max_width >=
name.len() + expr_snippet.len() + " = ,".len(),
"Enum variant exceeded column limit");
}
result

View File

@ -45,3 +45,9 @@ enum StructLikeVariants {
a: A,
},
}
enum X {
CreateWebGLPaintTask(Size2D<i32>,
GLContextAttributes,
IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>),
}