From aa284de1fc246b55fb53783ded3e9786e04b03d0 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 18 Feb 2013 17:45:56 -0800 Subject: rustc: For one-tuples, make parsing and printing the type work and add a test to reflect-visit-data --- src/libsyntax/parse/parser.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b5c68d6715e..a9b455c3304 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -576,12 +576,21 @@ pub impl Parser { self.bump(); ty_nil } else { + // (t) is a parenthesized ty + // (t,) is the type of a tuple with only one field, + // of type t let mut ts = ~[self.parse_ty(false)]; + let mut one_tuple = false; while self.token == token::COMMA { self.bump(); - ts.push(self.parse_ty(false)); + if self.token != token::RPAREN { + ts.push(self.parse_ty(false)); + } + else { + one_tuple = true; + } } - let t = if vec::len(ts) == 1u { ts[0].node } + let t = if ts.len() == 1 && !one_tuple { ts[0].node } else { ty_tup(ts) }; self.expect(token::RPAREN); t -- cgit 1.4.1-3-g733a5