Skip to content

Commit 91d83f5

Browse files
committed
rustc: Accept <T> for type parameters in type and item declarations
1 parent 3fd3f35 commit 91d83f5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,18 @@ fn parse_type_constraints(p: &parser) -> [@ast::ty_constr] {
423423

424424
fn parse_ty_postfix(orig_t: ast::ty_, p: &parser) -> @ast::ty {
425425
let lo = p.get_lo_pos();
426-
if p.peek() == token::LBRACKET {
426+
if p.peek() == token::LBRACKET || p.peek() == token::LT {
427+
let end;
428+
if p.peek() == token::LBRACKET {
429+
end = token::RBRACKET;
430+
} else {
431+
end = token::GT;
432+
}
433+
427434
// This is explicit type parameter instantiation.
428435
p.bump();
429436

430-
let seq =
431-
parse_seq_to_end(token::RBRACKET, some(token::COMMA),
432-
parse_ty, p);
437+
let seq = parse_seq_to_end(end, some(token::COMMA), parse_ty, p);
433438

434439
alt orig_t {
435440
ast::ty_path(pth, ann) {
@@ -1725,6 +1730,11 @@ fn parse_ty_params(p: &parser) -> [ast::ty_param] {
17251730
parse_seq(token::LBRACKET, token::RBRACKET, some(token::COMMA),
17261731
parse_ty_param, p).node;
17271732
}
1733+
if p.peek() == token::LT {
1734+
ty_params =
1735+
parse_seq(token::LT, token::GT, some(token::COMMA),
1736+
parse_ty_param, p).node;
1737+
}
17281738
ret ty_params;
17291739
}
17301740

0 commit comments

Comments
 (0)