diff --git a/src/libextra/par.rs b/src/libextra/par.rs index 1c686843ab0..74ebf525e00 100644 --- a/src/libextra/par.rs +++ b/src/libextra/par.rs @@ -85,7 +85,7 @@ fn map_slices( } /// A parallel version of map. -pub fn map( +pub fn map( 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 parallel version of mapi. -pub fn mapi( +pub fn mapi( xs: &[A], fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { let slices = map_slices(xs, || { diff --git a/src/libextra/serialize.rs b/src/libextra/serialize.rs index 9fec58e7495..53db93313a6 100644 --- a/src/libextra/serialize.rs +++ b/src/libextra/serialize.rs @@ -650,10 +650,7 @@ impl< } } -impl< - S: Encoder, - T: Encodable + Copy -> Encodable for DList { +impl> Encodable for @mut DList { fn encode(&self, s: &mut S) { do s.emit_seq(self.len()) |s| { let mut i = 0; diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index 8a21ea0bd3b..a11b819dda1 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -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(v: &[T], le: Le) -> ~[T] { +pub fn merge_sort(v: &[T], le: Le) -> ~[T] { type Slice = (uint, uint); return merge_sort_(v, (0u, v.len()), le); - fn merge_sort_(v: &[T], slice: Slice, le: Le) -> ~[T] { + fn merge_sort_(v: &[T], slice: Slice, le: Le) -> ~[T] { let begin = slice.first(); let end = slice.second(); @@ -44,7 +44,7 @@ pub fn merge_sort(v: &[T], le: Le) -> ~[T] { merge_sort_(v, b, |x,y| le(x,y))); } - fn merge(le: Le, a: &[T], b: &[T]) -> ~[T] { + fn merge(le: Le, 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(array: &mut [T]) { +pub fn tim_sort(array: &mut [T]) { let size = array.len(); if size < 2 { return; @@ -227,7 +227,7 @@ pub fn tim_sort(array: &mut [T]) { ms.merge_force_collapse(array); } -fn binarysort(array: &mut [T], start: uint) { +fn binarysort(array: &mut [T], start: uint) { let size = array.len(); let mut start = start; assert!(start <= size); @@ -419,7 +419,7 @@ fn MergeState() -> MergeState { } } -impl MergeState { +impl MergeState { 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(dest: &mut [T], } #[inline] -fn shift_vec(dest: &mut [T], - s1: uint, - s2: uint, - len: uint) { +fn shift_vec(dest: &mut [T], s1: uint, s2: uint, len: uint) { assert!(s1+len <= dest.len()); let tmp = dest.slice(s2, s2+len).to_owned(); diff --git a/src/libextra/timer.rs b/src/libextra/timer.rs index d957ac43801..1cfbeb9e514 100644 --- a/src/libextra/timer.rs +++ b/src/libextra/timer.rs @@ -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(iotask: &IoTask, - msecs: uint, - wait_po: &Port) - -> Option { +pub fn recv_timeout(iotask: &IoTask, msecs: uint, wait_po: &Port) + -> Option { let (timeout_po, timeout_ch) = stream::<()>(); let mut timeout_po = timeout_po; delayed_send(iotask, msecs, &timeout_ch, ()); diff --git a/src/librust/rust.rs b/src/librust/rust.rs index adf73a7e7f0..bc97ef0e8ca 100644 --- a/src/librust/rust.rs +++ b/src/librust/rust.rs @@ -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>, } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 2c1f3dd1918..e85b3239e80 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -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)); diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 3d4b22ecd8c..6865428cd69 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -37,7 +37,7 @@ fn no_prelude(attrs: &[ast::attribute]) -> bool { } fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate { - fn spanned(x: T) -> codemap::spanned { + fn spanned(x: T) -> codemap::spanned { codemap::spanned { node: x, span: dummy_sp() } } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 61a530b307c..e83c5ff6d10 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -343,7 +343,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item { return @item; } -fn nospan(t: T) -> codemap::spanned { +fn nospan(t: T) -> codemap::spanned { codemap::spanned { node: t, span: dummy_sp() } } diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 62bbe22a043..112965127a2 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -87,7 +87,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>, } as @FileSearch } -pub fn search(filesearch: @FileSearch, pick: pick) -> Option { +pub fn search(filesearch: @FileSearch, pick: pick) -> Option { let mut rslt = None; for filesearch.for_each_lib_search_path() |lib_search_path| { debug!("searching %s", lib_search_path.to_str()); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index d4d20e75c9d..6201283939f 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -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() -> alist { + fn new_int_alist() -> alist { 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() -> alist { + fn new_int_alist() -> alist { return alist {eq_fn: eq_int, data: ~[]}; } ).get()); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 6d3f50073f2..9fb07927d98 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -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(outer: visit::vt) -> visit::vt { +fn item_stopping_visitor(outer: visit::vt) -> visit::vt { visit::mk_vt(@visit::Visitor { visit_item: |_i, (_e, _v)| { }, visit_fn: |fk, fd, b, s, id, (e, v)| { diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index c708331e1c4..2c63079ad8f 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -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 } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 5910eaacc5d..8eefcb154ef 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -860,7 +860,7 @@ fn mk_rcache() -> creader_cache { return @mut HashMap::new(); } -pub fn new_ty_hash() -> @mut HashMap { +pub fn new_ty_hash() -> @mut HashMap { @mut HashMap::new() } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 42b861b7330..4a9e0fddbe7 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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(fcx: @mut FnCtxt, - expected: Option, - unpack: &fn(&ty::sty) -> Option) - -> Option { + fn unpack_expected(fcx: @mut FnCtxt, + expected: Option, + unpack: &fn(&ty::sty) -> Option) + -> Option { match expected { Some(t) => { match resolve_type(fcx.infcx(), t, force_tvar) { diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index b20d8cab2a4..16a89122a11 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -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(), diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index e766909b8ab..2c6312e01b2 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -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") - == ~"impl-of-conditiont-copy-clone"); + assert!(pandoc_header_id("impl of Condition") + == ~"impl-of-conditiont-clone"); } #[test] diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index f66aeca06ff..044ab322605 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -394,8 +394,8 @@ mod test { #[test] fn should_add_impl_bounds() { - let doc = mk_doc(~"impl Option { }"); - assert!(doc.cratemod().impls()[0].bounds_str == Some(~"")); + let doc = mk_doc(~"impl Option { }"); + assert!(doc.cratemod().impls()[0].bounds_str == Some(~"")); } #[test] diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 9d4c2f87a61..b6dabfd0b12 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -839,7 +839,7 @@ fn install_check_duplicates() { fail!("package database contains duplicate ID"); } else { - contents.push(copy *p); + contents.push((*p).clone()); } false }; diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 947aa5708c2..f24bc002a2b 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -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. */ diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index 80caa34ce06..10075137017 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -47,7 +47,7 @@ impl Condition { 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 } } diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index 6c16ecc0d4e..f2f8f46e7cd 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -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)]; diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 168bb7c14f0..2c1a3bb29a0 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -59,7 +59,7 @@ use task::local_data_priv::*; #[cfg(not(stage0))] pub type Key = &'static KeyValue; #[cfg(stage0)] -pub type Key<'self,T> = &'self fn:Copy(v: T); +pub type Key<'self,T> = &'self fn(v: T); pub enum KeyValue { Key } diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index 4468b51c261..fc199876902 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -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+Mul>(radix: uint, pow: uint) -> T { +pub fn pow_with_uint+Mul>(radix: uint, pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 4661bc20403..ab17c5f175a 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -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+ +pub fn from_str_bytes_common+ Mul+Sub+Neg+Add+ NumStrConv+Clone>( buf: &[u8], radix: uint, negative: bool, fractional: bool, @@ -663,7 +662,7 @@ pub fn from_str_bytes_common+ * `from_str_bytes_common()`, for details see there. */ #[inline] -pub fn from_str_common+Mul+ +pub fn from_str_common+Mul+ Sub+Neg+Add+NumStrConv+Clone>( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool, diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 8be34896bef..e3e042a4947 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -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}; diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 7d65ba63ff0..76dbc629168 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -356,7 +356,7 @@ pub trait RngUtil { * } * ~~~ */ - fn choose(&mut self, values: &[T]) -> T; + fn choose(&mut self, values: &[T]) -> T; /// Choose Some(item) randomly, returning None if values is empty fn choose_option(&mut self, values: &[T]) -> Option; /** @@ -379,7 +379,7 @@ pub trait RngUtil { * } * ~~~ */ - fn choose_weighted(&mut self, v : &[Weighted]) -> T; + fn choose_weighted(&mut self, v : &[Weighted]) -> 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(&mut self, values: &[T]) -> ~[T]; + fn shuffle(&mut self, values: &[T]) -> ~[T]; /** * Shuffle a mutable vec in place * @@ -532,7 +532,7 @@ impl RngUtil for R { } /// Choose an item randomly, failing if values is empty - fn choose(&mut self, values: &[T]) -> T { + fn choose(&mut self, values: &[T]) -> T { self.choose_option(values).get() } @@ -548,7 +548,7 @@ impl RngUtil for R { * Choose an item respecting the relative weights, failing if the sum of * the weights is 0 */ - fn choose_weighted(&mut self, v: &[Weighted]) -> T { + fn choose_weighted(&mut self, v: &[Weighted]) -> T { self.choose_weighted_option(v).get() } @@ -591,7 +591,7 @@ impl RngUtil for R { } /// Shuffle a vec - fn shuffle(&mut self, values: &[T]) -> ~[T] { + fn shuffle(&mut self, values: &[T]) -> ~[T] { let mut m = values.to_owned(); self.shuffle_mut(m); m diff --git a/src/libstd/task/local_data_priv.rs b/src/libstd/task/local_data_priv.rs index 75fd6eacc1b..d5f4973e8c7 100644 --- a/src/libstd/task/local_data_priv.rs +++ b/src/libstd/task/local_data_priv.rs @@ -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(key: local_data::Key) -> *libc::c_void { - unsafe { cast::transmute(key) } +unsafe fn key_to_key_value(key: local_data::Key) -> *libc::c_void { + let pair: sys::Closure = cast::transmute_copy(&key); + return pair.code as *libc::c_void; } pub unsafe fn local_pop(handle: Handle, diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 396fdaf2e6a..df6f77fd6ce 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -264,7 +264,8 @@ struct TrieNode { impl TrieNode { #[inline] fn new() -> TrieNode { - // 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, diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index 841be4df6e2..6201e753bc9 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -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 { } impl<'self, - A:Copy + Clone, - B:Copy + Clone> + A:Clone, + B:Clone> ExtendedTupleOps for (&'self [A], &'self [B]) { #[inline] @@ -109,10 +108,7 @@ impl<'self, } } -impl - ExtendedTupleOps for - (~[A], ~[B]) { +impl ExtendedTupleOps for (~[A], ~[B]) { #[inline] fn zip(&self) -> ~[(A, B)] { match *self { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 843fd4bdba2..d0dfb0fb06e 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -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") diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e2f37bd54bd..230640767c9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -414,7 +414,7 @@ pub enum MapChain { // get the map from an env frame -impl MapChain{ +impl MapChain{ // Constructor. I don't think we need a zero-arg one. fn new(init: ~HashMap) -> @mut MapChain { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ba8e3e72933..2f1d320fef7 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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(), - 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() diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f0b9258eaeb..adecbc050a3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -473,10 +473,10 @@ impl Parser { // parse a sequence bracketed by '<' and '>', stopping // before the '>'. - pub fn parse_seq_to_before_gt(&self, - sep: Option, - f: &fn(&Parser) -> T) - -> OptVec { + pub fn parse_seq_to_before_gt(&self, + sep: Option, + f: &fn(&Parser) -> T) + -> OptVec { 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(&self, - sep: Option, - f: &fn(&Parser) -> T) - -> OptVec { + pub fn parse_seq_to_gt(&self, + sep: Option, + f: &fn(&Parser) -> T) + -> OptVec { 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(&self, - ket: &token::Token, - sep: SeqSep, - f: &fn(&Parser) -> T) - -> ~[T] { + pub fn parse_seq_to_end(&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(&self, - ket: &token::Token, - sep: SeqSep, - f: &fn(&Parser) -> T) - -> ~[T] { + pub fn parse_seq_to_before_end(&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(&self, - bra: &token::Token, - ket: &token::Token, - sep: SeqSep, - f: &fn(&Parser) -> T) - -> ~[T] { + pub fn parse_unspanned_seq(&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(&self, - bra: &token::Token, - ket: &token::Token, - sep: SeqSep, - f: &fn(&Parser) -> T) - -> spanned<~[T]> { + pub fn parse_seq(&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); diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index b5b33853129..180cb18c745 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -35,7 +35,7 @@ impl read for bool { } } -pub fn read(s: ~str) -> T { +pub fn read(s: ~str) -> T { match read::readMaybe(s) { Some(x) => x, _ => fail!("read failed!") diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 64cfa2561a4..86ab99407b9 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -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( + fn le_by_val( 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( + fn le_by_key( 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( - orig: ~[(TT,UU)]) - -> ~[(TT,UU)] { + fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { return sort::merge_sort(sort::merge_sort(orig, le_by_key), le_by_val); } diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index d5b8f99ada0..db6db02ded5 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -9,15 +9,15 @@ // except according to those terms. fn foo() { - 1u.bar::(); //~ ERROR: does not fulfill `Copy` + 1u.bar::(); //~ ERROR: does not fulfill `Send` } trait bar { - fn bar(&self); + fn bar(&self); } impl bar for uint { - fn bar(&self) { + fn bar(&self) { } } diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index 098a395f017..b38cb895488 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -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() { diff --git a/src/test/compile-fail/closure-bounds-copy-cant-capture-noncopyable.rs b/src/test/compile-fail/closure-bounds-copy-cant-capture-noncopyable.rs deleted file mode 100644 index 0b11da14e71..00000000000 --- a/src/test/compile-fail/closure-bounds-copy-cant-capture-noncopyable.rs +++ /dev/null @@ -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 or the MIT license -// , 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(); -} diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index 0c9220d18ab..324634ac66d 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -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() {} diff --git a/src/test/compile-fail/fn-variance-2.rs b/src/test/compile-fail/fn-variance-2.rs index 61668cbdb9e..ab559190034 100644 --- a/src/test/compile-fail/fn-variance-2.rs +++ b/src/test/compile-fail/fn-variance-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn reproduce(t: T) -> @fn() -> T { +fn reproduce(t: T) -> @fn() -> T { let result: @fn() -> T = || t; result } diff --git a/src/test/compile-fail/fn-variance-3.rs b/src/test/compile-fail/fn-variance-3.rs index 4d145d3f9ea..630eb4b538d 100644 --- a/src/test/compile-fail/fn-variance-3.rs +++ b/src/test/compile-fail/fn-variance-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn mk_identity() -> @fn(T) -> T { +fn mk_identity() -> @fn(T) -> T { let result: @fn(t: T) -> T = |t| t; result } diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 314f282355d..47087337e34 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -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); } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 531d4eab535..c62c2874525 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -12,7 +12,7 @@ // than the trait method it's implementing trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze` + fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze` } fn main() {} diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index 9840650fa2e..9b8346da5c5 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -12,7 +12,7 @@ // an impl against a trait trait A { - fn b(&self, x: C) -> C; + fn b(&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(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type + fn b(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type } fn main() {} diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 33e122867bb..19b38769d95 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -10,11 +10,11 @@ trait repeat { fn get(&self) -> A; } -impl repeat for @A { +impl repeat for @A { fn get(&self) -> A { **self } } -fn repeater(v: @A) -> @repeat { +fn repeater(v: @A) -> @repeat { // Note: owned kind is not necessary as A appears in the trait type @v as @repeat // No } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 808bfba8298..4dc1c6f2f3e 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -18,11 +18,11 @@ trait foo { fn foo(&self, i: &'self int) -> int; } -impl foo for T { +impl foo for T { fn foo(&self, i: &'self int) -> int {*i} } -fn to_foo(t: T) { +fn to_foo(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: T) { assert_eq!(x.foo(v), 3); } -fn to_foo_2(t: T) -> @foo { +fn to_foo_2(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 { f: T } @F {f:t} as @foo //~ ERROR value may contain borrowed pointers; add `'static` bound } -fn to_foo_3(t: T) -> @foo { +fn to_foo_3(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 { f: T } diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index c2352e35a46..73d59ff8af2 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -10,13 +10,13 @@ trait foo { fn foo(&self); } -fn to_foo(t: T) -> @foo { +fn to_foo(t: T) -> @foo { @t as @foo //~^ ERROR value may contain borrowed pointers; add `'static` bound //~^^ ERROR cannot pack type } -fn to_foo2(t: T) -> @foo { +fn to_foo2(t: T) -> @foo { @t as @foo } diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index a96da398f5a..72d6b70a7c2 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -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:) { diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index 184fef52c8c..47cf1262901 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -16,7 +16,7 @@ struct Pair { a: T, b: U } struct Triple { x: int, y: int, z: int } -fn f(x: T, y: U) -> Pair { return Pair {a: x, b: y}; } +fn f(x: T, y: U) -> Pair { return Pair {a: x, b: y}; } pub fn main() { info!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x); diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 0788c74d078..440ad723a12 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(x: ~[T]) -> T { return x[0]; } +fn f(x: ~[T]) -> T { return x[0]; } fn g(act: &fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } diff --git a/src/test/run-pass/cond-macro-no-default.rs b/src/test/run-pass/cond-macro-no-default.rs index 6b90308f8a8..8bd1a772e55 100644 --- a/src/test/run-pass/cond-macro-no-default.rs +++ b/src/test/run-pass/cond-macro-no-default.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn clamp(x: T, mn: T, mx: T) -> T { +fn clamp(x: T, mn: T, mx: T) -> T { cond!( (x > mx) { return mx; } (x < mn) { return mn; } diff --git a/src/test/run-pass/cond-macro.rs b/src/test/run-pass/cond-macro.rs index 929752b3f1a..61a51b67261 100644 --- a/src/test/run-pass/cond-macro.rs +++ b/src/test/run-pass/cond-macro.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn clamp(x: T, mn: T, mx: T) -> T { +fn clamp(x: T, mn: T, mx: T) -> T { cond!( (x > mx) { mx } (x < mn) { mn } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 05f586f76e9..635ae704e41 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -12,7 +12,7 @@ // are const. -fn foo(x: T) -> T { x } +fn foo(x: T) -> T { x } struct F { field: int } diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 679210351bd..0249820410c 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -13,7 +13,7 @@ // -*- rust -*- type compare = @fn(~T, ~T) -> bool; -fn test_generic(expected: ~T, eq: compare) { +fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { expected.clone() }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index e4eae9c4c39..cba1bab3004 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -19,7 +19,7 @@ fn test_vec() { } fn test_generic() { - fn f(t: T) -> T { t } + fn f(t: T) -> T { t } assert_eq!(f(10), 10); } diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index 085d52d6d7f..0f564e6a780 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -13,7 +13,7 @@ // -*- rust -*- type compare = @fn(~T, ~T) -> bool; -fn test_generic(expected: ~T, eq: compare) { +fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { true => { expected.clone() }, _ => fail!("wat") diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index 7ef1fb8cab8..ae88d48bc44 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -13,7 +13,7 @@ type compare = @fn(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => expected.clone(), _ => fail!("wat") diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index efb514caba9..2cd505f1f7d 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -10,7 +10,7 @@ -fn id(t: T) -> T { return t; } +fn id(t: T) -> T { return t; } pub fn main() { let expected = @100; diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 203adf81cec..7a6cb9470b2 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -10,7 +10,7 @@ -fn id(t: T) -> T { return t; } +fn id(t: T) -> T { return t; } pub fn main() { let expected = ~100; diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index 7248e577069..a3e933f3ceb 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -10,7 +10,7 @@ -fn box(x: Box) -> @Box { return @x; } +fn box(x: Box) -> @Box { return @x; } struct Box {x: T, y: T, z: T} diff --git a/src/test/run-pass/generic-drop-glue.rs b/src/test/run-pass/generic-drop-glue.rs index 19e11197fd9..9592f9ff736 100644 --- a/src/test/run-pass/generic-drop-glue.rs +++ b/src/test/run-pass/generic-drop-glue.rs @@ -11,6 +11,6 @@ struct Pair { x: @int, y: @int } -fn f(t: T) { let t1: T = t; } +fn f(t: T) { let t1: T = t; } pub fn main() { let x = Pair {x: @10, y: @12}; f(x); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index 79ee544d495..b7fe704749c 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -12,7 +12,7 @@ struct Recbox {x: @T} -fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } +fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } pub fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index cc94fca6804..0820923efcf 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -10,7 +10,7 @@ struct Recbox {x: ~T} -fn reclift(t: T) -> Recbox { return Recbox {x: ~t}; } +fn reclift(t: T) -> Recbox { return Recbox {x: ~t}; } pub fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index 7c21bd52d46..092a17bf456 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -14,6 +14,6 @@ // -*- rust -*- // Issue #45: infer type parameters in function applications -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } pub fn main() { let x: int = 42; let y: int = id(x); assert!((x == y)); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index bf4729a0589..3c28b16d3a9 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -9,6 +9,6 @@ // except according to those terms. -fn f(x: ~T) -> ~T { return x; } +fn f(x: ~T) -> ~T { return x; } pub fn main() { let x = f(~3); info!(*x); } diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index e5e6beb8c70..34fb22ea0f4 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } struct Triple {x: int, y: int, z: int} diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index d09996cc2da..4a74330f7d6 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } +fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } pub fn main() { info!(get_third((1, 2, 3))); diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 8a4fc94135b..71cc4327860 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -10,7 +10,7 @@ struct Triple { x: T, y: T, z: T } -fn box(x: Triple) -> ~Triple { return ~x; } +fn box(x: Triple) -> ~Triple { return ~x; } pub fn main() { let x: ~Triple = box::(Triple{x: 1, y: 2, z: 3}); diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 9aef66fd35c..e951eef3705 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -8,25 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait clam { +trait clam { fn chowder(&self, y: A); } struct foo { x: A, } -impl clam for foo { +impl clam for foo { fn chowder(&self, y: A) { } } -fn foo(b: A) -> foo { +fn foo(b: A) -> foo { foo { x: b } } -fn f(x: @clam, a: A) { +fn f(x: @clam, a: A) { x.chowder(a); } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index 155f9cff296..df7c3b6e7d9 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -8,18 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait clam { } +trait clam { } struct foo { x: A, } -impl foo { +impl foo { pub fn bar>(&self, c: C) -> B { fail!(); } } -fn foo(b: A) -> foo { +fn foo(b: A) -> foo { foo { x: b } diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index c26038afd76..432e8c19d2a 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -12,18 +12,18 @@ struct c1 { x: T, } -impl c1 { +impl c1 { pub fn f1(&self, x: int) { } } -fn c1(x: T) -> c1 { +fn c1(x: T) -> c1 { c1 { x: x } } -impl c1 { +impl c1 { pub fn f2(&self, x: int) { } } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index 64d60725978..3c0a9355b58 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -12,17 +12,17 @@ struct c1 { x: T, } -impl c1 { +impl c1 { pub fn f1(&self, x: T) {} } -fn c1(x: T) -> c1 { +fn c1(x: T) -> c1 { c1 { x: x } } -impl c1 { +impl c1 { pub fn f2(&self, x: T) {} } diff --git a/src/test/run-pass/issue-2550.rs b/src/test/run-pass/issue-2550.rs index f5977713890..af0b937f602 100644 --- a/src/test/run-pass/issue-2550.rs +++ b/src/test/run-pass/issue-2550.rs @@ -18,7 +18,7 @@ fn C(x: uint) -> C { } } -fn f(_x: T) { +fn f(_x: T) { } #[deny(non_implicitly_copyable_typarams)] diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index 7f653552631..56c18d557f0 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -12,7 +12,7 @@ // than the traits require. trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but + fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but } fn main() {} diff --git a/src/test/run-pass/issue-3149.rs b/src/test/run-pass/issue-3149.rs index e433141c44d..ab64fb4fbfa 100644 --- a/src/test/run-pass/issue-3149.rs +++ b/src/test/run-pass/issue-3149.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn Matrix4(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 { - +fn Matrix4(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 { Matrix4 { m11: m11, m12: m12, m13: m13, m14: m14, m21: m21, m22: m22, m23: m23, m24: m24, diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 9791b6cdc53..1217f32826f 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn quux(x: T) -> T { let f = id::; return f(x); } +fn quux(x: T) -> T { let f = id::; return f(x); } -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } pub fn main() { assert!((quux(10) == 10)); } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 61c63245d70..ecf530f07f3 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn double(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; } +fn double(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; } fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index fe06c973dbf..eaf9eafa2a5 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -13,11 +13,11 @@ use std::int; trait vec_monad { - fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B]; + fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B]; } impl vec_monad for ~[A] { - fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B] { + fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B] { let mut r = ~[]; for self.iter().advance |elt| { r.push_all_move(f(elt)); diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index eb3c1e4cd27..3146c2a9499 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -25,7 +25,7 @@ impl Serializable for int { struct F { a: A } -impl Serializable for F { +impl Serializable for F { fn serialize(&self, s: S) { self.a.serialize(s); } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index c08f52cba15..8257d495d46 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -14,15 +14,15 @@ extern mod extra; use extra::list::*; -fn pure_length_go(ls: @List, acc: uint) -> uint { +fn pure_length_go(ls: @List, acc: uint) -> uint { match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } } } -fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } +fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } -fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } +fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } -fn safe_head(ls: @List) -> T { +fn safe_head(ls: @List) -> T { assert!(!is_empty(ls)); return head(ls); } diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index 2b8b7c6a788..341c1b96e36 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -23,7 +23,7 @@ fn iter(v: ~[T], it: &fn(&T) -> bool) -> bool { return true; } -fn find_pos(n: T, h: ~[T]) -> Option { +fn find_pos(n: T, h: ~[T]) -> Option { let mut i = 0u; for iter(h.clone()) |e| { if *e == n { return Some(i); } diff --git a/src/test/run-pass/ret-none.rs b/src/test/run-pass/ret-none.rs index d493f23ba84..b1974f71095 100644 --- a/src/test/run-pass/ret-none.rs +++ b/src/test/run-pass/ret-none.rs @@ -12,6 +12,6 @@ enum option { none, some(T), } -fn f() -> option { return none; } +fn f() -> option { return none; } pub fn main() { f::(); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 0ddc39d6b18..1588bd1a5a5 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -43,13 +43,13 @@ impl uint_utils for uint { trait vec_utils { fn length_(&self, ) -> uint; fn iter_(&self, f: &fn(&T)); - fn map_(&self, f: &fn(&T) -> U) -> ~[U]; + fn map_(&self, f: &fn(&T) -> U) -> ~[U]; } impl vec_utils for ~[T] { fn length_(&self) -> uint { self.len() } fn iter_(&self, f: &fn(&T)) { for self.iter().advance |x| { f(x); } } - fn map_(&self, f: &fn(&T) -> U) -> ~[U] { + fn map_(&self, f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; for self.iter().advance |elt| { r.push(f(elt)); diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 85a4f98d198..fa3b0a4ea33 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -24,7 +24,7 @@ struct t_rec { tB: a_tag } -fn mk_rec(a: A, b: B) -> t_rec { +fn mk_rec(a: A, b: B) -> t_rec { return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; } diff --git a/src/test/run-pass/trait-bounds-basic.rs b/src/test/run-pass/trait-bounds-basic.rs index e0d60d62bb5..cc2c12e4109 100644 --- a/src/test/run-pass/trait-bounds-basic.rs +++ b/src/test/run-pass/trait-bounds-basic.rs @@ -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); } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 5952afa6676..d6218a6ad8e 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -26,10 +26,10 @@ impl to_str for () { } trait map { - fn map(&self, f: &fn(&T) -> U) -> ~[U]; + fn map(&self, f: &fn(&T) -> U) -> ~[U]; } impl map for ~[T] { - fn map(&self, f: &fn(&T) -> U) -> ~[U] { + fn map(&self, f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; // FIXME: #7355 generates bad code with Iterator for std::uint::range(0, self.len()) |i| { diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index 21f840ca8d3..84d54d9d0df 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -14,7 +14,7 @@ extern mod trait_inheritance_overloading_xc; use trait_inheritance_overloading_xc::{MyNum, MyInt}; -fn f(x: T, y: T) -> (T, T, T) { +fn f(x: T, y: T) -> (T, T, T) { return (x + y, x - y, x * y); } diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index 302d3d87df9..d5321ea5298 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -33,7 +33,7 @@ impl Eq for MyInt { impl MyNum for MyInt; -fn f(x: T, y: T) -> (T, T, T) { +fn f(x: T, y: T) -> (T, T, T) { return (x + y, x - y, x * y); } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 216a7a939fe..8968fe49bc1 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -11,7 +11,7 @@ // xfail-fast fn p_foo(pinned: T) { } -fn s_foo(shared: T) { } +fn s_foo(shared: T) { } fn u_foo(unique: T) { } struct r { diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index 2c3424d1f06..5d115139bdc 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -20,7 +20,7 @@ struct Pointy { d : ~fn() -> uint, } -fn make_uniq_closure(a: A) -> ~fn() -> uint { +fn make_uniq_closure(a: A) -> ~fn() -> uint { let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint; result } diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 67ffc797ee4..eb2638f2568 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(t: T) -> T { +fn f(t: T) -> T { let t1 = t; t1 } diff --git a/src/test/run-pass/unique-generic-assign.rs b/src/test/run-pass/unique-generic-assign.rs index ab92b10a332..3805cbe47bf 100644 --- a/src/test/run-pass/unique-generic-assign.rs +++ b/src/test/run-pass/unique-generic-assign.rs @@ -10,7 +10,7 @@ // Issue #976 -fn f(x: ~T) { +fn f(x: ~T) { let _x2 = x; } pub fn main() { } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 391881deff6..11425a94ce9 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -30,11 +30,11 @@ fn sendable() { fn copyable() { - fn f(i: T, j: T) { + fn f(i: T, j: T) { assert_eq!(i, j); } - fn g(i: T, j: T) { + fn g(i: T, j: T) { assert!(i != j); } diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 05a6dee06cc..22f1ccb8bbb 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -1,8 +1,7 @@ -fn foldl( - values: &[T], - initial: U, - function: &fn(partial: U, element: &T) -> U -) -> U { +fn foldl(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( } } -fn foldr( - values: &[T], - initial: U, - function: &fn(element: &T, partial: U) -> U -) -> U { +fn foldr(values: &[T], + initial: U, + function: &fn(element: &T, partial: U) -> U) + -> U { match values { [..head, ref tail] => foldr(head, function(tail, initial), function),