]> git.lizzy.rs Git - rust.git/commitdiff
Round 1 fixes and rebase conflicts
authorAlex Crichton <alex@alexcrichton.com>
Wed, 18 Feb 2015 22:39:37 +0000 (14:39 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 18 Feb 2015 23:27:42 +0000 (15:27 -0800)
17 files changed:
src/libcollections/bit.rs
src/libcore/iter.rs
src/libcoretest/hash/mod.rs
src/librustc_trans/trans/tvec.rs
src/librustdoc/flock.rs
src/librustdoc/html/markdown.rs
src/libstd/collections/hash/map_stage0.rs
src/libstd/collections/hash/set_stage0.rs
src/libstd/ffi/c_str.rs
src/test/run-pass/bitv-perf-test.rs
src/test/run-pass/c-stack-returning-int64.rs
src/test/run-pass/const-polymorphic-paths.rs
src/test/run-pass/foreign-fn-linkname.rs
src/test/run-pass/issue-11736.rs
src/test/run-pass/issue-2383.rs
src/test/run-pass/rename-directory.rs
src/test/run-pass/variadic-ffi.rs

index d9c2290e68cedd91e30aa3d516d7586309f37a27..11c576eab152551c274b9036b4ac99a5ee30ae39 100644 (file)
@@ -925,7 +925,7 @@ fn default() -> BitVec { BitVec::new() }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl FromIterator<bool> for BitVec {
     fn from_iter<I: IntoIterator<Item=bool>>(iter: I) -> BitVec {
-        let mut ret = Bitv::new();
+        let mut ret = BitVec::new();
         ret.extend(iter);
         ret
     }
@@ -1146,7 +1146,7 @@ fn default() -> BitSet { BitSet::new() }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl FromIterator<usize> for BitSet {
     fn from_iter<I: IntoIterator<Item=usize>>(iter: I) -> BitSet {
-        let mut ret = BitvSet::new();
+        let mut ret = BitSet::new();
         ret.extend(iter);
         ret
     }
index 7a6c3a0077233346c0912742146022ca3518e4fb..194c0dc4f28ea235bef6d58648bbc2711d77a4a8 100644 (file)
@@ -522,11 +522,11 @@ fn fuse(self) -> Fuse<Self> {
     ///
     /// let a = [1, 4, 2, 3, 8, 9, 6];
     /// let sum = a.iter()
-    ///             .cloned()
-    ///             .inspect(|&x| println!("filtering {}", x))
-    ///             .filter(|&x| x % 2 == 0)
-    ///             .inspect(|&x| println!("{} made it through", x))
-    ///             .sum();
+    ///            .map(|x| *x)
+    ///            .inspect(|&x| println!("filtering {}", x))
+    ///            .filter(|&x| x % 2 == 0)
+    ///            .inspect(|&x| println!("{} made it through", x))
+    ///            .sum();
     /// println!("{}", sum);
     /// ```
     #[inline]
index 2d85769c0cddf27d2159a2b102787b3913eb730a..9b6af182f729c291751d2db896acfbc4e5c74200 100644 (file)
@@ -23,7 +23,6 @@ fn default() -> MyHasher {
 }
 
 impl Hasher for MyHasher {
-    type Output = u64;
     fn write(&mut self, buf: &[u8]) {
         for byte in buf {
             self.hash += *byte as u64;
@@ -85,7 +84,6 @@ struct Custom { hash: u64 }
 struct CustomHasher { output: u64 }
 
 impl Hasher for CustomHasher {
-    type Output = u64;
     fn finish(&self) -> u64 { self.output }
     fn write(&mut self, data: &[u8]) { panic!() }
     fn write_u64(&mut self, data: u64) { self.output = data; }
index 29a5d45a8be3f0ce3e8e3a6da8902431241a5997..7b59e0258ee224c4ec6cdd91e4c012afa800c072 100644 (file)
@@ -426,7 +426,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
     Br(bcx, loop_bcx.llbb, DebugLoc::None);
 
     let loop_counter = Phi(loop_bcx, bcx.ccx().int_type(),
-                           &[C_uint(bcx.ccx(), 0)], &[bcx.llbb]);
+                           &[C_uint(bcx.ccx(), 0 as usize)], &[bcx.llbb]);
 
     let bcx = loop_bcx;
 
index eba915af519c83addd2a32c6c686e2bc894fe068..ad91c3cb2c35b60e4b023c655ef8486403ebfd12 100644 (file)
@@ -112,7 +112,7 @@ pub struct Lock {
 
     impl Lock {
         pub fn new(p: &Path) -> Lock {
-            let buf = CString::from_slice(p.as_vec()).unwrap();
+            let buf = CString::new(p.as_vec()).unwrap();
             let fd = unsafe {
                 libc::open(buf.as_ptr(), libc::O_RDWR | libc::O_CREAT,
                            libc::S_IRWXU)
index 3ceaec5f53d824fcdfbf2cd6bc547002f9d34467..7ea5bd569e1996df853eeccd1e550b3a6309e49e 100644 (file)
@@ -236,7 +236,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
                 s.push_str(&highlight::highlight(&text,
                                                  None,
                                                  Some("rust-example-rendered")));
-                let output = CString::from_vec(s.into_bytes()).unwrap();
+                let output = CString::new(s).unwrap();
                 hoedown_buffer_puts(ob, output.as_ptr());
             })
         }
@@ -293,7 +293,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
                                format!("{} ", sec)
                            });
 
-        let text = CString::from_vec(text.into_bytes()).unwrap();
+        let text = CString::new(text).unwrap();
         unsafe { hoedown_buffer_puts(ob, text.as_ptr()) }
     }
 
index 18241c7a0c3d8135b3c325f44eebf6a2ee589bed..8ae195cf991d36901c1fd58688486ada765ad2bc 100644 (file)
@@ -1552,7 +1552,8 @@ impl<K, V, S, H> FromIterator<(K, V)> for HashMap<K, V, S>
           S: HashState<Hasher=H> + Default,
           H: hash::Hasher<Output=u64>
 {
-    fn from_iter<T: Iterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> {
+    fn from_iter<T: IntoIterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> {
+        let iter = iter.into_iter();
         let lower = iter.size_hint().0;
         let mut map = HashMap::with_capacity_and_hash_state(lower,
                                                             Default::default());
@@ -1567,7 +1568,7 @@ impl<K, V, S, H> Extend<(K, V)> for HashMap<K, V, S>
           S: HashState<Hasher=H>,
           H: hash::Hasher<Output=u64>
 {
-    fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) {
+    fn extend<T: IntoIterator<Item=(K, V)>>(&mut self, iter: T) {
         for (k, v) in iter {
             self.insert(k, v);
         }
index 3bc22236a47f25a4c546d822831e869161c7b21c..9d615d0c3ffcacc338df47d1c4737b49a8fbf63f 100644 (file)
@@ -622,7 +622,8 @@ impl<T, S, H> FromIterator<T> for HashSet<T, S>
           S: HashState<Hasher=H> + Default,
           H: hash::Hasher<Output=u64>
 {
-    fn from_iter<I: Iterator<Item=T>>(iter: I) -> HashSet<T, S> {
+    fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> HashSet<T, S> {
+        let iter = iter.into_iter();
         let lower = iter.size_hint().0;
         let mut set = HashSet::with_capacity_and_hash_state(lower, Default::default());
         set.extend(iter);
@@ -636,7 +637,7 @@ impl<T, S, H> Extend<T> for HashSet<T, S>
           S: HashState<Hasher=H>,
           H: hash::Hasher<Output=u64>
 {
-    fn extend<I: Iterator<Item=T>>(&mut self, iter: I) {
+    fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) {
         for k in iter {
             self.insert(k);
         }
index 70c14ef1978293b3cf42226218acbd2908698a39..8976813d3f91e9681a84f48d8ca552733319ff6c 100644 (file)
@@ -105,7 +105,7 @@ pub struct CString {
 /// }
 ///
 /// fn main() {
-///     let s = CString::from_slice(b"data data data data").unwrap();
+///     let s = CString::new("data data data data").unwrap();
 ///     work(&s);
 /// }
 /// ```
@@ -141,7 +141,7 @@ impl CString {
     /// extern { fn puts(s: *const libc::c_char); }
     ///
     /// fn main() {
-    ///     let to_print = CString::from_slice(b"Hello!").unwrap();
+    ///     let to_print = CString::new("Hello!").unwrap();
     ///     unsafe {
     ///         puts(to_print.as_ptr());
     ///     }
@@ -175,7 +175,7 @@ pub fn new<T: IntoBytes>(t: T) -> Result<CString, NulError> {
     /// extern { fn puts(s: *const libc::c_char); }
     ///
     /// fn main() {
-    ///     let to_print = CString::from_slice(b"Hello!").unwrap();
+    ///     let to_print = CString::new("Hello!").unwrap();
     ///     unsafe {
     ///         puts(to_print.as_ptr());
     ///     }
@@ -436,18 +436,18 @@ fn c_to_rust() {
 
     #[test]
     fn simple() {
-        let s = CString::from_slice(b"1234").unwrap();
+        let s = CString::new(b"1234").unwrap();
         assert_eq!(s.as_bytes(), b"1234");
         assert_eq!(s.as_bytes_with_nul(), b"1234\0");
     }
 
     #[test]
     fn build_with_zero1() {
-        assert!(CString::from_slice(b"\0").is_err());
+        assert!(CString::new(b"\0").is_err());
     }
     #[test]
     fn build_with_zero2() {
-        assert!(CString::from_vec(vec![0]).is_err());
+        assert!(CString::new(vec![0]).is_err());
     }
 
     #[test]
@@ -460,7 +460,7 @@ fn build_with_zero3() {
 
     #[test]
     fn formatted() {
-        let s = CString::from_slice(b"12").unwrap();
+        let s = CString::new(b"12").unwrap();
         assert_eq!(format!("{:?}", s), "\"12\"");
     }
 
index b6d428924e3e966b3102aecd481406ba56b98832..7bb9f042fe891ee418b2112c7f522f82fa54bbd7 100644 (file)
 #![feature(box_syntax)]
 
 extern crate collections;
-use std::collections::Bitv;
+use std::collections::BitVec;
 
 fn bitv_test() {
-    let mut v1 = box Bitv::from_elem(31, false);
-    let v2 = box Bitv::from_elem(31, true);
+    let mut v1 = box BitVec::from_elem(31, false);
+    let v2 = box BitVec::from_elem(31, true);
     v1.union(&*v2);
 }
 
index d18a3055b9c814662c8f08aa9e5328731ef99b31..6246ee9c6c41a9ad4bdcd7c94cc8c8a1dfa9c82f 100644 (file)
@@ -24,12 +24,12 @@ mod mlibc {
 }
 
 fn atol(s: String) -> int {
-    let c = CString::from_slice(s.as_bytes()).unwrap();
+    let c = CString::new(s).unwrap();
     unsafe { mlibc::atol(c.as_ptr()) as int }
 }
 
 fn atoll(s: String) -> i64 {
-    let c = CString::from_slice(s.as_bytes()).unwrap();
+    let c = CString::new(s).unwrap();
     unsafe { mlibc::atoll(c.as_ptr()) as i64 }
 }
 
index f8f92a56adb1a687c65033f37c1747f13b9a74d0..e9d10536b75a1085e47202605851bc3306212209 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(macro_rules)]
 
 use std::borrow::{Cow, IntoCow};
-use std::collections::Bitv;
+use std::collections::BitVec;
 use std::default::Default;
 use std::iter::FromIterator;
 use std::ops::Add;
@@ -63,8 +63,8 @@ macro_rules! tests {
     Vec::<()>::new, fn() -> Vec<()>, ();
     Vec::with_capacity, fn(uint) -> Vec<()>, (5);
     Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5);
-    Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
-    Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
+    BitVec::from_fn, fn(uint, fn(uint) -> bool) -> BitVec, (5, odd);
+    BitVec::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> 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);
index 69e5b9f43ea6264b8ccec977e08b5dc3ce8f0906..24b711328a18ab0fb5681e0de0d07b15d844f3d1 100644 (file)
@@ -24,7 +24,7 @@ mod mlibc {
 
 fn strlen(str: String) -> uint {
     // C string is terminated with a zero
-    let s = CString::from_slice(str.as_bytes()).unwrap();
+    let s = CString::new(str).unwrap();
     unsafe {
         mlibc::my_strlen(s.as_ptr()) as uint
     }
index d9bae6886fa2e6907b59721da70bc20c2495830c..b901e95ff55edb453c6a7b8642af99e394850d67 100644 (file)
 
 extern crate collections;
 
-use std::collections::Bitv;
+use std::collections::BitVec;
 use std::num::Float;
 
 fn main() {
     // Generate sieve of Eratosthenes for n up to 1e6
     let n = 1000000_usize;
-    let mut sieve = Bitv::from_elem(n+1, true);
+    let mut sieve = BitVec::from_elem(n+1, true);
     let limit: uint = (n as f32).sqrt() as uint;
     for i in 2..limit+1 {
         if sieve[i] {
index b8136323df66400dc6a230f23a5dcb097b34c759..a5a05283f80fde1f97420b3d90fe724bb63f414d 100644 (file)
@@ -10,9 +10,9 @@
 // except according to those terms.
 
 extern crate collections;
-use std::collections::RingBuf;
+use std::collections::VecDeque;
 
 pub fn main() {
-    let mut q = RingBuf::new();
+    let mut q = VecDeque::new();
     q.push_front(10);
 }
index 54e0e2de242981a30122ba63fd65a8581ff5831e..abe6ffe7d4ccaabdbac3ef7d7bf4a63cf364ba78 100644 (file)
@@ -31,12 +31,12 @@ fn rename_directory() {
         let test_file = &old_path.join("temp.txt");
 
         /* Write the temp input file */
-        let fromp = CString::from_slice(test_file.as_vec()).unwrap();
-        let modebuf = CString::from_slice(b"w+b").unwrap();
+        let fromp = CString::new(test_file.as_vec()).unwrap();
+        let modebuf = CString::new(b"w+b").unwrap();
         let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
         assert!((ostream as uint != 0_usize));
         let s = "hello".to_string();
-        let buf = CString::from_slice(b"hello").unwrap();
+        let buf = CString::new(b"hello").unwrap();
         let write_len = libc::fwrite(buf.as_ptr() as *mut _,
                                      1_usize as libc::size_t,
                                      (s.len() + 1_usize) as libc::size_t,
index 85f6ef0ddcd1bcd5e63c7c1059793d4e0e4e926c..5a476ed9ee2f89958d02a0cbb6abd8537eace2d0 100644 (file)
@@ -29,11 +29,11 @@ pub fn main() {
 
     unsafe {
         // Call with just the named parameter
-        let c = CString::from_slice(b"Hello World\n").unwrap();
+        let c = CString::new(b"Hello World\n").unwrap();
         check("Hello World\n", |s| sprintf(s, c.as_ptr()));
 
         // Call with variable number of arguments
-        let c = CString::from_slice(b"%d %f %c %s\n").unwrap();
+        let c = CString::new(b"%d %f %c %s\n").unwrap();
         check("42 42.500000 a %d %f %c %s\n\n", |s| {
             sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr());
         });
@@ -44,11 +44,11 @@ pub fn main() {
         // A function that takes a function pointer
         unsafe fn call(p: unsafe extern fn(*mut c_char, *const c_char, ...) -> c_int) {
             // Call with just the named parameter
-            let c = CString::from_slice(b"Hello World\n").unwrap();
+            let c = CString::new(b"Hello World\n").unwrap();
             check("Hello World\n", |s| sprintf(s, c.as_ptr()));
 
             // Call with variable number of arguments
-            let c = CString::from_slice(b"%d %f %c %s\n").unwrap();
+            let c = CString::new(b"%d %f %c %s\n").unwrap();
             check("42 42.500000 a %d %f %c %s\n\n", |s| {
                 sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr());
             });