librustc: Remove all uses of the Copy
bound.
This commit is contained in:
parent
99d44d24c7
commit
e20549ff19
94 changed files with 213 additions and 280 deletions
|
@ -85,7 +85,7 @@ fn map_slices<A:Clone + Send,B:Clone + Send>(
|
|||
}
|
||||
|
||||
/// A parallel version of map.
|
||||
pub fn map<A:Copy + Clone + Send,B:Copy + Clone + Send>(
|
||||
pub fn map<A:Clone + Send,B:Clone + Send>(
|
||||
xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] {
|
||||
vec::concat(map_slices(xs, || {
|
||||
let f = fn_factory();
|
||||
|
@ -96,7 +96,7 @@ pub fn map<A:Copy + Clone + Send,B:Copy + Clone + Send>(
|
|||
}
|
||||
|
||||
/// A parallel version of mapi.
|
||||
pub fn mapi<A:Copy + Clone + Send,B:Copy + Clone + Send>(
|
||||
pub fn mapi<A:Clone + Send,B:Clone + Send>(
|
||||
xs: &[A],
|
||||
fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] {
|
||||
let slices = map_slices(xs, || {
|
||||
|
|
|
@ -650,10 +650,7 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
S: Encoder,
|
||||
T: Encodable<S> + Copy
|
||||
> Encodable<S> for DList<T> {
|
||||
impl<S: Encoder, T: Encodable<S>> Encodable<S> for @mut DList<T> {
|
||||
fn encode(&self, s: &mut S) {
|
||||
do s.emit_seq(self.len()) |s| {
|
||||
let mut i = 0;
|
||||
|
|
|
@ -24,12 +24,12 @@ type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
|
|||
* Has worst case O(n log n) performance, best case O(n), but
|
||||
* is not space efficient. This is a stable sort.
|
||||
*/
|
||||
pub fn merge_sort<T:Copy + Clone>(v: &[T], le: Le<T>) -> ~[T] {
|
||||
pub fn merge_sort<T:Clone>(v: &[T], le: Le<T>) -> ~[T] {
|
||||
type Slice = (uint, uint);
|
||||
|
||||
return merge_sort_(v, (0u, v.len()), le);
|
||||
|
||||
fn merge_sort_<T:Copy + Clone>(v: &[T], slice: Slice, le: Le<T>) -> ~[T] {
|
||||
fn merge_sort_<T:Clone>(v: &[T], slice: Slice, le: Le<T>) -> ~[T] {
|
||||
let begin = slice.first();
|
||||
let end = slice.second();
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub fn merge_sort<T:Copy + Clone>(v: &[T], le: Le<T>) -> ~[T] {
|
|||
merge_sort_(v, b, |x,y| le(x,y)));
|
||||
}
|
||||
|
||||
fn merge<T:Copy + Clone>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
|
||||
fn merge<T:Clone>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
|
||||
let mut rs = vec::with_capacity(a.len() + b.len());
|
||||
let a_len = a.len();
|
||||
let mut a_ix = 0;
|
||||
|
@ -183,7 +183,7 @@ static MIN_GALLOP: uint = 7;
|
|||
static INITIAL_TMP_STORAGE: uint = 128;
|
||||
|
||||
#[allow(missing_doc)]
|
||||
pub fn tim_sort<T:Copy + Clone + Ord>(array: &mut [T]) {
|
||||
pub fn tim_sort<T:Clone + Ord>(array: &mut [T]) {
|
||||
let size = array.len();
|
||||
if size < 2 {
|
||||
return;
|
||||
|
@ -227,7 +227,7 @@ pub fn tim_sort<T:Copy + Clone + Ord>(array: &mut [T]) {
|
|||
ms.merge_force_collapse(array);
|
||||
}
|
||||
|
||||
fn binarysort<T:Copy + Clone + Ord>(array: &mut [T], start: uint) {
|
||||
fn binarysort<T:Clone + Ord>(array: &mut [T], start: uint) {
|
||||
let size = array.len();
|
||||
let mut start = start;
|
||||
assert!(start <= size);
|
||||
|
@ -419,7 +419,7 @@ fn MergeState<T>() -> MergeState<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Clone + Ord> MergeState<T> {
|
||||
impl<T:Clone + Ord> MergeState<T> {
|
||||
fn push_run(&mut self, run_base: uint, run_len: uint) {
|
||||
let tmp = RunState{base: run_base, len: run_len};
|
||||
self.runs.push(tmp);
|
||||
|
@ -739,10 +739,7 @@ fn copy_vec<T:Clone>(dest: &mut [T],
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn shift_vec<T:Copy + Clone>(dest: &mut [T],
|
||||
s1: uint,
|
||||
s2: uint,
|
||||
len: uint) {
|
||||
fn shift_vec<T:Clone>(dest: &mut [T], s1: uint, s2: uint, len: uint) {
|
||||
assert!(s1+len <= dest.len());
|
||||
|
||||
let tmp = dest.slice(s2, s2+len).to_owned();
|
||||
|
|
|
@ -118,10 +118,8 @@ pub fn sleep(iotask: &IoTask, msecs: uint) {
|
|||
* on the provided port in the allotted timeout period, then the result will
|
||||
* be a `Some(T)`. If not, then `None` will be returned.
|
||||
*/
|
||||
pub fn recv_timeout<T:Copy + Send>(iotask: &IoTask,
|
||||
msecs: uint,
|
||||
wait_po: &Port<T>)
|
||||
-> Option<T> {
|
||||
pub fn recv_timeout<T:Send>(iotask: &IoTask, msecs: uint, wait_po: &Port<T>)
|
||||
-> Option<T> {
|
||||
let (timeout_po, timeout_ch) = stream::<()>();
|
||||
let mut timeout_po = timeout_po;
|
||||
delayed_send(iotask, msecs, &timeout_ch, ());
|
||||
|
|
|
@ -43,19 +43,19 @@ impl ValidUsage {
|
|||
}
|
||||
}
|
||||
|
||||
enum Action<'self> {
|
||||
Call(&'self fn:Copy(args: &[~str]) -> ValidUsage),
|
||||
CallMain(&'static str, &'self fn:Copy()),
|
||||
enum Action {
|
||||
Call(extern "Rust" fn(args: &[~str]) -> ValidUsage),
|
||||
CallMain(&'static str, extern "Rust" fn()),
|
||||
}
|
||||
|
||||
enum UsageSource<'self> {
|
||||
UsgStr(&'self str),
|
||||
UsgCall(&'self fn:Copy()),
|
||||
UsgCall(extern "Rust" fn()),
|
||||
}
|
||||
|
||||
struct Command<'self> {
|
||||
cmd: &'self str,
|
||||
action: Action<'self>,
|
||||
action: Action,
|
||||
usage_line: &'self str,
|
||||
usage_full: UsageSource<'self>,
|
||||
}
|
||||
|
|
|
@ -199,8 +199,9 @@ pub fn compile_rest(sess: Session,
|
|||
//
|
||||
// baz! should not use this definition unless foo is enabled.
|
||||
crate = time(time_passes, ~"std macros injection", ||
|
||||
syntax::ext::expand::inject_std_macros(sess.parse_sess, copy cfg,
|
||||
crate));
|
||||
syntax::ext::expand::inject_std_macros(sess.parse_sess,
|
||||
cfg.clone(),
|
||||
crate));
|
||||
|
||||
crate = time(time_passes, ~"configuration 1", ||
|
||||
front::config::strip_unconfigured_items(crate));
|
||||
|
|
|
@ -37,7 +37,7 @@ fn no_prelude(attrs: &[ast::attribute]) -> bool {
|
|||
}
|
||||
|
||||
fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
|
||||
fn spanned<T:Copy>(x: T) -> codemap::spanned<T> {
|
||||
fn spanned<T>(x: T) -> codemap::spanned<T> {
|
||||
codemap::spanned { node: x, span: dummy_sp() }
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
|
|||
return @item;
|
||||
}
|
||||
|
||||
fn nospan<T:Copy>(t: T) -> codemap::spanned<T> {
|
||||
fn nospan<T>(t: T) -> codemap::spanned<T> {
|
||||
codemap::spanned { node: t, span: dummy_sp() }
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
|
|||
} as @FileSearch
|
||||
}
|
||||
|
||||
pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
|
||||
pub fn search<T>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
|
||||
let mut rslt = None;
|
||||
for filesearch.for_each_lib_search_path() |lib_search_path| {
|
||||
debug!("searching %s", lib_search_path.to_str());
|
||||
|
|
|
@ -1282,14 +1282,14 @@ fn test_more() {
|
|||
fn test_simplification() {
|
||||
let ext_cx = mk_ctxt();
|
||||
let item_in = ast::ii_item(quote_item!(
|
||||
fn new_int_alist<B:Copy>() -> alist<int, B> {
|
||||
fn new_int_alist<B>() -> alist<int, B> {
|
||||
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||
return alist {eq_fn: eq_int, data: ~[]};
|
||||
}
|
||||
).get());
|
||||
let item_out = simplify_ast(&item_in);
|
||||
let item_exp = ast::ii_item(quote_item!(
|
||||
fn new_int_alist<B:Copy>() -> alist<int, B> {
|
||||
fn new_int_alist<B>() -> alist<int, B> {
|
||||
return alist {eq_fn: eq_int, data: ~[]};
|
||||
}
|
||||
).get());
|
||||
|
|
|
@ -561,7 +561,7 @@ pub fn each_lint(sess: session::Session,
|
|||
// This is used to make the simple visitors used for the lint passes
|
||||
// not traverse into subitems, since that is handled by the outer
|
||||
// lint visitor.
|
||||
fn item_stopping_visitor<E: Copy>(outer: visit::vt<E>) -> visit::vt<E> {
|
||||
fn item_stopping_visitor<E>(outer: visit::vt<E>) -> visit::vt<E> {
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
visit_item: |_i, (_e, _v)| { },
|
||||
visit_fn: |fk, fd, b, s, id, (e, v)| {
|
||||
|
|
|
@ -62,7 +62,7 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
|
|||
|
||||
fn store_type_uses(cx: Context, fn_id: def_id) -> @~[type_uses] {
|
||||
let Context { uses, ccx } = cx;
|
||||
let uses = @copy *uses; // freeze
|
||||
let uses = @(*uses).clone(); // freeze
|
||||
ccx.type_use_cache.insert(fn_id, uses);
|
||||
uses
|
||||
}
|
||||
|
|
|
@ -860,7 +860,7 @@ fn mk_rcache() -> creader_cache {
|
|||
return @mut HashMap::new();
|
||||
}
|
||||
|
||||
pub fn new_ty_hash<V:Copy>() -> @mut HashMap<t, V> {
|
||||
pub fn new_ty_hash<V>() -> @mut HashMap<t, V> {
|
||||
@mut HashMap::new()
|
||||
}
|
||||
|
||||
|
|
|
@ -1686,10 +1686,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
// through the `unpack` function. It there is no expected type or
|
||||
// resolution is not possible (e.g., no constraints yet present), just
|
||||
// returns `none`.
|
||||
fn unpack_expected<O:Copy>(fcx: @mut FnCtxt,
|
||||
expected: Option<ty::t>,
|
||||
unpack: &fn(&ty::sty) -> Option<O>)
|
||||
-> Option<O> {
|
||||
fn unpack_expected<O>(fcx: @mut FnCtxt,
|
||||
expected: Option<ty::t>,
|
||||
unpack: &fn(&ty::sty) -> Option<O>)
|
||||
-> Option<O> {
|
||||
match expected {
|
||||
Some(t) => {
|
||||
match resolve_type(fcx.infcx(), t, force_tvar) {
|
||||
|
|
|
@ -114,7 +114,8 @@ fn build_ctxt(sess: Session,
|
|||
use rustc::front::config;
|
||||
|
||||
let ast = syntax::ext::expand::inject_std_macros(sess.parse_sess,
|
||||
copy sess.opts.cfg, ast);
|
||||
sess.opts.cfg.clone(),
|
||||
ast);
|
||||
let ast = config::strip_unconfigured_items(ast);
|
||||
let ast = syntax::ext::expand::expand_crate(sess.parse_sess,
|
||||
sess.opts.cfg.clone(),
|
||||
|
|
|
@ -208,8 +208,8 @@ mod test {
|
|||
== ~"impl-of-selectt-u-for-left-right");
|
||||
assert!(pandoc_header_id("impl of Condition<'self, T, U>")
|
||||
== ~"impl-of-conditionself-t-u");
|
||||
assert!(pandoc_header_id("impl of Condition<T: Copy + Clone>")
|
||||
== ~"impl-of-conditiont-copy-clone");
|
||||
assert!(pandoc_header_id("impl of Condition<T: Clone>")
|
||||
== ~"impl-of-conditiont-clone");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -394,8 +394,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn should_add_impl_bounds() {
|
||||
let doc = mk_doc(~"impl<T, U: Copy, V: Copy + Clone> Option<T, U, V> { }");
|
||||
assert!(doc.cratemod().impls()[0].bounds_str == Some(~"<T, U: Copy, V: Copy + Clone>"));
|
||||
let doc = mk_doc(~"impl<T, U, V: Clone> Option<T, U, V> { }");
|
||||
assert!(doc.cratemod().impls()[0].bounds_str == Some(~"<T, U, V: Clone>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -839,7 +839,7 @@ fn install_check_duplicates() {
|
|||
fail!("package database contains duplicate ID");
|
||||
}
|
||||
else {
|
||||
contents.push(copy *p);
|
||||
contents.push((*p).clone());
|
||||
}
|
||||
false
|
||||
};
|
||||
|
|
|
@ -15,10 +15,9 @@ assign them or pass them as arguments, the receiver will get a copy,
|
|||
leaving the original value in place. These types do not require
|
||||
allocation to copy and do not have finalizers (i.e. they do not
|
||||
contain owned boxes or implement `Drop`), so the compiler considers
|
||||
them cheap and safe to copy and automatically implements the `Copy`
|
||||
trait for them. For other types copies must be made explicitly,
|
||||
by convention implementing the `Clone` trait and calling the
|
||||
`clone` method.
|
||||
them cheap and safe to copy. For other types copies must be made
|
||||
explicitly, by convention implementing the `Clone` trait and calling
|
||||
the `clone` method.
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<T, U> Condition<T, U> {
|
|||
|
||||
pub fn raise(&self, t: T) -> U {
|
||||
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
|
||||
self.raise_default(t, || fail!(copy msg))
|
||||
self.raise_default(t, || fail!(msg.clone()))
|
||||
}
|
||||
|
||||
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
|
||||
|
@ -78,7 +78,8 @@ impl<'self, T, U> Condition<'self, T, U> {
|
|||
pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
|
||||
unsafe {
|
||||
let p : *RustClosure = ::cast::transmute(&h);
|
||||
let prev = local_data::get(self.key, |k| k.map(|&x| *x));
|
||||
let prev = local_data::get(::cast::unsafe_copy(&self.key),
|
||||
|k| k.map(|&x| *x));
|
||||
let h = @Handler { handle: *p, prev: prev };
|
||||
Trap { cond: self, handler: h }
|
||||
}
|
||||
|
@ -91,7 +92,7 @@ impl<'self, T, U> Condition<'self, T, U> {
|
|||
|
||||
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
|
||||
unsafe {
|
||||
match local_data::pop(self.key) {
|
||||
match local_data::pop(::cast::unsafe_copy(&self.key)) {
|
||||
None => {
|
||||
debug!("Condition.raise: found no handler");
|
||||
default()
|
||||
|
@ -100,12 +101,15 @@ impl<'self, T, U> Condition<'self, T, U> {
|
|||
debug!("Condition.raise: found handler");
|
||||
match handler.prev {
|
||||
None => {}
|
||||
Some(hp) => local_data::set(self.key, hp)
|
||||
Some(hp) => {
|
||||
local_data::set(::cast::unsafe_copy(&self.key),
|
||||
hp)
|
||||
}
|
||||
}
|
||||
let handle : &fn(T) -> U =
|
||||
::cast::transmute(handler.handle);
|
||||
let u = handle(t);
|
||||
local_data::set(self.key, handler);
|
||||
local_data::set(::cast::unsafe_copy(&self.key), handler);
|
||||
u
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,22 +18,13 @@ intrinsic properties of the type. These classifications, often called
|
|||
They cannot be implemented by user code, but are instead implemented
|
||||
by the compiler automatically for the types to which they apply.
|
||||
|
||||
The 3 kinds are
|
||||
|
||||
* Copy - types that may be copied without allocation. This includes
|
||||
scalar types and managed pointers, and exludes owned pointers. It
|
||||
also excludes types that implement `Drop`.
|
||||
The 2 kinds are
|
||||
|
||||
* Send - owned types and types containing owned types. These types
|
||||
may be transferred across task boundaries.
|
||||
|
||||
* Freeze - types that are deeply immutable.
|
||||
|
||||
`Copy` types include both implicitly copyable types that the compiler
|
||||
will copy automatically and non-implicitly copyable types that require
|
||||
the `copy` keyword to copy. Types that do not implement `Copy` may
|
||||
instead implement `Clone`.
|
||||
|
||||
*/
|
||||
|
||||
#[allow(missing_doc)];
|
||||
|
|
|
@ -59,7 +59,7 @@ use task::local_data_priv::*;
|
|||
#[cfg(not(stage0))]
|
||||
pub type Key<T> = &'static KeyValue<T>;
|
||||
#[cfg(stage0)]
|
||||
pub type Key<'self,T> = &'self fn:Copy(v: T);
|
||||
pub type Key<'self,T> = &'self fn(v: T);
|
||||
|
||||
pub enum KeyValue<T> { Key }
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use cmp::{Eq, ApproxEq, Ord};
|
|||
use ops::{Add, Sub, Mul, Div, Rem, Neg};
|
||||
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
|
||||
use option::Option;
|
||||
use kinds::Copy;
|
||||
|
||||
pub mod strconv;
|
||||
|
||||
|
@ -428,7 +427,7 @@ pub trait FromStrRadix {
|
|||
/// - If code written to use this function doesn't care about it, it's
|
||||
/// probably assuming that `x^0` always equals `1`.
|
||||
///
|
||||
pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(radix: uint, pow: uint) -> T {
|
||||
pub fn pow_with_uint<T:NumCast+One+Zero+Div<T,T>+Mul<T,T>>(radix: uint, pow: uint) -> T {
|
||||
let _0: T = Zero::zero();
|
||||
let _1: T = One::one();
|
||||
|
||||
|
|
|
@ -16,9 +16,8 @@ use core::cmp::{Ord, Eq};
|
|||
use ops::{Add, Sub, Mul, Div, Rem, Neg};
|
||||
use option::{None, Option, Some};
|
||||
use char;
|
||||
use str::{StrSlice};
|
||||
use str;
|
||||
use str::StrSlice;
|
||||
use kinds::Copy;
|
||||
use vec::{CopyableVector, ImmutableVector, MutableVector};
|
||||
use vec::OwnedVector;
|
||||
use num::{NumCast, Zero, One, cast, pow_with_uint, Integer};
|
||||
|
@ -466,7 +465,7 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
|
|||
* - Fails if `radix` > 18 and `special == true` due to conflict
|
||||
* between digit and lowest first character in `inf` and `NaN`, the `'i'`.
|
||||
*/
|
||||
pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
|
||||
pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
|
||||
Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
|
||||
NumStrConv+Clone>(
|
||||
buf: &[u8], radix: uint, negative: bool, fractional: bool,
|
||||
|
@ -663,7 +662,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
|
|||
* `from_str_bytes_common()`, for details see there.
|
||||
*/
|
||||
#[inline]
|
||||
pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+
|
||||
pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+Mul<T,T>+
|
||||
Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv+Clone>(
|
||||
buf: &str, radix: uint, negative: bool, fractional: bool,
|
||||
special: bool, exponent: ExponentFormat, empty_zero: bool,
|
||||
|
|
|
@ -29,7 +29,7 @@ Rust's prelude has three main parts:
|
|||
|
||||
// Reexported core operators
|
||||
pub use either::{Either, Left, Right};
|
||||
pub use kinds::{Copy, Sized};
|
||||
pub use kinds::Sized;
|
||||
pub use kinds::{Freeze, Send};
|
||||
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
|
||||
pub use ops::{BitAnd, BitOr, BitXor};
|
||||
|
|
|
@ -356,7 +356,7 @@ pub trait RngUtil {
|
|||
* }
|
||||
* ~~~
|
||||
*/
|
||||
fn choose<T:Copy + Clone>(&mut self, values: &[T]) -> T;
|
||||
fn choose<T:Clone>(&mut self, values: &[T]) -> T;
|
||||
/// Choose Some(item) randomly, returning None if values is empty
|
||||
fn choose_option<T:Clone>(&mut self, values: &[T]) -> Option<T>;
|
||||
/**
|
||||
|
@ -379,7 +379,7 @@ pub trait RngUtil {
|
|||
* }
|
||||
* ~~~
|
||||
*/
|
||||
fn choose_weighted<T:Copy + Clone>(&mut self, v : &[Weighted<T>]) -> T;
|
||||
fn choose_weighted<T:Clone>(&mut self, v : &[Weighted<T>]) -> T;
|
||||
/**
|
||||
* Choose Some(item) respecting the relative weights, returning none if
|
||||
* the sum of the weights is 0
|
||||
|
@ -439,7 +439,7 @@ pub trait RngUtil {
|
|||
* }
|
||||
* ~~~
|
||||
*/
|
||||
fn shuffle<T:Copy + Clone>(&mut self, values: &[T]) -> ~[T];
|
||||
fn shuffle<T:Clone>(&mut self, values: &[T]) -> ~[T];
|
||||
/**
|
||||
* Shuffle a mutable vec in place
|
||||
*
|
||||
|
@ -532,7 +532,7 @@ impl<R: Rng> RngUtil for R {
|
|||
}
|
||||
|
||||
/// Choose an item randomly, failing if values is empty
|
||||
fn choose<T:Copy + Clone>(&mut self, values: &[T]) -> T {
|
||||
fn choose<T:Clone>(&mut self, values: &[T]) -> T {
|
||||
self.choose_option(values).get()
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ impl<R: Rng> RngUtil for R {
|
|||
* Choose an item respecting the relative weights, failing if the sum of
|
||||
* the weights is 0
|
||||
*/
|
||||
fn choose_weighted<T:Copy + Clone>(&mut self, v: &[Weighted<T>]) -> T {
|
||||
fn choose_weighted<T:Clone>(&mut self, v: &[Weighted<T>]) -> T {
|
||||
self.choose_weighted_option(v).get()
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ impl<R: Rng> RngUtil for R {
|
|||
}
|
||||
|
||||
/// Shuffle a vec
|
||||
fn shuffle<T:Copy + Clone>(&mut self, values: &[T]) -> ~[T] {
|
||||
fn shuffle<T:Clone>(&mut self, values: &[T]) -> ~[T] {
|
||||
let mut m = values.to_owned();
|
||||
self.shuffle_mut(m);
|
||||
m
|
||||
|
|
|
@ -15,6 +15,7 @@ use libc;
|
|||
use local_data;
|
||||
use prelude::*;
|
||||
use ptr;
|
||||
use sys;
|
||||
use task::rt;
|
||||
use util;
|
||||
|
||||
|
@ -156,8 +157,9 @@ unsafe fn get_local_map(handle: Handle) -> &mut TaskLocalMap {
|
|||
}
|
||||
}
|
||||
|
||||
fn key_to_key_value<T: 'static>(key: local_data::Key<T>) -> *libc::c_void {
|
||||
unsafe { cast::transmute(key) }
|
||||
unsafe fn key_to_key_value<T: 'static>(key: local_data::Key<T>) -> *libc::c_void {
|
||||
let pair: sys::Closure = cast::transmute_copy(&key);
|
||||
return pair.code as *libc::c_void;
|
||||
}
|
||||
|
||||
pub unsafe fn local_pop<T: 'static>(handle: Handle,
|
||||
|
|
|
@ -264,7 +264,8 @@ struct TrieNode<T> {
|
|||
impl<T> TrieNode<T> {
|
||||
#[inline]
|
||||
fn new() -> TrieNode<T> {
|
||||
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
|
||||
// FIXME: #5244: [Nothing, ..SIZE] should be possible without implicit
|
||||
// copyability
|
||||
TrieNode{count: 0,
|
||||
children: [Nothing, Nothing, Nothing, Nothing,
|
||||
Nothing, Nothing, Nothing, Nothing,
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#[allow(missing_doc)];
|
||||
|
||||
use clone::Clone;
|
||||
use kinds::Copy;
|
||||
use vec;
|
||||
use vec::ImmutableVector;
|
||||
use iterator::IteratorUtil;
|
||||
|
@ -86,8 +85,8 @@ pub trait ExtendedTupleOps<A,B> {
|
|||
}
|
||||
|
||||
impl<'self,
|
||||
A:Copy + Clone,
|
||||
B:Copy + Clone>
|
||||
A:Clone,
|
||||
B:Clone>
|
||||
ExtendedTupleOps<A,B> for
|
||||
(&'self [A], &'self [B]) {
|
||||
#[inline]
|
||||
|
@ -109,10 +108,7 @@ impl<'self,
|
|||
}
|
||||
}
|
||||
|
||||
impl<A:Copy + Clone,
|
||||
B:Copy + Clone>
|
||||
ExtendedTupleOps<A,B> for
|
||||
(~[A], ~[B]) {
|
||||
impl<A:Clone, B:Clone> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
|
||||
#[inline]
|
||||
fn zip(&self) -> ~[(A, B)] {
|
||||
match *self {
|
||||
|
|
|
@ -16,11 +16,13 @@ use opt_vec;
|
|||
use parse::token;
|
||||
use visit;
|
||||
|
||||
use std::cast::unsafe_copy;
|
||||
use std::cast;
|
||||
use std::hashmap::HashMap;
|
||||
use std::int;
|
||||
use std::local_data;
|
||||
use std::num;
|
||||
use std::option;
|
||||
use std::local_data;
|
||||
|
||||
pub fn path_name_i(idents: &[ident]) -> ~str {
|
||||
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
|
||||
|
|
|
@ -414,7 +414,7 @@ pub enum MapChain<K,V> {
|
|||
|
||||
|
||||
// get the map from an env frame
|
||||
impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
|
||||
impl <K: Eq + Hash + IterBytes, V> MapChain<K,V>{
|
||||
|
||||
// Constructor. I don't think we need a zero-arg one.
|
||||
fn new(init: ~HashMap<K,@V>) -> @mut MapChain<K,V> {
|
||||
|
|
|
@ -693,7 +693,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
|
|||
cfg: ast::crate_cfg, c: &crate) -> @crate {
|
||||
let sm = match parse_item_from_source_str(@"<std-macros>",
|
||||
std_macros(),
|
||||
copy cfg,
|
||||
cfg.clone(),
|
||||
~[],
|
||||
parse_sess) {
|
||||
Some(item) => item,
|
||||
|
@ -708,7 +708,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
|
|||
ast::_mod {
|
||||
items: items,
|
||||
// FIXME #2543: Bad copy.
|
||||
.. copy *modd
|
||||
.. (*modd).clone()
|
||||
}
|
||||
},
|
||||
.. *default_ast_fold()
|
||||
|
|
|
@ -473,10 +473,10 @@ impl Parser {
|
|||
|
||||
// parse a sequence bracketed by '<' and '>', stopping
|
||||
// before the '>'.
|
||||
pub fn parse_seq_to_before_gt<T: Copy>(&self,
|
||||
sep: Option<token::Token>,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> OptVec<T> {
|
||||
pub fn parse_seq_to_before_gt<T>(&self,
|
||||
sep: Option<token::Token>,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> OptVec<T> {
|
||||
let mut first = true;
|
||||
let mut v = opt_vec::Empty;
|
||||
while *self.token != token::GT
|
||||
|
@ -493,10 +493,10 @@ impl Parser {
|
|||
return v;
|
||||
}
|
||||
|
||||
pub fn parse_seq_to_gt<T: Copy>(&self,
|
||||
sep: Option<token::Token>,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> OptVec<T> {
|
||||
pub fn parse_seq_to_gt<T>(&self,
|
||||
sep: Option<token::Token>,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> OptVec<T> {
|
||||
let v = self.parse_seq_to_before_gt(sep, f);
|
||||
self.expect_gt();
|
||||
return v;
|
||||
|
@ -505,11 +505,11 @@ impl Parser {
|
|||
// parse a sequence, including the closing delimiter. The function
|
||||
// f must consume tokens until reaching the next separator or
|
||||
// closing bracket.
|
||||
pub fn parse_seq_to_end<T: Copy>(&self,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
pub fn parse_seq_to_end<T>(&self,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
let val = self.parse_seq_to_before_end(ket, sep, f);
|
||||
self.bump();
|
||||
val
|
||||
|
@ -518,11 +518,11 @@ impl Parser {
|
|||
// parse a sequence, not including the closing delimiter. The function
|
||||
// f must consume tokens until reaching the next separator or
|
||||
// closing bracket.
|
||||
pub fn parse_seq_to_before_end<T: Copy>(&self,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
pub fn parse_seq_to_before_end<T>(&self,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
let mut first: bool = true;
|
||||
let mut v: ~[T] = ~[];
|
||||
while *self.token != *ket {
|
||||
|
@ -542,12 +542,12 @@ impl Parser {
|
|||
// parse a sequence, including the closing delimiter. The function
|
||||
// f must consume tokens until reaching the next separator or
|
||||
// closing bracket.
|
||||
pub fn parse_unspanned_seq<T: Copy>(&self,
|
||||
bra: &token::Token,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
pub fn parse_unspanned_seq<T>(&self,
|
||||
bra: &token::Token,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> ~[T] {
|
||||
self.expect(bra);
|
||||
let result = self.parse_seq_to_before_end(ket, sep, f);
|
||||
self.bump();
|
||||
|
@ -556,12 +556,12 @@ impl Parser {
|
|||
|
||||
// NB: Do not use this function unless you actually plan to place the
|
||||
// spanned list in the AST.
|
||||
pub fn parse_seq<T: Copy>(&self,
|
||||
bra: &token::Token,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> spanned<~[T]> {
|
||||
pub fn parse_seq<T>(&self,
|
||||
bra: &token::Token,
|
||||
ket: &token::Token,
|
||||
sep: SeqSep,
|
||||
f: &fn(&Parser) -> T)
|
||||
-> spanned<~[T]> {
|
||||
let lo = self.span.lo;
|
||||
self.expect(bra);
|
||||
let result = self.parse_seq_to_before_end(ket, sep, f);
|
||||
|
|
|
@ -35,7 +35,7 @@ impl read for bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn read<T:read + Copy>(s: ~str) -> T {
|
||||
pub fn read<T:read>(s: ~str) -> T {
|
||||
match read::readMaybe(s) {
|
||||
Some(x) => x,
|
||||
_ => fail!("read failed!")
|
||||
|
|
|
@ -34,8 +34,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
return (xx as float) * 100f / (yy as float);
|
||||
}
|
||||
|
||||
fn le_by_val<TT:Copy + Clone,
|
||||
UU:Copy + Clone + Ord>(
|
||||
fn le_by_val<TT:Clone,
|
||||
UU:Clone + Ord>(
|
||||
kv0: &(TT,UU),
|
||||
kv1: &(TT,UU))
|
||||
-> bool {
|
||||
|
@ -44,8 +44,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
return v0 >= v1;
|
||||
}
|
||||
|
||||
fn le_by_key<TT:Copy + Clone + Ord,
|
||||
UU:Copy + Clone>(
|
||||
fn le_by_key<TT:Clone + Ord,
|
||||
UU:Clone>(
|
||||
kv0: &(TT,UU),
|
||||
kv1: &(TT,UU))
|
||||
-> bool {
|
||||
|
@ -55,10 +55,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
}
|
||||
|
||||
// sort by key, then by value
|
||||
fn sortKV<TT:Copy + Clone + Ord,
|
||||
UU:Copy + Clone + Ord>(
|
||||
orig: ~[(TT,UU)])
|
||||
-> ~[(TT,UU)] {
|
||||
fn sortKV<TT:Clone + Ord, UU:Clone + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
|
||||
return sort::merge_sort(sort::merge_sort(orig, le_by_key), le_by_val);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn foo<T>() {
|
||||
1u.bar::<T>(); //~ ERROR: does not fulfill `Copy`
|
||||
1u.bar::<T>(); //~ ERROR: does not fulfill `Send`
|
||||
}
|
||||
|
||||
trait bar {
|
||||
fn bar<T:Copy>(&self);
|
||||
fn bar<T:Send>(&self);
|
||||
}
|
||||
|
||||
impl bar for uint {
|
||||
fn bar<T:Copy>(&self) {
|
||||
fn bar<T:Send>(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct X {
|
||||
field: @fn:Copy(),
|
||||
field: @fn:Send(),
|
||||
}
|
||||
|
||||
fn foo(blk: @fn:()) -> X {
|
||||
return X { field: blk }; //~ ERROR expected bounds `Copy` but found no bounds
|
||||
return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm;
|
||||
|
||||
// If this were legal you could use it to copy captured noncopyables.
|
||||
// Issue (#2828)
|
||||
|
||||
fn foo(blk: ~fn:Copy()) {
|
||||
blk();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (p,c) = comm::stream();
|
||||
do foo {
|
||||
c.send(()); //~ ERROR does not fulfill `Copy`
|
||||
}
|
||||
p.recv();
|
||||
}
|
|
@ -2,38 +2,16 @@
|
|||
fn take_any(_: &fn:()) {
|
||||
}
|
||||
|
||||
fn take_copyable(_: &fn:Copy()) {
|
||||
}
|
||||
|
||||
fn take_copyable_owned(_: &fn:Copy+Send()) {
|
||||
}
|
||||
|
||||
fn take_const_owned(_: &fn:Freeze+Send()) {
|
||||
}
|
||||
|
||||
fn give_any(f: &fn:()) {
|
||||
take_any(f);
|
||||
take_copyable(f); //~ ERROR expected bounds `Copy` but found no bounds
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found no bounds
|
||||
}
|
||||
|
||||
fn give_copyable(f: &fn:Copy()) {
|
||||
take_any(f);
|
||||
take_copyable(f);
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Copy`
|
||||
}
|
||||
|
||||
fn give_owned(f: &fn:Send()) {
|
||||
take_any(f);
|
||||
take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Send`
|
||||
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Send`
|
||||
}
|
||||
|
||||
fn give_copyable_owned(f: &fn:Copy+Send()) {
|
||||
take_any(f);
|
||||
take_copyable(f);
|
||||
take_copyable_owned(f);
|
||||
take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Copy+Send`
|
||||
take_const_owned(f); //~ ERROR expected bounds `Freeze+Send` but found bounds `Send`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn reproduce<T:Copy>(t: T) -> @fn() -> T {
|
||||
fn reproduce<T>(t: T) -> @fn() -> T {
|
||||
let result: @fn() -> T = || t;
|
||||
result
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn mk_identity<T:Copy>() -> @fn(T) -> T {
|
||||
fn mk_identity<T>() -> @fn(T) -> T {
|
||||
let result: @fn(t: T) -> T = |t| t;
|
||||
result
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ fn main() {
|
|||
let mut res = foo(x);
|
||||
|
||||
let mut v = ~[];
|
||||
v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy`
|
||||
v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Clone`
|
||||
assert_eq!(v.len(), 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// than the trait method it's implementing
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy,D>(x: C) -> C;
|
||||
fn b<C,D>(x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
@ -20,7 +20,7 @@ struct E {
|
|||
}
|
||||
|
||||
impl A for E {
|
||||
fn b<F:Copy + Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
|
||||
fn b<F:Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// an impl against a trait
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy,D>(&self, x: C) -> C;
|
||||
fn b<C:Clone,D>(&self, x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
@ -21,7 +21,7 @@ struct E {
|
|||
|
||||
impl A for E {
|
||||
// n.b. The error message is awful -- see #3404
|
||||
fn b<F:Copy,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
|
||||
fn b<F:Clone,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
trait repeat<A> { fn get(&self) -> A; }
|
||||
|
||||
impl<A:Copy> repeat<A> for @A {
|
||||
impl<A:Clone> repeat<A> for @A {
|
||||
fn get(&self) -> A { **self }
|
||||
}
|
||||
|
||||
fn repeater<A:Copy>(v: @A) -> @repeat<A> {
|
||||
fn repeater<A:Clone>(v: @A) -> @repeat<A> {
|
||||
// Note: owned kind is not necessary as A appears in the trait type
|
||||
@v as @repeat<A> // No
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ trait foo {
|
|||
fn foo(&self, i: &'self int) -> int;
|
||||
}
|
||||
|
||||
impl<T:Copy> foo for T {
|
||||
impl<T:Clone> foo for T {
|
||||
fn foo(&self, i: &'self int) -> int {*i}
|
||||
}
|
||||
|
||||
fn to_foo<T:Copy>(t: T) {
|
||||
fn to_foo<T:Clone>(t: T) {
|
||||
// This version is ok because, although T may contain borrowed
|
||||
// pointers, it never escapes the fn body. We know this because
|
||||
// the type of foo includes a region which will be resolved to
|
||||
|
@ -33,14 +33,14 @@ fn to_foo<T:Copy>(t: T) {
|
|||
assert_eq!(x.foo(v), 3);
|
||||
}
|
||||
|
||||
fn to_foo_2<T:Copy>(t: T) -> @foo {
|
||||
fn to_foo_2<T:Clone>(t: T) -> @foo {
|
||||
// Not OK---T may contain borrowed ptrs and it is going to escape
|
||||
// as part of the returned foo value
|
||||
struct F<T> { f: T }
|
||||
@F {f:t} as @foo //~ ERROR value may contain borrowed pointers; add `'static` bound
|
||||
}
|
||||
|
||||
fn to_foo_3<T:Copy + 'static>(t: T) -> @foo {
|
||||
fn to_foo_3<T:Clone + 'static>(t: T) -> @foo {
|
||||
// OK---T may escape as part of the returned foo value, but it is
|
||||
// owned and hence does not contain borrowed ptrs
|
||||
struct F<T> { f: T }
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
trait foo { fn foo(&self); }
|
||||
|
||||
fn to_foo<T:Copy + foo>(t: T) -> @foo {
|
||||
fn to_foo<T:Clone + foo>(t: T) -> @foo {
|
||||
@t as @foo
|
||||
//~^ ERROR value may contain borrowed pointers; add `'static` bound
|
||||
//~^^ ERROR cannot pack type
|
||||
}
|
||||
|
||||
fn to_foo2<T:Copy + foo + 'static>(t: T) -> @foo {
|
||||
fn to_foo2<T:Clone + foo + 'static>(t: T) -> @foo {
|
||||
@t as @foo
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ trait Foo {
|
|||
fn a(_x: ~Foo:Send) {
|
||||
}
|
||||
|
||||
fn b(_x: ~Foo:Send+Copy) {
|
||||
fn b(_x: ~Foo:Send+Clone) {
|
||||
}
|
||||
|
||||
fn c(x: ~Foo:Freeze+Send) {
|
||||
b(x); //~ ERROR expected bounds `Copy+Send`
|
||||
b(x); //~ ERROR expected bounds `Clone+Send`
|
||||
}
|
||||
|
||||
fn d(x: ~Foo:) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
struct Pair<T, U> { a: T, b: U }
|
||||
struct Triple { x: int, y: int, z: int }
|
||||
|
||||
fn f<T:Copy,U:Copy>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
|
||||
fn f<T,U>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
|
||||
|
||||
pub fn main() {
|
||||
info!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f<T:Copy>(x: ~[T]) -> T { return x[0]; }
|
||||
fn f<T>(x: ~[T]) -> T { return x[0]; }
|
||||
|
||||
fn g(act: &fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); }
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
fn clamp<T:Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
cond!(
|
||||
(x > mx) { return mx; }
|
||||
(x < mn) { return mn; }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
fn clamp<T:Ord + Signed>(x: T, mn: T, mx: T) -> T {
|
||||
cond!(
|
||||
(x > mx) { mx }
|
||||
(x < mn) { mn }
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// are const.
|
||||
|
||||
|
||||
fn foo<T:Copy + Freeze>(x: T) -> T { x }
|
||||
fn foo<T:Freeze>(x: T) -> T { x }
|
||||
|
||||
struct F { field: int }
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// -*- rust -*-
|
||||
type compare<T> = @fn(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = { expected.clone() };
|
||||
assert!((eq(expected, actual)));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ fn test_vec() {
|
|||
}
|
||||
|
||||
fn test_generic() {
|
||||
fn f<T:Copy>(t: T) -> T { t }
|
||||
fn f<T>(t: T) -> T { t }
|
||||
assert_eq!(f(10), 10);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// -*- rust -*-
|
||||
type compare<T> = @fn(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = match true {
|
||||
true => { expected.clone() },
|
||||
_ => fail!("wat")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
type compare<T> = @fn(T, T) -> bool;
|
||||
|
||||
fn test_generic<T:Copy+Clone>(expected: T, eq: compare<T>) {
|
||||
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
|
||||
let actual: T = match true {
|
||||
true => expected.clone(),
|
||||
_ => fail!("wat")
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn id<T:Copy>(t: T) -> T { return t; }
|
||||
fn id<T>(t: T) -> T { return t; }
|
||||
|
||||
pub fn main() {
|
||||
let expected = @100;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn id<T:Copy + Send>(t: T) -> T { return t; }
|
||||
fn id<T:Send>(t: T) -> T { return t; }
|
||||
|
||||
pub fn main() {
|
||||
let expected = ~100;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
|
||||
fn box<T:Copy>(x: Box<T>) -> @Box<T> { return @x; }
|
||||
fn box<T>(x: Box<T>) -> @Box<T> { return @x; }
|
||||
|
||||
struct Box<T> {x: T, y: T, z: T}
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
struct Pair { x: @int, y: @int }
|
||||
|
||||
fn f<T:Copy>(t: T) { let t1: T = t; }
|
||||
fn f<T>(t: T) { let t1: T = t; }
|
||||
|
||||
pub fn main() { let x = Pair {x: @10, y: @12}; f(x); }
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
struct Recbox<T> {x: @T}
|
||||
|
||||
fn reclift<T:Copy>(t: T) -> Recbox<T> { return Recbox {x: @t}; }
|
||||
fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: @t}; }
|
||||
|
||||
pub fn main() {
|
||||
let foo: int = 17;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
struct Recbox<T> {x: ~T}
|
||||
|
||||
fn reclift<T:Copy>(t: T) -> Recbox<T> { return Recbox {x: ~t}; }
|
||||
fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: ~t}; }
|
||||
|
||||
pub fn main() {
|
||||
let foo: int = 17;
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// Issue #45: infer type parameters in function applications
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
pub fn main() { let x: int = 42; let y: int = id(x); assert!((x == y)); }
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
fn f<T:Copy>(x: ~T) -> ~T { return x; }
|
||||
fn f<T>(x: ~T) -> ~T { return x; }
|
||||
|
||||
pub fn main() { let x = f(~3); info!(*x); }
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
// -*- rust -*-
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
struct Triple {x: int, y: int, z: int}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn get_third<T:Copy>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
|
||||
fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
|
||||
|
||||
pub fn main() {
|
||||
info!(get_third((1, 2, 3)));
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
struct Triple<T> { x: T, y: T, z: T }
|
||||
|
||||
fn box<T:Copy>(x: Triple<T>) -> ~Triple<T> { return ~x; }
|
||||
fn box<T>(x: Triple<T>) -> ~Triple<T> { return ~x; }
|
||||
|
||||
pub fn main() {
|
||||
let x: ~Triple<int> = box::<int>(Triple{x: 1, y: 2, z: 3});
|
||||
|
|
|
@ -8,25 +8,25 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait clam<A:Copy> {
|
||||
trait clam<A> {
|
||||
fn chowder(&self, y: A);
|
||||
}
|
||||
struct foo<A> {
|
||||
x: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> clam<A> for foo<A> {
|
||||
impl<A> clam<A> for foo<A> {
|
||||
fn chowder(&self, y: A) {
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<A:Copy>(b: A) -> foo<A> {
|
||||
fn foo<A>(b: A) -> foo<A> {
|
||||
foo {
|
||||
x: b
|
||||
}
|
||||
}
|
||||
|
||||
fn f<A:Copy>(x: @clam<A>, a: A) {
|
||||
fn f<A>(x: @clam<A>, a: A) {
|
||||
x.chowder(a);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait clam<A:Copy> { }
|
||||
trait clam<A> { }
|
||||
struct foo<A> {
|
||||
x: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> foo<A> {
|
||||
impl<A> foo<A> {
|
||||
pub fn bar<B,C:clam<A>>(&self, c: C) -> B {
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<A:Copy>(b: A) -> foo<A> {
|
||||
fn foo<A>(b: A) -> foo<A> {
|
||||
foo {
|
||||
x: b
|
||||
}
|
||||
|
|
|
@ -12,18 +12,18 @@ struct c1<T> {
|
|||
x: T,
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f1(&self, x: int) {
|
||||
}
|
||||
}
|
||||
|
||||
fn c1<T:Copy>(x: T) -> c1<T> {
|
||||
fn c1<T>(x: T) -> c1<T> {
|
||||
c1 {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f2(&self, x: int) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,17 @@ struct c1<T> {
|
|||
x: T,
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f1(&self, x: T) {}
|
||||
}
|
||||
|
||||
fn c1<T:Copy>(x: T) -> c1<T> {
|
||||
fn c1<T>(x: T) -> c1<T> {
|
||||
c1 {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Copy> c1<T> {
|
||||
impl<T> c1<T> {
|
||||
pub fn f2(&self, x: T) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ fn C(x: uint) -> C {
|
|||
}
|
||||
}
|
||||
|
||||
fn f<T:Copy>(_x: T) {
|
||||
fn f<T>(_x: T) {
|
||||
}
|
||||
|
||||
#[deny(non_implicitly_copyable_typarams)]
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// than the traits require.
|
||||
|
||||
trait A {
|
||||
fn b<C:Copy + Freeze,D>(x: C) -> C;
|
||||
fn b<C:Freeze,D>(x: C) -> C;
|
||||
}
|
||||
|
||||
struct E {
|
||||
|
@ -20,7 +20,7 @@ struct E {
|
|||
}
|
||||
|
||||
impl A for E {
|
||||
fn b<F:Copy,G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
|
||||
fn b<F,G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn Matrix4<T:Copy>(m11: T, m12: T, m13: T, m14: T,
|
||||
m21: T, m22: T, m23: T, m24: T,
|
||||
m31: T, m32: T, m33: T, m34: T,
|
||||
m41: T, m42: T, m43: T, m44: T)
|
||||
-> Matrix4<T> {
|
||||
|
||||
fn Matrix4<T>(m11: T, m12: T, m13: T, m14: T,
|
||||
m21: T, m22: T, m23: T, m24: T,
|
||||
m31: T, m32: T, m33: T, m34: T,
|
||||
m41: T, m42: T, m43: T, m44: T)
|
||||
-> Matrix4<T> {
|
||||
Matrix4 {
|
||||
m11: m11, m12: m12, m13: m13, m14: m14,
|
||||
m21: m21, m22: m22, m23: m23, m24: m24,
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn quux<T:Copy>(x: T) -> T { let f = id::<T>; return f(x); }
|
||||
fn quux<T>(x: T) -> T { let f = id::<T>; return f(x); }
|
||||
|
||||
fn id<T:Copy>(x: T) -> T { return x; }
|
||||
fn id<T>(x: T) -> T { return x; }
|
||||
|
||||
pub fn main() { assert!((quux(10) == 10)); }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn double<T:Copy + Clone>(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; }
|
||||
fn double<T:Clone>(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; }
|
||||
|
||||
fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; }
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
use std::int;
|
||||
|
||||
trait vec_monad<A> {
|
||||
fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
|
||||
fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
|
||||
}
|
||||
|
||||
impl<A> vec_monad<A> for ~[A] {
|
||||
fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
|
||||
fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
|
||||
let mut r = ~[];
|
||||
for self.iter().advance |elt| {
|
||||
r.push_all_move(f(elt));
|
||||
|
|
|
@ -25,7 +25,7 @@ impl Serializable for int {
|
|||
|
||||
struct F<A> { a: A }
|
||||
|
||||
impl<A:Copy + Serializable> Serializable for F<A> {
|
||||
impl<A:Serializable> Serializable for F<A> {
|
||||
fn serialize<S:Serializer>(&self, s: S) {
|
||||
self.a.serialize(s);
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ extern mod extra;
|
|||
|
||||
use extra::list::*;
|
||||
|
||||
fn pure_length_go<T:Copy>(ls: @List<T>, acc: uint) -> uint {
|
||||
fn pure_length_go<T>(ls: @List<T>, acc: uint) -> uint {
|
||||
match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } }
|
||||
}
|
||||
|
||||
fn pure_length<T:Copy>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
|
||||
fn pure_length<T>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
|
||||
|
||||
fn nonempty_list<T:Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
||||
fn nonempty_list<T>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
||||
|
||||
fn safe_head<T:Copy>(ls: @List<T>) -> T {
|
||||
fn safe_head<T>(ls: @List<T>) -> T {
|
||||
assert!(!is_empty(ls));
|
||||
return head(ls);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ fn iter<T>(v: ~[T], it: &fn(&T) -> bool) -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
fn find_pos<T:Eq + Copy + Clone>(n: T, h: ~[T]) -> Option<uint> {
|
||||
fn find_pos<T:Eq + Clone>(n: T, h: ~[T]) -> Option<uint> {
|
||||
let mut i = 0u;
|
||||
for iter(h.clone()) |e| {
|
||||
if *e == n { return Some(i); }
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
enum option<T> { none, some(T), }
|
||||
|
||||
fn f<T:Copy>() -> option<T> { return none; }
|
||||
fn f<T>() -> option<T> { return none; }
|
||||
|
||||
pub fn main() { f::<int>(); }
|
||||
|
|
|
@ -43,13 +43,13 @@ impl uint_utils for uint {
|
|||
trait vec_utils<T> {
|
||||
fn length_(&self, ) -> uint;
|
||||
fn iter_(&self, f: &fn(&T));
|
||||
fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
}
|
||||
|
||||
impl<T> vec_utils<T> for ~[T] {
|
||||
fn length_(&self) -> uint { self.len() }
|
||||
fn iter_(&self, f: &fn(&T)) { for self.iter().advance |x| { f(x); } }
|
||||
fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
let mut r = ~[];
|
||||
for self.iter().advance |elt| {
|
||||
r.push(f(elt));
|
||||
|
|
|
@ -24,7 +24,7 @@ struct t_rec<A,B> {
|
|||
tB: a_tag<A,B>
|
||||
}
|
||||
|
||||
fn mk_rec<A:Copy,B:Copy>(a: A, b: B) -> t_rec<A,B> {
|
||||
fn mk_rec<A,B>(a: A, b: B) -> t_rec<A,B> {
|
||||
return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ fn c(x: ~Foo:Freeze+Send) {
|
|||
a(x);
|
||||
}
|
||||
|
||||
fn d(x: ~Foo:Send+Copy) {
|
||||
fn d(x: ~Foo:Send) {
|
||||
b(x);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ impl to_str for () {
|
|||
}
|
||||
|
||||
trait map<T> {
|
||||
fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
fn map<U>(&self, f: &fn(&T) -> U) -> ~[U];
|
||||
}
|
||||
impl<T> map<T> for ~[T] {
|
||||
fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
fn map<U>(&self, f: &fn(&T) -> U) -> ~[U] {
|
||||
let mut r = ~[];
|
||||
// FIXME: #7355 generates bad code with Iterator
|
||||
for std::uint::range(0, self.len()) |i| {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
extern mod trait_inheritance_overloading_xc;
|
||||
use trait_inheritance_overloading_xc::{MyNum, MyInt};
|
||||
|
||||
fn f<T:Copy + MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
return (x + y, x - y, x * y);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ impl Eq for MyInt {
|
|||
|
||||
impl MyNum for MyInt;
|
||||
|
||||
fn f<T:Copy + MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
||||
return (x + y, x - y, x * y);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// xfail-fast
|
||||
|
||||
fn p_foo<T>(pinned: T) { }
|
||||
fn s_foo<T:Copy>(shared: T) { }
|
||||
fn s_foo<T>(shared: T) { }
|
||||
fn u_foo<T:Send>(unique: T) { }
|
||||
|
||||
struct r {
|
||||
|
|
|
@ -20,7 +20,7 @@ struct Pointy {
|
|||
d : ~fn() -> uint,
|
||||
}
|
||||
|
||||
fn make_uniq_closure<A:Send + Copy>(a: A) -> ~fn() -> uint {
|
||||
fn make_uniq_closure<A:Send>(a: A) -> ~fn() -> uint {
|
||||
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||
result
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f<T:Copy>(t: T) -> T {
|
||||
fn f<T>(t: T) -> T {
|
||||
let t1 = t;
|
||||
t1
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// Issue #976
|
||||
|
||||
fn f<T:Copy>(x: ~T) {
|
||||
fn f<T>(x: ~T) {
|
||||
let _x2 = x;
|
||||
}
|
||||
pub fn main() { }
|
||||
|
|
|
@ -30,11 +30,11 @@ fn sendable() {
|
|||
|
||||
fn copyable() {
|
||||
|
||||
fn f<T:Copy + Eq>(i: T, j: T) {
|
||||
fn f<T:Eq>(i: T, j: T) {
|
||||
assert_eq!(i, j);
|
||||
}
|
||||
|
||||
fn g<T:Copy + Eq>(i: T, j: T) {
|
||||
fn g<T:Eq>(i: T, j: T) {
|
||||
assert!(i != j);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
fn foldl<T, U: Copy+Clone>(
|
||||
values: &[T],
|
||||
initial: U,
|
||||
function: &fn(partial: U, element: &T) -> U
|
||||
) -> U {
|
||||
fn foldl<T,U:Clone>(values: &[T],
|
||||
initial: U,
|
||||
function: &fn(partial: U, element: &T) -> U)
|
||||
-> U {
|
||||
match values {
|
||||
[ref head, ..tail] =>
|
||||
foldl(tail, function(initial, head), function),
|
||||
|
@ -10,11 +9,10 @@ fn foldl<T, U: Copy+Clone>(
|
|||
}
|
||||
}
|
||||
|
||||
fn foldr<T, U: Copy+Clone>(
|
||||
values: &[T],
|
||||
initial: U,
|
||||
function: &fn(element: &T, partial: U) -> U
|
||||
) -> U {
|
||||
fn foldr<T,U:Clone>(values: &[T],
|
||||
initial: U,
|
||||
function: &fn(element: &T, partial: U) -> U)
|
||||
-> U {
|
||||
match values {
|
||||
[..head, ref tail] =>
|
||||
foldr(head, function(tail, initial), function),
|
||||
|
|
Loading…
Add table
Reference in a new issue