diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index 940c89bb0c682..6e4507d4277ab 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -666,12 +666,8 @@ impl BitvSet { pub fn symmetric_difference_with(&mut self, other: &BitvSet) { self.other_op(other, |w1, w2| w1 ^ w2); } -} - -impl BaseIter for BitvSet { - fn size_hint(&self) -> Option { Some(self.len()) } - fn each(&self, blk: &fn(v: &uint) -> bool) -> bool { + pub fn each(&self, blk: &fn(v: &uint) -> bool) -> bool { for self.bitv.storage.iter().enumerate().advance |(i, &w)| { if !iterate_bits(i * uint::bits, w, |b| blk(&b)) { return false; diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs index 953803c6843f7..1767aa8c39725 100644 --- a/src/libextra/dlist.rs +++ b/src/libextra/dlist.rs @@ -21,8 +21,6 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. use core::prelude::*; use core::managed; -use core::old_iter; -use core::vec; pub type DListLink = Option<@mut DListNode>; @@ -213,6 +211,42 @@ impl DList { } impl DList { + /** + * Iterates through the current contents. + * + * Attempts to access this dlist during iteration are allowed (to + * allow for e.g. breadth-first search with in-place enqueues), but + * removing the current node is forbidden. + */ + pub fn each(@mut self, f: &fn(v: &T) -> bool) -> bool { + let mut link = self.peek_n(); + while link.is_some() { + let nobe = link.get(); + assert!(nobe.linked); + + { + let frozen_nobe = &*nobe; + if !f(&frozen_nobe.data) { return false; } + } + + // Check (weakly) that the user didn't do a remove. + if self.size == 0 { + fail!("The dlist became empty during iteration??") + } + if !nobe.linked || + (!((nobe.prev.is_some() + || managed::mut_ptr_eq(self.hd.expect("headless dlist?"), + nobe)) + && (nobe.next.is_some() + || managed::mut_ptr_eq(self.tl.expect("tailless dlist?"), + nobe)))) { + fail!("Removing a dlist node during iteration is forbidden!") + } + link = nobe.next_link(); + } + return true; + } + /// Get the size of the list. O(1). pub fn len(@mut self) -> uint { self.size } /// Returns true if the list is empty. O(1). @@ -484,56 +518,6 @@ impl DList { /// Get data at the list's tail, failing if empty. O(1). pub fn tail(@mut self) -> T { copy self.tail_n().data } - - /// Get the elements of the list as a vector. O(n). - pub fn to_vec(@mut self) -> ~[T] { - let mut v = vec::with_capacity(self.size); - for old_iter::eachi(&self) |index,data| { - v[index] = copy *data; - } - v - } -} - -impl BaseIter for @mut DList { - /** - * Iterates through the current contents. - * - * Attempts to access this dlist during iteration are allowed (to - * allow for e.g. breadth-first search with in-place enqueues), but - * removing the current node is forbidden. - */ - fn each(&self, f: &fn(v: &T) -> bool) -> bool { - let mut link = self.peek_n(); - while link.is_some() { - let nobe = link.get(); - assert!(nobe.linked); - - { - let frozen_nobe = &*nobe; - if !f(&frozen_nobe.data) { return false; } - } - - // Check (weakly) that the user didn't do a remove. - if self.size == 0 { - fail!("The dlist became empty during iteration??") - } - if !nobe.linked || - (!((nobe.prev.is_some() - || managed::mut_ptr_eq(self.hd.expect("headless dlist?"), - nobe)) - && (nobe.next.is_some() - || managed::mut_ptr_eq(self.tl.expect("tailless dlist?"), - nobe)))) { - fail!("Removing a dlist node during iteration is forbidden!") - } - link = nobe.next_link(); - } - return true; - } - - #[inline] - fn size_hint(&self) -> Option { Some(self.len()) } } #[cfg(test)] @@ -542,7 +526,6 @@ mod tests { use super::*; - use core::old_iter; use core::vec; #[test] @@ -759,11 +742,6 @@ mod tests { assert_eq!(l.len(), 3); } #[test] - fn test_dlist_foldl() { - let l = from_vec(vec::from_fn(101, |x|x)); - assert_eq!(old_iter::foldl(&l, 0, |accum,elem| *accum+*elem), 5050); - } - #[test] fn test_dlist_break_early() { let l = from_vec([1,2,3,4,5]); let mut x = 0; diff --git a/src/libextra/priority_queue.rs b/src/libextra/priority_queue.rs index 31c9acbbd54d4..4e201a6538ba4 100644 --- a/src/libextra/priority_queue.rs +++ b/src/libextra/priority_queue.rs @@ -14,25 +14,15 @@ use core::prelude::*; -use core::old_iter::BaseIter; use core::unstable::intrinsics::{move_val_init, init}; use core::util::{replace, swap}; use core::vec; -#[allow(missing_doc)] +/// A priority queue implemented with a binary heap pub struct PriorityQueue { priv data: ~[T], } -impl BaseIter for PriorityQueue { - /// Visit all values in the underlying vector. - /// - /// The values are **not** visited in order. - fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.iter().advance(f) } - - fn size_hint(&self) -> Option { Some(self.data.len()) } -} - impl Container for PriorityQueue { /// Returns the length of the queue fn len(&self) -> uint { self.data.len() } @@ -47,6 +37,11 @@ impl Mutable for PriorityQueue { } impl PriorityQueue { + /// Visit all values in the underlying vector. + /// + /// The values are **not** visited in order. + pub fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.iter().advance(f) } + /// Returns the greatest item in the queue - fails if empty pub fn top<'a>(&'a self) -> &'a T { &self.data[0] } diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index aee087d3764db..17126f0d32b53 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -19,8 +19,6 @@ use core::prelude::*; use core::cmp; use core::container::{Container, Mutable, Map, Set}; -use core::old_iter::BaseIter; -use core::old_iter; use core::uint; use core::util::replace; use core::vec; @@ -212,12 +210,6 @@ impl Mutable for SmallIntSet { fn clear(&mut self) { self.map.clear() } } -impl BaseIter for SmallIntSet { - /// Visit all values in order - fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } - fn size_hint(&self) -> Option { Some(self.len()) } -} - impl Set for SmallIntSet { /// Return true if the set contains a value fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) } @@ -233,12 +225,14 @@ impl Set for SmallIntSet { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty uintersection. fn is_disjoint(&self, other: &SmallIntSet) -> bool { - old_iter::all(self, |v| !other.contains(v)) + for self.each |v| { if other.contains(v) { return false } } + true } /// Return true if the set is a subset of another fn is_subset(&self, other: &SmallIntSet) -> bool { - old_iter::all(self, |v| other.contains(v)) + for self.each |v| { if !other.contains(v) { return false } } + true } /// Return true if the set is a superset of another @@ -286,6 +280,9 @@ impl Set for SmallIntSet { impl SmallIntSet { /// Create an empty SmallIntSet pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} } + + /// Visit all values in order + pub fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } } #[cfg(test)] diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 87932c25cda18..4929dea9045bf 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -249,22 +249,6 @@ pub struct TreeSet { priv map: TreeMap } -impl BaseIter for TreeSet { - /// Visit all values in order - #[inline] - fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) } - #[inline] - fn size_hint(&self) -> Option { Some(self.len()) } -} - -impl ReverseIter for TreeSet { - /// Visit all values in reverse order - #[inline] - fn each_reverse(&self, f: &fn(&T) -> bool) -> bool { - self.map.each_key_reverse(f) - } -} - impl Eq for TreeSet { #[inline] fn eq(&self, other: &TreeSet) -> bool { self.map == other.map } @@ -499,6 +483,16 @@ impl TreeSet { pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> { TreeSetIterator{iter: self.map.iter()} } + + /// Visit all values in order + #[inline] + pub fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) } + + /// Visit all values in reverse order + #[inline] + pub fn each_reverse(&self, f: &fn(&T) -> bool) -> bool { + self.map.each_key_reverse(f) + } } /// Lazy forward iterator over a set diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 94cad18ece2cd..1f2ede670fa1b 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -731,8 +731,8 @@ fn encode_info_for_method(ecx: &EncodeContext, } let mut combined_ty_params = opt_vec::Empty; - combined_ty_params.push_all(&owner_generics.ty_params); - combined_ty_params.push_all(&method_generics.ty_params); + for owner_generics.ty_params.each |x| { combined_ty_params.push(copy *x) } + for method_generics.ty_params.each |x| { combined_ty_params.push(copy *x) } let len = combined_ty_params.len(); encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 0b94eeecba871..7396dc1bd7bff 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -507,7 +507,7 @@ impl FlowedMoveData { for self.dfcx_moves.each_bit_on_entry_frozen(id) |index| { let move = &self.move_data.moves[index]; let moved_path = move.path; - if base_indices.contains(&moved_path) { + if base_indices.iter().any_(|x| x == &moved_path) { // Scenario 1 or 2: `loan_path` or some base path of // `loan_path` was moved. if !f(move, self.move_data.path(moved_path).loan_path) { @@ -536,7 +536,7 @@ impl FlowedMoveData { -> bool { //! True if `id` is the id of the LHS of an assignment - self.move_data.assignee_ids.contains(&id) + self.move_data.assignee_ids.iter().any_(|x| x == &id) } pub fn each_assignment_of(&self, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index eed0b12b9e123..562bbca69297b 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -3710,7 +3710,7 @@ impl Resolver { let function_type_rib = @Rib(rib_kind); self.type_ribs.push(function_type_rib); - for generics.ty_params.eachi |index, type_parameter| { + for generics.ty_params.iter().enumerate().advance |(index, type_parameter)| { let name = type_parameter.ident; debug!("with_type_parameter_rib: %d %d", node_id, type_parameter.id); diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 2b846c923c48f..b871ed3d57afb 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -14,7 +14,6 @@ use cast::transmute; use container::Container; use iterator::IteratorUtil; use kinds::Copy; -use old_iter; use option::Option; use sys; use uint; @@ -129,7 +128,7 @@ pub fn map(v: &[T], f: &fn(x: &T) -> U) -> @[U] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub fn from_fn(n_elts: uint, op: old_iter::InitOp) -> @[T] { +pub fn from_fn(n_elts: uint, op: &fn(uint) -> T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(op(i)); i += 1u; } diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 5ec594cef7ee6..046693632c604 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -56,6 +56,18 @@ impl<'self, T> Clone for &'self T { fn clone(&self) -> &'self T { *self } } +impl<'self, T> Clone for &'self [T] { + /// Return a shallow copy of the slice. + #[inline] + fn clone(&self) -> &'self [T] { *self } +} + +impl<'self> Clone for &'self str { + /// Return a shallow copy of the slice. + #[inline] + fn clone(&self) -> &'self str { *self } +} + macro_rules! clone_impl( ($t:ty) => { impl Clone for $t { diff --git a/src/libstd/core.rc b/src/libstd/core.rc index 6911c00e55ba6..13c54799fac4d 100644 --- a/src/libstd/core.rc +++ b/src/libstd/core.rc @@ -138,7 +138,6 @@ pub mod from_str; #[path = "num/num.rs"] pub mod num; pub mod iter; -pub mod old_iter; pub mod iterator; pub mod to_str; pub mod to_bytes; diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 46e059355941f..d96191f296d77 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -20,7 +20,7 @@ implementing the `Iterator` trait. #[allow(default_methods)]; // solid enough for the use case here use cmp; -use iter::{FromIter, Times}; +use iter::Times; use num::{Zero, One}; use option::{Option, Some, None}; use ops::{Add, Mul}; @@ -240,7 +240,7 @@ pub trait IteratorUtil { fn advance(&mut self, f: &fn(A) -> bool) -> bool; /// Loops through the entire iterator, collecting all of the elements into - /// a container implementing `FromIter`. + /// a container implementing `FromIterator`. /// /// # Example /// @@ -249,7 +249,7 @@ pub trait IteratorUtil { /// let b: ~[int] = a.iter().transform(|&x| x).collect(); /// assert!(a == b); /// ~~~ - fn collect>(&mut self) -> B; + fn collect>(&mut self) -> B; /// Loops through `n` iterations, returning the `n`th element of the /// iterator. @@ -411,8 +411,8 @@ impl> IteratorUtil for T { } #[inline] - fn collect>(&mut self) -> B { - FromIter::from_iter::(|f| self.advance(f)) + fn collect>(&mut self) -> B { + FromIterator::from_iterator(self) } /// Return the `n`th item yielded by an iterator. diff --git a/src/libstd/old_iter.rs b/src/libstd/old_iter.rs deleted file mode 100644 index 9b87d76a309d0..0000000000000 --- a/src/libstd/old_iter.rs +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright 2012-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. - -/*! - -**Deprecated** iteration traits and common implementations. - -*/ - -#[allow(missing_doc)]; - -use cmp::Eq; -use kinds::Copy; -use option::{None, Option, Some}; -use vec; - -/// A function used to initialize the elements of a sequence -pub type InitOp<'self,T> = &'self fn(uint) -> T; - -pub trait BaseIter { - fn each(&self, blk: &fn(v: &A) -> bool) -> bool; - fn size_hint(&self) -> Option; -} - -pub trait ReverseIter: BaseIter { - fn each_reverse(&self, blk: &fn(&A) -> bool) -> bool; -} - -pub trait ExtendedIter { - fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool; - fn all(&self, blk: &fn(&A) -> bool) -> bool; - fn any(&self, blk: &fn(&A) -> bool) -> bool; - fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; - fn position(&self, f: &fn(&A) -> bool) -> Option; - fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; - fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; -} - -pub trait EqIter { - fn contains(&self, x: &A) -> bool; - fn count(&self, x: &A) -> uint; -} - -pub trait CopyableIter { - fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; - fn to_vec(&self) -> ~[A]; - fn find(&self, p: &fn(&A) -> bool) -> Option; -} - -// A trait for sequences that can be built by imperatively pushing elements -// onto them. -pub trait Buildable { - /** - * Builds a buildable sequence by calling a provided function with - * an argument function that pushes an element onto the back of - * the sequence. - * This version takes an initial size for the sequence. - * - * # Arguments - * - * * size - A hint for an initial size of the sequence - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. - */ - fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self; -} - -#[inline] -pub fn _eachi>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { - let mut i = 0; - for this.each |a| { - if !blk(i, a) { - return false; - } - i += 1; - } - return true; -} - -pub fn eachi>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { - _eachi(this, blk) -} - -#[inline] -pub fn all>(this: &IA, blk: &fn(&A) -> bool) -> bool { - for this.each |a| { - if !blk(a) { - return false; - } - } - return true; -} - -#[inline] -pub fn any>(this: &IA, blk: &fn(&A) -> bool) -> bool { - for this.each |a| { - if blk(a) { - return true; - } - } - return false; -} - -#[inline] -pub fn filter_to_vec>(this: &IA, - prd: &fn(&A) -> bool) - -> ~[A] { - do vec::build_sized_opt(this.size_hint()) |push| { - for this.each |a| { - if prd(a) { push(copy *a); } - } - } -} - -#[inline] -pub fn map_to_vec>(this: &IA, op: &fn(&A) -> B) -> ~[B] { - do vec::build_sized_opt(this.size_hint()) |push| { - for this.each |a| { - push(op(a)); - } - } -} - -#[inline] -pub fn flat_map_to_vec,IB:BaseIter>(this: &IA, - op: &fn(&A) -> IB) - -> ~[B] { - do vec::build |push| { - for this.each |a| { - for op(a).each |&b| { - push(b); - } - } - } -} - -#[inline] -pub fn foldl>(this: &IA, b0: B, blk: &fn(&B, &A) -> B) - -> B { - let mut b = b0; - for this.each |a| { - b = blk(&b, a); - } - b -} - -#[inline] -pub fn to_vec>(this: &IA) -> ~[A] { - map_to_vec(this, |&x| x) -} - -#[inline] -pub fn contains>(this: &IA, x: &A) -> bool { - for this.each |a| { - if *a == *x { return true; } - } - return false; -} - -#[inline] -pub fn count>(this: &IA, x: &A) -> uint { - do foldl(this, 0) |count, value| { - if *value == *x { - *count + 1 - } else { - *count - } - } -} - -#[inline] -pub fn position>(this: &IA, f: &fn(&A) -> bool) - -> Option { - let mut i = 0; - for this.each |a| { - if f(a) { return Some(i); } - i += 1; - } - return None; -} - -#[inline] -pub fn find>(this: &IA, f: &fn(&A) -> bool) - -> Option { - for this.each |i| { - if f(i) { return Some(copy *i) } - } - return None; -} - -// Some functions for just building - -/** - * Builds a sequence by calling a provided function with an argument - * function that pushes an element to the back of a sequence. - * - * # Arguments - * - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. - */ -#[inline] -pub fn build>(builder: &fn(push: &fn(A))) -> B { - Buildable::build_sized(4, builder) -} - -/** - * Builds a sequence by calling a provided function with an argument - * function that pushes an element to the back of the sequence. - * This version takes an initial size for the sequence. - * - * # Arguments - * - * * size - An option, maybe containing initial size of the sequence - * to reserve. - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. - */ -#[inline] -pub fn build_sized_opt>(size: Option, - builder: &fn(push: &fn(A))) -> B { - Buildable::build_sized(size.get_or_default(4), builder) -} - -// Functions that combine iteration and building - -/// Applies a function to each element of an iterable and returns the results -/// in a sequence built via `BU`. See also `map_to_vec`. -#[inline] -pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) - -> BU { - do build_sized_opt(v.size_hint()) |push| { - for v.each() |elem| { - push(f(elem)); - } - } -} - -/** - * Creates and initializes a generic sequence from a function. - * - * Creates a generic sequence of size `n_elts` and initializes the elements - * to the value returned by the function `op`. - */ -#[inline] -pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { - do Buildable::build_sized(n_elts) |push| { - let mut i: uint = 0u; - while i < n_elts { push(op(i)); i += 1u; } - } -} - -/** - * Creates and initializes a generic sequence with some elements. - * - * Creates an immutable vector of size `n_elts` and initializes the elements - * to the value `t`. - */ -#[inline] -pub fn from_elem>(n_elts: uint, t: T) -> BT { - do Buildable::build_sized(n_elts) |push| { - let mut i: uint = 0; - while i < n_elts { push(copy t); i += 1; } - } -} - -/// Appends two generic sequences. -#[inline] -pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) - -> BT { - let size_opt = lhs.size_hint().chain_ref( - |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); - do build_sized_opt(size_opt) |push| { - for lhs.each |x| { push(copy *x); } - for rhs.each |x| { push(copy *x); } - } -} - -/// Copies a generic sequence, possibly converting it to a different -/// type of sequence. -#[inline] -pub fn copy_seq,BT:Buildable>(v: &IT) -> BT { - do build_sized_opt(v.size_hint()) |push| { - for v.each |x| { push(copy *x); } - } -} diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 309df27e151d2..6d7cb2a28a88d 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -46,8 +46,6 @@ pub use cmp::{Eq, ApproxEq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Great pub use char::Char; pub use container::{Container, Mutable, Map, Set}; pub use hash::Hash; -pub use old_iter::{BaseIter, ReverseIter, ExtendedIter, EqIter}; -pub use old_iter::CopyableIter; pub use iter::{Times, FromIter}; pub use iterator::{Iterator, IteratorUtil, OrdIterator}; pub use num::{Num, NumCast}; diff --git a/src/libstd/rt/uvio.rs b/src/libstd/rt/uvio.rs index 070ccf7fb446d..f4a79934e7e43 100644 --- a/src/libstd/rt/uvio.rs +++ b/src/libstd/rt/uvio.rs @@ -15,7 +15,6 @@ use super::io::net::ip::IpAddr; use super::uv::*; use super::rtio::*; use ops::Drop; -use old_iter::CopyableIter; use cell::Cell; use cast::transmute; use super::sched::{Scheduler, local_sched}; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 45ba85283754c..16c287c1da823 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -29,7 +29,6 @@ use iterator::{Iterator, IteratorUtil, FilterIterator, AdditiveIterator, MapIter use libc; use num::Zero; use option::{None, Option, Some}; -use old_iter::EqIter; use ptr; use ptr::RawPtr; use to_str::ToStr; @@ -2225,7 +2224,6 @@ mod tests { use option::Some; use libc::c_char; use libc; - use old_iter::BaseIter; use ptr; use str::*; use vec; diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 56078a69f28f3..9f81228862136 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -21,7 +21,6 @@ use iterator::IteratorUtil; use container::Map; use hash::Hash; use cmp::Eq; -use old_iter::BaseIter; use vec::ImmutableVector; use iterator::IteratorUtil; diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 39980ffa59915..e6449ef49229c 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -176,22 +176,6 @@ pub struct TrieSet { priv map: TrieMap<()> } -impl BaseIter for TrieSet { - /// Visit all values in order - #[inline] - fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } - #[inline] - fn size_hint(&self) -> Option { Some(self.len()) } -} - -impl ReverseIter for TrieSet { - /// Visit all values in reverse order - #[inline] - fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool { - self.map.each_key_reverse(f) - } -} - impl Container for TrieSet { /// Return the number of elements in the set #[inline] @@ -234,6 +218,16 @@ impl TrieSet { pub fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) } + + /// Visit all values in order + #[inline] + pub fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } + + /// Visit all values in reverse order + #[inline] + pub fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool { + self.map.each_key_reverse(f) + } } struct TrieNode { diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 17eb7e8e82be2..7b7a3020b9394 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -17,7 +17,6 @@ use cast; use container::{Container, Mutable}; use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater}; use clone::Clone; -use old_iter; use iterator::{FromIterator, Iterator, IteratorUtil}; use iter::FromIter; use kinds::Copy; @@ -124,7 +123,7 @@ pub fn capacity(v: &const ~[T]) -> uint { * Creates an owned vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub fn from_fn(n_elts: uint, op: old_iter::InitOp) -> ~[T] { +pub fn from_fn(n_elts: uint, op: &fn(uint) -> T) -> ~[T] { unsafe { let mut v = with_capacity(n_elts); do as_mut_buf(v) |p, _len| { @@ -815,7 +814,7 @@ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { * * init_op - A function to call to retreive each appended element's * value */ -pub fn grow_fn(v: &mut ~[T], n: uint, op: old_iter::InitOp) { +pub fn grow_fn(v: &mut ~[T], n: uint, op: &fn(uint) -> T) { let new_len = v.len() + n; reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; @@ -1985,7 +1984,7 @@ pub trait OwnedVector { fn consume_reverse(self, f: &fn(uint, v: T)); fn filter(self, f: &fn(t: &T) -> bool) -> ~[T]; fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]); - fn grow_fn(&mut self, n: uint, op: old_iter::InitOp); + fn grow_fn(&mut self, n: uint, op: &fn(uint) -> T); } impl OwnedVector for ~[T] { @@ -2064,7 +2063,7 @@ impl OwnedVector for ~[T] { } #[inline] - fn grow_fn(&mut self, n: uint, op: old_iter::InitOp) { + fn grow_fn(&mut self, n: uint, op: &fn(uint) -> T) { grow_fn(self, n, op); } } @@ -2501,7 +2500,17 @@ impl FromIter for ~[T]{ } } -#[cfg(not(stage0))] +impl> FromIterator for ~[A] { + pub fn from_iterator(iterator: &mut T) -> ~[A] { + let mut xs = ~[]; + for iterator.advance |x| { + xs.push(x); + } + xs + } +} + +/* FIXME: #7341 - ICE impl> FromIterator for ~[A] { pub fn from_iterator(iterator: &mut T) -> ~[A] { let (lower, _) = iterator.size_hint(); @@ -2512,6 +2521,7 @@ impl> FromIterator for ~[A] { xs } } +*/ #[cfg(test)] mod tests { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index a20528082ab55..55ac9c5ec1c82 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -375,7 +375,7 @@ impl gen_init for protocol { let mut params: OptVec = opt_vec::Empty; for (copy self.states).iter().advance |s| { for s.generics.ty_params.each |tp| { - match params.find(|tpp| tp.ident == tpp.ident) { + match params.iter().find_(|tpp| tp.ident == tpp.ident) { None => params.push(*tp), _ => () } @@ -393,7 +393,7 @@ impl gen_init for protocol { let mut params: OptVec = opt_vec::Empty; let fields = do (copy self.states).iter().transform |s| { for s.generics.ty_params.each |tp| { - match params.find(|tpp| tp.ident == tpp.ident) { + match params.iter().find_(|tpp| tp.ident == tpp.ident) { None => params.push(*tp), _ => () } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index c537a3e8eba36..8917b481dc726 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -17,9 +17,7 @@ */ use core::prelude::*; - -use core::old_iter; -use core::old_iter::BaseIter; +use core::vec::VecIterator; #[deriving(Encodable, Decodable)] pub enum OptVec { @@ -40,6 +38,13 @@ pub fn from(t: ~[T]) -> OptVec { } impl OptVec { + fn each(&self, blk: &fn(v: &T) -> bool) -> bool { + match *self { + Empty => true, + Vec(ref v) => v.iter().advance(blk) + } + } + fn push(&mut self, t: T) { match *self { Vec(ref mut v) => { @@ -78,6 +83,28 @@ impl OptVec { Vec(ref v) => v.len() } } + + #[inline] + fn iter<'r>(&'r self) -> OptVecIterator<'r, T> { + match *self { + Empty => OptVecIterator{iter: None}, + Vec(ref v) => OptVecIterator{iter: Some(v.iter())} + } + } + + #[inline] + fn map_to_vec(&self, op: &fn(&T) -> B) -> ~[B] { + self.iter().transform(op).collect() + } + + fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { + let mut index = 0; + self.map_to_vec(|a| { + let i = index; + index += 1; + op(i, a) + }) + } } pub fn take_vec(v: OptVec) -> ~[T] { @@ -96,22 +123,6 @@ impl OptVec { } return Vec(v0); } - - fn push_all>(&mut self, from: &I) { - for from.each |e| { - self.push(copy *e); - } - } - - #[inline] - fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { - let mut index = 0; - old_iter::map_to_vec(self, |a| { - let i = index; - index += 1; - op(i, a) - }) - } } impl Eq for OptVec { @@ -131,68 +142,16 @@ impl Eq for OptVec { } } -impl BaseIter for OptVec { - fn each(&self, blk: &fn(v: &A) -> bool) -> bool { - match *self { - Empty => true, - Vec(ref v) => v.iter().advance(blk) - } - } - - fn size_hint(&self) -> Option { - Some(self.len()) - } +pub struct OptVecIterator<'self, T> { + priv iter: Option> } -impl old_iter::ExtendedIter for OptVec { +impl<'self, T> Iterator<&'self T> for OptVecIterator<'self, T> { #[inline] - fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool { - old_iter::eachi(self, blk) - } - #[inline] - fn all(&self, blk: &fn(&A) -> bool) -> bool { - old_iter::all(self, blk) - } - #[inline] - fn any(&self, blk: &fn(&A) -> bool) -> bool { - old_iter::any(self, blk) - } - #[inline] - fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - old_iter::foldl(self, b0, blk) - } - #[inline] - fn position(&self, f: &fn(&A) -> bool) -> Option { - old_iter::position(self, f) - } - #[inline] - fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - old_iter::map_to_vec(self, op) - } - #[inline] - fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) - -> ~[B] { - old_iter::flat_map_to_vec(self, op) - } - -} - -impl old_iter::EqIter for OptVec { - #[inline] - fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } - #[inline] - fn count(&self, x: &A) -> uint { old_iter::count(self, x) } -} - -impl old_iter::CopyableIter for OptVec { - #[inline] - fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - old_iter::filter_to_vec(self, pred) - } - #[inline] - fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } - #[inline] - fn find(&self, f: &fn(&A) -> bool) -> Option { - old_iter::find(self, f) + fn next(&mut self) -> Option<&'self T> { + match self.iter { + Some(ref mut x) => x.next(), + None => None + } } } diff --git a/src/test/run-fail/extern-fail.rs b/src/test/run-fail/extern-fail.rs index 2be41d3bed00f..3d15ea16241f9 100644 --- a/src/test/run-fail/extern-fail.rs +++ b/src/test/run-fail/extern-fail.rs @@ -13,7 +13,6 @@ // Instead the failure will be delivered after the callbacks return. use std::libc; -use std::old_iter; use std::task; mod rustrt { diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 9cfdac0a330b0..0fe30059ef65a 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -1,6 +1,4 @@ -// xfail-test -// xfail'd because of a problem with by-value self. - +// xfail-test #5321 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate.rs b/src/test/run-pass/class-cast-to-trait-cross-crate.rs deleted file mode 100644 index 6674147e14769..0000000000000 --- a/src/test/run-pass/class-cast-to-trait-cross-crate.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2012 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. - -// xfail-test - -use to_str::*; -use to_str::to_str; - -class cat : to_str { - priv { - let mut meows : uint; - fn meow() { - error!("Meow"); - self.meows += 1u; - if self.meows % 5u == 0u { - self.how_hungry += 1; - } - } - } - - let mut how_hungry : int; - let name : str; - - new(in_x : uint, in_y : int, in_name: str) - { self.meows = in_x; self.how_hungry = in_y; self.name = in_name; } - - fn speak() { self.meow(); } - - fn eat() -> bool { - if self.how_hungry > 0 { - error!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - error!("Not hungry!"); - return false; - } - } - - fn to_str() -> str { self.name } -} - -fn print_out(thing: T, expected: str) { - let actual = thing.to_str(); - debug!("%s", actual); - assert_eq!(actual, expected); -} - -pub fn main() { - let nyan : to_str = cat(0u, 2, "nyan") as to_str; - print_out(nyan, "nyan"); -} diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 09967f0ab361d..655a9d4a0c072 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #7307 // xfail-fast extern mod extra; diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 88686bcdbfa35..c54b8db46c889 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -13,7 +13,6 @@ use std::cmp; use std::container::{Container, Mutable, Map}; use std::int; -use std::old_iter::BaseIter; use std::uint; enum cat_type { tuxedo, tabby, tortoiseshell } diff --git a/src/test/run-pass/class-implements-multiple-traits.rs b/src/test/run-pass/class-implements-multiple-traits.rs index 7a3045db91f1a..8565ab038413c 100644 --- a/src/test/run-pass/class-implements-multiple-traits.rs +++ b/src/test/run-pass/class-implements-multiple-traits.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #7305 extern mod extra; use extra::oldmap::*; diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs deleted file mode 100644 index 75c62abcb0d55..0000000000000 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 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. - -// xfail-test - -extern mod extra; -use extra::oldmap::{map, hashmap, int_hash}; - -class keys> - : old_iter::base_iter { - - let map: M; - - new(map: M) { - self.map = map; - } - - fn each(blk: &fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) } - fn size_hint() -> Option { Some(self.map.size()) } - fn eachi(blk: &fn(uint, K) -> bool) { old_iter::eachi(self, blk) } -} - -pub fn main() { - let m = int_hash(); - m.insert(1, 2); - m.insert(3, 4); - assert_eq!(old_iter::to_vec(keys(m)), ~[1, 3]); -} diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs index 3f12c0d635311..f0c5b58d1559c 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs @@ -1,8 +1,6 @@ -// xfail-test - fn sum(x: &[int]) -> int { let mut sum = 0; - for x.each |y| { sum += *y; } + for x.iter().advance |y| { sum += *y; } return sum; } @@ -14,8 +12,10 @@ fn sum_imm(y: &[int]) -> int { sum(y) } +/* FIXME #7304 fn sum_const(y: &const [int]) -> int { sum(y) } +*/ pub fn main() {} diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index 7ab80920849b3..590cd8250208a 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -1,20 +1,20 @@ -// xfail-test - +/* FIXME #7302 fn foo(v: &const [uint]) -> ~[uint] { - v.to_vec() + v.to_owned() } +*/ fn bar(v: &mut [uint]) -> ~[uint] { - v.to_vec() + v.to_owned() } fn bip(v: &[uint]) -> ~[uint] { - v.to_vec() + v.to_owned() } pub fn main() { - let mut the_vec = ~[1, 2, 3, 100]; - assert_eq!(the_vec, foo(the_vec)); - assert_eq!(the_vec, bar(the_vec)); - assert_eq!(the_vec, bip(the_vec)); + let mut the_vec = ~[1u, 2, 3, 100]; +// assert_eq!(the_vec.clone(), foo(the_vec)); + assert_eq!(the_vec.clone(), bar(the_vec)); + assert_eq!(the_vec.clone(), bip(the_vec)); } diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass/deriving-global.rs index 3d5bacee71c67..7804ce48c7053 100644 --- a/src/test/run-pass/deriving-global.rs +++ b/src/test/run-pass/deriving-global.rs @@ -1,4 +1,5 @@ -// xfail-test #7103 `extern mod` does not work on windows +// xfail-fast #7103 `extern mod` does not work on windows +// xfail-pretty - does not converge // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at diff --git a/src/test/run-pass/deriving-meta-empty-trait-list.rs b/src/test/run-pass/deriving-meta-empty-trait-list.rs index 8e7afffaf0dbb..955e02d4d2d89 100644 --- a/src/test/run-pass/deriving-meta-empty-trait-list.rs +++ b/src/test/run-pass/deriving-meta-empty-trait-list.rs @@ -10,6 +10,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-fast + #[deriving] //~ WARNING empty trait list in `deriving` struct Foo; diff --git a/src/test/run-pass/extern-mod-url.rs b/src/test/run-pass/extern-mod-url.rs index 457c61067e3c2..363c54f68129a 100644 --- a/src/test/run-pass/extern-mod-url.rs +++ b/src/test/run-pass/extern-mod-url.rs @@ -10,7 +10,7 @@ // Just a test that new-style extern mods parse -// xfail-test +// xfail-test FIXME #6407 extern mod test = "github.com/catamorphism/test-pkg"; -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/fn-bare-size.rs b/src/test/run-pass/fn-bare-size.rs index dc47dda420cea..144cc7c1e287a 100644 --- a/src/test/run-pass/fn-bare-size.rs +++ b/src/test/run-pass/fn-bare-size.rs @@ -8,12 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - -extern mod extra; +use std::sys; pub fn main() { // Bare functions should just be a pointer - assert!(sys::rustrt::size_of::() == - sys::rustrt::size_of::()); + assert_eq!(sys::size_of::(), sys::size_of::()); } diff --git a/src/test/run-pass/foreign-mod.rc b/src/test/run-pass/foreign-mod.rc index 390de82765730..a11e89f37be15 100644 --- a/src/test/run-pass/foreign-mod.rc +++ b/src/test/run-pass/foreign-mod.rc @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #7308 // -*- rust -*- native mod libc = target_libc { diff --git a/src/test/run-pass/issue-1866.rs b/src/test/run-pass/issue-1866.rs index cb5e9b111660f..530f40c6a83d4 100644 --- a/src/test/run-pass/issue-1866.rs +++ b/src/test/run-pass/issue-1866.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #1866 mod a { pub type rust_task = uint; pub mod rustrt { + use super::rust_task; pub extern { pub fn rust_task_is_unwinding(rt: *rust_task) -> bool; } @@ -21,6 +22,7 @@ mod a { mod b { pub type rust_task = bool; pub mod rustrt { + use super::rust_task; pub extern { pub fn rust_task_is_unwinding(rt: *rust_task) -> bool; } diff --git a/src/test/run-pass/issue-2101.rs b/src/test/run-pass/issue-2101.rs deleted file mode 100644 index 423888c1cf5b6..0000000000000 --- a/src/test/run-pass/issue-2101.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 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. - -// xfail-test -extern mod extra; -use extra::arena; -use extra::arena::Arena; - -enum hold { s(str) } - -fn init(ar: &a.arena::Arena, str: str) -> &a.hold { - new(*ar) s(str) -} - -pub fn main(args: ~[str]) { - let ar = arena::Arena(); - let leak = init(&ar, args[0]); - match *leak { - s(astr) { - io::println(fmt!("%?", astr)); - } - }; -} diff --git a/src/test/run-pass/issue-2190-2.rs b/src/test/run-pass/issue-2190-2.rs index 3842e073faf13..d5ee712d412bc 100644 --- a/src/test/run-pass/issue-2190-2.rs +++ b/src/test/run-pass/issue-2190-2.rs @@ -8,23 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #2190 mod a { -fn foo(f: &fn()) { f() } -fn bar() {} -pub fn main() { foo(||bar()); } + fn foo(f: &fn()) { f() } + fn bar() {} + pub fn main() { foo(||bar()); } } mod b { -fn foo(f: Option<&fn()>) { f.iter(|x|x()) } -fn bar() {} -pub fn main() { foo(Some(bar)); } + fn foo(f: Option<&fn()>) { f.iter(|x|x()) } + fn bar() {} + pub fn main() { foo(Some(bar)); } } mod c { -fn foo(f: Option<&fn()>) { f.iter(|x|x()) } -fn bar() {} -pub fn main() { foo(Some(||bar())); } + fn foo(f: Option<&fn()>) { f.iter(|x|x()) } + fn bar() {} + pub fn main() { foo(Some(||bar())); } } pub fn main() { diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index 3f8ce032d0d9e..5cdc4238eafba 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #3290 fn main() { let mut x = ~3; x = x; diff --git a/src/test/run-pass/issue-3796.rs b/src/test/run-pass/issue-3796.rs index 0091c09625584..5f4409391396a 100644 --- a/src/test/run-pass/issue-3796.rs +++ b/src/test/run-pass/issue-3796.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #3796 #[deny(dead_assignment)]; fn main() { let mut x = 1; diff --git a/src/test/run-pass/issue-3874.rs b/src/test/run-pass/issue-3874.rs index f54d2f9fafc4e..e293e40ac6903 100644 --- a/src/test/run-pass/issue-3874.rs +++ b/src/test/run-pass/issue-3874.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #3874 enum PureCounter { PureCounter(uint) } fn each(self: PureCounter, blk: &fn(v: &uint)) { diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs index a04e35108028c..9a8b90db185bc 100644 --- a/src/test/run-pass/issue-3979-2.rs +++ b/src/test/run-pass/issue-3979-2.rs @@ -9,16 +9,17 @@ // except according to those terms. // xfail-test + trait A { - fn a_method(); + fn a_method(&self); } trait B: A { - fn b_method(); + fn b_method(&self); } trait C: B { - fn c_method() { + fn c_method(&self) { self.a_method(); } } diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index b91ec5711cf21..5884a35a1a106 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-test FIXME #5946 trait Positioned { fn SetX(&mut self, S); fn X(&self) -> S; diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 23e5f3945b12d..5b668d710ddeb 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -8,11 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// xfail-fast + extern mod extra; use extra::net::tcp::TcpSocketBuf; +use std::io; +use std::int; + use std::io::{ReaderUtil,WriterUtil}; enum Result { @@ -97,9 +101,9 @@ priv fn cmd_to_str(cmd: ~[~str]) -> ~str { let mut res = ~"*"; res.push_str(cmd.len().to_str()); res.push_str("\r\n"); - for cmd.each |s| { + for cmd.iter().advance |s| { res.push_str([~"$", s.len().to_str(), ~"\r\n", - copy *s, ~"\r\n"].concat())); + copy *s, ~"\r\n"].concat() ); } res } diff --git a/src/test/run-pass/issue-4541.rs b/src/test/run-pass/issue-4541.rs index 24a8adfcb1a53..7b80974313e37 100644 --- a/src/test/run-pass/issue-4541.rs +++ b/src/test/run-pass/issue-4541.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +use std::io; + fn parse_args() -> ~str { - let args = std::os::args(); + let args = ::std::os::args(); let mut n = 0; while n < args.len() { diff --git a/src/test/run-pass/issue-4542.rs b/src/test/run-pass/issue-4542.rs index a5e5b10d07642..4aa83b853de45 100644 --- a/src/test/run-pass/issue-4542.rs +++ b/src/test/run-pass/issue-4542.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +use std::os; + pub fn main() { - for os::args().each |arg| { + let x = os::args(); + for x.iter().advance |arg| { match arg.clone() { s => { } } diff --git a/src/test/run-pass/issue_3882.rs b/src/test/run-pass/issue_3882.rs index 7b1af0d151f73..202385681ce62 100644 --- a/src/test/run-pass/issue_3882.rs +++ b/src/test/run-pass/issue_3882.rs @@ -1,5 +1,3 @@ -// xfail-test - // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -10,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-test // aux-build:issue_3882.rc extern mod linenoise; use linenoise::issue_3882::*; diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs index 32cd7f0c7f8a7..b6b6e0e143795 100644 --- a/src/test/run-pass/labeled-break.rs +++ b/src/test/run-pass/labeled-break.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-fast -// xfail-test - pub fn main() { 'foo: loop { loop { diff --git a/src/test/run-pass/match-borrowed_str.rs b/src/test/run-pass/match-borrowed_str.rs index 1a58174a3fbcf..99e1ae6ec56e3 100644 --- a/src/test/run-pass/match-borrowed_str.rs +++ b/src/test/run-pass/match-borrowed_str.rs @@ -1,6 +1,8 @@ -// xfail-test +// FIXME #7306 // xfail-fast -// -*- rust -*- + +use std::io; + fn f1(ref_string: &str) { match ref_string { "a" => io::println("found a"), diff --git a/src/test/run-pass/pipe-select-macro.rs b/src/test/run-pass/pipe-select-macro.rs index a77e6acbb2508..2db6605414506 100644 --- a/src/test/run-pass/pipe-select-macro.rs +++ b/src/test/run-pass/pipe-select-macro.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test +// FIXME #7303: xfail-test // Protocols proto! foo ( diff --git a/src/test/run-pass/preempt.rs b/src/test/run-pass/preempt.rs index 3d3e178f064ae..aa750c21d4588 100644 --- a/src/test/run-pass/preempt.rs +++ b/src/test/run-pass/preempt.rs @@ -11,23 +11,30 @@ // xfail-test // This checks that preemption works. -fn starve_main(alive: chan) { +// note: halfway done porting to modern rust +extern mod extra; + +use std::comm; +use extra::comm; + +fn starve_main(alive: Port) { debug!("signalling main"); - alive.recv(1); + alive.recv(); debug!("starving main"); - let i: int = 0; + let mut i: int = 0; loop { i += 1; } } pub fn main() { - let alive: port = port(); + let (port, chan) = stream(); + debug!("main started"); - let s: task = do task::spawn { - starve_main(chan(alive)); + do spawn { + starve_main(port); }; - let i: int; + let mut i: int = 0; debug!("main waiting for alive signal"); - alive.send(i); + chan.send(i); debug!("main got alive signal"); while i < 50 { debug!("main iterated"); i += 1; } debug!("main completed"); diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index fbd7d851fa378..c8e87af9ec0a3 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -1,6 +1,3 @@ -// xfail-test -// xfail'd due to segfaults with by-value self. - // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -15,26 +12,24 @@ trait get { fn get(self) -> int; } -// Note: impl on a slice -impl get for &'self int { +// FIXME #7302: Note: impl on a slice +impl<'self> get for &'self int { fn get(self) -> int { - return **self; + return *self; } } pub fn main() { - /* let x = @mut 6; let y = x.get(); assert_eq!(y, 6); - */ let x = @6; let y = x.get(); debug!("y=%d", y); assert_eq!(y, 6); - let mut x = ~6; + let x = ~6; let y = x.get(); debug!("y=%d", y); assert_eq!(y, 6); diff --git a/src/test/run-pass/regions-borrow-evec-at.rs b/src/test/run-pass/regions-borrow-evec-at.rs index a018dad64b366..45e5b1ad9c94a 100644 --- a/src/test/run-pass/regions-borrow-evec-at.rs +++ b/src/test/run-pass/regions-borrow-evec-at.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - fn foo(x: &[uint]) -> uint { x[0] } diff --git a/src/test/run-pass/resolve-issue-2428.rs b/src/test/run-pass/resolve-issue-2428.rs index 6d00210898bd0..57f6596d1d720 100644 --- a/src/test/run-pass/resolve-issue-2428.rs +++ b/src/test/run-pass/resolve-issue-2428.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - static foo: int = 4 >> 1; enum bs { thing = foo } pub fn main() { assert!((thing as int == foo)); } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index cd94bd30c21e0..85a4f98d198c3 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -10,6 +10,8 @@ // xfail-test +use std::ptr; + enum a_tag { varA(A), varB(B) diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index ea60f389663cf..28088aa571eb2 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -10,6 +10,8 @@ // xfail-test +use std::ptr; + enum a_tag { a_tag(u64) } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index f21ea06697d8f..637fc7a70f585 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -1,4 +1,4 @@ -// xfail-test +// xfail-test FIXME #5882 // Weird borrow check bug // Copyright 2012 The Rust Project Developers. See the COPYRIGHT @@ -17,45 +17,45 @@ struct Tree(@mut TreeR); struct TreeR { left: Option, right: Option, - val: to_str + val: ~to_str } trait to_str { - fn to_str(&self) -> ~str; + fn to_str_(&self) -> ~str; } impl to_str for Option { - fn to_str(&self) -> ~str { + fn to_str_(&self) -> ~str { match *self { None => { ~"none" } - Some(ref t) => { ~"some(" + t.to_str() + ~")" } + Some(ref t) => { ~"some(" + t.to_str_() + ~")" } } } } impl to_str for int { - fn to_str(&self) -> ~str { int::str(*self) } + fn to_str_(&self) -> ~str { self.to_str() } } impl to_str for Tree { - fn to_str(&self) -> ~str { - let l = self.left, r = self.right; + fn to_str_(&self) -> ~str { + let (l, r) = (self.left, self.right); let val = &self.val; - fmt!("[%s, %s, %s]", val.to_str(), l.to_str(), r.to_str()) + fmt!("[%s, %s, %s]", val.to_str_(), l.to_str_(), r.to_str_()) } } -fn foo(x: T) -> ~str { x.to_str() } +fn foo(x: T) -> ~str { x.to_str_() } pub fn main() { let t1 = Tree(@mut TreeR{left: None, right: None, - val: 1 as to_str }); + val: ~1 as ~to_str }); let t2 = Tree(@mut TreeR{left: Some(t1), right: Some(t1), - val: 2 as to_str }); + val: ~2 as ~to_str }); let expected = ~"[2, some([1, none, none]), some([1, none, none])]"; - assert_eq!(t2.to_str(), expected); - assert_eq!(foo(t2 as to_str), expected); + assert!(t2.to_str_() == expected); + assert!(foo(t2) == expected); t1.left = Some(t2); // create cycle } diff --git a/src/test/run-pass/traits.rs b/src/test/run-pass/traits.rs deleted file mode 100644 index ba3e8e082b345..0000000000000 --- a/src/test/run-pass/traits.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012 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. - -//xfail-test - -// Sketching traits. - -// methods with no implementation are required; methods with an -// implementation are provided. No "req" keyword necessary. -trait Eq { - fn eq(a: self) -> bool; - - fn neq(a: self) -> bool { - !self.eq(a) - } -} - -// The `<` is pronounced `extends`. Also under consideration is `<:`. -// Just using `:` is frowned upon, because (paraphrasing dherman) `:` -// is supposed to separate things from different universes. -trait Ord < Eq { - - fn lt(a: self) -> bool; - - fn lte(a: self) -> bool { - self.lt(a) || self.eq(a) - } - - fn gt(a: self) -> bool { - !self.lt(a) && !self.eq(a) - } - - fn gte(a: self) -> bool { - !self.lt(a) - } -} - -// pronounced "impl of Ord for int" -- not sold on this yet -impl Ord for int { - fn lt(a: &int) -> bool { - self < (*a) - } - - // is this the place to put this? - fn eq(a: &int) -> bool { - self == (*a) - } -} diff --git a/src/test/run-pass/unconstrained-region.rs b/src/test/run-pass/unconstrained-region.rs index b6e2ba553df4a..2341ee8d100c1 100644 --- a/src/test/run-pass/unconstrained-region.rs +++ b/src/test/run-pass/unconstrained-region.rs @@ -9,14 +9,15 @@ // except according to those terms. // xfail-test -// See #3283 -fn foo(blk: &fn(p: &'a fn() -> &'a fn())) { - let mut state = 0; - let statep = &mut state; +// FIXME: #7336: codegen bug makes this segfault on Linux x86_64 + +fn foo<'a>(blk: &fn(p: &'a fn() -> &'a fn())) { + let mut state = 0; + let statep = &mut state; do blk { || { *statep = 1; } } } fn main() { do foo |p| { p()() } -} \ No newline at end of file +}