From 7a0aee74bf15446a235830c0ea7a32ac1ea765a4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 28 Oct 2011 15:09:12 +0200 Subject: [PATCH] Move to short type parameter keywords Issue #1076 --- src/comp/middle/kind.rs | 4 ++-- src/comp/syntax/parse/parser.rs | 10 +++++----- src/comp/syntax/print/pprust.rs | 4 ++-- src/lib/comm.rs | 20 ++++++++++---------- src/lib/task.rs | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 149e463c111d..e76c95b6560c 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -26,9 +26,9 @@ * * Since this forms a lattice, we denote the capabilites in terms of a * worst-case requirement. That is, if your function needs to move-and-send (or -* copy) your T, you write fn(...). If you need to move but not send, +* copy) your T, you write fn(...). If you need to move but not send, * you write fn(...). And if you need neither -- can work with any sort of -* pinned data at all -- then you write fn(...). +* pinned data at all -- then you write fn(...). * * Most types are unique or shared. Other possible name combinations for these * two: (tree, graph; pruned, pooled; message, local; owned, common) are diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index ee308c55af54..9c33901741a6 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1735,11 +1735,11 @@ 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, "pinned") || eat_word(p, "pin") { - ast::kind_pinned - } else if eat_word(p, "unique") || eat_word(p, "uniq") { - ast::kind_unique - } else { eat_word(p, "shar"); ast::kind_shared }; + let k = if eat_word(p, "pin") { ast::kind_pinned } + else if eat_word(p, "uniq") { ast::kind_unique } + else if eat_word(p, "shar") { ast::kind_shared } + // FIXME distinguish implied shared from explicit + else { ast::kind_shared }; ret {ident: parse_ident(p), kind: k}; } diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index e95ce36252f8..f30688f7ee5a 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1193,8 +1193,8 @@ fn print_arg_mode(s: ps, m: ast::mode) { fn print_kind(s: ps, kind: ast::kind) { alt kind { - ast::kind_unique. { word_nbsp(s, "unique"); } - ast::kind_pinned. { word_nbsp(s, "pinned"); } + ast::kind_unique. { word_nbsp(s, "uniq"); } + ast::kind_pinned. { word_nbsp(s, "pin"); } _ {/* fallthrough */ } } } diff --git a/src/lib/comm.rs b/src/lib/comm.rs index f6d150bc295c..7599bb241857 100644 --- a/src/lib/comm.rs +++ b/src/lib/comm.rs @@ -41,9 +41,9 @@ native "c-stack-cdecl" mod rustrt { type void; type rust_port; - fn chan_id_send(t: *sys::type_desc, - target_task: task::task, target_port: port_id, - -data: T); + fn chan_id_send(t: *sys::type_desc, + target_task: task::task, target_port: port_id, + -data: T); fn new_port(unit_sz: uint) -> *rust_port; fn del_port(po: *rust_port); @@ -52,7 +52,7 @@ native "c-stack-cdecl" mod rustrt { } native "rust-intrinsic" mod rusti { - fn recv(port: *rustrt::rust_port) -> T; + fn recv(port: *rustrt::rust_port) -> T; } type port_id = int; @@ -75,7 +75,7 @@ dropped. Channels may be duplicated and themselves transmitted over other channels. */ -tag chan { +tag chan { chan_t(task::task, port_id); } @@ -95,7 +95,7 @@ transmitted. If a port value is copied, both copies refer to the same port. Ports may be associated with multiple s. */ -tag port { port_t(@port_ptr); } +tag port { port_t(@port_ptr); } /* Function: send @@ -105,7 +105,7 @@ Sends data over a channel. The sent data is moved into the channel, whereupon the caller loses access to it. */ -fn send(ch: chan, -data: T) { +fn send(ch: chan, -data: T) { let chan_t(t, p) = ch; rustrt::chan_id_send(sys::get_type_desc::(), t, p, data); task::yield(); @@ -116,7 +116,7 @@ Function: port Constructs a port. */ -fn port() -> port { +fn port() -> port { port_t(@port_ptr(rustrt::new_port(sys::size_of::()))) } @@ -128,7 +128,7 @@ Receive from a port. If no data is available on the port then the task will block until data becomes available. */ -fn recv(p: port) -> T { ret rusti::recv(***p) } +fn recv(p: port) -> T { ret rusti::recv(***p) } /* Function: chan @@ -137,6 +137,6 @@ Constructs a channel. The channel is bound to the port used to construct it. */ -fn chan(p: port) -> chan { +fn chan(p: port) -> chan { chan_t(task::get_task(), rustrt::get_port_id(***p)) } diff --git a/src/lib/task.rs b/src/lib/task.rs index 415856847204..1b5ebb999cfa 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -228,7 +228,7 @@ Returns: A handle to the new task */ -fn spawn(-data: T, f: fn(T)) -> task { +fn spawn(-data: T, f: fn(T)) -> task { spawn_inner(data, f, none) } @@ -241,7 +241,7 @@ termination Immediately before termination, either on success or failure, the spawned task will send a message on the provided channel. */ -fn spawn_notify(-data: T, f: fn(T), +fn spawn_notify(-data: T, f: fn(T), notify: comm::chan) -> task { spawn_inner(data, f, some(notify)) } @@ -255,7 +255,7 @@ This is a convenience wrapper around spawn_notify which, when paired with can be easily used to spawn a task then wait for it to complete. */ -fn spawn_joinable(-data: T, f: fn(T)) -> joinable_task { +fn spawn_joinable(-data: T, f: fn(T)) -> joinable_task { let p = comm::port::(); let id = spawn_notify(data, f, comm::chan::(p)); ret (id, p); @@ -271,11 +271,11 @@ fn spawn_joinable(-data: T, f: fn(T)) -> joinable_task { // // After the transition this should all be rewritten. -fn spawn_inner(-data: T, f: fn(T), +fn spawn_inner(-data: T, f: fn(T), notify: option>) -> task { - fn wrapper(-data: *u8, f: fn(T)) { + fn wrapper(-data: *u8, f: fn(T)) { let data: ~T = unsafe::reinterpret_cast(data); f(*data); }