Skip to content

Commit cfdf193

Browse files
committed
Update our code to new type parameter kind syntax
Closes #1067
1 parent 58c82a8 commit cfdf193

File tree

94 files changed

+289
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+289
-288
lines changed

src/comp/driver/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str)
8888
ret {crate: crate, src: src};
8989
}
9090

91-
fn time<@T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
91+
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
9292
if !do_it { ret thunk(); }
9393
let start = std::time::precise_time_s();
9494
let rv = thunk();

src/comp/front/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn require_unique_names(sess: session::session, metas: [@ast::meta_item]) {
182182
}
183183
}
184184

185-
fn span<@T>(item: T) -> ast::spanned<T> {
185+
fn span<T>(item: T) -> ast::spanned<T> {
186186
ret {node: item, span: ast_util::dummy_sp()};
187187
}
188188

src/comp/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
180180
ret @item;
181181
}
182182

183-
fn nospan<@T>(t: T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; }
183+
fn nospan<T>(t: T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; }
184184

185185
fn mk_tests(cx: test_ctxt) -> @ast::item {
186186
let ret_ty = mk_test_desc_vec_ty(cx);

src/comp/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer) ->
391391

392392
// Path and definition ID indexing
393393

394-
fn create_index<@T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
394+
fn create_index<T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
395395
[@[entry<T>]] {
396396
let buckets: [@mutable [entry<T>]] = [];
397397
uint::range(0u, 256u) {|_i| buckets += [@mutable []]; };

src/comp/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
150150
}
151151
}
152152

153-
fn parse_constr<@T>(st: @pstate, sd: str_def, pser: arg_parser<T>) ->
153+
fn parse_constr<T>(st: @pstate, sd: str_def, pser: arg_parser<T>) ->
154154
@ty::constr_general<T> {
155155
let sp = ast_util::dummy_sp(); // FIXME: use a real span
156156
let args: [@sp_constr_arg<T>] = [];

src/comp/middle/ast_map.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn map_expr(cx: ctx, ex: @expr) {
7575
cx.map.insert(ex.id, node_expr(ex));
7676
}
7777

78-
fn new_smallintmap_int_adapter<@V>() -> std::map::hashmap<int, V> {
78+
fn new_smallintmap_int_adapter<V>() -> std::map::hashmap<int, V> {
7979
let key_idx = fn (&&key: int) -> uint { key as uint };
8080
let idx_key = fn (idx: uint) -> int { idx as int };
8181
ret new_smallintmap_adapter(key_idx, idx_key);
@@ -86,13 +86,13 @@ fn new_smallintmap_int_adapter<@V>() -> std::map::hashmap<int, V> {
8686
// the entire codebase adapting all the callsites to the different
8787
// interface.
8888
// FIXME: hashmap and smallintmap should support the same interface.
89-
fn new_smallintmap_adapter<@K, @V>(key_idx: fn(K) -> uint,
89+
fn new_smallintmap_adapter<K, V>(key_idx: fn(K) -> uint,
9090
idx_key: fn(uint) -> K)
9191
-> std::map::hashmap<K, V> {
9292

93-
obj adapter<@K, @V>(map: smallintmap::smallintmap<V>,
94-
key_idx: fn(K) -> uint,
95-
idx_key: fn(uint) -> K) {
93+
obj adapter<K, V>(map: smallintmap::smallintmap<V>,
94+
key_idx: fn(K) -> uint,
95+
idx_key: fn(uint) -> K) {
9696

9797
fn size() -> uint { fail }
9898

src/comp/middle/kind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
*
2626
*
2727
* Since this forms a lattice, we denote the capabilites in terms of a
28-
* worst-case requirement. That is, if your function needs to move-and-send
29-
* (or copy) your T, you write fn<~T>(...). If you need to move but not send,
30-
* you write fn<@T>(...). And if you need neither -- can work with any sort of
31-
* pinned data at all -- then you write fn<T>(...).
28+
* worst-case requirement. That is, if your function needs to move-and-send (or
29+
* copy) your T, you write fn<unique T>(...). If you need to move but not send,
30+
* you write fn<T>(...). And if you need neither -- can work with any sort of
31+
* pinned data at all -- then you write fn<pinned T>(...).
3232
*
3333
* Most types are unique or shared. Other possible name combinations for these
3434
* two: (tree, graph; pruned, pooled; message, local; owned, common) are

src/comp/syntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import std::{str, option};
22
import codemap::span;
33
import ast::*;
44

5-
fn respan<@T>(sp: span, t: T) -> spanned<T> { ret {node: t, span: sp}; }
5+
fn respan<T>(sp: span, t: T) -> spanned<T> { ret {node: t, span: sp}; }
66

77
/* assuming that we're not in macro expansion */
88
fn mk_sp(lo: uint, hi: uint) -> span {
@@ -186,7 +186,7 @@ fn eq_def_id(&&a: def_id, &&b: def_id) -> bool {
186186
a == b
187187
}
188188

189-
fn new_def_id_hash<@T>() -> std::map::hashmap<def_id, T> {
189+
fn new_def_id_hash<T>() -> std::map::hashmap<def_id, T> {
190190
std::map::mk_hashmap(hash_def_id, eq_def_id)
191191
}
192192

src/comp/syntax/ext/simplext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
104104
}
105105
}
106106

107-
fn option_flatten_map<T, @U>(f: fn@(T) -> option::t<U>, v: [T]) ->
107+
fn option_flatten_map<T, U>(f: fn@(T) -> option::t<U>, v: [T]) ->
108108
option::t<[U]> {
109109
let res = [];
110110
for elem: T in v {

src/comp/syntax/parse/parser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn expect_gt(p: parser) {
210210
}
211211
}
212212

213-
fn spanned<@T>(lo: uint, hi: uint, node: T) -> spanned<T> {
213+
fn spanned<T>(lo: uint, hi: uint, node: T) -> spanned<T> {
214214
ret {node: node, span: ast_util::mk_sp(lo, hi)};
215215
}
216216

@@ -595,7 +595,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
595595
ret {mode: m, ty: t, ident: i, id: p.get_id()};
596596
}
597597

598-
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
598+
fn parse_seq_to_before_gt<T>(sep: option::t<token::token>,
599599
f: fn@(parser) -> T,
600600
p: parser) -> [T] {
601601
let first = true;
@@ -612,15 +612,15 @@ fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
612612
ret v;
613613
}
614614

615-
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
615+
fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn@(parser) -> T,
616616
p: parser) -> [T] {
617617
let v = parse_seq_to_before_gt(sep, f, p);
618618
expect_gt(p);
619619

620620
ret v;
621621
}
622622

623-
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
623+
fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn@(parser) -> T,
624624
p: parser) -> spanned<[T]> {
625625
let lo = p.get_lo_pos();
626626
expect(p, token::LT);
@@ -630,14 +630,14 @@ fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
630630
ret spanned(lo, hi, result);
631631
}
632632

633-
fn parse_seq_to_end<@T>(ket: token::token, sep: option::t<token::token>,
633+
fn parse_seq_to_end<T>(ket: token::token, sep: option::t<token::token>,
634634
f: fn(parser) -> T, p: parser) -> [T] {
635635
let val = parse_seq_to_before_end(ket, sep, f, p);
636636
p.bump();
637637
ret val;
638638
}
639639

640-
fn parse_seq_to_before_end<@T>(ket: token::token,
640+
fn parse_seq_to_before_end<T>(ket: token::token,
641641
sep: option::t<token::token>,
642642
f: fn@(parser) -> T, p: parser) -> [T] {
643643
let first: bool = true;
@@ -653,7 +653,7 @@ fn parse_seq_to_before_end<@T>(ket: token::token,
653653
}
654654

655655

656-
fn parse_seq<@T>(bra: token::token, ket: token::token,
656+
fn parse_seq<T>(bra: token::token, ket: token::token,
657657
sep: option::t<token::token>, f: fn@(parser) -> T, p: parser)
658658
-> spanned<[T]> {
659659
let lo = p.get_lo_pos();

src/comp/syntax/util/interner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ type interner<T> =
1111
hasher: hashfn<T>,
1212
eqer: eqfn<T>};
1313

14-
fn mk<@T>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
14+
fn mk<T>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
1515
let m = map::mk_hashmap::<T, uint>(hasher, eqer);
1616
ret {map: m, mutable vect: [], hasher: hasher, eqer: eqer};
1717
}
1818

19-
fn intern<@T>(itr: interner<T>, val: T) -> uint {
19+
fn intern<T>(itr: interner<T>, val: T) -> uint {
2020
alt itr.map.find(val) {
2121
some(idx) { ret idx; }
2222
none. {
@@ -31,7 +31,7 @@ fn intern<@T>(itr: interner<T>, val: T) -> uint {
3131
// |get| isn't "pure" in the traditional sense, because it can go from
3232
// failing to returning a value as items are interned. But for typestate,
3333
// where we first check a pred and then rely on it, ceasing to fail is ok.
34-
pure fn get<@T>(itr: interner<T>, idx: uint) -> T {
34+
pure fn get<T>(itr: interner<T>, idx: uint) -> T {
3535
unchecked {
3636
itr.vect[idx]
3737
}

src/comp/util/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn hash_def(d: ast::def_id) -> uint {
2525
ret h;
2626
}
2727

28-
fn new_def_hash<@V>() -> std::map::hashmap<ast::def_id, V> {
28+
fn new_def_hash<V>() -> std::map::hashmap<ast::def_id, V> {
2929
let hasher: std::map::hashfn<ast::def_id> = hash_def;
3030
let eqer: std::map::eqfn<ast::def_id> = def_eq;
3131
ret std::map::mk_hashmap::<ast::def_id, V>(hasher, eqer);
@@ -166,7 +166,7 @@ fn lit_in_range(l: @ast::lit, m1: @ast::lit, m2: @ast::lit) -> bool {
166166
}
167167
}
168168

169-
fn ranges_overlap<@T>(a1: T, a2: T, b1: T, b2: T) -> bool {
169+
fn ranges_overlap<T>(a1: T, a2: T, b1: T, b2: T) -> bool {
170170
let min1 = min(a1, a2);
171171
let max1 = max(a1, a2);
172172
let min2 = min(b1, b2);

src/comp/util/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export pick_file;
1616
export search;
1717
export relative_target_lib_path;
1818

19-
type pick<@T> = block(path: fs::path) -> option::t<T>;
19+
type pick<T> = block(path: fs::path) -> option::t<T>;
2020

2121
fn pick_file(file: fs::path, path: fs::path) -> option::t<fs::path> {
2222
if fs::basename(path) == file { option::some(path) }
@@ -57,7 +57,7 @@ fn mk_filesearch(maybe_sysroot: option::t<fs::path>,
5757
}
5858

5959
// FIXME #1001: This can't be an obj method
60-
fn search<@T>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
60+
fn search<T>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
6161
for lib_search_path in filesearch.lib_search_paths() {
6262
log #fmt["searching %s", lib_search_path];
6363
for path in fs::list_dir(lib_search_path) {

src/compiletest/procsrv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,17 @@ fn worker(p: port<request>) {
154154

155155
// Only windows needs to set the library path
156156
#[cfg(target_os = "win32")]
157-
fn maybe_with_lib_path<@T>(path: str, f: fn@() -> T) -> T {
157+
fn maybe_with_lib_path<T>(path: str, f: fn@() -> T) -> T {
158158
with_lib_path(path, f)
159159
}
160160

161161
#[cfg(target_os = "linux")]
162162
#[cfg(target_os = "macos")]
163-
fn maybe_with_lib_path<@T>(_path: str, f: fn@() -> T) -> T {
163+
fn maybe_with_lib_path<T>(_path: str, f: fn@() -> T) -> T {
164164
f()
165165
}
166166

167-
fn with_lib_path<@T>(path: str, f: fn@() -> T) -> T {
167+
fn with_lib_path<T>(path: str, f: fn@() -> T) -> T {
168168
let maybe_oldpath = getenv(util::lib_path_env_var());
169169
append_lib_path(path);
170170
let res = f();

src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap,
227227
check_variants_T(crate, codemap, filename, "ty", stolen.tys, pprust::ty_to_str, replace_ty_in_crate, cx);
228228
}
229229

230-
fn check_variants_T<@T>(
230+
fn check_variants_T<T>(
231231
crate: ast::crate,
232232
codemap: codemap::codemap,
233233
filename: str,

src/fuzzer/ivec_fuzz.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ import std::vec::slice;
2222
import std::vec::len;
2323
import std::int;
2424

25-
fn vec_omit<@T>(v: [T], i: uint) -> [T] {
25+
fn vec_omit<T>(v: [T], i: uint) -> [T] {
2626
slice(v, 0u, i) + slice(v, i + 1u, len(v))
2727
}
28-
fn vec_dup<@T>(v: [T], i: uint) -> [T] {
28+
fn vec_dup<T>(v: [T], i: uint) -> [T] {
2929
slice(v, 0u, i) + [v[i]] + slice(v, i, len(v))
3030
}
31-
fn vec_swadj<@T>(v: [T], i: uint) -> [T] {
31+
fn vec_swadj<T>(v: [T], i: uint) -> [T] {
3232
slice(v, 0u, i) + [v[i + 1u], v[i]] + slice(v, i + 2u, len(v))
3333
}
34-
fn vec_prefix<@T>(v: [T], i: uint) -> [T] { slice(v, 0u, i) }
35-
fn vec_suffix<@T>(v: [T], i: uint) -> [T] { slice(v, i, len(v)) }
34+
fn vec_prefix<T>(v: [T], i: uint) -> [T] { slice(v, 0u, i) }
35+
fn vec_suffix<T>(v: [T], i: uint) -> [T] { slice(v, i, len(v)) }
3636

37-
fn vec_poke<@T>(v: [T], i: uint, x: T) -> [T] {
37+
fn vec_poke<T>(v: [T], i: uint, x: T) -> [T] {
3838
slice(v, 0u, i) + [x] + slice(v, i + 1u, len(v))
3939
}
40-
fn vec_insert<@T>(v: [T], i: uint, x: T) -> [T] {
40+
fn vec_insert<T>(v: [T], i: uint, x: T) -> [T] {
4141
slice(v, 0u, i) + [x] + slice(v, i, len(v))
4242
}
4343

@@ -48,7 +48,7 @@ fn ix(skip_low: uint, skip_high: uint, length: uint, it: block(uint)) {
4848
}
4949

5050
// Returns a bunch of modified versions of v, some of which introduce new elements (borrowed from xs).
51-
fn vec_edits<@T>(v: [T], xs: [T]) -> [[T]] {
51+
fn vec_edits<T>(v: [T], xs: [T]) -> [[T]] {
5252
let edits: [[T]] = [];
5353
let Lv: uint = len(v);
5454

src/fuzzer/rand_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn choice<T>(r : rand::rng, v : [T]) -> T { assert vec::len(v) != 0u; v[under(r,
1212
fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u }
1313

1414
// shuffle a vec in place
15-
fn shuffle<@T>(r : rand::rng, &v : [mutable T]) {
15+
fn shuffle<T>(r : rand::rng, &v : [mutable T]) {
1616
let i = vec::len(v);
1717
while i >= 2u {
1818
// Loop invariant: elements with index >= i have been locked in place.
@@ -22,7 +22,7 @@ fn shuffle<@T>(r : rand::rng, &v : [mutable T]) {
2222
}
2323

2424
// create a shuffled copy of a vec
25-
fn shuffled<@T>(r : rand::rng, v : [T]) -> [T] {
25+
fn shuffled<T>(r : rand::rng, v : [T]) -> [T] {
2626
let w = vec::to_mut(v);
2727
shuffle(r, w);
2828
vec::from_mut(w) // Shouldn't this happen automatically?
@@ -35,7 +35,7 @@ fn shuffled<@T>(r : rand::rng, v : [T]) -> [T] {
3535
// * weighted_choice is O(number of choices) time
3636
// * weighted_vec is O(total weight) space
3737
type weighted<T> = { weight: uint, item: T };
38-
fn weighted_choice<@T>(r : rand::rng, v : [weighted<T>]) -> T {
38+
fn weighted_choice<T>(r : rand::rng, v : [weighted<T>]) -> T {
3939
assert vec::len(v) != 0u;
4040
let total = 0u;
4141
for {weight: weight, item: _} in v {

src/lib/comm.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ native "c-stack-cdecl" mod rustrt {
1212
type void;
1313
type rust_port;
1414

15-
fn chan_id_send<~T>(t: *sys::type_desc,
16-
target_task: task::task, target_port: port_id,
17-
-data: T);
15+
fn chan_id_send<unique T>(t: *sys::type_desc,
16+
target_task: task::task, target_port: port_id,
17+
-data: T);
1818

1919
fn new_port(unit_sz: uint) -> *rust_port;
2020
fn del_port(po: *rust_port);
@@ -23,38 +23,38 @@ native "c-stack-cdecl" mod rustrt {
2323
}
2424

2525
native "rust-intrinsic" mod rusti {
26-
fn recv<~T>(port: *rustrt::rust_port) -> T;
26+
fn recv<unique T>(port: *rustrt::rust_port) -> T;
2727
}
2828

2929
type port_id = int;
3030

3131
// It's critical that this only have one variant, so it has a record
3232
// layout, and will work in the rust_task structure in task.rs.
33-
tag chan<~T> { chan_t(task::task, port_id); }
33+
tag chan<unique T> { chan_t(task::task, port_id); }
3434

3535
resource port_ptr(po: *rustrt::rust_port) {
3636
rustrt::drop_port(po);
3737
rustrt::del_port(po);
3838
}
3939

40-
tag port<~T> { port_t(@port_ptr); }
40+
tag port<unique T> { port_t(@port_ptr); }
4141

42-
fn send<~T>(ch: chan<T>, -data: T) {
42+
fn send<unique T>(ch: chan<T>, -data: T) {
4343
let chan_t(t, p) = ch;
4444
rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
4545
task::yield();
4646
}
4747

48-
fn port<~T>() -> port<T> {
48+
fn port<unique T>() -> port<T> {
4949
let p = rustrt::new_port(sys::size_of::<T>());
5050
ret port_t(@port_ptr(p));
5151
}
5252

53-
fn recv<~T>(p: port<T>) -> T {
53+
fn recv<unique T>(p: port<T>) -> T {
5454
ret rusti::recv(***p);
5555
}
5656

57-
fn chan<~T>(p: port<T>) -> chan<T> {
57+
fn chan<unique T>(p: port<T>) -> chan<T> {
5858
let id = rustrt::get_port_id(***p);
5959
ret chan_t(task::get_task_id(), id);
6060
}

0 commit comments

Comments
 (0)