Prevent conversion of empty tuples to unit structs

Fixes #1408
This commit is contained in:
Aaron Lobb 2017-03-24 23:58:34 -07:00
parent 488c0b9546
commit 548de69d2d
2 changed files with 59 additions and 47 deletions

View file

@ -260,8 +260,8 @@ fn rewrite_tuple_pat(pats: &[ptr::P<ast::Pat>],
}
if pat_vec.is_empty() {
path_str
} else {
return Some(format!("{}()", try_opt!(path_str)));
}
// add comma if `(x,)`
let add_comma = path_str.is_none() && pat_vec.len() == 1 && dotdot_pos.is_none();
@ -310,7 +310,6 @@ fn rewrite_tuple_pat(pats: &[ptr::P<ast::Pat>],
})
}
}
}
}
fn count_wildcard_suffix_len(items: &[ListItem]) -> usize {

View file

@ -0,0 +1,13 @@
enum TestEnum {
Arm1(),
Arm2,
}
fn foo() {
let test = TestEnum::Arm1;
match test {
TestEnum::Arm1() => {}
TestEnum::Arm2 => {}
}
}