Skip to content

Commit e20549f

Browse files
committed
librustc: Remove all uses of the Copy bound.
1 parent 99d44d2 commit e20549f

File tree

94 files changed

+213
-280
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

+213
-280
lines changed

src/libextra/par.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn map_slices<A:Clone + Send,B:Clone + Send>(
8585
}
8686

8787
/// A parallel version of map.
88-
pub fn map<A:Copy + Clone + Send,B:Copy + Clone + Send>(
88+
pub fn map<A:Clone + Send,B:Clone + Send>(
8989
xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] {
9090
vec::concat(map_slices(xs, || {
9191
let f = fn_factory();
@@ -96,7 +96,7 @@ pub fn map<A:Copy + Clone + Send,B:Copy + Clone + Send>(
9696
}
9797

9898
/// A parallel version of mapi.
99-
pub fn mapi<A:Copy + Clone + Send,B:Copy + Clone + Send>(
99+
pub fn mapi<A:Clone + Send,B:Clone + Send>(
100100
xs: &[A],
101101
fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] {
102102
let slices = map_slices(xs, || {

src/libextra/serialize.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,7 @@ impl<
650650
}
651651
}
652652

653-
impl<
654-
S: Encoder,
655-
T: Encodable<S> + Copy
656-
> Encodable<S> for DList<T> {
653+
impl<S: Encoder, T: Encodable<S>> Encodable<S> for @mut DList<T> {
657654
fn encode(&self, s: &mut S) {
658655
do s.emit_seq(self.len()) |s| {
659656
let mut i = 0;

src/libextra/sort.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
2424
* Has worst case O(n log n) performance, best case O(n), but
2525
* is not space efficient. This is a stable sort.
2626
*/
27-
pub fn merge_sort<T:Copy + Clone>(v: &[T], le: Le<T>) -> ~[T] {
27+
pub fn merge_sort<T:Clone>(v: &[T], le: Le<T>) -> ~[T] {
2828
type Slice = (uint, uint);
2929

3030
return merge_sort_(v, (0u, v.len()), le);
3131

32-
fn merge_sort_<T:Copy + Clone>(v: &[T], slice: Slice, le: Le<T>) -> ~[T] {
32+
fn merge_sort_<T:Clone>(v: &[T], slice: Slice, le: Le<T>) -> ~[T] {
3333
let begin = slice.first();
3434
let end = slice.second();
3535

@@ -44,7 +44,7 @@ pub fn merge_sort<T:Copy + Clone>(v: &[T], le: Le<T>) -> ~[T] {
4444
merge_sort_(v, b, |x,y| le(x,y)));
4545
}
4646

47-
fn merge<T:Copy + Clone>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
47+
fn merge<T:Clone>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
4848
let mut rs = vec::with_capacity(a.len() + b.len());
4949
let a_len = a.len();
5050
let mut a_ix = 0;
@@ -183,7 +183,7 @@ static MIN_GALLOP: uint = 7;
183183
static INITIAL_TMP_STORAGE: uint = 128;
184184

185185
#[allow(missing_doc)]
186-
pub fn tim_sort<T:Copy + Clone + Ord>(array: &mut [T]) {
186+
pub fn tim_sort<T:Clone + Ord>(array: &mut [T]) {
187187
let size = array.len();
188188
if size < 2 {
189189
return;
@@ -227,7 +227,7 @@ pub fn tim_sort<T:Copy + Clone + Ord>(array: &mut [T]) {
227227
ms.merge_force_collapse(array);
228228
}
229229

230-
fn binarysort<T:Copy + Clone + Ord>(array: &mut [T], start: uint) {
230+
fn binarysort<T:Clone + Ord>(array: &mut [T], start: uint) {
231231
let size = array.len();
232232
let mut start = start;
233233
assert!(start <= size);
@@ -419,7 +419,7 @@ fn MergeState<T>() -> MergeState<T> {
419419
}
420420
}
421421

422-
impl<T:Copy + Clone + Ord> MergeState<T> {
422+
impl<T:Clone + Ord> MergeState<T> {
423423
fn push_run(&mut self, run_base: uint, run_len: uint) {
424424
let tmp = RunState{base: run_base, len: run_len};
425425
self.runs.push(tmp);
@@ -739,10 +739,7 @@ fn copy_vec<T:Clone>(dest: &mut [T],
739739
}
740740

741741
#[inline]
742-
fn shift_vec<T:Copy + Clone>(dest: &mut [T],
743-
s1: uint,
744-
s2: uint,
745-
len: uint) {
742+
fn shift_vec<T:Clone>(dest: &mut [T], s1: uint, s2: uint, len: uint) {
746743
assert!(s1+len <= dest.len());
747744

748745
let tmp = dest.slice(s2, s2+len).to_owned();

src/libextra/timer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ pub fn sleep(iotask: &IoTask, msecs: uint) {
118118
* on the provided port in the allotted timeout period, then the result will
119119
* be a `Some(T)`. If not, then `None` will be returned.
120120
*/
121-
pub fn recv_timeout<T:Copy + Send>(iotask: &IoTask,
122-
msecs: uint,
123-
wait_po: &Port<T>)
124-
-> Option<T> {
121+
pub fn recv_timeout<T:Send>(iotask: &IoTask, msecs: uint, wait_po: &Port<T>)
122+
-> Option<T> {
125123
let (timeout_po, timeout_ch) = stream::<()>();
126124
let mut timeout_po = timeout_po;
127125
delayed_send(iotask, msecs, &timeout_ch, ());

src/librust/rust.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ impl ValidUsage {
4343
}
4444
}
4545

46-
enum Action<'self> {
47-
Call(&'self fn:Copy(args: &[~str]) -> ValidUsage),
48-
CallMain(&'static str, &'self fn:Copy()),
46+
enum Action {
47+
Call(extern "Rust" fn(args: &[~str]) -> ValidUsage),
48+
CallMain(&'static str, extern "Rust" fn()),
4949
}
5050

5151
enum UsageSource<'self> {
5252
UsgStr(&'self str),
53-
UsgCall(&'self fn:Copy()),
53+
UsgCall(extern "Rust" fn()),
5454
}
5555

5656
struct Command<'self> {
5757
cmd: &'self str,
58-
action: Action<'self>,
58+
action: Action,
5959
usage_line: &'self str,
6060
usage_full: UsageSource<'self>,
6161
}

src/librustc/driver/driver.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ pub fn compile_rest(sess: Session,
199199
//
200200
// baz! should not use this definition unless foo is enabled.
201201
crate = time(time_passes, ~"std macros injection", ||
202-
syntax::ext::expand::inject_std_macros(sess.parse_sess, copy cfg,
203-
crate));
202+
syntax::ext::expand::inject_std_macros(sess.parse_sess,
203+
cfg.clone(),
204+
crate));
204205

205206
crate = time(time_passes, ~"configuration 1", ||
206207
front::config::strip_unconfigured_items(crate));

src/librustc/front/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn no_prelude(attrs: &[ast::attribute]) -> bool {
3737
}
3838

3939
fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
40-
fn spanned<T:Copy>(x: T) -> codemap::spanned<T> {
40+
fn spanned<T>(x: T) -> codemap::spanned<T> {
4141
codemap::spanned { node: x, span: dummy_sp() }
4242
}
4343

src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
343343
return @item;
344344
}
345345

346-
fn nospan<T:Copy>(t: T) -> codemap::spanned<T> {
346+
fn nospan<T>(t: T) -> codemap::spanned<T> {
347347
codemap::spanned { node: t, span: dummy_sp() }
348348
}
349349

src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
8787
} as @FileSearch
8888
}
8989

90-
pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
90+
pub fn search<T>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
9191
let mut rslt = None;
9292
for filesearch.for_each_lib_search_path() |lib_search_path| {
9393
debug!("searching %s", lib_search_path.to_str());

src/librustc/middle/astencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,14 +1282,14 @@ fn test_more() {
12821282
fn test_simplification() {
12831283
let ext_cx = mk_ctxt();
12841284
let item_in = ast::ii_item(quote_item!(
1285-
fn new_int_alist<B:Copy>() -> alist<int, B> {
1285+
fn new_int_alist<B>() -> alist<int, B> {
12861286
fn eq_int(a: int, b: int) -> bool { a == b }
12871287
return alist {eq_fn: eq_int, data: ~[]};
12881288
}
12891289
).get());
12901290
let item_out = simplify_ast(&item_in);
12911291
let item_exp = ast::ii_item(quote_item!(
1292-
fn new_int_alist<B:Copy>() -> alist<int, B> {
1292+
fn new_int_alist<B>() -> alist<int, B> {
12931293
return alist {eq_fn: eq_int, data: ~[]};
12941294
}
12951295
).get());

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ pub fn each_lint(sess: session::Session,
561561
// This is used to make the simple visitors used for the lint passes
562562
// not traverse into subitems, since that is handled by the outer
563563
// lint visitor.
564-
fn item_stopping_visitor<E: Copy>(outer: visit::vt<E>) -> visit::vt<E> {
564+
fn item_stopping_visitor<E>(outer: visit::vt<E>) -> visit::vt<E> {
565565
visit::mk_vt(@visit::Visitor {
566566
visit_item: |_i, (_e, _v)| { },
567567
visit_fn: |fk, fd, b, s, id, (e, v)| {

src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
6262

6363
fn store_type_uses(cx: Context, fn_id: def_id) -> @~[type_uses] {
6464
let Context { uses, ccx } = cx;
65-
let uses = @copy *uses; // freeze
65+
let uses = @(*uses).clone(); // freeze
6666
ccx.type_use_cache.insert(fn_id, uses);
6767
uses
6868
}

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ fn mk_rcache() -> creader_cache {
860860
return @mut HashMap::new();
861861
}
862862

863-
pub fn new_ty_hash<V:Copy>() -> @mut HashMap<t, V> {
863+
pub fn new_ty_hash<V>() -> @mut HashMap<t, V> {
864864
@mut HashMap::new()
865865
}
866866

src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,10 +1686,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
16861686
// through the `unpack` function. It there is no expected type or
16871687
// resolution is not possible (e.g., no constraints yet present), just
16881688
// returns `none`.
1689-
fn unpack_expected<O:Copy>(fcx: @mut FnCtxt,
1690-
expected: Option<ty::t>,
1691-
unpack: &fn(&ty::sty) -> Option<O>)
1692-
-> Option<O> {
1689+
fn unpack_expected<O>(fcx: @mut FnCtxt,
1690+
expected: Option<ty::t>,
1691+
unpack: &fn(&ty::sty) -> Option<O>)
1692+
-> Option<O> {
16931693
match expected {
16941694
Some(t) => {
16951695
match resolve_type(fcx.infcx(), t, force_tvar) {

src/librustdoc/astsrv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ fn build_ctxt(sess: Session,
114114
use rustc::front::config;
115115

116116
let ast = syntax::ext::expand::inject_std_macros(sess.parse_sess,
117-
copy sess.opts.cfg, ast);
117+
sess.opts.cfg.clone(),
118+
ast);
118119
let ast = config::strip_unconfigured_items(ast);
119120
let ast = syntax::ext::expand::expand_crate(sess.parse_sess,
120121
sess.opts.cfg.clone(),

src/librustdoc/markdown_index_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ mod test {
208208
== ~"impl-of-selectt-u-for-left-right");
209209
assert!(pandoc_header_id("impl of Condition<'self, T, U>")
210210
== ~"impl-of-conditionself-t-u");
211-
assert!(pandoc_header_id("impl of Condition<T: Copy + Clone>")
212-
== ~"impl-of-conditiont-copy-clone");
211+
assert!(pandoc_header_id("impl of Condition<T: Clone>")
212+
== ~"impl-of-conditiont-clone");
213213
}
214214
215215
#[test]

src/librustdoc/tystr_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ mod test {
394394
395395
#[test]
396396
fn should_add_impl_bounds() {
397-
let doc = mk_doc(~"impl<T, U: Copy, V: Copy + Clone> Option<T, U, V> { }");
398-
assert!(doc.cratemod().impls()[0].bounds_str == Some(~"<T, U: Copy, V: Copy + Clone>"));
397+
let doc = mk_doc(~"impl<T, U, V: Clone> Option<T, U, V> { }");
398+
assert!(doc.cratemod().impls()[0].bounds_str == Some(~"<T, U, V: Clone>"));
399399
}
400400
401401
#[test]

src/librustpkg/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ fn install_check_duplicates() {
839839
fail!("package database contains duplicate ID");
840840
}
841841
else {
842-
contents.push(copy *p);
842+
contents.push((*p).clone());
843843
}
844844
false
845845
};

src/libstd/clone.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ assign them or pass them as arguments, the receiver will get a copy,
1515
leaving the original value in place. These types do not require
1616
allocation to copy and do not have finalizers (i.e. they do not
1717
contain owned boxes or implement `Drop`), so the compiler considers
18-
them cheap and safe to copy and automatically implements the `Copy`
19-
trait for them. For other types copies must be made explicitly,
20-
by convention implementing the `Clone` trait and calling the
21-
`clone` method.
18+
them cheap and safe to copy. For other types copies must be made
19+
explicitly, by convention implementing the `Clone` trait and calling
20+
the `clone` method.
2221
2322
*/
2423

src/libstd/condition.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<T, U> Condition<T, U> {
4747

4848
pub fn raise(&self, t: T) -> U {
4949
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
50-
self.raise_default(t, || fail!(copy msg))
50+
self.raise_default(t, || fail!(msg.clone()))
5151
}
5252

5353
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
@@ -78,7 +78,8 @@ impl<'self, T, U> Condition<'self, T, U> {
7878
pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
7979
unsafe {
8080
let p : *RustClosure = ::cast::transmute(&h);
81-
let prev = local_data::get(self.key, |k| k.map(|&x| *x));
81+
let prev = local_data::get(::cast::unsafe_copy(&self.key),
82+
|k| k.map(|&x| *x));
8283
let h = @Handler { handle: *p, prev: prev };
8384
Trap { cond: self, handler: h }
8485
}
@@ -91,7 +92,7 @@ impl<'self, T, U> Condition<'self, T, U> {
9192

9293
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
9394
unsafe {
94-
match local_data::pop(self.key) {
95+
match local_data::pop(::cast::unsafe_copy(&self.key)) {
9596
None => {
9697
debug!("Condition.raise: found no handler");
9798
default()
@@ -100,12 +101,15 @@ impl<'self, T, U> Condition<'self, T, U> {
100101
debug!("Condition.raise: found handler");
101102
match handler.prev {
102103
None => {}
103-
Some(hp) => local_data::set(self.key, hp)
104+
Some(hp) => {
105+
local_data::set(::cast::unsafe_copy(&self.key),
106+
hp)
107+
}
104108
}
105109
let handle : &fn(T) -> U =
106110
::cast::transmute(handler.handle);
107111
let u = handle(t);
108-
local_data::set(self.key, handler);
112+
local_data::set(::cast::unsafe_copy(&self.key), handler);
109113
u
110114
}
111115
}

src/libstd/kinds.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,13 @@ intrinsic properties of the type. These classifications, often called
1818
They cannot be implemented by user code, but are instead implemented
1919
by the compiler automatically for the types to which they apply.
2020
21-
The 3 kinds are
22-
23-
* Copy - types that may be copied without allocation. This includes
24-
scalar types and managed pointers, and exludes owned pointers. It
25-
also excludes types that implement `Drop`.
21+
The 2 kinds are
2622
2723
* Send - owned types and types containing owned types. These types
2824
may be transferred across task boundaries.
2925
3026
* Freeze - types that are deeply immutable.
3127
32-
`Copy` types include both implicitly copyable types that the compiler
33-
will copy automatically and non-implicitly copyable types that require
34-
the `copy` keyword to copy. Types that do not implement `Copy` may
35-
instead implement `Clone`.
36-
3728
*/
3829

3930
#[allow(missing_doc)];

src/libstd/local_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use task::local_data_priv::*;
5959
#[cfg(not(stage0))]
6060
pub type Key<T> = &'static KeyValue<T>;
6161
#[cfg(stage0)]
62-
pub type Key<'self,T> = &'self fn:Copy(v: T);
62+
pub type Key<'self,T> = &'self fn(v: T);
6363

6464
pub enum KeyValue<T> { Key }
6565

src/libstd/num/num.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use cmp::{Eq, ApproxEq, Ord};
1616
use ops::{Add, Sub, Mul, Div, Rem, Neg};
1717
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
1818
use option::Option;
19-
use kinds::Copy;
2019

2120
pub mod strconv;
2221

@@ -428,7 +427,7 @@ pub trait FromStrRadix {
428427
/// - If code written to use this function doesn't care about it, it's
429428
/// probably assuming that `x^0` always equals `1`.
430429
///
431-
pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(radix: uint, pow: uint) -> T {
430+
pub fn pow_with_uint<T:NumCast+One+Zero+Div<T,T>+Mul<T,T>>(radix: uint, pow: uint) -> T {
432431
let _0: T = Zero::zero();
433432
let _1: T = One::one();
434433

0 commit comments

Comments
 (0)