Step one towards new type param kind syntax

Issue #1067

Needs a snapshot to finalize.
This commit is contained in:
Marijn Haverbeke
2011-10-25 14:31:56 +02:00
parent ea740a8bb0
commit 2884c722fe
4 changed files with 9 additions and 5 deletions

View File

@@ -1739,7 +1739,11 @@ fn parse_ty_param(p: parser) -> ast::ty_param {
alt p.peek() { alt p.peek() {
token::TILDE. { p.bump(); ast::kind_unique } token::TILDE. { p.bump(); ast::kind_unique }
token::AT. { p.bump(); ast::kind_shared } token::AT. { p.bump(); ast::kind_shared }
_ { ast::kind_pinned } _ {
if eat_word(p, "pinned") { ast::kind_pinned }
else if eat_word(p, "unique") { ast::kind_unique }
else { ast::kind_shared }
}
}; };
ret {ident: parse_ident(p), kind: k}; ret {ident: parse_ident(p), kind: k};
} }

View File

@@ -1193,8 +1193,8 @@ fn print_arg_mode(s: ps, m: ast::mode) {
fn print_kind(s: ps, kind: ast::kind) { fn print_kind(s: ps, kind: ast::kind) {
alt kind { alt kind {
ast::kind_unique. { word(s.s, "~"); } ast::kind_unique. { word_nbsp(s, "unique"); }
ast::kind_shared. { word(s.s, "@"); } ast::kind_pinned. { word_nbsp(s, "pinned"); }
_ {/* fallthrough */ } _ {/* fallthrough */ }
} }
} }

View File

@@ -4,7 +4,7 @@ resource r(i: @mutable int) {
*i = *i + 1; *i = *i + 1;
} }
fn movearg<T>(i: T) { fn movearg<pinned T>(i: T) {
// Implicit copy to mutate reference i // Implicit copy to mutate reference i
let j <- i; let j <- i;
} }

View File

@@ -5,7 +5,7 @@ type closable = @mutable bool;
resource close_res(i: closable) { *i = false; } resource close_res(i: closable) { *i = false; }
tag option<T> { none; some(T); } tag option<pinned T> { none; some(T); }
fn sink(res: option<close_res>) { } fn sink(res: option<close_res>) { }