Skip to content

Commit 365bd9a

Browse files
committed
Round 1 fixes and rebase conflicts
1 parent b64dfff commit 365bd9a

File tree

17 files changed

+44
-44
lines changed

17 files changed

+44
-44
lines changed

src/libcollections/bit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ impl Default for BitVec {
925925
#[stable(feature = "rust1", since = "1.0.0")]
926926
impl FromIterator<bool> for BitVec {
927927
fn from_iter<I: IntoIterator<Item=bool>>(iter: I) -> BitVec {
928-
let mut ret = Bitv::new();
928+
let mut ret = BitVec::new();
929929
ret.extend(iter);
930930
ret
931931
}
@@ -1146,7 +1146,7 @@ impl Default for BitSet {
11461146
#[stable(feature = "rust1", since = "1.0.0")]
11471147
impl FromIterator<usize> for BitSet {
11481148
fn from_iter<I: IntoIterator<Item=usize>>(iter: I) -> BitSet {
1149-
let mut ret = BitvSet::new();
1149+
let mut ret = BitSet::new();
11501150
ret.extend(iter);
11511151
ret
11521152
}

src/libcore/iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@ pub trait IteratorExt: Iterator + Sized {
522522
///
523523
/// let a = [1, 4, 2, 3, 8, 9, 6];
524524
/// let sum = a.iter()
525-
/// .cloned()
526-
/// .inspect(|&x| println!("filtering {}", x))
527-
/// .filter(|&x| x % 2 == 0)
528-
/// .inspect(|&x| println!("{} made it through", x))
529-
/// .sum();
525+
/// .map(|x| *x)
526+
/// .inspect(|&x| println!("filtering {}", x))
527+
/// .filter(|&x| x % 2 == 0)
528+
/// .inspect(|&x| println!("{} made it through", x))
529+
/// .sum();
530530
/// println!("{}", sum);
531531
/// ```
532532
#[inline]

src/libcoretest/hash/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ impl Default for MyHasher {
2323
}
2424

2525
impl Hasher for MyHasher {
26-
type Output = u64;
2726
fn write(&mut self, buf: &[u8]) {
2827
for byte in buf {
2928
self.hash += *byte as u64;
@@ -85,7 +84,6 @@ struct Custom { hash: u64 }
8584
struct CustomHasher { output: u64 }
8685

8786
impl Hasher for CustomHasher {
88-
type Output = u64;
8987
fn finish(&self) -> u64 { self.output }
9088
fn write(&mut self, data: &[u8]) { panic!() }
9189
fn write_u64(&mut self, data: u64) { self.output = data; }

src/librustc_trans/trans/tvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
426426
Br(bcx, loop_bcx.llbb, DebugLoc::None);
427427

428428
let loop_counter = Phi(loop_bcx, bcx.ccx().int_type(),
429-
&[C_uint(bcx.ccx(), 0)], &[bcx.llbb]);
429+
&[C_uint(bcx.ccx(), 0 as usize)], &[bcx.llbb]);
430430

431431
let bcx = loop_bcx;
432432

src/librustdoc/flock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod imp {
112112

113113
impl Lock {
114114
pub fn new(p: &Path) -> Lock {
115-
let buf = CString::from_slice(p.as_vec()).unwrap();
115+
let buf = CString::new(p.as_vec()).unwrap();
116116
let fd = unsafe {
117117
libc::open(buf.as_ptr(), libc::O_RDWR | libc::O_CREAT,
118118
libc::S_IRWXU)

src/librustdoc/html/markdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
236236
s.push_str(&highlight::highlight(&text,
237237
None,
238238
Some("rust-example-rendered")));
239-
let output = CString::from_vec(s.into_bytes()).unwrap();
239+
let output = CString::new(s).unwrap();
240240
hoedown_buffer_puts(ob, output.as_ptr());
241241
})
242242
}
@@ -293,7 +293,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
293293
format!("{} ", sec)
294294
});
295295

296-
let text = CString::from_vec(text.into_bytes()).unwrap();
296+
let text = CString::new(text).unwrap();
297297
unsafe { hoedown_buffer_puts(ob, text.as_ptr()) }
298298
}
299299

src/libstd/collections/hash/map_stage0.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@ impl<K, V, S, H> FromIterator<(K, V)> for HashMap<K, V, S>
15521552
S: HashState<Hasher=H> + Default,
15531553
H: hash::Hasher<Output=u64>
15541554
{
1555-
fn from_iter<T: Iterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> {
1555+
fn from_iter<T: IntoIterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> {
1556+
let iter = iter.into_iter();
15561557
let lower = iter.size_hint().0;
15571558
let mut map = HashMap::with_capacity_and_hash_state(lower,
15581559
Default::default());
@@ -1567,7 +1568,7 @@ impl<K, V, S, H> Extend<(K, V)> for HashMap<K, V, S>
15671568
S: HashState<Hasher=H>,
15681569
H: hash::Hasher<Output=u64>
15691570
{
1570-
fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) {
1571+
fn extend<T: IntoIterator<Item=(K, V)>>(&mut self, iter: T) {
15711572
for (k, v) in iter {
15721573
self.insert(k, v);
15731574
}

src/libstd/collections/hash/set_stage0.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ impl<T, S, H> FromIterator<T> for HashSet<T, S>
622622
S: HashState<Hasher=H> + Default,
623623
H: hash::Hasher<Output=u64>
624624
{
625-
fn from_iter<I: Iterator<Item=T>>(iter: I) -> HashSet<T, S> {
625+
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> HashSet<T, S> {
626+
let iter = iter.into_iter();
626627
let lower = iter.size_hint().0;
627628
let mut set = HashSet::with_capacity_and_hash_state(lower, Default::default());
628629
set.extend(iter);
@@ -636,7 +637,7 @@ impl<T, S, H> Extend<T> for HashSet<T, S>
636637
S: HashState<Hasher=H>,
637638
H: hash::Hasher<Output=u64>
638639
{
639-
fn extend<I: Iterator<Item=T>>(&mut self, iter: I) {
640+
fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) {
640641
for k in iter {
641642
self.insert(k);
642643
}

src/libstd/ffi/c_str.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct CString {
105105
/// }
106106
///
107107
/// fn main() {
108-
/// let s = CString::from_slice(b"data data data data").unwrap();
108+
/// let s = CString::new("data data data data").unwrap();
109109
/// work(&s);
110110
/// }
111111
/// ```
@@ -141,7 +141,7 @@ impl CString {
141141
/// extern { fn puts(s: *const libc::c_char); }
142142
///
143143
/// fn main() {
144-
/// let to_print = CString::from_slice(b"Hello!").unwrap();
144+
/// let to_print = CString::new("Hello!").unwrap();
145145
/// unsafe {
146146
/// puts(to_print.as_ptr());
147147
/// }
@@ -175,7 +175,7 @@ impl CString {
175175
/// extern { fn puts(s: *const libc::c_char); }
176176
///
177177
/// fn main() {
178-
/// let to_print = CString::from_slice(b"Hello!").unwrap();
178+
/// let to_print = CString::new("Hello!").unwrap();
179179
/// unsafe {
180180
/// puts(to_print.as_ptr());
181181
/// }
@@ -436,18 +436,18 @@ mod tests {
436436

437437
#[test]
438438
fn simple() {
439-
let s = CString::from_slice(b"1234").unwrap();
439+
let s = CString::new(b"1234").unwrap();
440440
assert_eq!(s.as_bytes(), b"1234");
441441
assert_eq!(s.as_bytes_with_nul(), b"1234\0");
442442
}
443443

444444
#[test]
445445
fn build_with_zero1() {
446-
assert!(CString::from_slice(b"\0").is_err());
446+
assert!(CString::new(b"\0").is_err());
447447
}
448448
#[test]
449449
fn build_with_zero2() {
450-
assert!(CString::from_vec(vec![0]).is_err());
450+
assert!(CString::new(vec![0]).is_err());
451451
}
452452

453453
#[test]
@@ -460,7 +460,7 @@ mod tests {
460460

461461
#[test]
462462
fn formatted() {
463-
let s = CString::from_slice(b"12").unwrap();
463+
let s = CString::new(b"12").unwrap();
464464
assert_eq!(format!("{:?}", s), "\"12\"");
465465
}
466466

src/test/run-pass/bitv-perf-test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
#![feature(box_syntax)]
1414

1515
extern crate collections;
16-
use std::collections::Bitv;
16+
use std::collections::BitVec;
1717

1818
fn bitv_test() {
19-
let mut v1 = box Bitv::from_elem(31, false);
20-
let v2 = box Bitv::from_elem(31, true);
19+
let mut v1 = box BitVec::from_elem(31, false);
20+
let v2 = box BitVec::from_elem(31, true);
2121
v1.union(&*v2);
2222
}
2323

src/test/run-pass/c-stack-returning-int64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ mod mlibc {
2424
}
2525

2626
fn atol(s: String) -> int {
27-
let c = CString::from_slice(s.as_bytes()).unwrap();
27+
let c = CString::new(s).unwrap();
2828
unsafe { mlibc::atol(c.as_ptr()) as int }
2929
}
3030

3131
fn atoll(s: String) -> i64 {
32-
let c = CString::from_slice(s.as_bytes()).unwrap();
32+
let c = CString::new(s).unwrap();
3333
unsafe { mlibc::atoll(c.as_ptr()) as i64 }
3434
}
3535

src/test/run-pass/const-polymorphic-paths.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![feature(macro_rules)]
1212

1313
use std::borrow::{Cow, IntoCow};
14-
use std::collections::Bitv;
14+
use std::collections::BitVec;
1515
use std::default::Default;
1616
use std::iter::FromIterator;
1717
use std::ops::Add;
@@ -63,8 +63,8 @@ tests! {
6363
Vec::<()>::new, fn() -> Vec<()>, ();
6464
Vec::with_capacity, fn(uint) -> Vec<()>, (5);
6565
Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5);
66-
Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
67-
Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
66+
BitVec::from_fn, fn(uint, fn(uint) -> bool) -> BitVec, (5, odd);
67+
BitVec::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> BitVec, (5, odd);
6868

6969
// Inherent non-static method.
7070
Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8);

src/test/run-pass/foreign-fn-linkname.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod mlibc {
2424

2525
fn strlen(str: String) -> uint {
2626
// C string is terminated with a zero
27-
let s = CString::from_slice(str.as_bytes()).unwrap();
27+
let s = CString::new(str).unwrap();
2828
unsafe {
2929
mlibc::my_strlen(s.as_ptr()) as uint
3030
}

src/test/run-pass/issue-11736.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
extern crate collections;
1212

13-
use std::collections::Bitv;
13+
use std::collections::BitVec;
1414
use std::num::Float;
1515

1616
fn main() {
1717
// Generate sieve of Eratosthenes for n up to 1e6
1818
let n = 1000000_usize;
19-
let mut sieve = Bitv::from_elem(n+1, true);
19+
let mut sieve = BitVec::from_elem(n+1, true);
2020
let limit: uint = (n as f32).sqrt() as uint;
2121
for i in 2..limit+1 {
2222
if sieve[i] {

src/test/run-pass/issue-2383.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
// except according to those terms.
1111

1212
extern crate collections;
13-
use std::collections::RingBuf;
13+
use std::collections::VecDeque;
1414

1515
pub fn main() {
16-
let mut q = RingBuf::new();
16+
let mut q = VecDeque::new();
1717
q.push_front(10);
1818
}

src/test/run-pass/rename-directory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ fn rename_directory() {
3131
let test_file = &old_path.join("temp.txt");
3232

3333
/* Write the temp input file */
34-
let fromp = CString::from_slice(test_file.as_vec()).unwrap();
35-
let modebuf = CString::from_slice(b"w+b").unwrap();
34+
let fromp = CString::new(test_file.as_vec()).unwrap();
35+
let modebuf = CString::new(b"w+b").unwrap();
3636
let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
3737
assert!((ostream as uint != 0_usize));
3838
let s = "hello".to_string();
39-
let buf = CString::from_slice(b"hello").unwrap();
39+
let buf = CString::new(b"hello").unwrap();
4040
let write_len = libc::fwrite(buf.as_ptr() as *mut _,
4141
1_usize as libc::size_t,
4242
(s.len() + 1_usize) as libc::size_t,

src/test/run-pass/variadic-ffi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub fn main() {
2929

3030
unsafe {
3131
// Call with just the named parameter
32-
let c = CString::from_slice(b"Hello World\n").unwrap();
32+
let c = CString::new(b"Hello World\n").unwrap();
3333
check("Hello World\n", |s| sprintf(s, c.as_ptr()));
3434

3535
// Call with variable number of arguments
36-
let c = CString::from_slice(b"%d %f %c %s\n").unwrap();
36+
let c = CString::new(b"%d %f %c %s\n").unwrap();
3737
check("42 42.500000 a %d %f %c %s\n\n", |s| {
3838
sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr());
3939
});
@@ -44,11 +44,11 @@ pub fn main() {
4444
// A function that takes a function pointer
4545
unsafe fn call(p: unsafe extern fn(*mut c_char, *const c_char, ...) -> c_int) {
4646
// Call with just the named parameter
47-
let c = CString::from_slice(b"Hello World\n").unwrap();
47+
let c = CString::new(b"Hello World\n").unwrap();
4848
check("Hello World\n", |s| sprintf(s, c.as_ptr()));
4949

5050
// Call with variable number of arguments
51-
let c = CString::from_slice(b"%d %f %c %s\n").unwrap();
51+
let c = CString::new(b"%d %f %c %s\n").unwrap();
5252
check("42 42.500000 a %d %f %c %s\n\n", |s| {
5353
sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr());
5454
});

0 commit comments

Comments
 (0)