diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-12-28 17:50:12 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-12-28 21:18:16 +0100 |
| commit | 1ed6a275487607b71716a4d8ec4cac58cd803c1f (patch) | |
| tree | c58f05a60a423ed141071ea2cb16765a3ead5b2c /src/comp/syntax/parse | |
| parent | 5930463faa07ce95268b6011db37c5be183f9f10 (diff) | |
Change representation of type params to handle interface bounds
Issue #1227
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 978b976eb03..b681f713422 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1718,10 +1718,18 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk { } fn parse_ty_param(p: parser) -> ast::ty_param { - let k = if eat_word(p, "send") { ast::kind_sendable } - else if eat_word(p, "copy") { ast::kind_copyable } - else { ast::kind_noncopyable }; - ret {ident: parse_ident(p), kind: k}; + let bounds = []; + if eat_word(p, "send") { bounds += [ast::bound_send]; } + else if eat_word(p, "copy") { bounds += [ast::bound_copy]; } + let ident = parse_ident(p); + if eat(p, token::COLON) { + while p.peek() != token::COMMA && p.peek() != token::GT { + if eat_word(p, "send") { bounds += [ast::bound_send]; } + else if eat_word(p, "copy") { bounds += [ast::bound_copy]; } + else { bounds += [ast::bound_iface(parse_ty(p, false))]; } + } + } + ret {ident: ident, id: p.get_id(), bounds: @bounds}; } fn parse_ty_params(p: parser) -> [ast::ty_param] { @@ -1856,7 +1864,8 @@ fn parse_item_impl(p: parser, attrs: [ast::attribute]) -> @ast::item { ast::ty_path(pt, _) { if vec::len(pt.node.idents) == 1u && vec::len(pt.node.types) == 0u { - ret {ident: pt.node.idents[0], kind: ast::kind_sendable}; + ret {ident: pt.node.idents[0], id: p.get_id(), + bounds: @[]}; } } _ {} |
