]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/ufcs-polymorphic-paths.rs
std: Clean out deprecated APIs
[rust.git] / src / test / run-pass / ufcs-polymorphic-paths.rs
index 27f11d0411c47f11f194b4a1d765d13a196318ba..491045564ce222b6f81d2530311feaf5b1d34e66 100644 (file)
@@ -8,12 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-#![feature(collections, rand, into_cow, map_in_place, bitvec)]
-#![allow(warnings)]
-
-use std::borrow::{Cow, IntoCow};
-use std::collections::BitVec;
+use std::borrow::{Cow, ToOwned};
 use std::default::Default;
 use std::iter::FromIterator;
 use std::ops::Add;
 impl Rng for XorShiftRng {}
 pub trait Rng {}
 pub trait Rand: Default + Sized {
-    fn rand<R: Rng>(rng: &mut R) -> Self { Default::default() }
+    fn rand<R: Rng>(_rng: &mut R) -> Self { Default::default() }
 }
 impl Rand for i32 { }
 
+pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
+    fn into_cow(self) -> Cow<'a, B>;
+}
+
+impl<'a> IntoCow<'a, str> for String {
+    fn into_cow(self) -> Cow<'a, str> {
+        Cow::Owned(self)
+    }
+}
+
 #[derive(PartialEq, Eq)]
 struct Newt<T>(T);
 
@@ -42,6 +47,25 @@ fn size() -> usize { std::mem::size_of::<Self>() }
 }
 impl<T> Size for T {}
 
+#[derive(PartialEq, Eq)]
+struct BitVec;
+
+impl BitVec {
+    fn from_fn<F>(_: usize, _: F) -> BitVec where F: FnMut(usize) -> bool {
+        BitVec
+    }
+}
+
+#[derive(PartialEq, Eq)]
+struct Foo<T>(T);
+
+impl<T> Foo<T> {
+    fn map_in_place<U, F>(self, mut f: F) -> Foo<U> where F: FnMut(T) -> U {
+        Foo(f(self.0))
+    }
+
+}
+
 macro_rules! tests {
     ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
         const C: $ty = $expr;
@@ -76,13 +100,13 @@ macro_rules! tests {
     BitVec::from_fn::<fn(usize) -> bool>, fn(usize, fn(usize) -> bool) -> BitVec, (5, odd);
 
     // Inherent non-static method.
-    Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8);
-    Vec::map_in_place::<i8, fn(u8) -> i8>, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>,
-        (vec![b'f', b'o', b'o'], u8_as_i8);
-    Vec::<u8>::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        , (vec![b'f', b'o', b'o'], u8_as_i8);
-    Vec::<u8>::map_in_place::<i8, fn(u8) -> i8>, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        , (vec![b'f', b'o', b'o'], u8_as_i8);
+    Foo::map_in_place, fn(Foo<u8>, fn(u8) -> i8) -> Foo<i8>, (Foo(b'f'), u8_as_i8);
+    Foo::map_in_place::<i8, fn(u8) -> i8>, fn(Foo<u8>, fn(u8) -> i8) -> Foo<i8>,
+        (Foo(b'f'), u8_as_i8);
+    Foo::<u8>::map_in_place, fn(Foo<u8>, fn(u8) -> i8) -> Foo<i8>
+        , (Foo(b'f'), u8_as_i8);
+    Foo::<u8>::map_in_place::<i8, fn(u8) -> i8>, fn(Foo<u8>, fn(u8) -> i8) -> Foo<i8>
+        , (Foo(b'f'), u8_as_i8);
 
     // Trait static methods.
     bool::size, fn() -> usize, ();