Skip to content

Commit 60ae159

Browse files
committed
Switch to new param kind bound syntax
And remove support for the old syntax
1 parent 1f71a0f commit 60ae159

File tree

87 files changed

+251
-252
lines changed

Some content is hidden

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

87 files changed

+251
-252
lines changed

src/comp/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
114114
fn inject_libcore_reference(sess: session::session,
115115
crate: @ast::crate) -> @ast::crate {
116116

117-
fn spanned<copy T>(x: T) -> @ast::spanned<T> {
117+
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
118118
ret @{node: x,
119119
span: {lo: 0u, hi: 0u,
120120
expanded_from: codemap::os_none}};

src/comp/front/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn native_abi(attrs: [ast::attribute]) -> either::t<str, ast::native_abi> {
221221
};
222222
}
223223

224-
fn span<copy T>(item: T) -> ast::spanned<T> {
224+
fn span<T: copy>(item: T) -> ast::spanned<T> {
225225
ret {node: item, span: ast_util::dummy_sp()};
226226
}
227227

src/comp/front/test.rs

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

185-
fn nospan<copy T>(t: T) -> ast::spanned<T> {
185+
fn nospan<T: copy>(t: T) -> ast::spanned<T> {
186186
ret {node: t, span: dummy_sp()};
187187
}
188188

src/comp/metadata/encoder.rs

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

493493
// Path and definition ID indexing
494494

495-
fn create_index<copy T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
495+
fn create_index<T: copy>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
496496
[@[entry<T>]] {
497497
let buckets: [@mutable [entry<T>]] = [];
498498
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
@@ -145,7 +145,7 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
145145
}
146146
}
147147

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

src/comp/middle/ast_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn map_expr(cx: ctx, ex: @expr) {
9898
}
9999
}
100100

101-
fn new_smallintmap_int_adapter<copy V>() -> std::map::hashmap<int, V> {
101+
fn new_smallintmap_int_adapter<V: copy>() -> std::map::hashmap<int, V> {
102102
let key_idx = fn (&&key: int) -> uint { key as uint };
103103
let idx_key = fn (idx: uint) -> int { idx as int };
104104
ret new_smallintmap_adapter(key_idx, idx_key);
@@ -109,11 +109,11 @@ fn new_smallintmap_int_adapter<copy V>() -> std::map::hashmap<int, V> {
109109
// the entire codebase adapting all the callsites to the different
110110
// interface.
111111
// FIXME: hashmap and smallintmap should support the same interface.
112-
fn new_smallintmap_adapter<copy K, copy V>(key_idx: fn(K) -> uint,
112+
fn new_smallintmap_adapter<K: copy, V: copy>(key_idx: fn(K) -> uint,
113113
idx_key: fn(uint) -> K)
114114
-> std::map::hashmap<K, V> {
115115

116-
obj adapter<copy K, copy V>(map: smallintmap::smallintmap<V>,
116+
obj adapter<K: copy, V: copy>(map: smallintmap::smallintmap<V>,
117117
key_idx: fn(K) -> uint,
118118
idx_key: fn(uint) -> K) {
119119

src/comp/middle/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ tag debug_metadata {
118118
retval_metadata(@metadata<retval_md>);
119119
}
120120

121-
fn cast_safely<copy T, U>(val: T) -> U unsafe {
121+
fn cast_safely<T: copy, U>(val: T) -> U unsafe {
122122
let val2 = val;
123123
let val3 = unsafe::reinterpret_cast(val2);
124124
unsafe::leak(val2);
@@ -138,7 +138,7 @@ fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {
138138
}
139139
}
140140

141-
fn cached_metadata<copy T>(cache: metadata_cache, mdtag: int,
141+
fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
142142
eq: block(md: T) -> bool) -> option::t<T> unsafe {
143143
if cache.contains_key(mdtag) {
144144
let items = cache.get(mdtag);

src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ fn mk_rcache() -> creader_cache {
414414
ret map::mk_hashmap(hash_cache_entry, eq_cache_entries);
415415
}
416416

417-
fn new_ty_hash<copy V>() -> map::hashmap<t, V> { map::new_uint_hash() }
417+
fn new_ty_hash<V: copy>() -> map::hashmap<t, V> { map::new_uint_hash() }
418418

419419
fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
420420
freevars: freevars::freevar_map) -> ctxt {

src/comp/syntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import codemap::span;
22
import ast::*;
33

4-
fn respan<copy T>(sp: span, t: T) -> spanned<T> {
4+
fn respan<T: copy>(sp: span, t: T) -> spanned<T> {
55
ret {node: t, span: sp};
66
}
77

@@ -201,7 +201,7 @@ fn eq_def_id(&&a: def_id, &&b: def_id) -> bool {
201201
a == b
202202
}
203203

204-
fn new_def_id_hash<copy T>() -> std::map::hashmap<def_id, T> {
204+
fn new_def_id_hash<T: copy>() -> std::map::hashmap<def_id, T> {
205205
std::map::mk_hashmap(hash_def_id, eq_def_id)
206206
}
207207

src/comp/syntax/ext/simplext.rs

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

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

src/comp/syntax/parse/parser.rs

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

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

@@ -378,7 +378,7 @@ fn parse_constr_in_type(p: parser) -> @ast::ty_constr {
378378
}
379379

380380

381-
fn parse_constrs<copy T>(pser: block(parser) -> @ast::constr_general<T>,
381+
fn parse_constrs<T: copy>(pser: block(parser) -> @ast::constr_general<T>,
382382
p: parser) ->
383383
[@ast::constr_general<T>] {
384384
let constrs: [@ast::constr_general<T>] = [];
@@ -554,7 +554,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
554554
ret {mode: m, ty: t, ident: i, id: p.get_id()};
555555
}
556556

557-
fn parse_seq_to_before_gt<copy T>(sep: option::t<token::token>,
557+
fn parse_seq_to_before_gt<T: copy>(sep: option::t<token::token>,
558558
f: block(parser) -> T,
559559
p: parser) -> [T] {
560560
let first = true;
@@ -571,15 +571,15 @@ fn parse_seq_to_before_gt<copy T>(sep: option::t<token::token>,
571571
ret v;
572572
}
573573

574-
fn parse_seq_to_gt<copy T>(sep: option::t<token::token>,
574+
fn parse_seq_to_gt<T: copy>(sep: option::t<token::token>,
575575
f: block(parser) -> T, p: parser) -> [T] {
576576
let v = parse_seq_to_before_gt(sep, f, p);
577577
expect_gt(p);
578578

579579
ret v;
580580
}
581581

582-
fn parse_seq_lt_gt<copy T>(sep: option::t<token::token>,
582+
fn parse_seq_lt_gt<T: copy>(sep: option::t<token::token>,
583583
f: block(parser) -> T,
584584
p: parser) -> spanned<[T]> {
585585
let lo = p.get_lo_pos();
@@ -590,7 +590,7 @@ fn parse_seq_lt_gt<copy T>(sep: option::t<token::token>,
590590
ret spanned(lo, hi, result);
591591
}
592592

593-
fn parse_seq_to_end<copy T>(ket: token::token, sep: seq_sep,
593+
fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep,
594594
f: block(parser) -> T, p: parser) -> [T] {
595595
let val = parse_seq_to_before_end(ket, sep, f, p);
596596
p.bump();
@@ -612,7 +612,7 @@ fn seq_sep_none() -> seq_sep {
612612
ret {sep: option::none, trailing_opt: false};
613613
}
614614

615-
fn parse_seq_to_before_end<copy T>(ket: token::token,
615+
fn parse_seq_to_before_end<T: copy>(ket: token::token,
616616
sep: seq_sep,
617617
f: block(parser) -> T, p: parser) -> [T] {
618618
let first: bool = true;
@@ -629,7 +629,7 @@ fn parse_seq_to_before_end<copy T>(ket: token::token,
629629
}
630630

631631

632-
fn parse_seq<copy T>(bra: token::token, ket: token::token,
632+
fn parse_seq<T: copy>(bra: token::token, ket: token::token,
633633
sep: seq_sep, f: block(parser) -> T,
634634
p: parser) -> spanned<[T]> {
635635
let lo = p.get_lo_pos();
@@ -1700,8 +1700,6 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
17001700

17011701
fn parse_ty_param(p: parser) -> ast::ty_param {
17021702
let bounds = [];
1703-
if eat_word(p, "send") { bounds += [ast::bound_send]; }
1704-
else if eat_word(p, "copy") { bounds += [ast::bound_copy]; }
17051703
let ident = parse_ident(p);
17061704
if eat(p, token::COLON) {
17071705
while p.peek() != token::COMMA && p.peek() != token::GT {

src/comp/syntax/util/interner.rs

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

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

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

src/comp/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn hash_def(d: ast::def_id) -> uint {
2121
ret h;
2222
}
2323

24-
fn new_def_hash<copy V>() -> std::map::hashmap<ast::def_id, V> {
24+
fn new_def_hash<V: copy>() -> std::map::hashmap<ast::def_id, V> {
2525
let hasher: std::map::hashfn<ast::def_id> = hash_def;
2626
let eqer: std::map::eqfn<ast::def_id> = def_eq;
2727
ret std::map::mk_hashmap::<ast::def_id, V>(hasher, eqer);

src/comp/util/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn mk_filesearch(maybe_sysroot: option::t<fs::path>,
5555
}
5656

5757
// FIXME #1001: This can't be an obj method
58-
fn search<copy T>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
58+
fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
5959
for lib_search_path in filesearch.lib_search_paths() {
6060
#debug("searching %s", lib_search_path);
6161
for path in fs::list_dir(lib_search_path) {

src/fuzzer/fuzzer.rs

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

229-
fn check_variants_T<copy T>(
229+
fn check_variants_T<T: copy>(
230230
crate: ast::crate,
231231
codemap: codemap::codemap,
232232
filename: str,

src/libcore/comm.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ native mod rustrt {
3939
type void;
4040
type rust_port;
4141

42-
fn chan_id_send<send T>(t: *sys::type_desc,
42+
fn chan_id_send<T: send>(t: *sys::type_desc,
4343
target_task: task::task, target_port: port_id,
4444
data: T) -> ctypes::uintptr_t;
4545

@@ -55,7 +55,7 @@ native mod rustrt {
5555

5656
#[abi = "rust-intrinsic"]
5757
native mod rusti {
58-
fn call_with_retptr<send T>(&&f: fn@(*uint)) -> T;
58+
fn call_with_retptr<T: send>(&&f: fn@(*uint)) -> T;
5959
}
6060

6161
type port_id = int;
@@ -78,11 +78,11 @@ dropped.
7878
7979
Channels may be duplicated and themselves transmitted over other channels.
8080
*/
81-
tag chan<send T> {
81+
tag chan<T: send> {
8282
chan_t(task::task, port_id);
8383
}
8484

85-
resource port_ptr<send T>(po: *rustrt::rust_port) {
85+
resource port_ptr<T: send>(po: *rustrt::rust_port) {
8686
// Once the port is detached it's guaranteed not to receive further
8787
// messages
8888
rustrt::rust_port_detach(po);
@@ -106,7 +106,7 @@ transmitted. If a port value is copied, both copies refer to the same port.
106106
107107
Ports may be associated with multiple <chan>s.
108108
*/
109-
tag port<send T> { port_t(@port_ptr<T>); }
109+
tag port<T: send> { port_t(@port_ptr<T>); }
110110

111111
/*
112112
Function: send
@@ -116,7 +116,7 @@ Sends data over a channel.
116116
The sent data is moved into the channel, whereupon the caller loses access
117117
to it.
118118
*/
119-
fn send<send T>(ch: chan<T>, -data: T) {
119+
fn send<T: send>(ch: chan<T>, -data: T) {
120120
let chan_t(t, p) = ch;
121121
let res = rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
122122
if res != 0u unsafe {
@@ -131,7 +131,7 @@ Function: port
131131
132132
Constructs a port.
133133
*/
134-
fn port<send T>() -> port<T> {
134+
fn port<T: send>() -> port<T> {
135135
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>())))
136136
}
137137

@@ -143,10 +143,10 @@ Receive from a port.
143143
If no data is available on the port then the task will block until data
144144
becomes available.
145145
*/
146-
fn recv<send T>(p: port<T>) -> T { recv_(***p) }
146+
fn recv<T: send>(p: port<T>) -> T { recv_(***p) }
147147

148148
// Receive on a raw port pointer
149-
fn recv_<send T>(p: *rustrt::rust_port) -> T {
149+
fn recv_<T: send>(p: *rustrt::rust_port) -> T {
150150
// FIXME: Due to issue 1185 we can't use a return pointer when
151151
// calling C code, and since we can't create our own return
152152
// pointer on the stack, we're going to call a little intrinsic
@@ -179,6 +179,6 @@ Constructs a channel.
179179
180180
The channel is bound to the port used to construct it.
181181
*/
182-
fn chan<send T>(p: port<T>) -> chan<T> {
182+
fn chan<T: send>(p: port<T>) -> chan<T> {
183183
chan_t(task::get_task(), rustrt::get_port_id(***p))
184184
}

src/libcore/either.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Function: lefts
3939
4040
Extracts from a vector of either all the left values.
4141
*/
42-
fn lefts<copy T, U>(eithers: [t<T, U>]) -> [T] {
42+
fn lefts<T: copy, U>(eithers: [t<T, U>]) -> [T] {
4343
let result: [T] = [];
4444
for elt: t<T, U> in eithers {
4545
alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
@@ -52,7 +52,7 @@ Function: rights
5252
5353
Extracts from a vector of either all the right values
5454
*/
55-
fn rights<T, copy U>(eithers: [t<T, U>]) -> [U] {
55+
fn rights<T, U: copy>(eithers: [t<T, U>]) -> [U] {
5656
let result: [U] = [];
5757
for elt: t<T, U> in eithers {
5858
alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
@@ -68,7 +68,7 @@ Extracts from a vector of either all the left values and right values
6868
Returns a structure containing a vector of left values and a vector of
6969
right values.
7070
*/
71-
fn partition<copy T, copy U>(eithers: [t<T, U>])
71+
fn partition<T: copy, U: copy>(eithers: [t<T, U>])
7272
-> {lefts: [T], rights: [U]} {
7373
let lefts: [T] = [];
7474
let rights: [U] = [];
@@ -83,7 +83,7 @@ Function: flip
8383
8484
Flips between left and right of a given either
8585
*/
86-
pure fn flip<copy T, copy U>(eith: t<T, U>) -> t<U, T> {
86+
pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
8787
alt eith {
8888
right(r) { left(r) }
8989
left(l) { right(l) }
@@ -96,7 +96,7 @@ Function: to_result
9696
Converts either::t to a result::t, making the "right" choice
9797
an ok result, and the "left" choice a fail
9898
*/
99-
pure fn to_result<copy T, copy U>(eith: t<T, U>) -> result::t<U, T> {
99+
pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
100100
alt eith {
101101
right(r) { result::ok(r) }
102102
left(l) { result::err(l) }

src/libcore/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,14 @@ Function: min
467467
468468
Returns the minimum of two values
469469
*/
470-
pure fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
470+
pure fn min<T: copy>(x: T, y: T) -> T { x < y ? x : y }
471471

472472
/*
473473
Function: max
474474
475475
Returns the maximum of two values
476476
*/
477-
pure fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
477+
pure fn max<T: copy>(x: T, y: T) -> T { x < y ? y : x }
478478

479479
/*
480480
Function: acos

0 commit comments

Comments
 (0)