1
Fork 0

Split ast::PatKind::Enum into tuple struct and path patterns

This commit is contained in:
Vadim Petrochenkov 2016-02-13 15:51:27 +03:00
parent 14adc9bb63
commit 9f414a44a7
8 changed files with 47 additions and 26 deletions

View file

@ -827,7 +827,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.pat(span, pat)
}
fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
let pat = PatKind::Enum(path, Some(subpats));
let pat = if subpats.is_empty() {
PatKind::Path(path)
} else {
PatKind::TupleStruct(path, Some(subpats))
};
self.pat(span, pat)
}
fn pat_struct(&self, span: Span,