1
Fork 0

auto merge of #19027 : nick29581/rust/coercions-4, r=alexcrichton

The forwards compatible parts of #18645, rebased. Converts implicit coercions from `[T, ..n]` to `&[T]` into explicit references.
This commit is contained in:
bors 2014-11-17 11:22:00 +00:00
commit 0047dbe59c
142 changed files with 1269 additions and 1283 deletions

View file

@ -399,7 +399,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
procsrv::run("", procsrv::run("",
config.adb_path.as_slice(), config.adb_path.as_slice(),
None, None,
[ &[
"push".to_string(), "push".to_string(),
exe_file.as_str().unwrap().to_string(), exe_file.as_str().unwrap().to_string(),
config.adb_test_dir.clone() config.adb_test_dir.clone()
@ -411,7 +411,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
procsrv::run("", procsrv::run("",
config.adb_path.as_slice(), config.adb_path.as_slice(),
None, None,
[ &[
"forward".to_string(), "forward".to_string(),
"tcp:5039".to_string(), "tcp:5039".to_string(),
"tcp:5039".to_string() "tcp:5039".to_string()
@ -432,7 +432,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
config.adb_path config.adb_path
.as_slice(), .as_slice(),
None, None,
[ &[
"shell".to_string(), "shell".to_string(),
adb_arg.clone() adb_arg.clone()
], ],
@ -746,7 +746,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
cmd.arg(lldb_script_path) cmd.arg(lldb_script_path)
.arg(test_executable) .arg(test_executable)
.arg(debugger_script) .arg(debugger_script)
.env_set_all([("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]); .env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]);
let (status, out, err) = match cmd.spawn() { let (status, out, err) = match cmd.spawn() {
Ok(process) => { Ok(process) => {
@ -1142,11 +1142,11 @@ struct ProcRes {
fn compile_test(config: &Config, props: &TestProps, fn compile_test(config: &Config, props: &TestProps,
testfile: &Path) -> ProcRes { testfile: &Path) -> ProcRes {
compile_test_(config, props, testfile, []) compile_test_(config, props, testfile, &[])
} }
fn jit_test(config: &Config, props: &TestProps, testfile: &Path) -> ProcRes { fn jit_test(config: &Config, props: &TestProps, testfile: &Path) -> ProcRes {
compile_test_(config, props, testfile, ["--jit".to_string()]) compile_test_(config, props, testfile, &["--jit".to_string()])
} }
fn compile_test_(config: &Config, props: &TestProps, fn compile_test_(config: &Config, props: &TestProps,
@ -1507,7 +1507,7 @@ fn _arm_exec_compiled_test(config: &Config,
let copy_result = procsrv::run("", let copy_result = procsrv::run("",
config.adb_path.as_slice(), config.adb_path.as_slice(),
None, None,
[ &[
"push".to_string(), "push".to_string(),
args.prog.clone(), args.prog.clone(),
config.adb_test_dir.clone() config.adb_test_dir.clone()
@ -1624,7 +1624,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
let copy_result = procsrv::run("", let copy_result = procsrv::run("",
config.adb_path.as_slice(), config.adb_path.as_slice(),
None, None,
[ &[
"push".to_string(), "push".to_string(),
file.as_str() file.as_str()
.unwrap() .unwrap()

View file

@ -84,7 +84,7 @@ will be counted as a failure. For example:
#[test] #[test]
#[should_fail] #[should_fail]
fn test_out_of_bounds_failure() { fn test_out_of_bounds_failure() {
let v: &[int] = []; let v: &[int] = &[];
v[0]; v[0];
} }
~~~ ~~~

View file

@ -267,7 +267,7 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let bv = bitv::from_bytes([0b01100000]); /// let bv = bitv::from_bytes(&[0b01100000]);
/// assert_eq!(bv.get(0), false); /// assert_eq!(bv.get(0), false);
/// assert_eq!(bv.get(1), true); /// assert_eq!(bv.get(1), true);
/// ///
@ -319,9 +319,9 @@ impl Bitv {
/// let before = 0b01100000; /// let before = 0b01100000;
/// let after = 0b11111111; /// let after = 0b11111111;
/// ///
/// let mut bv = bitv::from_bytes([before]); /// let mut bv = bitv::from_bytes(&[before]);
/// bv.set_all(); /// bv.set_all();
/// assert_eq!(bv, bitv::from_bytes([after])); /// assert_eq!(bv, bitv::from_bytes(&[after]));
/// ``` /// ```
#[inline] #[inline]
pub fn set_all(&mut self) { pub fn set_all(&mut self) {
@ -338,9 +338,9 @@ impl Bitv {
/// let before = 0b01100000; /// let before = 0b01100000;
/// let after = 0b10011111; /// let after = 0b10011111;
/// ///
/// let mut bv = bitv::from_bytes([before]); /// let mut bv = bitv::from_bytes(&[before]);
/// bv.negate(); /// bv.negate();
/// assert_eq!(bv, bitv::from_bytes([after])); /// assert_eq!(bv, bitv::from_bytes(&[after]));
/// ``` /// ```
#[inline] #[inline]
pub fn negate(&mut self) { pub fn negate(&mut self) {
@ -366,11 +366,11 @@ impl Bitv {
/// let b = 0b01011010; /// let b = 0b01011010;
/// let res = 0b01111110; /// let res = 0b01111110;
/// ///
/// let mut a = bitv::from_bytes([a]); /// let mut a = bitv::from_bytes(&[a]);
/// let b = bitv::from_bytes([b]); /// let b = bitv::from_bytes(&[b]);
/// ///
/// assert!(a.union(&b)); /// assert!(a.union(&b));
/// assert_eq!(a, bitv::from_bytes([res])); /// assert_eq!(a, bitv::from_bytes(&[res]));
/// ``` /// ```
#[inline] #[inline]
pub fn union(&mut self, other: &Bitv) -> bool { pub fn union(&mut self, other: &Bitv) -> bool {
@ -396,11 +396,11 @@ impl Bitv {
/// let b = 0b01011010; /// let b = 0b01011010;
/// let res = 0b01000000; /// let res = 0b01000000;
/// ///
/// let mut a = bitv::from_bytes([a]); /// let mut a = bitv::from_bytes(&[a]);
/// let b = bitv::from_bytes([b]); /// let b = bitv::from_bytes(&[b]);
/// ///
/// assert!(a.intersect(&b)); /// assert!(a.intersect(&b));
/// assert_eq!(a, bitv::from_bytes([res])); /// assert_eq!(a, bitv::from_bytes(&[res]));
/// ``` /// ```
#[inline] #[inline]
pub fn intersect(&mut self, other: &Bitv) -> bool { pub fn intersect(&mut self, other: &Bitv) -> bool {
@ -427,17 +427,17 @@ impl Bitv {
/// let a_b = 0b00100100; // a - b /// let a_b = 0b00100100; // a - b
/// let b_a = 0b00011010; // b - a /// let b_a = 0b00011010; // b - a
/// ///
/// let mut bva = bitv::from_bytes([a]); /// let mut bva = bitv::from_bytes(&[a]);
/// let bvb = bitv::from_bytes([b]); /// let bvb = bitv::from_bytes(&[b]);
/// ///
/// assert!(bva.difference(&bvb)); /// assert!(bva.difference(&bvb));
/// assert_eq!(bva, bitv::from_bytes([a_b])); /// assert_eq!(bva, bitv::from_bytes(&[a_b]));
/// ///
/// let bva = bitv::from_bytes([a]); /// let bva = bitv::from_bytes(&[a]);
/// let mut bvb = bitv::from_bytes([b]); /// let mut bvb = bitv::from_bytes(&[b]);
/// ///
/// assert!(bvb.difference(&bva)); /// assert!(bvb.difference(&bva));
/// assert_eq!(bvb, bitv::from_bytes([b_a])); /// assert_eq!(bvb, bitv::from_bytes(&[b_a]));
/// ``` /// ```
#[inline] #[inline]
pub fn difference(&mut self, other: &Bitv) -> bool { pub fn difference(&mut self, other: &Bitv) -> bool {
@ -474,7 +474,7 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let bv = bitv::from_bytes([0b01110100, 0b10010010]); /// let bv = bitv::from_bytes(&[0b01110100, 0b10010010]);
/// assert_eq!(bv.iter().filter(|x| *x).count(), 7); /// assert_eq!(bv.iter().filter(|x| *x).count(), 7);
/// ``` /// ```
#[inline] #[inline]
@ -569,7 +569,7 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let bv = bitv::from_bytes([0b10100000]); /// let bv = bitv::from_bytes(&[0b10100000]);
/// assert_eq!(bv.to_bools(), vec!(true, false, true, false, /// assert_eq!(bv.to_bools(), vec!(true, false, true, false,
/// false, false, false, false)); /// false, false, false, false));
/// ``` /// ```
@ -589,10 +589,10 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let bv = bitv::from_bytes([0b10100000]); /// let bv = bitv::from_bytes(&[0b10100000]);
/// ///
/// assert!(bv.eq_vec([true, false, true, false, /// assert!(bv.eq_vec(&[true, false, true, false,
/// false, false, false, false])); /// false, false, false, false]));
/// ``` /// ```
pub fn eq_vec(&self, v: &[bool]) -> bool { pub fn eq_vec(&self, v: &[bool]) -> bool {
assert_eq!(self.nbits, v.len()); assert_eq!(self.nbits, v.len());
@ -614,9 +614,9 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let mut bv = bitv::from_bytes([0b01001011]); /// let mut bv = bitv::from_bytes(&[0b01001011]);
/// bv.truncate(2); /// bv.truncate(2);
/// assert!(bv.eq_vec([false, true])); /// assert!(bv.eq_vec(&[false, true]));
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn truncate(&mut self, len: uint) { pub fn truncate(&mut self, len: uint) {
@ -675,7 +675,7 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let mut bv = bitv::from_bytes([0b01001011]); /// let mut bv = bitv::from_bytes(&[0b01001011]);
/// bv.grow(2, true); /// bv.grow(2, true);
/// assert_eq!(bv.len(), 10); /// assert_eq!(bv.len(), 10);
/// assert_eq!(bv.to_bytes(), vec!(0b01001011, 0b11000000)); /// assert_eq!(bv.to_bytes(), vec!(0b01001011, 0b11000000));
@ -727,7 +727,7 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let mut bv = bitv::from_bytes([0b01001001]); /// let mut bv = bitv::from_bytes(&[0b01001001]);
/// assert_eq!(bv.pop(), true); /// assert_eq!(bv.pop(), true);
/// assert_eq!(bv.pop(), false); /// assert_eq!(bv.pop(), false);
/// assert_eq!(bv.len(), 6); /// assert_eq!(bv.len(), 6);
@ -753,7 +753,7 @@ impl Bitv {
/// let mut bv = Bitv::new(); /// let mut bv = Bitv::new();
/// bv.push(true); /// bv.push(true);
/// bv.push(false); /// bv.push(false);
/// assert!(bv.eq_vec([true, false])); /// assert!(bv.eq_vec(&[true, false]));
/// ``` /// ```
pub fn push(&mut self, elem: bool) { pub fn push(&mut self, elem: bool) {
let insert_pos = self.nbits; let insert_pos = self.nbits;
@ -791,11 +791,11 @@ impl Bitv {
/// ``` /// ```
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let bv = bitv::from_bytes([0b10100000, 0b00010010]); /// let bv = bitv::from_bytes(&[0b10100000, 0b00010010]);
/// assert!(bv.eq_vec([true, false, true, false, /// assert!(bv.eq_vec(&[true, false, true, false,
/// false, false, false, false, /// false, false, false, false,
/// false, false, false, true, /// false, false, false, true,
/// false, false, true, false])); /// false, false, true, false]));
/// ``` /// ```
pub fn from_bytes(bytes: &[u8]) -> Bitv { pub fn from_bytes(bytes: &[u8]) -> Bitv {
from_fn(bytes.len() * 8, |i| { from_fn(bytes.len() * 8, |i| {
@ -814,7 +814,7 @@ pub fn from_bytes(bytes: &[u8]) -> Bitv {
/// use std::collections::bitv::from_fn; /// use std::collections::bitv::from_fn;
/// ///
/// let bv = from_fn(5, |i| { i % 2 == 0 }); /// let bv = from_fn(5, |i| { i % 2 == 0 });
/// assert!(bv.eq_vec([true, false, true, false, true])); /// assert!(bv.eq_vec(&[true, false, true, false, true]));
/// ``` /// ```
pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv { pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv {
let mut bitv = Bitv::with_capacity(len, false); let mut bitv = Bitv::with_capacity(len, false);
@ -987,7 +987,7 @@ impl<'a> RandomAccessIterator<bool> for Bits<'a> {
/// } /// }
/// ///
/// // Can initialize from a `Bitv` /// // Can initialize from a `Bitv`
/// let other = BitvSet::from_bitv(bitv::from_bytes([0b11010000])); /// let other = BitvSet::from_bitv(bitv::from_bytes(&[0b11010000]));
/// ///
/// s.union_with(&other); /// s.union_with(&other);
/// ///
@ -1089,7 +1089,7 @@ impl BitvSet {
/// ``` /// ```
/// use std::collections::{bitv, BitvSet}; /// use std::collections::{bitv, BitvSet};
/// ///
/// let bv = bitv::from_bytes([0b01100000]); /// let bv = bitv::from_bytes(&[0b01100000]);
/// let s = BitvSet::from_bitv(bv); /// let s = BitvSet::from_bitv(bv);
/// ///
/// // Print 1, 2 in arbitrary order /// // Print 1, 2 in arbitrary order
@ -1244,7 +1244,7 @@ impl BitvSet {
/// use std::collections::BitvSet; /// use std::collections::BitvSet;
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let s = BitvSet::from_bitv(bitv::from_bytes([0b01001010])); /// let s = BitvSet::from_bitv(bitv::from_bytes(&[0b01001010]));
/// ///
/// // Print 1, 4, 6 in arbitrary order /// // Print 1, 4, 6 in arbitrary order
/// for x in s.iter() { /// for x in s.iter() {
@ -1266,8 +1266,8 @@ impl BitvSet {
/// use std::collections::BitvSet; /// use std::collections::BitvSet;
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000]));
/// ///
/// // Print 0, 1, 2, 4 in arbitrary order /// // Print 0, 1, 2, 4 in arbitrary order
/// for x in a.union(&b) { /// for x in a.union(&b) {
@ -1295,8 +1295,8 @@ impl BitvSet {
/// use std::collections::BitvSet; /// use std::collections::BitvSet;
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000]));
/// ///
/// // Print 2 /// // Print 2
/// for x in a.intersection(&b) { /// for x in a.intersection(&b) {
@ -1325,8 +1325,8 @@ impl BitvSet {
/// use std::collections::BitvSet; /// use std::collections::BitvSet;
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000]));
/// ///
/// // Print 1, 4 in arbitrary order /// // Print 1, 4 in arbitrary order
/// for x in a.difference(&b) { /// for x in a.difference(&b) {
@ -1362,8 +1362,8 @@ impl BitvSet {
/// use std::collections::BitvSet; /// use std::collections::BitvSet;
/// use std::collections::bitv; /// use std::collections::bitv;
/// ///
/// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000]));
/// ///
/// // Print 0, 1, 4 in arbitrary order /// // Print 0, 1, 4 in arbitrary order
/// for x in a.symmetric_difference(&b) { /// for x in a.symmetric_difference(&b) {
@ -1394,9 +1394,9 @@ impl BitvSet {
/// let b = 0b10100000; /// let b = 0b10100000;
/// let res = 0b11101000; /// let res = 0b11101000;
/// ///
/// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([b])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b]));
/// let res = BitvSet::from_bitv(bitv::from_bytes([res])); /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res]));
/// ///
/// a.union_with(&b); /// a.union_with(&b);
/// assert_eq!(a, res); /// assert_eq!(a, res);
@ -1418,9 +1418,9 @@ impl BitvSet {
/// let b = 0b10100000; /// let b = 0b10100000;
/// let res = 0b00100000; /// let res = 0b00100000;
/// ///
/// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([b])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b]));
/// let res = BitvSet::from_bitv(bitv::from_bytes([res])); /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res]));
/// ///
/// a.intersect_with(&b); /// a.intersect_with(&b);
/// assert_eq!(a, res); /// assert_eq!(a, res);
@ -1444,16 +1444,16 @@ impl BitvSet {
/// let a_b = 0b01001000; // a - b /// let a_b = 0b01001000; // a - b
/// let b_a = 0b10000000; // b - a /// let b_a = 0b10000000; // b - a
/// ///
/// let mut bva = BitvSet::from_bitv(bitv::from_bytes([a])); /// let mut bva = BitvSet::from_bitv(bitv::from_bytes(&[a]));
/// let bvb = BitvSet::from_bitv(bitv::from_bytes([b])); /// let bvb = BitvSet::from_bitv(bitv::from_bytes(&[b]));
/// let bva_b = BitvSet::from_bitv(bitv::from_bytes([a_b])); /// let bva_b = BitvSet::from_bitv(bitv::from_bytes(&[a_b]));
/// let bvb_a = BitvSet::from_bitv(bitv::from_bytes([b_a])); /// let bvb_a = BitvSet::from_bitv(bitv::from_bytes(&[b_a]));
/// ///
/// bva.difference_with(&bvb); /// bva.difference_with(&bvb);
/// assert_eq!(bva, bva_b); /// assert_eq!(bva, bva_b);
/// ///
/// let bva = BitvSet::from_bitv(bitv::from_bytes([a])); /// let bva = BitvSet::from_bitv(bitv::from_bytes(&[a]));
/// let mut bvb = BitvSet::from_bitv(bitv::from_bytes([b])); /// let mut bvb = BitvSet::from_bitv(bitv::from_bytes(&[b]));
/// ///
/// bvb.difference_with(&bva); /// bvb.difference_with(&bva);
/// assert_eq!(bvb, bvb_a); /// assert_eq!(bvb, bvb_a);
@ -1476,9 +1476,9 @@ impl BitvSet {
/// let b = 0b10100000; /// let b = 0b10100000;
/// let res = 0b11001000; /// let res = 0b11001000;
/// ///
/// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a]));
/// let b = BitvSet::from_bitv(bitv::from_bytes([b])); /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b]));
/// let res = BitvSet::from_bitv(bitv::from_bytes([res])); /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res]));
/// ///
/// a.symmetric_difference_with(&b); /// a.symmetric_difference_with(&b);
/// assert_eq!(a, res); /// assert_eq!(a, res);
@ -1708,9 +1708,9 @@ mod tests {
#[test] #[test]
fn test_1_element() { fn test_1_element() {
let mut act = Bitv::with_capacity(1u, false); let mut act = Bitv::with_capacity(1u, false);
assert!(act.eq_vec([false])); assert!(act.eq_vec(&[false]));
act = Bitv::with_capacity(1u, true); act = Bitv::with_capacity(1u, true);
assert!(act.eq_vec([true])); assert!(act.eq_vec(&[true]));
} }
#[test] #[test]
@ -1728,11 +1728,11 @@ mod tests {
act = Bitv::with_capacity(10u, false); act = Bitv::with_capacity(10u, false);
assert!((act.eq_vec( assert!((act.eq_vec(
[false, false, false, false, false, false, false, false, false, false]))); &[false, false, false, false, false, false, false, false, false, false])));
// all 1 // all 1
act = Bitv::with_capacity(10u, true); act = Bitv::with_capacity(10u, true);
assert!((act.eq_vec([true, true, true, true, true, true, true, true, true, true]))); assert!((act.eq_vec(&[true, true, true, true, true, true, true, true, true, true])));
// mixed // mixed
act = Bitv::with_capacity(10u, false); act = Bitv::with_capacity(10u, false);
@ -1741,7 +1741,7 @@ mod tests {
act.set(2u, true); act.set(2u, true);
act.set(3u, true); act.set(3u, true);
act.set(4u, true); act.set(4u, true);
assert!((act.eq_vec([true, true, true, true, true, false, false, false, false, false]))); assert!((act.eq_vec(&[true, true, true, true, true, false, false, false, false, false])));
// mixed // mixed
act = Bitv::with_capacity(10u, false); act = Bitv::with_capacity(10u, false);
@ -1750,7 +1750,7 @@ mod tests {
act.set(7u, true); act.set(7u, true);
act.set(8u, true); act.set(8u, true);
act.set(9u, true); act.set(9u, true);
assert!((act.eq_vec([false, false, false, false, false, true, true, true, true, true]))); assert!((act.eq_vec(&[false, false, false, false, false, true, true, true, true, true])));
// mixed // mixed
act = Bitv::with_capacity(10u, false); act = Bitv::with_capacity(10u, false);
@ -1758,7 +1758,7 @@ mod tests {
act.set(3u, true); act.set(3u, true);
act.set(6u, true); act.set(6u, true);
act.set(9u, true); act.set(9u, true);
assert!((act.eq_vec([true, false, false, true, false, false, true, false, false, true]))); assert!((act.eq_vec(&[true, false, false, true, false, false, true, false, false, true])));
} }
#[test] #[test]
@ -1768,16 +1768,16 @@ mod tests {
act = Bitv::with_capacity(31u, false); act = Bitv::with_capacity(31u, false);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false, false]));
// all 1 // all 1
act = Bitv::with_capacity(31u, true); act = Bitv::with_capacity(31u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, true, true, true, true, true, &[true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true])); true, true, true, true, true]));
// mixed // mixed
act = Bitv::with_capacity(31u, false); act = Bitv::with_capacity(31u, false);
@ -1790,9 +1790,9 @@ mod tests {
act.set(6u, true); act.set(6u, true);
act.set(7u, true); act.set(7u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, false, false, false, false, false, &[true, true, true, true, true, true, true, true, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false])); false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(31u, false); act = Bitv::with_capacity(31u, false);
@ -1805,9 +1805,9 @@ mod tests {
act.set(22u, true); act.set(22u, true);
act.set(23u, true); act.set(23u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true,
false, false, false, false, false, false, false])); false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(31u, false); act = Bitv::with_capacity(31u, false);
@ -1819,9 +1819,9 @@ mod tests {
act.set(29u, true); act.set(29u, true);
act.set(30u, true); act.set(30u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, true, true, true, true, true, true, true])); false, false, true, true, true, true, true, true, true]));
// mixed // mixed
act = Bitv::with_capacity(31u, false); act = Bitv::with_capacity(31u, false);
@ -1829,9 +1829,9 @@ mod tests {
act.set(17u, true); act.set(17u, true);
act.set(30u, true); act.set(30u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, true, false, false, false, false, false, false, false, false, &[false, false, false, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false,
false, false, false, false, false, false, true])); false, false, false, false, false, false, true]));
} }
#[test] #[test]
@ -1841,16 +1841,16 @@ mod tests {
act = Bitv::with_capacity(32u, false); act = Bitv::with_capacity(32u, false);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false, false, false]));
// all 1 // all 1
act = Bitv::with_capacity(32u, true); act = Bitv::with_capacity(32u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, true, true, true, true, true, &[true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true])); true, true, true, true, true, true]));
// mixed // mixed
act = Bitv::with_capacity(32u, false); act = Bitv::with_capacity(32u, false);
@ -1863,9 +1863,9 @@ mod tests {
act.set(6u, true); act.set(6u, true);
act.set(7u, true); act.set(7u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, false, false, false, false, false, &[true, true, true, true, true, true, true, true, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(32u, false); act = Bitv::with_capacity(32u, false);
@ -1878,9 +1878,9 @@ mod tests {
act.set(22u, true); act.set(22u, true);
act.set(23u, true); act.set(23u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true,
false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(32u, false); act = Bitv::with_capacity(32u, false);
@ -1893,9 +1893,9 @@ mod tests {
act.set(30u, true); act.set(30u, true);
act.set(31u, true); act.set(31u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, true, true, true, true, true, true, true, true])); false, false, true, true, true, true, true, true, true, true]));
// mixed // mixed
act = Bitv::with_capacity(32u, false); act = Bitv::with_capacity(32u, false);
@ -1904,9 +1904,9 @@ mod tests {
act.set(30u, true); act.set(30u, true);
act.set(31u, true); act.set(31u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, true, false, false, false, false, false, false, false, false, &[false, false, false, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false,
false, false, false, false, false, false, true, true])); false, false, false, false, false, false, true, true]));
} }
#[test] #[test]
@ -1916,16 +1916,16 @@ mod tests {
act = Bitv::with_capacity(33u, false); act = Bitv::with_capacity(33u, false);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false, false, false, false]));
// all 1 // all 1
act = Bitv::with_capacity(33u, true); act = Bitv::with_capacity(33u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, true, true, true, true, true, &[true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true])); true, true, true, true, true, true, true]));
// mixed // mixed
act = Bitv::with_capacity(33u, false); act = Bitv::with_capacity(33u, false);
@ -1938,9 +1938,9 @@ mod tests {
act.set(6u, true); act.set(6u, true);
act.set(7u, true); act.set(7u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[true, true, true, true, true, true, true, true, false, false, false, false, false, &[true, true, true, true, true, true, true, true, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(33u, false); act = Bitv::with_capacity(33u, false);
@ -1953,9 +1953,9 @@ mod tests {
act.set(22u, true); act.set(22u, true);
act.set(23u, true); act.set(23u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true,
false, false, false, false, false, false, false, false, false])); false, false, false, false, false, false, false, false, false]));
// mixed // mixed
act = Bitv::with_capacity(33u, false); act = Bitv::with_capacity(33u, false);
@ -1968,9 +1968,9 @@ mod tests {
act.set(30u, true); act.set(30u, true);
act.set(31u, true); act.set(31u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, false, false, false, false, false, false, false, false, &[false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, true, true, true, true, true, true, true, true, false])); false, false, true, true, true, true, true, true, true, true, false]));
// mixed // mixed
act = Bitv::with_capacity(33u, false); act = Bitv::with_capacity(33u, false);
@ -1980,9 +1980,9 @@ mod tests {
act.set(31u, true); act.set(31u, true);
act.set(32u, true); act.set(32u, true);
assert!(act.eq_vec( assert!(act.eq_vec(
[false, false, false, true, false, false, false, false, false, false, false, false, &[false, false, false, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false,
false, false, false, false, false, false, true, true, true])); false, false, false, false, false, false, true, true, true]));
} }
#[test] #[test]
@ -2027,7 +2027,7 @@ mod tests {
#[test] #[test]
fn test_from_bytes() { fn test_from_bytes() {
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
let str = format!("{}{}{}", "10110110", "00000000", "11111111"); let str = format!("{}{}{}", "10110110", "00000000", "11111111");
assert_eq!(bitv.to_string().as_slice(), str.as_slice()); assert_eq!(bitv.to_string().as_slice(), str.as_slice());
} }
@ -2065,7 +2065,7 @@ mod tests {
#[test] #[test]
fn test_to_bools() { fn test_to_bools() {
let bools = vec!(false, false, true, false, false, true, true, false); let bools = vec!(false, false, true, false, false, true, true, false);
assert_eq!(from_bytes([0b00100110]).iter().collect::<Vec<bool>>(), bools); assert_eq!(from_bytes(&[0b00100110]).iter().collect::<Vec<bool>>(), bools);
} }
#[test] #[test]
@ -2303,10 +2303,10 @@ mod tests {
#[test] #[test]
fn test_bitv_set_is_disjoint() { fn test_bitv_set_is_disjoint() {
let a = BitvSet::from_bitv(from_bytes([0b10100010])); let a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let b = BitvSet::from_bitv(from_bytes([0b01000000])); let b = BitvSet::from_bitv(from_bytes(&[0b01000000]));
let c = BitvSet::new(); let c = BitvSet::new();
let d = BitvSet::from_bitv(from_bytes([0b00110000])); let d = BitvSet::from_bitv(from_bytes(&[0b00110000]));
assert!(!a.is_disjoint(&d)); assert!(!a.is_disjoint(&d));
assert!(!d.is_disjoint(&a)); assert!(!d.is_disjoint(&a));
@ -2326,13 +2326,13 @@ mod tests {
a.insert(0); a.insert(0);
let mut b = BitvSet::new(); let mut b = BitvSet::new();
b.insert(5); b.insert(5);
let expected = BitvSet::from_bitv(from_bytes([0b10000100])); let expected = BitvSet::from_bitv(from_bytes(&[0b10000100]));
a.union_with(&b); a.union_with(&b);
assert_eq!(a, expected); assert_eq!(a, expected);
// Standard // Standard
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010]));
let c = a.clone(); let c = a.clone();
a.union_with(&b); a.union_with(&b);
b.union_with(&c); b.union_with(&c);
@ -2343,8 +2343,8 @@ mod tests {
#[test] #[test]
fn test_bitv_set_intersect_with() { fn test_bitv_set_intersect_with() {
// Explicitly 0'ed bits // Explicitly 0'ed bits
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let mut b = BitvSet::from_bitv(from_bytes([0b00000000])); let mut b = BitvSet::from_bitv(from_bytes(&[0b00000000]));
let c = a.clone(); let c = a.clone();
a.intersect_with(&b); a.intersect_with(&b);
b.intersect_with(&c); b.intersect_with(&c);
@ -2352,7 +2352,7 @@ mod tests {
assert!(b.is_empty()); assert!(b.is_empty());
// Uninitialized bits should behave like 0's // Uninitialized bits should behave like 0's
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let mut b = BitvSet::new(); let mut b = BitvSet::new();
let c = a.clone(); let c = a.clone();
a.intersect_with(&b); a.intersect_with(&b);
@ -2361,8 +2361,8 @@ mod tests {
assert!(b.is_empty()); assert!(b.is_empty());
// Standard // Standard
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010]));
let c = a.clone(); let c = a.clone();
a.intersect_with(&b); a.intersect_with(&b);
b.intersect_with(&c); b.intersect_with(&c);
@ -2373,20 +2373,20 @@ mod tests {
#[test] #[test]
fn test_bitv_set_difference_with() { fn test_bitv_set_difference_with() {
// Explicitly 0'ed bits // Explicitly 0'ed bits
let mut a = BitvSet::from_bitv(from_bytes([0b00000000])); let mut a = BitvSet::from_bitv(from_bytes(&[0b00000000]));
let b = BitvSet::from_bitv(from_bytes([0b10100010])); let b = BitvSet::from_bitv(from_bytes(&[0b10100010]));
a.difference_with(&b); a.difference_with(&b);
assert!(a.is_empty()); assert!(a.is_empty());
// Uninitialized bits should behave like 0's // Uninitialized bits should behave like 0's
let mut a = BitvSet::new(); let mut a = BitvSet::new();
let b = BitvSet::from_bitv(from_bytes([0b11111111])); let b = BitvSet::from_bitv(from_bytes(&[0b11111111]));
a.difference_with(&b); a.difference_with(&b);
assert!(a.is_empty()); assert!(a.is_empty());
// Standard // Standard
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010]));
let c = a.clone(); let c = a.clone();
a.difference_with(&b); a.difference_with(&b);
b.difference_with(&c); b.difference_with(&c);
@ -2403,19 +2403,19 @@ mod tests {
let mut b = BitvSet::new(); let mut b = BitvSet::new();
b.insert(1); b.insert(1);
b.insert(5); b.insert(5);
let expected = BitvSet::from_bitv(from_bytes([0b10000100])); let expected = BitvSet::from_bitv(from_bytes(&[0b10000100]));
a.symmetric_difference_with(&b); a.symmetric_difference_with(&b);
assert_eq!(a, expected); assert_eq!(a, expected);
let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let b = BitvSet::new(); let b = BitvSet::new();
let c = a.clone(); let c = a.clone();
a.symmetric_difference_with(&b); a.symmetric_difference_with(&b);
assert_eq!(a, c); assert_eq!(a, c);
// Standard // Standard
let mut a = BitvSet::from_bitv(from_bytes([0b11100010])); let mut a = BitvSet::from_bitv(from_bytes(&[0b11100010]));
let mut b = BitvSet::from_bitv(from_bytes([0b01101010])); let mut b = BitvSet::from_bitv(from_bytes(&[0b01101010]));
let c = a.clone(); let c = a.clone();
a.symmetric_difference_with(&b); a.symmetric_difference_with(&b);
b.symmetric_difference_with(&c); b.symmetric_difference_with(&c);
@ -2425,8 +2425,8 @@ mod tests {
#[test] #[test]
fn test_bitv_set_eq() { fn test_bitv_set_eq() {
let a = BitvSet::from_bitv(from_bytes([0b10100010])); let a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let b = BitvSet::from_bitv(from_bytes([0b00000000])); let b = BitvSet::from_bitv(from_bytes(&[0b00000000]));
let c = BitvSet::new(); let c = BitvSet::new();
assert!(a == a); assert!(a == a);
@ -2439,8 +2439,8 @@ mod tests {
#[test] #[test]
fn test_bitv_set_cmp() { fn test_bitv_set_cmp() {
let a = BitvSet::from_bitv(from_bytes([0b10100010])); let a = BitvSet::from_bitv(from_bytes(&[0b10100010]));
let b = BitvSet::from_bitv(from_bytes([0b00000000])); let b = BitvSet::from_bitv(from_bytes(&[0b00000000]));
let c = BitvSet::new(); let c = BitvSet::new();
assert_eq!(a.cmp(&b), Greater); assert_eq!(a.cmp(&b), Greater);
@ -2519,17 +2519,17 @@ mod tests {
#[test] #[test]
fn test_small_bitv_tests() { fn test_small_bitv_tests() {
let v = from_bytes([0]); let v = from_bytes(&[0]);
assert!(!v.all()); assert!(!v.all());
assert!(!v.any()); assert!(!v.any());
assert!(v.none()); assert!(v.none());
let v = from_bytes([0b00010100]); let v = from_bytes(&[0b00010100]);
assert!(!v.all()); assert!(!v.all());
assert!(v.any()); assert!(v.any());
assert!(!v.none()); assert!(!v.none());
let v = from_bytes([0xFF]); let v = from_bytes(&[0xFF]);
assert!(v.all()); assert!(v.all());
assert!(v.any()); assert!(v.any());
assert!(!v.none()); assert!(!v.none());
@ -2537,7 +2537,7 @@ mod tests {
#[test] #[test]
fn test_big_bitv_tests() { fn test_big_bitv_tests() {
let v = from_bytes([ // 88 bits let v = from_bytes(&[ // 88 bits
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0]); 0, 0, 0]);
@ -2545,7 +2545,7 @@ mod tests {
assert!(!v.any()); assert!(!v.any());
assert!(v.none()); assert!(v.none());
let v = from_bytes([ // 88 bits let v = from_bytes(&[ // 88 bits
0, 0, 0b00010100, 0, 0, 0, 0b00010100, 0,
0, 0, 0, 0b00110100, 0, 0, 0, 0b00110100,
0, 0, 0]); 0, 0, 0]);
@ -2553,7 +2553,7 @@ mod tests {
assert!(v.any()); assert!(v.any());
assert!(!v.none()); assert!(!v.none());
let v = from_bytes([ // 88 bits let v = from_bytes(&[ // 88 bits
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF]); 0xFF, 0xFF, 0xFF]);
@ -2632,24 +2632,24 @@ mod tests {
#[test] #[test]
fn test_bitv_grow() { fn test_bitv_grow() {
let mut bitv = from_bytes([0b10110110, 0b00000000, 0b10101010]); let mut bitv = from_bytes(&[0b10110110, 0b00000000, 0b10101010]);
bitv.grow(32, true); bitv.grow(32, true);
assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010,
0xFF, 0xFF, 0xFF, 0xFF])); 0xFF, 0xFF, 0xFF, 0xFF]));
bitv.grow(64, false); bitv.grow(64, false);
assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010,
0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0])); 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0]));
bitv.grow(16, true); bitv.grow(16, true);
assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010,
0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF])); 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]));
} }
#[test] #[test]
fn test_bitv_extend() { fn test_bitv_extend() {
let mut bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let mut bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
let ext = from_bytes([0b01001001, 0b10010010, 0b10111101]); let ext = from_bytes(&[0b01001001, 0b10010010, 0b10111101]);
bitv.extend(ext.iter()); bitv.extend(ext.iter());
assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b11111111, assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b11111111,
0b01001001, 0b10010010, 0b10111101])); 0b01001001, 0b10010010, 0b10111101]));
} }

View file

@ -467,14 +467,14 @@ mod test {
check(a, b, expected, |x, y, f| x.intersection(y).all(f)) check(a, b, expected, |x, y, f| x.intersection(y).all(f))
} }
check_intersection([], [], []); check_intersection(&[], &[], &[]);
check_intersection([1, 2, 3], [], []); check_intersection(&[1, 2, 3], &[], &[]);
check_intersection([], [1, 2, 3], []); check_intersection(&[], &[1, 2, 3], &[]);
check_intersection([2], [1, 2, 3], [2]); check_intersection(&[2], &[1, 2, 3], &[2]);
check_intersection([1, 2, 3], [2], [2]); check_intersection(&[1, 2, 3], &[2], &[2]);
check_intersection([11, 1, 3, 77, 103, 5, -5], check_intersection(&[11, 1, 3, 77, 103, 5, -5],
[2, 11, 77, -9, -42, 5, 3], &[2, 11, 77, -9, -42, 5, 3],
[3, 5, 11, 77]); &[3, 5, 11, 77]);
} }
#[test] #[test]
@ -483,15 +483,15 @@ mod test {
check(a, b, expected, |x, y, f| x.difference(y).all(f)) check(a, b, expected, |x, y, f| x.difference(y).all(f))
} }
check_difference([], [], []); check_difference(&[], &[], &[]);
check_difference([1, 12], [], [1, 12]); check_difference(&[1, 12], &[], &[1, 12]);
check_difference([], [1, 2, 3, 9], []); check_difference(&[], &[1, 2, 3, 9], &[]);
check_difference([1, 3, 5, 9, 11], check_difference(&[1, 3, 5, 9, 11],
[3, 9], &[3, 9],
[1, 5, 11]); &[1, 5, 11]);
check_difference([-5, 11, 22, 33, 40, 42], check_difference(&[-5, 11, 22, 33, 40, 42],
[-12, -5, 14, 23, 34, 38, 39, 50], &[-12, -5, 14, 23, 34, 38, 39, 50],
[11, 22, 33, 40, 42]); &[11, 22, 33, 40, 42]);
} }
#[test] #[test]
@ -501,12 +501,12 @@ mod test {
check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f)) check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
} }
check_symmetric_difference([], [], []); check_symmetric_difference(&[], &[], &[]);
check_symmetric_difference([1, 2, 3], [2], [1, 3]); check_symmetric_difference(&[1, 2, 3], &[2], &[1, 3]);
check_symmetric_difference([2], [1, 2, 3], [1, 3]); check_symmetric_difference(&[2], &[1, 2, 3], &[1, 3]);
check_symmetric_difference([1, 3, 5, 9, 11], check_symmetric_difference(&[1, 3, 5, 9, 11],
[-2, 3, 9, 14, 22], &[-2, 3, 9, 14, 22],
[-2, 1, 5, 11, 14, 22]); &[-2, 1, 5, 11, 14, 22]);
} }
#[test] #[test]
@ -516,12 +516,12 @@ mod test {
check(a, b, expected, |x, y, f| x.union(y).all(f)) check(a, b, expected, |x, y, f| x.union(y).all(f))
} }
check_union([], [], []); check_union(&[], &[], &[]);
check_union([1, 2, 3], [2], [1, 2, 3]); check_union(&[1, 2, 3], &[2], &[1, 2, 3]);
check_union([2], [1, 2, 3], [1, 2, 3]); check_union(&[2], &[1, 2, 3], &[1, 2, 3]);
check_union([1, 3, 5, 9, 11, 16, 19, 24], check_union(&[1, 3, 5, 9, 11, 16, 19, 24],
[-2, 1, 5, 9, 13, 19], &[-2, 1, 5, 9, 13, 19],
[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]); &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]);
} }
#[test] #[test]

View file

@ -1088,8 +1088,8 @@ mod tests {
#[test] #[test]
fn test_merge() { fn test_merge() {
let mut m = list_from([0i, 1, 3, 5, 6, 7, 2]); let mut m = list_from(&[0i, 1, 3, 5, 6, 7, 2]);
let n = list_from([-1i, 0, 0, 7, 7, 9]); let n = list_from(&[-1i, 0, 0, 7, 7, 9]);
let len = m.len() + n.len(); let len = m.len() + n.len();
m.merge(n, |a, b| a <= b); m.merge(n, |a, b| a <= b);
assert_eq!(m.len(), len); assert_eq!(m.len(), len);
@ -1129,7 +1129,7 @@ mod tests {
#[test] #[test]
fn test_send() { fn test_send() {
let n = list_from([1i,2,3]); let n = list_from(&[1i,2,3]);
spawn(proc() { spawn(proc() {
check_links(&n); check_links(&n);
let a: &[_] = &[&1,&2,&3]; let a: &[_] = &[&1,&2,&3];
@ -1139,16 +1139,16 @@ mod tests {
#[test] #[test]
fn test_eq() { fn test_eq() {
let mut n: DList<u8> = list_from([]); let mut n: DList<u8> = list_from(&[]);
let mut m = list_from([]); let mut m = list_from(&[]);
assert!(n == m); assert!(n == m);
n.push_front(1); n.push_front(1);
assert!(n != m); assert!(n != m);
m.push_back(1); m.push_back(1);
assert!(n == m); assert!(n == m);
let n = list_from([2i,3,4]); let n = list_from(&[2i,3,4]);
let m = list_from([1i,2,3]); let m = list_from(&[1i,2,3]);
assert!(n != m); assert!(n != m);
} }
@ -1172,8 +1172,8 @@ mod tests {
#[test] #[test]
fn test_ord() { fn test_ord() {
let n: DList<int> = list_from([]); let n: DList<int> = list_from(&[]);
let m = list_from([1i,2,3]); let m = list_from(&[1i,2,3]);
assert!(n < m); assert!(n < m);
assert!(m > n); assert!(m > n);
assert!(n <= n); assert!(n <= n);
@ -1183,29 +1183,29 @@ mod tests {
#[test] #[test]
fn test_ord_nan() { fn test_ord_nan() {
let nan = 0.0f64/0.0; let nan = 0.0f64/0.0;
let n = list_from([nan]); let n = list_from(&[nan]);
let m = list_from([nan]); let m = list_from(&[nan]);
assert!(!(n < m)); assert!(!(n < m));
assert!(!(n > m)); assert!(!(n > m));
assert!(!(n <= m)); assert!(!(n <= m));
assert!(!(n >= m)); assert!(!(n >= m));
let n = list_from([nan]); let n = list_from(&[nan]);
let one = list_from([1.0f64]); let one = list_from(&[1.0f64]);
assert!(!(n < one)); assert!(!(n < one));
assert!(!(n > one)); assert!(!(n > one));
assert!(!(n <= one)); assert!(!(n <= one));
assert!(!(n >= one)); assert!(!(n >= one));
let u = list_from([1.0f64,2.0,nan]); let u = list_from(&[1.0f64,2.0,nan]);
let v = list_from([1.0f64,2.0,3.0]); let v = list_from(&[1.0f64,2.0,3.0]);
assert!(!(u < v)); assert!(!(u < v));
assert!(!(u > v)); assert!(!(u > v));
assert!(!(u <= v)); assert!(!(u <= v));
assert!(!(u >= v)); assert!(!(u >= v));
let s = list_from([1.0f64,2.0,4.0,2.0]); let s = list_from(&[1.0f64,2.0,4.0,2.0]);
let t = list_from([1.0f64,2.0,3.0,2.0]); let t = list_from(&[1.0f64,2.0,3.0,2.0]);
assert!(!(s < t)); assert!(!(s < t));
assert!(s > one); assert!(s > one);
assert!(!(s <= one)); assert!(!(s <= one));

View file

@ -151,7 +151,7 @@ macro_rules! impl_hash_tuple(
impl<S: Writer> Hash<S> for () { impl<S: Writer> Hash<S> for () {
#[inline] #[inline]
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
state.write([]); state.write(&[]);
} }
} }
); );

View file

@ -414,7 +414,7 @@ mod tests {
assert_eq!(f, v); assert_eq!(f, v);
buf.push(t as u8); buf.push(t as u8);
state_inc.write([t as u8]); state_inc.write(&[t as u8]);
t += 1; t += 1;
} }

View file

@ -18,7 +18,7 @@
//! let vec = vec!(1i, 2, 3); //! let vec = vec!(1i, 2, 3);
//! let int_slice = vec.as_slice(); //! let int_slice = vec.as_slice();
//! // coercing an array to a slice //! // coercing an array to a slice
//! let str_slice: &[&str] = ["one", "two", "three"]; //! let str_slice: &[&str] = &["one", "two", "three"];
//! ``` //! ```
//! //!
//! Slices are either mutable or shared. The shared slice type is `&[T]`, //! Slices are either mutable or shared. The shared slice type is `&[T]`,
@ -26,7 +26,7 @@
//! block of memory that a mutable slice points to: //! block of memory that a mutable slice points to:
//! //!
//! ```rust //! ```rust
//! let x: &mut[int] = [1i, 2, 3]; //! let x: &mut[int] = &mut [1i, 2, 3];
//! x[1] = 7; //! x[1] = 7;
//! assert_eq!(x[0], 1); //! assert_eq!(x[0], 1);
//! assert_eq!(x[1], 7); //! assert_eq!(x[1], 7);
@ -1962,7 +1962,7 @@ mod tests {
assert!(!b"foo".starts_with(b"foobar")); assert!(!b"foo".starts_with(b"foobar"));
assert!(!b"bar".starts_with(b"foobar")); assert!(!b"bar".starts_with(b"foobar"));
assert!(b"foobar".starts_with(b"foobar")); assert!(b"foobar".starts_with(b"foobar"));
let empty: &[u8] = []; let empty: &[u8] = &[];
assert!(empty.starts_with(empty)); assert!(empty.starts_with(empty));
assert!(!empty.starts_with(b"foo")); assert!(!empty.starts_with(b"foo"));
assert!(b"foobar".starts_with(empty)); assert!(b"foobar".starts_with(empty));
@ -1976,7 +1976,7 @@ mod tests {
assert!(!b"foo".ends_with(b"foobar")); assert!(!b"foo".ends_with(b"foobar"));
assert!(!b"bar".ends_with(b"foobar")); assert!(!b"bar".ends_with(b"foobar"));
assert!(b"foobar".ends_with(b"foobar")); assert!(b"foobar".ends_with(b"foobar"));
let empty: &[u8] = []; let empty: &[u8] = &[];
assert!(empty.ends_with(empty)); assert!(empty.ends_with(empty));
assert!(!empty.ends_with(b"foo")); assert!(!empty.ends_with(b"foo"));
assert!(b"foobar".ends_with(empty)); assert!(b"foobar".ends_with(empty));
@ -2054,7 +2054,7 @@ mod tests {
let h = x.last_mut(); let h = x.last_mut();
assert_eq!(*h.unwrap(), 5); assert_eq!(*h.unwrap(), 5);
let y: &mut [int] = []; let y: &mut [int] = &mut [];
assert!(y.last_mut().is_none()); assert!(y.last_mut().is_none());
} }

View file

@ -923,13 +923,13 @@ mod tests {
fn t(v: &[String], s: &str) { fn t(v: &[String], s: &str) {
assert_eq!(v.concat().as_slice(), s); assert_eq!(v.concat().as_slice(), s);
} }
t([String::from_str("you"), String::from_str("know"), t(&[String::from_str("you"), String::from_str("know"),
String::from_str("I'm"), String::from_str("I'm"),
String::from_str("no"), String::from_str("good")], String::from_str("no"), String::from_str("good")],
"youknowI'mnogood"); "youknowI'mnogood");
let v: &[String] = []; let v: &[String] = &[];
t(v, ""); t(v, "");
t([String::from_str("hi")], "hi"); t(&[String::from_str("hi")], "hi");
} }
#[test] #[test]
@ -937,13 +937,13 @@ mod tests {
fn t(v: &[String], sep: &str, s: &str) { fn t(v: &[String], sep: &str, s: &str) {
assert_eq!(v.connect(sep).as_slice(), s); assert_eq!(v.connect(sep).as_slice(), s);
} }
t([String::from_str("you"), String::from_str("know"), t(&[String::from_str("you"), String::from_str("know"),
String::from_str("I'm"), String::from_str("I'm"),
String::from_str("no"), String::from_str("good")], String::from_str("no"), String::from_str("good")],
" ", "you know I'm no good"); " ", "you know I'm no good");
let v: &[String] = []; let v: &[String] = &[];
t(v, " ", ""); t(v, " ", "");
t([String::from_str("hi")], " ", "hi"); t(&[String::from_str("hi")], " ", "hi");
} }
#[test] #[test]
@ -951,10 +951,10 @@ mod tests {
fn t(v: &[&str], s: &str) { fn t(v: &[&str], s: &str) {
assert_eq!(v.concat().as_slice(), s); assert_eq!(v.concat().as_slice(), s);
} }
t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); t(&["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
let v: &[&str] = []; let v: &[&str] = &[];
t(v, ""); t(v, "");
t(["hi"], "hi"); t(&["hi"], "hi");
} }
#[test] #[test]
@ -962,10 +962,10 @@ mod tests {
fn t(v: &[&str], sep: &str, s: &str) { fn t(v: &[&str], sep: &str, s: &str) {
assert_eq!(v.connect(sep).as_slice(), s); assert_eq!(v.connect(sep).as_slice(), s);
} }
t(["you", "know", "I'm", "no", "good"], t(&["you", "know", "I'm", "no", "good"],
" ", "you know I'm no good"); " ", "you know I'm no good");
t([], " ", ""); t(&[], " ", "");
t(["hi"], " ", "hi"); t(&["hi"], " ", "hi");
} }
#[test] #[test]
@ -1266,26 +1266,26 @@ mod tests {
#[test] #[test]
fn test_is_utf8() { fn test_is_utf8() {
// deny overlong encodings // deny overlong encodings
assert!(!is_utf8([0xc0, 0x80])); assert!(!is_utf8(&[0xc0, 0x80]));
assert!(!is_utf8([0xc0, 0xae])); assert!(!is_utf8(&[0xc0, 0xae]));
assert!(!is_utf8([0xe0, 0x80, 0x80])); assert!(!is_utf8(&[0xe0, 0x80, 0x80]));
assert!(!is_utf8([0xe0, 0x80, 0xaf])); assert!(!is_utf8(&[0xe0, 0x80, 0xaf]));
assert!(!is_utf8([0xe0, 0x81, 0x81])); assert!(!is_utf8(&[0xe0, 0x81, 0x81]));
assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac])); assert!(!is_utf8(&[0xf0, 0x82, 0x82, 0xac]));
assert!(!is_utf8([0xf4, 0x90, 0x80, 0x80])); assert!(!is_utf8(&[0xf4, 0x90, 0x80, 0x80]));
// deny surrogates // deny surrogates
assert!(!is_utf8([0xED, 0xA0, 0x80])); assert!(!is_utf8(&[0xED, 0xA0, 0x80]));
assert!(!is_utf8([0xED, 0xBF, 0xBF])); assert!(!is_utf8(&[0xED, 0xBF, 0xBF]));
assert!(is_utf8([0xC2, 0x80])); assert!(is_utf8(&[0xC2, 0x80]));
assert!(is_utf8([0xDF, 0xBF])); assert!(is_utf8(&[0xDF, 0xBF]));
assert!(is_utf8([0xE0, 0xA0, 0x80])); assert!(is_utf8(&[0xE0, 0xA0, 0x80]));
assert!(is_utf8([0xED, 0x9F, 0xBF])); assert!(is_utf8(&[0xED, 0x9F, 0xBF]));
assert!(is_utf8([0xEE, 0x80, 0x80])); assert!(is_utf8(&[0xEE, 0x80, 0x80]));
assert!(is_utf8([0xEF, 0xBF, 0xBF])); assert!(is_utf8(&[0xEF, 0xBF, 0xBF]));
assert!(is_utf8([0xF0, 0x90, 0x80, 0x80])); assert!(is_utf8(&[0xF0, 0x90, 0x80, 0x80]));
assert!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF])); assert!(is_utf8(&[0xF4, 0x8F, 0xBF, 0xBF]));
} }
#[test] #[test]
@ -1293,58 +1293,58 @@ mod tests {
macro_rules! pos ( ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }); macro_rules! pos ( ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } });
// non-surrogates // non-surrogates
pos!([0x0000], pos!(&[0x0000],
[0x0001, 0x0002], &[0x0001, 0x0002],
[0xD7FF], &[0xD7FF],
[0xE000]); &[0xE000]);
// surrogate pairs (randomly generated with Python 3's // surrogate pairs (randomly generated with Python 3's
// .encode('utf-16be')) // .encode('utf-16be'))
pos!([0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45], pos!(&[0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45],
[0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14], &[0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14],
[0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]); &[0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]);
// mixtures (also random) // mixtures (also random)
pos!([0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65], pos!(&[0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65],
[0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006], &[0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006],
[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]); &[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]);
// negative tests // negative tests
macro_rules! neg ( ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }); macro_rules! neg ( ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } });
neg!( neg!(
// surrogate + regular unit // surrogate + regular unit
[0xdb45, 0x0000], &[0xdb45, 0x0000],
// surrogate + lead surrogate // surrogate + lead surrogate
[0xd900, 0xd900], &[0xd900, 0xd900],
// unterminated surrogate // unterminated surrogate
[0xd8ff], &[0xd8ff],
// trail surrogate without a lead // trail surrogate without a lead
[0xddb7]); &[0xddb7]);
// random byte sequences that Python 3's .decode('utf-16be') // random byte sequences that Python 3's .decode('utf-16be')
// failed on // failed on
neg!([0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7], neg!(&[0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7],
[0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3], &[0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3],
[0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca], &[0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca],
[0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278], &[0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278],
[0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e], &[0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e],
[0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5], &[0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5],
[0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee], &[0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee],
[0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7], &[0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7],
[0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a], &[0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a],
[0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a], &[0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a],
[0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe], &[0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe],
[0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf], &[0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf],
[0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e], &[0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e],
[0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5], &[0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5],
[0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f], &[0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f],
[0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b], &[0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b],
[0x934b, 0x8956, 0xc434, 0x1881, 0xddf7], &[0x934b, 0x8956, 0xc434, 0x1881, 0xddf7],
[0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9], &[0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9],
[0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8], &[0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8],
[0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282], &[0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282],
[0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]); &[0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]);
} }
#[test] #[test]
@ -1456,22 +1456,22 @@ mod tests {
fn test_truncate_utf16_at_nul() { fn test_truncate_utf16_at_nul() {
let v = []; let v = [];
let b: &[u16] = &[]; let b: &[u16] = &[];
assert_eq!(truncate_utf16_at_nul(v), b); assert_eq!(truncate_utf16_at_nul(&v), b);
let v = [0, 2, 3]; let v = [0, 2, 3];
assert_eq!(truncate_utf16_at_nul(v), b); assert_eq!(truncate_utf16_at_nul(&v), b);
let v = [1, 0, 3]; let v = [1, 0, 3];
let b: &[u16] = &[1]; let b: &[u16] = &[1];
assert_eq!(truncate_utf16_at_nul(v), b); assert_eq!(truncate_utf16_at_nul(&v), b);
let v = [1, 2, 0]; let v = [1, 2, 0];
let b: &[u16] = &[1, 2]; let b: &[u16] = &[1, 2];
assert_eq!(truncate_utf16_at_nul(v), b); assert_eq!(truncate_utf16_at_nul(&v), b);
let v = [1, 2, 3]; let v = [1, 2, 3];
let b: &[u16] = &[1, 2, 3]; let b: &[u16] = &[1, 2, 3];
assert_eq!(truncate_utf16_at_nul(v), b); assert_eq!(truncate_utf16_at_nul(&v), b);
} }
#[test] #[test]
@ -1585,7 +1585,7 @@ mod tests {
fn test_chars_decoding() { fn test_chars_decoding() {
let mut bytes = [0u8, ..4]; let mut bytes = [0u8, ..4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) { for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(bytes).unwrap_or(0); let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(bytes[..len]).unwrap(); let s = ::core::str::from_utf8(bytes[..len]).unwrap();
if Some(c) != s.chars().next() { if Some(c) != s.chars().next() {
panic!("character {:x}={} does not decode correctly", c as u32, c); panic!("character {:x}={} does not decode correctly", c as u32, c);
@ -1597,7 +1597,7 @@ mod tests {
fn test_chars_rev_decoding() { fn test_chars_rev_decoding() {
let mut bytes = [0u8, ..4]; let mut bytes = [0u8, ..4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) { for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(bytes).unwrap_or(0); let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(bytes[..len]).unwrap(); let s = ::core::str::from_utf8(bytes[..len]).unwrap();
if Some(c) != s.chars().rev().next() { if Some(c) != s.chars().rev().next() {
panic!("character {:x}={} does not decode correctly", c as u32, c); panic!("character {:x}={} does not decode correctly", c as u32, c);
@ -2114,20 +2114,20 @@ mod tests {
let v: Vec<&str> = s.split_str(sep).collect(); let v: Vec<&str> = s.split_str(sep).collect();
assert_eq!(v.as_slice(), u.as_slice()); assert_eq!(v.as_slice(), u.as_slice());
} }
t("--1233345--", "12345", ["--1233345--"]); t("--1233345--", "12345", &["--1233345--"]);
t("abc::hello::there", "::", ["abc", "hello", "there"]); t("abc::hello::there", "::", &["abc", "hello", "there"]);
t("::hello::there", "::", ["", "hello", "there"]); t("::hello::there", "::", &["", "hello", "there"]);
t("hello::there::", "::", ["hello", "there", ""]); t("hello::there::", "::", &["hello", "there", ""]);
t("::hello::there::", "::", ["", "hello", "there", ""]); t("::hello::there::", "::", &["", "hello", "there", ""]);
t("ประเทศไทย中华Việt Nam", "中华", ["ประเทศไทย", "Việt Nam"]); t("ประเทศไทย中华Việt Nam", "中华", &["ประเทศไทย", "Việt Nam"]);
t("zzXXXzzYYYzz", "zz", ["", "XXX", "YYY", ""]); t("zzXXXzzYYYzz", "zz", &["", "XXX", "YYY", ""]);
t("zzXXXzYYYz", "XXX", ["zz", "zYYYz"]); t("zzXXXzYYYz", "XXX", &["zz", "zYYYz"]);
t(".XXX.YYY.", ".", ["", "XXX", "YYY", ""]); t(".XXX.YYY.", ".", &["", "XXX", "YYY", ""]);
t("", ".", [""]); t("", ".", &[""]);
t("zz", "zz", ["",""]); t("zz", "zz", &["",""]);
t("ok", "z", ["ok"]); t("ok", "z", &["ok"]);
t("zzz", "zz", ["","z"]); t("zzz", "zz", &["","z"]);
t("zzzzz", "zz", ["","","z"]); t("zzzzz", "zz", &["","","z"]);
} }
#[test] #[test]
@ -2149,12 +2149,12 @@ mod tests {
} }
let s = String::from_str("01234"); let s = String::from_str("01234");
assert_eq!(5, sum_len(["012", "", "34"])); assert_eq!(5, sum_len(&["012", "", "34"]));
assert_eq!(5, sum_len([String::from_str("01").as_slice(), assert_eq!(5, sum_len(&[String::from_str("01").as_slice(),
String::from_str("2").as_slice(), String::from_str("2").as_slice(),
String::from_str("34").as_slice(), String::from_str("34").as_slice(),
String::from_str("").as_slice()])); String::from_str("").as_slice()]));
assert_eq!(5, sum_len([s.as_slice()])); assert_eq!(5, sum_len(&[s.as_slice()]));
} }
#[test] #[test]

View file

@ -244,8 +244,8 @@ impl String {
/// ///
/// ```rust /// ```rust
/// // 𝄞music /// // 𝄞music
/// let mut v = [0xD834, 0xDD1E, 0x006d, 0x0075, /// let mut v = &mut [0xD834, 0xDD1E, 0x006d, 0x0075,
/// 0x0073, 0x0069, 0x0063]; /// 0x0073, 0x0069, 0x0063];
/// assert_eq!(String::from_utf16(v), Some("𝄞music".to_string())); /// assert_eq!(String::from_utf16(v), Some("𝄞music".to_string()));
/// ///
/// // 𝄞mu<invalid>ic /// // 𝄞mu<invalid>ic
@ -270,9 +270,9 @@ impl String {
/// # Example /// # Example
/// ```rust /// ```rust
/// // 𝄞mus<invalid>ic<invalid> /// // 𝄞mus<invalid>ic<invalid>
/// let v = [0xD834, 0xDD1E, 0x006d, 0x0075, /// let v = &[0xD834, 0xDD1E, 0x006d, 0x0075,
/// 0x0073, 0xDD1E, 0x0069, 0x0063, /// 0x0073, 0xDD1E, 0x0069, 0x0063,
/// 0xD834]; /// 0xD834];
/// ///
/// assert_eq!(String::from_utf16_lossy(v), /// assert_eq!(String::from_utf16_lossy(v),
/// "𝄞mus\uFFFDic\uFFFD".to_string()); /// "𝄞mus\uFFFDic\uFFFD".to_string());
@ -287,7 +287,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// let chars = ['h', 'e', 'l', 'l', 'o']; /// let chars = &['h', 'e', 'l', 'l', 'o'];
/// let s = String::from_chars(chars); /// let s = String::from_chars(chars);
/// assert_eq!(s.as_slice(), "hello"); /// assert_eq!(s.as_slice(), "hello");
/// ``` /// ```
@ -600,7 +600,7 @@ impl String {
assert!(self.as_slice().is_char_boundary(idx)); assert!(self.as_slice().is_char_boundary(idx));
self.vec.reserve(4); self.vec.reserve(4);
let mut bits = [0, ..4]; let mut bits = [0, ..4];
let amt = ch.encode_utf8(bits).unwrap(); let amt = ch.encode_utf8(&mut bits).unwrap();
unsafe { unsafe {
ptr::copy_memory(self.vec.as_mut_ptr().offset((idx + amt) as int), ptr::copy_memory(self.vec.as_mut_ptr().offset((idx + amt) as int),
@ -1016,30 +1016,30 @@ mod tests {
fn test_utf16_invalid() { fn test_utf16_invalid() {
// completely positive cases tested above. // completely positive cases tested above.
// lead + eof // lead + eof
assert_eq!(String::from_utf16([0xD800]), None); assert_eq!(String::from_utf16(&[0xD800]), None);
// lead + lead // lead + lead
assert_eq!(String::from_utf16([0xD800, 0xD800]), None); assert_eq!(String::from_utf16(&[0xD800, 0xD800]), None);
// isolated trail // isolated trail
assert_eq!(String::from_utf16([0x0061, 0xDC00]), None); assert_eq!(String::from_utf16(&[0x0061, 0xDC00]), None);
// general // general
assert_eq!(String::from_utf16([0xD800, 0xd801, 0xdc8b, 0xD800]), None); assert_eq!(String::from_utf16(&[0xD800, 0xd801, 0xdc8b, 0xD800]), None);
} }
#[test] #[test]
fn test_from_utf16_lossy() { fn test_from_utf16_lossy() {
// completely positive cases tested above. // completely positive cases tested above.
// lead + eof // lead + eof
assert_eq!(String::from_utf16_lossy([0xD800]), String::from_str("\uFFFD")); assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from_str("\uFFFD"));
// lead + lead // lead + lead
assert_eq!(String::from_utf16_lossy([0xD800, 0xD800]), String::from_str("\uFFFD\uFFFD")); assert_eq!(String::from_utf16_lossy(&[0xD800, 0xD800]), String::from_str("\uFFFD\uFFFD"));
// isolated trail // isolated trail
assert_eq!(String::from_utf16_lossy([0x0061, 0xDC00]), String::from_str("a\uFFFD")); assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from_str("a\uFFFD"));
// general // general
assert_eq!(String::from_utf16_lossy([0xD800, 0xd801, 0xdc8b, 0xD800]), assert_eq!(String::from_utf16_lossy(&[0xD800, 0xd801, 0xdc8b, 0xD800]),
String::from_str("\uFFFD𐒋\uFFFD")); String::from_str("\uFFFD𐒋\uFFFD"));
} }
@ -1066,7 +1066,7 @@ mod tests {
let mut s = String::from_str("ABC"); let mut s = String::from_str("ABC");
unsafe { unsafe {
let mv = s.as_mut_vec(); let mv = s.as_mut_vec();
mv.push_all([b'D']); mv.push_all(&[b'D']);
} }
assert_eq!(s.as_slice(), "ABCD"); assert_eq!(s.as_slice(), "ABCD");
} }

View file

@ -860,14 +860,14 @@ mod test {
check(a, b, expected, |x, y, f| x.intersection(y).all(f)) check(a, b, expected, |x, y, f| x.intersection(y).all(f))
} }
check_intersection([], [], []); check_intersection(&[], &[], &[]);
check_intersection([1, 2, 3], [], []); check_intersection(&[1, 2, 3], &[], &[]);
check_intersection([], [1, 2, 3], []); check_intersection(&[], &[1, 2, 3], &[]);
check_intersection([2], [1, 2, 3], [2]); check_intersection(&[2], &[1, 2, 3], &[2]);
check_intersection([1, 2, 3], [2], [2]); check_intersection(&[1, 2, 3], &[2], &[2]);
check_intersection([11, 1, 3, 77, 103, 5, -5], check_intersection(&[11, 1, 3, 77, 103, 5, -5],
[2, 11, 77, -9, -42, 5, 3], &[2, 11, 77, -9, -42, 5, 3],
[3, 5, 11, 77]); &[3, 5, 11, 77]);
} }
#[test] #[test]
@ -876,15 +876,15 @@ mod test {
check(a, b, expected, |x, y, f| x.difference(y).all(f)) check(a, b, expected, |x, y, f| x.difference(y).all(f))
} }
check_difference([], [], []); check_difference(&[], &[], &[]);
check_difference([1, 12], [], [1, 12]); check_difference(&[1, 12], &[], &[1, 12]);
check_difference([], [1, 2, 3, 9], []); check_difference(&[], &[1, 2, 3, 9], &[]);
check_difference([1, 3, 5, 9, 11], check_difference(&[1, 3, 5, 9, 11],
[3, 9], &[3, 9],
[1, 5, 11]); &[1, 5, 11]);
check_difference([-5, 11, 22, 33, 40, 42], check_difference(&[-5, 11, 22, 33, 40, 42],
[-12, -5, 14, 23, 34, 38, 39, 50], &[-12, -5, 14, 23, 34, 38, 39, 50],
[11, 22, 33, 40, 42]); &[11, 22, 33, 40, 42]);
} }
#[test] #[test]
@ -894,12 +894,12 @@ mod test {
check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f)) check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
} }
check_symmetric_difference([], [], []); check_symmetric_difference(&[], &[], &[]);
check_symmetric_difference([1, 2, 3], [2], [1, 3]); check_symmetric_difference(&[1, 2, 3], &[2], &[1, 3]);
check_symmetric_difference([2], [1, 2, 3], [1, 3]); check_symmetric_difference(&[2], &[1, 2, 3], &[1, 3]);
check_symmetric_difference([1, 3, 5, 9, 11], check_symmetric_difference(&[1, 3, 5, 9, 11],
[-2, 3, 9, 14, 22], &[-2, 3, 9, 14, 22],
[-2, 1, 5, 11, 14, 22]); &[-2, 1, 5, 11, 14, 22]);
} }
#[test] #[test]
@ -909,12 +909,12 @@ mod test {
check(a, b, expected, |x, y, f| x.union(y).all(f)) check(a, b, expected, |x, y, f| x.union(y).all(f))
} }
check_union([], [], []); check_union(&[], &[], &[]);
check_union([1, 2, 3], [2], [1, 2, 3]); check_union(&[1, 2, 3], &[2], &[1, 2, 3]);
check_union([2], [1, 2, 3], [1, 2, 3]); check_union(&[2], &[1, 2, 3], &[1, 2, 3]);
check_union([1, 3, 5, 9, 11, 16, 19, 24], check_union(&[1, 3, 5, 9, 11, 16, 19, 24],
[-2, 1, 5, 9, 13, 19], &[-2, 1, 5, 9, 13, 19],
[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]); &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]);
} }
#[test] #[test]

View file

@ -47,7 +47,7 @@ use slice::{CloneSliceAllocPrelude};
/// vec[0] = 7i; /// vec[0] = 7i;
/// assert_eq!(vec[0], 7); /// assert_eq!(vec[0], 7);
/// ///
/// vec.push_all([1, 2, 3]); /// vec.push_all(&[1, 2, 3]);
/// ///
/// for x in vec.iter() { /// for x in vec.iter() {
/// println!("{}", x); /// println!("{}", x);
@ -306,7 +306,7 @@ impl<T: Clone> Vec<T> {
/// ///
/// ``` /// ```
/// let mut vec = vec![1i]; /// let mut vec = vec![1i];
/// vec.push_all([2i, 3, 4]); /// vec.push_all(&[2i, 3, 4]);
/// assert_eq!(vec, vec![1, 2, 3, 4]); /// assert_eq!(vec, vec![1, 2, 3, 4]);
/// ``` /// ```
#[inline] #[inline]
@ -639,7 +639,7 @@ impl<T> Vec<T> {
/// ///
/// ``` /// ```
/// let mut vec: Vec<int> = Vec::with_capacity(10); /// let mut vec: Vec<int> = Vec::with_capacity(10);
/// vec.push_all([1, 2, 3]); /// vec.push_all(&[1, 2, 3]);
/// assert_eq!(vec.capacity(), 10); /// assert_eq!(vec.capacity(), 10);
/// vec.shrink_to_fit(); /// vec.shrink_to_fit();
/// assert!(vec.capacity() >= 3); /// assert!(vec.capacity() >= 3);
@ -1682,7 +1682,7 @@ mod tests {
#[test] #[test]
fn test_as_vec() { fn test_as_vec() {
let xs = [1u8, 2u8, 3u8]; let xs = [1u8, 2u8, 3u8];
assert_eq!(as_vec(xs).as_slice(), xs.as_slice()); assert_eq!(as_vec(&xs).as_slice(), xs.as_slice());
} }
#[test] #[test]
@ -1772,13 +1772,13 @@ mod tests {
let mut values = vec![1u8,2,3,4,5]; let mut values = vec![1u8,2,3,4,5];
{ {
let slice = values.slice_from_mut(2); let slice = values.slice_from_mut(2);
assert!(slice == [3, 4, 5]); assert!(slice == &mut [3, 4, 5]);
for p in slice.iter_mut() { for p in slice.iter_mut() {
*p += 2; *p += 2;
} }
} }
assert!(values.as_slice() == [1, 2, 5, 6, 7]); assert!(values.as_slice() == &[1, 2, 5, 6, 7]);
} }
#[test] #[test]
@ -1786,13 +1786,13 @@ mod tests {
let mut values = vec![1u8,2,3,4,5]; let mut values = vec![1u8,2,3,4,5];
{ {
let slice = values.slice_to_mut(2); let slice = values.slice_to_mut(2);
assert!(slice == [1, 2]); assert!(slice == &mut [1, 2]);
for p in slice.iter_mut() { for p in slice.iter_mut() {
*p += 1; *p += 1;
} }
} }
assert!(values.as_slice() == [2, 3, 3, 4, 5]); assert!(values.as_slice() == &[2, 3, 3, 4, 5]);
} }
#[test] #[test]

View file

@ -79,7 +79,7 @@ impl<T> Finally<T> for fn() -> T {
* *
* struct State<'a> { buffer: &'a mut [u8], len: uint } * struct State<'a> { buffer: &'a mut [u8], len: uint }
* # let mut buf = []; * # let mut buf = [];
* let mut state = State { buffer: buf, len: 0 }; * let mut state = State { buffer: &mut buf, len: 0 };
* try_finally( * try_finally(
* &mut state, (), * &mut state, (),
* |state, ()| { * |state, ()| {

View file

@ -315,7 +315,7 @@ pub fn float_to_str_bytes_common<T: Float, U>(
} }
} }
let mut filler = Filler { buf: buf, end: &mut end }; let mut filler = Filler { buf: &mut buf, end: &mut end };
match sign { match sign {
SignNeg => { SignNeg => {
let _ = format_args!(|args| { let _ = format_args!(|args| {

View file

@ -392,7 +392,7 @@ impl<'a> Formatter<'a> {
let write_prefix = |f: &mut Formatter| { let write_prefix = |f: &mut Formatter| {
for c in sign.into_iter() { for c in sign.into_iter() {
let mut b = [0, ..4]; let mut b = [0, ..4];
let n = c.encode_utf8(b).unwrap_or(0); let n = c.encode_utf8(&mut b).unwrap_or(0);
try!(f.buf.write(b[..n])); try!(f.buf.write(b[..n]));
} }
if prefixed { f.buf.write(prefix.as_bytes()) } if prefixed { f.buf.write(prefix.as_bytes()) }
@ -497,7 +497,7 @@ impl<'a> Formatter<'a> {
}; };
let mut fill = [0u8, ..4]; let mut fill = [0u8, ..4];
let len = self.fill.encode_utf8(fill).unwrap_or(0); let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
for _ in range(0, pre_pad) { for _ in range(0, pre_pad) {
try!(self.buf.write(fill[..len])); try!(self.buf.write(fill[..len]));
@ -586,7 +586,7 @@ impl Char for char {
use char::Char; use char::Char;
let mut utf8 = [0u8, ..4]; let mut utf8 = [0u8, ..4];
let amt = self.encode_utf8(utf8).unwrap_or(0); let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
let s: &str = unsafe { mem::transmute(utf8[..amt]) }; let s: &str = unsafe { mem::transmute(utf8[..amt]) };
String::fmt(s, f) String::fmt(s, f)
} }

View file

@ -228,7 +228,7 @@ extern "rust-intrinsic" {
/// use std::mem; /// use std::mem;
/// ///
/// let v: &[u8] = unsafe { mem::transmute("L") }; /// let v: &[u8] = unsafe { mem::transmute("L") };
/// assert!(v == [76u8]); /// assert!(v == &[76u8]);
/// ``` /// ```
pub fn transmute<T,U>(e: T) -> U; pub fn transmute<T,U>(e: T) -> U;

View file

@ -271,9 +271,9 @@ impl<T> Option<T> {
/// let mut x = Some("Diamonds"); /// let mut x = Some("Diamonds");
/// { /// {
/// let v = x.as_mut_slice(); /// let v = x.as_mut_slice();
/// assert!(v == ["Diamonds"]); /// assert!(v == &mut ["Diamonds"]);
/// v[0] = "Dirt"; /// v[0] = "Dirt";
/// assert!(v == ["Dirt"]); /// assert!(v == &mut ["Dirt"]);
/// } /// }
/// assert_eq!(x, Some("Dirt")); /// assert_eq!(x, Some("Dirt"));
/// ``` /// ```

View file

@ -451,14 +451,14 @@ impl<T, E> Result<T, E> {
/// let mut x: Result<&str, uint> = Ok("Gold"); /// let mut x: Result<&str, uint> = Ok("Gold");
/// { /// {
/// let v = x.as_mut_slice(); /// let v = x.as_mut_slice();
/// assert!(v == ["Gold"]); /// assert!(v == &mut ["Gold"]);
/// v[0] = "Silver"; /// v[0] = "Silver";
/// assert!(v == ["Silver"]); /// assert!(v == &mut ["Silver"]);
/// } /// }
/// assert_eq!(x, Ok("Silver")); /// assert_eq!(x, Ok("Silver"));
/// ///
/// let mut x: Result<&str, uint> = Err(45); /// let mut x: Result<&str, uint> = Err(45);
/// assert!(x.as_mut_slice() == []); /// assert!(x.as_mut_slice() == &mut []);
/// ``` /// ```
#[inline] #[inline]
#[unstable = "waiting for mut conventions"] #[unstable = "waiting for mut conventions"]

View file

@ -973,11 +973,11 @@ pub trait CloneSlicePrelude<T> for Sized? {
/// let mut dst = [0i, 0, 0]; /// let mut dst = [0i, 0, 0];
/// let src = [1i, 2]; /// let src = [1i, 2];
/// ///
/// assert!(dst.clone_from_slice(src) == 2); /// assert!(dst.clone_from_slice(&src) == 2);
/// assert!(dst == [1, 2, 0]); /// assert!(dst == [1, 2, 0]);
/// ///
/// let src2 = [3i, 4, 5, 6]; /// let src2 = [3i, 4, 5, 6];
/// assert!(dst.clone_from_slice(src2) == 3); /// assert!(dst.clone_from_slice(&src2) == 3);
/// assert!(dst == [3i, 4, 5]); /// assert!(dst == [3i, 4, 5]);
/// ``` /// ```
fn clone_from_slice(&mut self, &[T]) -> uint; fn clone_from_slice(&mut self, &[T]) -> uint;

View file

@ -1008,7 +1008,7 @@ impl<'a> Iterator<Utf16Item> for Utf16Items<'a> {
/// 0x0073, 0xDD1E, 0x0069, 0x0063, /// 0x0073, 0xDD1E, 0x0069, 0x0063,
/// 0xD834]; /// 0xD834];
/// ///
/// assert_eq!(str::utf16_items(v).collect::<Vec<_>>(), /// assert_eq!(str::utf16_items(&v).collect::<Vec<_>>(),
/// vec![ScalarValue('𝄞'), /// vec![ScalarValue('𝄞'),
/// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'), /// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'),
/// LoneSurrogate(0xDD1E), /// LoneSurrogate(0xDD1E),
@ -1030,12 +1030,12 @@ pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a> {
/// // "abcd" /// // "abcd"
/// let mut v = ['a' as u16, 'b' as u16, 'c' as u16, 'd' as u16]; /// let mut v = ['a' as u16, 'b' as u16, 'c' as u16, 'd' as u16];
/// // no NULs so no change /// // no NULs so no change
/// assert_eq!(str::truncate_utf16_at_nul(v), v.as_slice()); /// assert_eq!(str::truncate_utf16_at_nul(&v), v.as_slice());
/// ///
/// // "ab\0d" /// // "ab\0d"
/// v[2] = 0; /// v[2] = 0;
/// let b: &[_] = &['a' as u16, 'b' as u16]; /// let b: &[_] = &['a' as u16, 'b' as u16];
/// assert_eq!(str::truncate_utf16_at_nul(v), b); /// assert_eq!(str::truncate_utf16_at_nul(&v), b);
/// ``` /// ```
pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
match v.iter().position(|c| *c == 0) { match v.iter().position(|c| *c == 0) {

View file

@ -177,10 +177,10 @@ fn test_encode_utf8() {
assert_eq!(buf[..n], expect); assert_eq!(buf[..n], expect);
} }
check('x', [0x78]); check('x', &[0x78]);
check('\u00e9', [0xc3, 0xa9]); check('\u00e9', &[0xc3, 0xa9]);
check('\ua66e', [0xea, 0x99, 0xae]); check('\ua66e', &[0xea, 0x99, 0xae]);
check('\U0001f4a9', [0xf0, 0x9f, 0x92, 0xa9]); check('\U0001f4a9', &[0xf0, 0x9f, 0x92, 0xa9]);
} }
#[test] #[test]
@ -191,10 +191,10 @@ fn test_encode_utf16() {
assert_eq!(buf[..n], expect); assert_eq!(buf[..n], expect);
} }
check('x', [0x0078]); check('x', &[0x0078]);
check('\u00e9', [0x00e9]); check('\u00e9', &[0x00e9]);
check('\ua66e', [0xa66e]); check('\ua66e', &[0xa66e]);
check('\U0001f4a9', [0xd83d, 0xdca9]); check('\U0001f4a9', &[0xd83d, 0xdca9]);
} }
#[test] #[test]

View file

@ -627,7 +627,7 @@ fn test_random_access_zip() {
#[test] #[test]
fn test_random_access_take() { fn test_random_access_take() {
let xs = [1i, 2, 3, 4, 5]; let xs = [1i, 2, 3, 4, 5];
let empty: &[int] = []; let empty: &[int] = &[];
check_randacc_iter(xs.iter().take(3), 3); check_randacc_iter(xs.iter().take(3), 3);
check_randacc_iter(xs.iter().take(20), xs.len()); check_randacc_iter(xs.iter().take(20), xs.len());
check_randacc_iter(xs.iter().take(0), 0); check_randacc_iter(xs.iter().take(0), 0);
@ -637,7 +637,7 @@ fn test_random_access_take() {
#[test] #[test]
fn test_random_access_skip() { fn test_random_access_skip() {
let xs = [1i, 2, 3, 4, 5]; let xs = [1i, 2, 3, 4, 5];
let empty: &[int] = []; let empty: &[int] = &[];
check_randacc_iter(xs.iter().skip(2), xs.len() - 2); check_randacc_iter(xs.iter().skip(2), xs.len() - 2);
check_randacc_iter(empty.iter().skip(2), 0); check_randacc_iter(empty.iter().skip(2), 0);
} }
@ -669,7 +669,7 @@ fn test_random_access_map() {
#[test] #[test]
fn test_random_access_cycle() { fn test_random_access_cycle() {
let xs = [1i, 2, 3, 4, 5]; let xs = [1i, 2, 3, 4, 5];
let empty: &[int] = []; let empty: &[int] = &[];
check_randacc_iter(xs.iter().cycle().take(27), 27); check_randacc_iter(xs.iter().cycle().take(27), 27);
check_randacc_iter(empty.iter().cycle(), 0); check_randacc_iter(empty.iter().cycle(), 0);
} }

View file

@ -454,12 +454,12 @@ mod tests {
#[test] #[test]
fn simple() { fn simple() {
same("asdf", [String("asdf")]); same("asdf", &[String("asdf")]);
same("a{{b", [String("a"), String("{b")]); same("a{{b", &[String("a"), String("{b")]);
same("a}}b", [String("a"), String("}b")]); same("a}}b", &[String("a"), String("}b")]);
same("a}}", [String("a"), String("}")]); same("a}}", &[String("a"), String("}")]);
same("}}", [String("}")]); same("}}", &[String("}")]);
same("\\}}", [String("\\"), String("}")]); same("\\}}", &[String("\\"), String("}")]);
} }
#[test] fn invalid01() { musterr("{") } #[test] fn invalid01() { musterr("{") }
@ -470,28 +470,28 @@ mod tests {
#[test] #[test]
fn format_nothing() { fn format_nothing() {
same("{}", [NextArgument(Argument { same("{}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: fmtdflt(), format: fmtdflt(),
})]); })]);
} }
#[test] #[test]
fn format_position() { fn format_position() {
same("{3}", [NextArgument(Argument { same("{3}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: fmtdflt(), format: fmtdflt(),
})]); })]);
} }
#[test] #[test]
fn format_position_nothing_else() { fn format_position_nothing_else() {
same("{3:}", [NextArgument(Argument { same("{3:}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: fmtdflt(), format: fmtdflt(),
})]); })]);
} }
#[test] #[test]
fn format_type() { fn format_type() {
same("{3:a}", [NextArgument(Argument { same("{3:a}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -505,7 +505,7 @@ mod tests {
} }
#[test] #[test]
fn format_align_fill() { fn format_align_fill() {
same("{3:>}", [NextArgument(Argument { same("{3:>}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -516,7 +516,7 @@ mod tests {
ty: "", ty: "",
}, },
})]); })]);
same("{3:0<}", [NextArgument(Argument { same("{3:0<}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: FormatSpec { format: FormatSpec {
fill: Some('0'), fill: Some('0'),
@ -527,7 +527,7 @@ mod tests {
ty: "", ty: "",
}, },
})]); })]);
same("{3:*<abcd}", [NextArgument(Argument { same("{3:*<abcd}", &[NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: FormatSpec { format: FormatSpec {
fill: Some('*'), fill: Some('*'),
@ -541,7 +541,7 @@ mod tests {
} }
#[test] #[test]
fn format_counts() { fn format_counts() {
same("{:10s}", [NextArgument(Argument { same("{:10s}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -552,7 +552,7 @@ mod tests {
ty: "s", ty: "s",
}, },
})]); })]);
same("{:10$.10s}", [NextArgument(Argument { same("{:10$.10s}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -563,7 +563,7 @@ mod tests {
ty: "s", ty: "s",
}, },
})]); })]);
same("{:.*s}", [NextArgument(Argument { same("{:.*s}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -574,7 +574,7 @@ mod tests {
ty: "s", ty: "s",
}, },
})]); })]);
same("{:.10$s}", [NextArgument(Argument { same("{:.10$s}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -585,7 +585,7 @@ mod tests {
ty: "s", ty: "s",
}, },
})]); })]);
same("{:a$.b$s}", [NextArgument(Argument { same("{:a$.b$s}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -599,7 +599,7 @@ mod tests {
} }
#[test] #[test]
fn format_flags() { fn format_flags() {
same("{:-}", [NextArgument(Argument { same("{:-}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -610,7 +610,7 @@ mod tests {
ty: "", ty: "",
}, },
})]); })]);
same("{:+#}", [NextArgument(Argument { same("{:+#}", &[NextArgument(Argument {
position: ArgumentNext, position: ArgumentNext,
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
@ -624,7 +624,7 @@ mod tests {
} }
#[test] #[test]
fn format_mixture() { fn format_mixture() {
same("abcd {3:a} efg", [String("abcd "), NextArgument(Argument { same("abcd {3:a} efg", &[String("abcd "), NextArgument(Argument {
position: ArgumentIs(3), position: ArgumentIs(3),
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,

View file

@ -55,7 +55,7 @@
//! //!
//! let program = args[0].clone(); //! let program = args[0].clone();
//! //!
//! let opts = [ //! let opts = &[
//! optopt("o", "", "set output file name", "NAME"), //! optopt("o", "", "set output file name", "NAME"),
//! optflag("h", "help", "print this help menu") //! optflag("h", "help", "print this help menu")
//! ]; //! ];
@ -942,16 +942,16 @@ fn test_split_within() {
each_split_within(s, i, |s| { v.push(s.to_string()); true }); each_split_within(s, i, |s| { v.push(s.to_string()); true });
assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b));
} }
t("", 0, []); t("", 0, &[]);
t("", 15, []); t("", 15, &[]);
t("hello", 15, ["hello".to_string()]); t("hello", 15, &["hello".to_string()]);
t("\nMary had a little lamb\nLittle lamb\n", 15, [ t("\nMary had a little lamb\nLittle lamb\n", 15, &[
"Mary had a".to_string(), "Mary had a".to_string(),
"little lamb".to_string(), "little lamb".to_string(),
"Little lamb".to_string() "Little lamb".to_string()
]); ]);
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX, t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX,
["Mary had a little lamb\nLittle lamb".to_string()]); &["Mary had a little lamb\nLittle lamb".to_string()]);
} }
#[cfg(test)] #[cfg(test)]
@ -1414,17 +1414,17 @@ mod tests {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(_) => panic!() result::Err(_) => panic!()
}; };
assert!(matches_single.opts_present(["e".to_string()])); assert!(matches_single.opts_present(&["e".to_string()]));
assert!(matches_single.opts_present(["encrypt".to_string(), "e".to_string()])); assert!(matches_single.opts_present(&["encrypt".to_string(), "e".to_string()]));
assert!(matches_single.opts_present(["e".to_string(), "encrypt".to_string()])); assert!(matches_single.opts_present(&["e".to_string(), "encrypt".to_string()]));
assert!(!matches_single.opts_present(["encrypt".to_string()])); assert!(!matches_single.opts_present(&["encrypt".to_string()]));
assert!(!matches_single.opts_present(["thing".to_string()])); assert!(!matches_single.opts_present(&["thing".to_string()]));
assert!(!matches_single.opts_present([])); assert!(!matches_single.opts_present(&[]));
assert_eq!(matches_single.opts_str(["e".to_string()]).unwrap(), "foo".to_string()); assert_eq!(matches_single.opts_str(&["e".to_string()]).unwrap(), "foo".to_string());
assert_eq!(matches_single.opts_str(["e".to_string(), "encrypt".to_string()]).unwrap(), assert_eq!(matches_single.opts_str(&["e".to_string(), "encrypt".to_string()]).unwrap(),
"foo".to_string()); "foo".to_string());
assert_eq!(matches_single.opts_str(["encrypt".to_string(), "e".to_string()]).unwrap(), assert_eq!(matches_single.opts_str(&["encrypt".to_string(), "e".to_string()]).unwrap(),
"foo".to_string()); "foo".to_string());
let args_both = vec!("-e".to_string(), "foo".to_string(), "--encrypt".to_string(), let args_both = vec!("-e".to_string(), "foo".to_string(), "--encrypt".to_string(),
@ -1434,19 +1434,19 @@ mod tests {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(_) => panic!() result::Err(_) => panic!()
}; };
assert!(matches_both.opts_present(["e".to_string()])); assert!(matches_both.opts_present(&["e".to_string()]));
assert!(matches_both.opts_present(["encrypt".to_string()])); assert!(matches_both.opts_present(&["encrypt".to_string()]));
assert!(matches_both.opts_present(["encrypt".to_string(), "e".to_string()])); assert!(matches_both.opts_present(&["encrypt".to_string(), "e".to_string()]));
assert!(matches_both.opts_present(["e".to_string(), "encrypt".to_string()])); assert!(matches_both.opts_present(&["e".to_string(), "encrypt".to_string()]));
assert!(!matches_both.opts_present(["f".to_string()])); assert!(!matches_both.opts_present(&["f".to_string()]));
assert!(!matches_both.opts_present(["thing".to_string()])); assert!(!matches_both.opts_present(&["thing".to_string()]));
assert!(!matches_both.opts_present([])); assert!(!matches_both.opts_present(&[]));
assert_eq!(matches_both.opts_str(["e".to_string()]).unwrap(), "foo".to_string()); assert_eq!(matches_both.opts_str(&["e".to_string()]).unwrap(), "foo".to_string());
assert_eq!(matches_both.opts_str(["encrypt".to_string()]).unwrap(), "foo".to_string()); assert_eq!(matches_both.opts_str(&["encrypt".to_string()]).unwrap(), "foo".to_string());
assert_eq!(matches_both.opts_str(["e".to_string(), "encrypt".to_string()]).unwrap(), assert_eq!(matches_both.opts_str(&["e".to_string(), "encrypt".to_string()]).unwrap(),
"foo".to_string()); "foo".to_string());
assert_eq!(matches_both.opts_str(["encrypt".to_string(), "e".to_string()]).unwrap(), assert_eq!(matches_both.opts_str(&["encrypt".to_string(), "e".to_string()]).unwrap(),
"foo".to_string()); "foo".to_string());
} }
@ -1459,10 +1459,10 @@ mod tests {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(_) => panic!() result::Err(_) => panic!()
}; };
assert!(matches.opts_present(["L".to_string()])); assert!(matches.opts_present(&["L".to_string()]));
assert_eq!(matches.opts_str(["L".to_string()]).unwrap(), "foo".to_string()); assert_eq!(matches.opts_str(&["L".to_string()]).unwrap(), "foo".to_string());
assert!(matches.opts_present(["M".to_string()])); assert!(matches.opts_present(&["M".to_string()]));
assert_eq!(matches.opts_str(["M".to_string()]).unwrap(), ".".to_string()); assert_eq!(matches.opts_str(&["M".to_string()]).unwrap(), ".".to_string());
} }
@ -1475,9 +1475,9 @@ mod tests {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(e) => panic!( "{}", e ) result::Err(e) => panic!( "{}", e )
}; };
assert!(matches.opts_present(["L".to_string()])); assert!(matches.opts_present(&["L".to_string()]));
assert_eq!(matches.opts_str(["L".to_string()]).unwrap(), "verbose".to_string()); assert_eq!(matches.opts_str(&["L".to_string()]).unwrap(), "verbose".to_string());
assert!(matches.opts_present(["v".to_string()])); assert!(matches.opts_present(&["v".to_string()]));
assert_eq!(3, matches.opt_count("v")); assert_eq!(3, matches.opt_count("v"));
} }

View file

@ -514,13 +514,13 @@ pub fn render<'a, N:'a, E:'a, G:Labeller<'a,N,E>+GraphWalk<'a,N,E>, W:Writer>(
w.write_str(" ") w.write_str(" ")
} }
try!(writeln(w, ["digraph ", g.graph_id().as_slice(), " {"])); try!(writeln(w, &["digraph ", g.graph_id().as_slice(), " {"]));
for n in g.nodes().iter() { for n in g.nodes().iter() {
try!(indent(w)); try!(indent(w));
let id = g.node_id(n); let id = g.node_id(n);
let escaped = g.node_label(n).escape(); let escaped = g.node_label(n).escape();
try!(writeln(w, [id.as_slice(), try!(writeln(w, &[id.as_slice(),
"[label=\"", escaped.as_slice(), "\"];"])); "[label=\"", escaped.as_slice(), "\"];"]));
} }
for e in g.edges().iter() { for e in g.edges().iter() {
@ -530,11 +530,11 @@ pub fn render<'a, N:'a, E:'a, G:Labeller<'a,N,E>+GraphWalk<'a,N,E>, W:Writer>(
let target = g.target(e); let target = g.target(e);
let source_id = g.node_id(&source); let source_id = g.node_id(&source);
let target_id = g.node_id(&target); let target_id = g.node_id(&target);
try!(writeln(w, [source_id.as_slice(), " -> ", target_id.as_slice(), try!(writeln(w, &[source_id.as_slice(), " -> ", target_id.as_slice(),
"[label=\"", escaped_label.as_slice(), "\"];"])); "[label=\"", escaped_label.as_slice(), "\"];"]));
} }
writeln(w, ["}"]) writeln(w, &["}"])
} }
#[cfg(test)] #[cfg(test)]

View file

@ -44,8 +44,8 @@ impl Stack {
// allocation failure, which would fail to spawn the task. But there's // allocation failure, which would fail to spawn the task. But there's
// not many sensible things to do on OOM. Failure seems fine (and is // not many sensible things to do on OOM. Failure seems fine (and is
// what the old stack allocation did). // what the old stack allocation did).
let stack = match MemoryMap::new(size, [MapReadable, MapWritable, let stack = match MemoryMap::new(size, &[MapReadable, MapWritable,
MapNonStandardFlags(STACK_FLAGS)]) { MapNonStandardFlags(STACK_FLAGS)]) {
Ok(map) => map, Ok(map) => map,
Err(e) => panic!("mmap for stack of size {} failed: {}", size, e) Err(e) => panic!("mmap for stack of size {} failed: {}", size, e)
}; };

View file

@ -349,7 +349,7 @@ mod tests {
#[test] #[should_fail] #[test] #[should_fail]
fn test_weighted_choice_no_items() { fn test_weighted_choice_no_items() {
WeightedChoice::<int>::new([]); WeightedChoice::<int>::new(&mut []);
} }
#[test] #[should_fail] #[test] #[should_fail]
fn test_weighted_choice_zero_weight() { fn test_weighted_choice_zero_weight() {

View file

@ -185,9 +185,9 @@ mod tests {
macro_rules! t ( macro_rules! t (
($($ty:ty),*) => {{ ($($ty:ty),*) => {{
$( $(
let v: &[($ty, $ty)] = [(0, 10), let v: &[($ty, $ty)] = &[(0, 10),
(10, 127), (10, 127),
(Int::min_value(), Int::max_value())]; (Int::min_value(), Int::max_value())];
for &(low, high) in v.iter() { for &(low, high) in v.iter() {
let mut sampler: Range<$ty> = Range::new(low, high); let mut sampler: Range<$ty> = Range::new(low, high);
for _ in range(0u, 1000) { for _ in range(0u, 1000) {
@ -210,10 +210,10 @@ mod tests {
macro_rules! t ( macro_rules! t (
($($ty:ty),*) => {{ ($($ty:ty),*) => {{
$( $(
let v: &[($ty, $ty)] = [(0.0, 100.0), let v: &[($ty, $ty)] = &[(0.0, 100.0),
(-1e35, -1e25), (-1e35, -1e25),
(1e-35, 1e-25), (1e-35, 1e-25),
(-1e35, 1e35)]; (-1e35, 1e35)];
for &(low, high) in v.iter() { for &(low, high) in v.iter() {
let mut sampler: Range<$ty> = Range::new(low, high); let mut sampler: Range<$ty> = Range::new(low, high);
for _ in range(0u, 1000) { for _ in range(0u, 1000) {

View file

@ -142,7 +142,7 @@ pub trait Rng {
/// use std::rand::{task_rng, Rng}; /// use std::rand::{task_rng, Rng};
/// ///
/// let mut v = [0u8, .. 13579]; /// let mut v = [0u8, .. 13579];
/// task_rng().fill_bytes(v); /// task_rng().fill_bytes(&mut v);
/// println!("{}", v.as_slice()); /// println!("{}", v.as_slice());
/// ``` /// ```
fn fill_bytes(&mut self, dest: &mut [u8]) { fn fill_bytes(&mut self, dest: &mut [u8]) {
@ -268,7 +268,7 @@ pub trait Rng {
/// ///
/// let choices = [1i, 2, 4, 8, 16, 32]; /// let choices = [1i, 2, 4, 8, 16, 32];
/// let mut rng = task_rng(); /// let mut rng = task_rng();
/// println!("{}", rng.choose(choices)); /// println!("{}", rng.choose(&choices));
/// assert_eq!(rng.choose(choices[..0]), None); /// assert_eq!(rng.choose(choices[..0]), None);
/// ``` /// ```
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
@ -288,9 +288,9 @@ pub trait Rng {
/// ///
/// let mut rng = task_rng(); /// let mut rng = task_rng();
/// let mut y = [1i, 2, 3]; /// let mut y = [1i, 2, 3];
/// rng.shuffle(y); /// rng.shuffle(&mut y);
/// println!("{}", y.as_slice()); /// println!("{}", y.as_slice());
/// rng.shuffle(y); /// rng.shuffle(&mut y);
/// println!("{}", y.as_slice()); /// println!("{}", y.as_slice());
/// ``` /// ```
fn shuffle<T>(&mut self, values: &mut [T]) { fn shuffle<T>(&mut self, values: &mut [T]) {
@ -347,7 +347,7 @@ pub trait SeedableRng<Seed>: Rng {
/// let seed: &[_] = &[1, 2, 3, 4]; /// let seed: &[_] = &[1, 2, 3, 4];
/// let mut rng: StdRng = SeedableRng::from_seed(seed); /// let mut rng: StdRng = SeedableRng::from_seed(seed);
/// println!("{}", rng.gen::<f64>()); /// println!("{}", rng.gen::<f64>());
/// rng.reseed([5, 6, 7, 8]); /// rng.reseed(&[5, 6, 7, 8]);
/// println!("{}", rng.gen::<f64>()); /// println!("{}", rng.gen::<f64>());
/// ``` /// ```
fn reseed(&mut self, Seed); fn reseed(&mut self, Seed);

View file

@ -42,7 +42,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64>
/// use rbml::io::SeekableMemWriter; /// use rbml::io::SeekableMemWriter;
/// ///
/// let mut w = SeekableMemWriter::new(); /// let mut w = SeekableMemWriter::new();
/// w.write([0, 1, 2]); /// w.write(&[0, 1, 2]);
/// ///
/// assert_eq!(w.unwrap(), vec!(0, 1, 2)); /// assert_eq!(w.unwrap(), vec!(0, 1, 2));
/// ``` /// ```
@ -138,32 +138,32 @@ mod tests {
fn test_seekable_mem_writer() { fn test_seekable_mem_writer() {
let mut writer = SeekableMemWriter::new(); let mut writer = SeekableMemWriter::new();
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
writer.write([0]).unwrap(); writer.write(&[0]).unwrap();
assert_eq!(writer.tell(), Ok(1)); assert_eq!(writer.tell(), Ok(1));
writer.write([1, 2, 3]).unwrap(); writer.write(&[1, 2, 3]).unwrap();
writer.write([4, 5, 6, 7]).unwrap(); writer.write(&[4, 5, 6, 7]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
writer.seek(0, io::SeekSet).unwrap(); writer.seek(0, io::SeekSet).unwrap();
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
writer.write([3, 4]).unwrap(); writer.write(&[3, 4]).unwrap();
let b: &[_] = &[3, 4, 2, 3, 4, 5, 6, 7]; let b: &[_] = &[3, 4, 2, 3, 4, 5, 6, 7];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
writer.seek(1, io::SeekCur).unwrap(); writer.seek(1, io::SeekCur).unwrap();
writer.write([0, 1]).unwrap(); writer.write(&[0, 1]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 7]; let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 7];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
writer.seek(-1, io::SeekEnd).unwrap(); writer.seek(-1, io::SeekEnd).unwrap();
writer.write([1, 2]).unwrap(); writer.write(&[1, 2]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2]; let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
writer.seek(1, io::SeekEnd).unwrap(); writer.seek(1, io::SeekEnd).unwrap();
writer.write([1]).unwrap(); writer.write(&[1]).unwrap();
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]; let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
} }
@ -172,7 +172,7 @@ mod tests {
fn seek_past_end() { fn seek_past_end() {
let mut r = SeekableMemWriter::new(); let mut r = SeekableMemWriter::new();
r.seek(10, io::SeekSet).unwrap(); r.seek(10, io::SeekSet).unwrap();
assert!(r.write([3]).is_ok()); assert!(r.write(&[3]).is_ok());
} }
#[test] #[test]

View file

@ -599,7 +599,7 @@ pub mod reader {
f: |&mut Decoder<'doc>, bool| -> DecodeResult<T>) -> DecodeResult<T> { f: |&mut Decoder<'doc>, bool| -> DecodeResult<T>) -> DecodeResult<T> {
debug!("read_option()"); debug!("read_option()");
self.read_enum("Option", |this| { self.read_enum("Option", |this| {
this.read_enum_variant(["None", "Some"], |this, idx| { this.read_enum_variant(&["None", "Some"], |this, idx| {
match idx { match idx {
0 => f(this, false), 0 => f(this, false),
1 => f(this, true), 1 => f(this, true),
@ -1062,7 +1062,7 @@ mod tests {
#[test] #[test]
fn test_vuint_at() { fn test_vuint_at() {
let data = [ let data = &[
0x80, 0x80,
0xff, 0xff,
0x40, 0x00, 0x40, 0x00,

View file

@ -879,7 +879,7 @@ fn link_args(cmd: &mut Command,
v.push_all(morestack.as_vec()); v.push_all(morestack.as_vec());
cmd.arg(v.as_slice()); cmd.arg(v.as_slice());
} else { } else {
cmd.args(["-Wl,--whole-archive", "-lmorestack", "-Wl,--no-whole-archive"]); cmd.args(&["-Wl,--whole-archive", "-lmorestack", "-Wl,--no-whole-archive"]);
} }
} }
@ -997,7 +997,7 @@ fn link_args(cmd: &mut Command,
if dylib { if dylib {
// On mac we need to tell the linker to let this library be rpathed // On mac we need to tell the linker to let this library be rpathed
if sess.target.target.options.is_like_osx { if sess.target.target.options.is_like_osx {
cmd.args(["-dynamiclib", "-Wl,-dylib"]); cmd.args(&["-dynamiclib", "-Wl,-dylib"]);
if sess.opts.cg.rpath { if sess.opts.cg.rpath {
let mut v = "-Wl,-install_name,@rpath/".as_bytes().to_vec(); let mut v = "-Wl,-install_name,@rpath/".as_bytes().to_vec();

View file

@ -886,11 +886,11 @@ mod test {
#[test] #[test]
fn test_switch_implies_cfg_test() { fn test_switch_implies_cfg_test() {
let matches = let matches =
&match getopts(["--test".to_string()], optgroups().as_slice()) { &match getopts(&["--test".to_string()], optgroups().as_slice()) {
Ok(m) => m, Ok(m) => m,
Err(f) => panic!("test_switch_implies_cfg_test: {}", f) Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
}; };
let registry = diagnostics::registry::Registry::new([]); let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(matches); let sessopts = build_session_options(matches);
let sess = build_session(sessopts, None, registry); let sess = build_session(sessopts, None, registry);
let cfg = build_configuration(&sess); let cfg = build_configuration(&sess);
@ -902,14 +902,14 @@ mod test {
#[test] #[test]
fn test_switch_implies_cfg_test_unless_cfg_test() { fn test_switch_implies_cfg_test_unless_cfg_test() {
let matches = let matches =
&match getopts(["--test".to_string(), "--cfg=test".to_string()], &match getopts(&["--test".to_string(), "--cfg=test".to_string()],
optgroups().as_slice()) { optgroups().as_slice()) {
Ok(m) => m, Ok(m) => m,
Err(f) => { Err(f) => {
panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f) panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
} }
}; };
let registry = diagnostics::registry::Registry::new([]); let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(matches); let sessopts = build_session_options(matches);
let sess = build_session(sessopts, None, registry); let sess = build_session(sessopts, None, registry);
let cfg = build_configuration(&sess); let cfg = build_configuration(&sess);

View file

@ -543,7 +543,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
let output_type = write::OutputTypeAssembly; let output_type = write::OutputTypeAssembly;
time(sess.time_passes(), "LLVM passes", (), |_| time(sess.time_passes(), "LLVM passes", (), |_|
write::run_passes(sess, trans, [output_type], outputs)); write::run_passes(sess, trans, &[output_type], outputs));
write::run_assembler(sess, outputs); write::run_assembler(sess, outputs);

View file

@ -48,7 +48,7 @@ fn run_compiler(args: &[String]) {
None => return None => return
}; };
let descriptions = diagnostics::registry::Registry::new(super::DIAGNOSTICS); let descriptions = diagnostics::registry::Registry::new(&super::DIAGNOSTICS);
match matches.opt_str("explain") { match matches.opt_str("explain") {
Some(ref code) => { Some(ref code) => {
match descriptions.find_description(code.as_slice()) { match descriptions.find_description(code.as_slice()) {

View file

@ -345,7 +345,7 @@ fn parse_str(st: &mut PState, term: char) -> String {
let mut result = String::new(); let mut result = String::new();
while peek(st) != term { while peek(st) != term {
unsafe { unsafe {
result.as_mut_vec().push_all([next_byte(st)]) result.as_mut_vec().push_all(&[next_byte(st)])
} }
} }
next(st); next(st);

View file

@ -748,10 +748,10 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
tcx: &ty::ctxt, cdata: &cstore::crate_metadata) tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-> typeck::vtable_origin { -> typeck::vtable_origin {
self.read_enum("vtable_origin", |this| { self.read_enum("vtable_origin", |this| {
this.read_enum_variant(["vtable_static", this.read_enum_variant(&["vtable_static",
"vtable_param", "vtable_param",
"vtable_error", "vtable_error",
"vtable_unboxed_closure"], "vtable_unboxed_closure"],
|this, i| { |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
@ -1401,8 +1401,8 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
-> typeck::MethodOrigin -> typeck::MethodOrigin
{ {
self.read_enum("MethodOrigin", |this| { self.read_enum("MethodOrigin", |this| {
let variants = ["MethodStatic", "MethodStaticUnboxedClosure", let variants = &["MethodStatic", "MethodStaticUnboxedClosure",
"MethodTypeParam", "MethodTraitObject"]; "MethodTypeParam", "MethodTraitObject"];
this.read_enum_variant(variants, |this, i| { this.read_enum_variant(variants, |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
@ -1576,7 +1576,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
fn read_auto_adjustment(&mut self, dcx: &DecodeContext) -> ty::AutoAdjustment { fn read_auto_adjustment(&mut self, dcx: &DecodeContext) -> ty::AutoAdjustment {
self.read_enum("AutoAdjustment", |this| { self.read_enum("AutoAdjustment", |this| {
let variants = ["AutoAddEnv", "AutoDerefRef"]; let variants = ["AutoAddEnv", "AutoDerefRef"];
this.read_enum_variant(variants, |this, i| { this.read_enum_variant(&variants, |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
let store: ty::TraitStore = let store: ty::TraitStore =
@ -1622,7 +1622,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
"AutoUnsize", "AutoUnsize",
"AutoUnsizeUniq", "AutoUnsizeUniq",
"AutoUnsafe"]; "AutoUnsafe"];
this.read_enum_variant(variants, |this, i| { this.read_enum_variant(&variants, |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
let r: ty::Region = let r: ty::Region =
@ -1676,7 +1676,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
fn read_unsize_kind(&mut self, dcx: &DecodeContext) -> ty::UnsizeKind { fn read_unsize_kind(&mut self, dcx: &DecodeContext) -> ty::UnsizeKind {
self.read_enum("UnsizeKind", |this| { self.read_enum("UnsizeKind", |this| {
let variants = ["UnsizeLength", "UnsizeStruct", "UnsizeVtable"]; let variants = &["UnsizeLength", "UnsizeStruct", "UnsizeVtable"];
this.read_enum_variant(variants, |this, i| { this.read_enum_variant(variants, |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
@ -1726,7 +1726,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
dcx.tcx, dcx.tcx,
|s, a| this.convert_def_id(dcx, s, a))) |s, a| this.convert_def_id(dcx, s, a)))
}).unwrap(); }).unwrap();
let variants = [ let variants = &[
"FnUnboxedClosureKind", "FnUnboxedClosureKind",
"FnMutUnboxedClosureKind", "FnMutUnboxedClosureKind",
"FnOnceUnboxedClosureKind" "FnOnceUnboxedClosureKind"

View file

@ -73,19 +73,19 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let expr_exit = self.opt_expr(&blk.expr, stmts_exit); let expr_exit = self.opt_expr(&blk.expr, stmts_exit);
self.add_node(blk.id, [expr_exit]) self.add_node(blk.id, &[expr_exit])
} }
fn stmt(&mut self, stmt: &ast::Stmt, pred: CFGIndex) -> CFGIndex { fn stmt(&mut self, stmt: &ast::Stmt, pred: CFGIndex) -> CFGIndex {
match stmt.node { match stmt.node {
ast::StmtDecl(ref decl, id) => { ast::StmtDecl(ref decl, id) => {
let exit = self.decl(&**decl, pred); let exit = self.decl(&**decl, pred);
self.add_node(id, [exit]) self.add_node(id, &[exit])
} }
ast::StmtExpr(ref expr, id) | ast::StmtSemi(ref expr, id) => { ast::StmtExpr(ref expr, id) | ast::StmtSemi(ref expr, id) => {
let exit = self.expr(&**expr, pred); let exit = self.expr(&**expr, pred);
self.add_node(id, [exit]) self.add_node(id, &[exit])
} }
ast::StmtMac(..) => { ast::StmtMac(..) => {
@ -114,33 +114,33 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
ast::PatLit(..) | ast::PatLit(..) |
ast::PatRange(..) | ast::PatRange(..) |
ast::PatWild(_) => { ast::PatWild(_) => {
self.add_node(pat.id, [pred]) self.add_node(pat.id, &[pred])
} }
ast::PatBox(ref subpat) | ast::PatBox(ref subpat) |
ast::PatRegion(ref subpat) | ast::PatRegion(ref subpat) |
ast::PatIdent(_, _, Some(ref subpat)) => { ast::PatIdent(_, _, Some(ref subpat)) => {
let subpat_exit = self.pat(&**subpat, pred); let subpat_exit = self.pat(&**subpat, pred);
self.add_node(pat.id, [subpat_exit]) self.add_node(pat.id, &[subpat_exit])
} }
ast::PatEnum(_, Some(ref subpats)) | ast::PatEnum(_, Some(ref subpats)) |
ast::PatTup(ref subpats) => { ast::PatTup(ref subpats) => {
let pats_exit = self.pats_all(subpats.iter(), pred); let pats_exit = self.pats_all(subpats.iter(), pred);
self.add_node(pat.id, [pats_exit]) self.add_node(pat.id, &[pats_exit])
} }
ast::PatStruct(_, ref subpats, _) => { ast::PatStruct(_, ref subpats, _) => {
let pats_exit = let pats_exit =
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred); self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
self.add_node(pat.id, [pats_exit]) self.add_node(pat.id, &[pats_exit])
} }
ast::PatVec(ref pre, ref vec, ref post) => { ast::PatVec(ref pre, ref vec, ref post) => {
let pre_exit = self.pats_all(pre.iter(), pred); let pre_exit = self.pats_all(pre.iter(), pred);
let vec_exit = self.pats_all(vec.iter(), pre_exit); let vec_exit = self.pats_all(vec.iter(), pre_exit);
let post_exit = self.pats_all(post.iter(), vec_exit); let post_exit = self.pats_all(post.iter(), vec_exit);
self.add_node(pat.id, [post_exit]) self.add_node(pat.id, &[post_exit])
} }
ast::PatMac(_) => { ast::PatMac(_) => {
@ -165,7 +165,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
if pats.len() == 1 { if pats.len() == 1 {
self.pat(&*pats[0], pred) self.pat(&*pats[0], pred)
} else { } else {
let collect = self.add_dummy_node([]); let collect = self.add_dummy_node(&[]);
for pat in pats.iter() { for pat in pats.iter() {
let pat_exit = self.pat(&**pat, pred); let pat_exit = self.pat(&**pat, pred);
self.add_contained_edge(pat_exit, collect); self.add_contained_edge(pat_exit, collect);
@ -178,7 +178,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
match expr.node { match expr.node {
ast::ExprBlock(ref blk) => { ast::ExprBlock(ref blk) => {
let blk_exit = self.block(&**blk, pred); let blk_exit = self.block(&**blk, pred);
self.add_node(expr.id, [blk_exit]) self.add_node(expr.id, &[blk_exit])
} }
ast::ExprIf(ref cond, ref then, None) => { ast::ExprIf(ref cond, ref then, None) => {
@ -198,7 +198,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// //
let cond_exit = self.expr(&**cond, pred); // 1 let cond_exit = self.expr(&**cond, pred); // 1
let then_exit = self.block(&**then, cond_exit); // 2 let then_exit = self.block(&**then, cond_exit); // 2
self.add_node(expr.id, [cond_exit, then_exit]) // 3,4 self.add_node(expr.id, &[cond_exit, then_exit]) // 3,4
} }
ast::ExprIf(ref cond, ref then, Some(ref otherwise)) => { ast::ExprIf(ref cond, ref then, Some(ref otherwise)) => {
@ -219,7 +219,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let cond_exit = self.expr(&**cond, pred); // 1 let cond_exit = self.expr(&**cond, pred); // 1
let then_exit = self.block(&**then, cond_exit); // 2 let then_exit = self.block(&**then, cond_exit); // 2
let else_exit = self.expr(&**otherwise, cond_exit); // 3 let else_exit = self.expr(&**otherwise, cond_exit); // 3
self.add_node(expr.id, [then_exit, else_exit]) // 4, 5 self.add_node(expr.id, &[then_exit, else_exit]) // 4, 5
} }
ast::ExprIfLet(..) => { ast::ExprIfLet(..) => {
@ -245,9 +245,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// may cause additional edges. // may cause additional edges.
// Is the condition considered part of the loop? // Is the condition considered part of the loop?
let loopback = self.add_dummy_node([pred]); // 1 let loopback = self.add_dummy_node(&[pred]); // 1
let cond_exit = self.expr(&**cond, loopback); // 2 let cond_exit = self.expr(&**cond, loopback); // 2
let expr_exit = self.add_node(expr.id, [cond_exit]); // 3 let expr_exit = self.add_node(expr.id, &[cond_exit]); // 3
self.loop_scopes.push(LoopScope { self.loop_scopes.push(LoopScope {
loop_id: expr.id, loop_id: expr.id,
continue_index: loopback, continue_index: loopback,
@ -286,10 +286,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// Note that `break` and `continue` statements // Note that `break` and `continue` statements
// may cause additional edges. // may cause additional edges.
let head = self.expr(&**head, pred); // 1 let head = self.expr(&**head, pred); // 1
let loopback = self.add_dummy_node([head]); // 2 let loopback = self.add_dummy_node(&[head]); // 2
let cond = self.add_dummy_node([loopback]); // 3 let cond = self.add_dummy_node(&[loopback]); // 3
let expr_exit = self.add_node(expr.id, [cond]); // 4 let expr_exit = self.add_node(expr.id, &[cond]); // 4
self.loop_scopes.push(LoopScope { self.loop_scopes.push(LoopScope {
loop_id: expr.id, loop_id: expr.id,
continue_index: loopback, continue_index: loopback,
@ -317,8 +317,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// Note that `break` and `loop` statements // Note that `break` and `loop` statements
// may cause additional edges. // may cause additional edges.
let loopback = self.add_dummy_node([pred]); // 1 let loopback = self.add_dummy_node(&[pred]); // 1
let expr_exit = self.add_node(expr.id, []); // 2 let expr_exit = self.add_node(expr.id, &[]); // 2
self.loop_scopes.push(LoopScope { self.loop_scopes.push(LoopScope {
loop_id: expr.id, loop_id: expr.id,
continue_index: loopback, continue_index: loopback,
@ -358,10 +358,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// //
let discr_exit = self.expr(&**discr, pred); // 1 let discr_exit = self.expr(&**discr, pred); // 1
let expr_exit = self.add_node(expr.id, []); let expr_exit = self.add_node(expr.id, &[]);
let mut cond_exit = discr_exit; let mut cond_exit = discr_exit;
for arm in arms.iter() { for arm in arms.iter() {
cond_exit = self.add_dummy_node([cond_exit]); // 2 cond_exit = self.add_dummy_node(&[cond_exit]); // 2
let pats_exit = self.pats_any(arm.pats.as_slice(), let pats_exit = self.pats_any(arm.pats.as_slice(),
cond_exit); // 3 cond_exit); // 3
let guard_exit = self.opt_expr(&arm.guard, let guard_exit = self.opt_expr(&arm.guard,
@ -389,30 +389,30 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// //
let l_exit = self.expr(&**l, pred); // 1 let l_exit = self.expr(&**l, pred); // 1
let r_exit = self.expr(&**r, l_exit); // 2 let r_exit = self.expr(&**r, l_exit); // 2
self.add_node(expr.id, [l_exit, r_exit]) // 3,4 self.add_node(expr.id, &[l_exit, r_exit]) // 3,4
} }
ast::ExprRet(ref v) => { ast::ExprRet(ref v) => {
let v_exit = self.opt_expr(v, pred); let v_exit = self.opt_expr(v, pred);
let b = self.add_node(expr.id, [v_exit]); let b = self.add_node(expr.id, &[v_exit]);
self.add_returning_edge(expr, b); self.add_returning_edge(expr, b);
self.add_node(ast::DUMMY_NODE_ID, []) self.add_node(ast::DUMMY_NODE_ID, &[])
} }
ast::ExprBreak(label) => { ast::ExprBreak(label) => {
let loop_scope = self.find_scope(expr, label); let loop_scope = self.find_scope(expr, label);
let b = self.add_node(expr.id, [pred]); let b = self.add_node(expr.id, &[pred]);
self.add_exiting_edge(expr, b, self.add_exiting_edge(expr, b,
loop_scope, loop_scope.break_index); loop_scope, loop_scope.break_index);
self.add_node(ast::DUMMY_NODE_ID, []) self.add_node(ast::DUMMY_NODE_ID, &[])
} }
ast::ExprAgain(label) => { ast::ExprAgain(label) => {
let loop_scope = self.find_scope(expr, label); let loop_scope = self.find_scope(expr, label);
let a = self.add_node(expr.id, [pred]); let a = self.add_node(expr.id, &[pred]);
self.add_exiting_edge(expr, a, self.add_exiting_edge(expr, a,
loop_scope, loop_scope.continue_index); loop_scope, loop_scope.continue_index);
self.add_node(ast::DUMMY_NODE_ID, []) self.add_node(ast::DUMMY_NODE_ID, &[])
} }
ast::ExprVec(ref elems) => { ast::ExprVec(ref elems) => {
@ -492,7 +492,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let &(_, ref expr, _) = a; let &(_, ref expr, _) = a;
&**expr &**expr
}), post_inputs); }), post_inputs);
self.add_node(expr.id, [post_outputs]) self.add_node(expr.id, &[post_outputs])
} }
ast::ExprMac(..) | ast::ExprMac(..) |
@ -520,7 +520,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred); let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
let ret = self.straightline(call_expr, func_or_rcvr_exit, args); let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
if return_ty == ty::FnDiverging { if return_ty == ty::FnDiverging {
self.add_node(ast::DUMMY_NODE_ID, []) self.add_node(ast::DUMMY_NODE_ID, &[])
} else { } else {
ret ret
} }
@ -547,7 +547,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
//! Handles case of an expression that evaluates `subexprs` in order //! Handles case of an expression that evaluates `subexprs` in order
let subexprs_exit = self.exprs(subexprs, pred); let subexprs_exit = self.exprs(subexprs, pred);
self.add_node(expr.id, [subexprs_exit]) self.add_node(expr.id, &[subexprs_exit])
} }
fn add_dummy_node(&mut self, preds: &[CFGIndex]) -> CFGIndex { fn add_dummy_node(&mut self, preds: &[CFGIndex]) -> CFGIndex {

View file

@ -40,7 +40,7 @@ fn replace_newline_with_backslash_l(s: String) -> String {
let mut last_two: Vec<_> = let mut last_two: Vec<_> =
s.as_slice().chars().rev().take(2).collect(); s.as_slice().chars().rev().take(2).collect();
last_two.reverse(); last_two.reverse();
if last_two.as_slice() != ['\\', 'l'] { if last_two.as_slice() != &['\\', 'l'] {
s.push_str("\\l"); s.push_str("\\l");
} }
s s

View file

@ -932,7 +932,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
fn is_refutable<A>(cx: &MatchCheckCtxt, pat: &Pat, refutable: |&Pat| -> A) -> Option<A> { fn is_refutable<A>(cx: &MatchCheckCtxt, pat: &Pat, refutable: |&Pat| -> A) -> Option<A> {
let pats = Matrix(vec!(vec!(pat))); let pats = Matrix(vec!(vec!(pat)));
match is_useful(cx, &pats, [DUMMY_WILD_PAT], ConstructWitness) { match is_useful(cx, &pats, &[DUMMY_WILD_PAT], ConstructWitness) {
UsefulWithWitness(pats) => { UsefulWithWitness(pats) => {
assert_eq!(pats.len(), 1); assert_eq!(pats.len(), 1);
Some(refutable(&*pats[0])) Some(refutable(&*pats[0]))

View file

@ -419,31 +419,31 @@ mod test {
fn each_adjacent_from_a() { fn each_adjacent_from_a() {
let graph = create_graph(); let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(0), "A", test_adjacent_edges(&graph, NodeIndex(0), "A",
[], &[],
[("AB", "B")]); &[("AB", "B")]);
} }
#[test] #[test]
fn each_adjacent_from_b() { fn each_adjacent_from_b() {
let graph = create_graph(); let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(1), "B", test_adjacent_edges(&graph, NodeIndex(1), "B",
[("FB", "F"), ("AB", "A"),], &[("FB", "F"), ("AB", "A"),],
[("BD", "D"), ("BC", "C"),]); &[("BD", "D"), ("BC", "C"),]);
} }
#[test] #[test]
fn each_adjacent_from_c() { fn each_adjacent_from_c() {
let graph = create_graph(); let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(2), "C", test_adjacent_edges(&graph, NodeIndex(2), "C",
[("EC", "E"), ("BC", "B")], &[("EC", "E"), ("BC", "B")],
[]); &[]);
} }
#[test] #[test]
fn each_adjacent_from_d() { fn each_adjacent_from_d() {
let graph = create_graph(); let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(3), "D", test_adjacent_edges(&graph, NodeIndex(3), "D",
[("BD", "B")], &[("BD", "B")],
[("DE", "E")]); &[("DE", "E")]);
} }
} }

View file

@ -57,7 +57,7 @@ pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
* `supertraits(Baz)` yields `[Baz, Bar, Foo, Foo]` in some order. * `supertraits(Baz)` yields `[Baz, Bar, Foo, Foo]` in some order.
*/ */
transitive_bounds(tcx, [trait_ref]) transitive_bounds(tcx, &[trait_ref])
} }
pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>, pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,

View file

@ -643,8 +643,8 @@ fn bind_subslice_pat(bcx: Block,
ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable}); ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable});
let scratch = rvalue_scratch_datum(bcx, slice_ty, ""); let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
Store(bcx, slice_begin, Store(bcx, slice_begin,
GEPi(bcx, scratch.val, [0u, abi::slice_elt_base])); GEPi(bcx, scratch.val, &[0u, abi::slice_elt_base]));
Store(bcx, slice_len, GEPi(bcx, scratch.val, [0u, abi::slice_elt_len])); Store(bcx, slice_len, GEPi(bcx, scratch.val, &[0u, abi::slice_elt_len]));
scratch.val scratch.val
} }
@ -658,9 +658,9 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let vec_datum = match_datum(val, left_ty); let vec_datum = match_datum(val, left_ty);
let (base, len) = vec_datum.get_vec_base_and_len(bcx); let (base, len) = vec_datum.get_vec_base_and_len(bcx);
let mut elems = vec![]; let mut elems = vec![];
elems.extend(range(0, before).map(|i| GEPi(bcx, base, [i]))); elems.extend(range(0, before).map(|i| GEPi(bcx, base, &[i])));
elems.extend(range(0, after).rev().map(|i| { elems.extend(range(0, after).rev().map(|i| {
InBoundsGEP(bcx, base, [ InBoundsGEP(bcx, base, &[
Sub(bcx, len, C_uint(bcx.ccx(), i + 1)) Sub(bcx, len, C_uint(bcx.ccx(), i + 1))
]) ])
})); }));
@ -796,7 +796,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
format!("comparison of `{}`", format!("comparison of `{}`",
cx.ty_to_string(rhs_t)).as_slice(), cx.ty_to_string(rhs_t)).as_slice(),
StrEqFnLangItem); StrEqFnLangItem);
callee::trans_lang_call(cx, did, [lhs, rhs], None) callee::trans_lang_call(cx, did, &[lhs, rhs], None)
} }
let _icx = push_ctxt("compare_values"); let _icx = push_ctxt("compare_values");
@ -1390,7 +1390,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
&& arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle) && arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle)
}); });
compile_submatch(bcx, matches.as_slice(), [discr_datum.val], &chk, has_default); compile_submatch(bcx, matches.as_slice(), &[discr_datum.val], &chk, has_default);
let mut arm_cxs = Vec::new(); let mut arm_cxs = Vec::new();
for arm_data in arm_datas.iter() { for arm_data in arm_datas.iter() {

View file

@ -635,7 +635,7 @@ pub fn trans_get_discr(bcx: Block, r: &Repr, scrutinee: ValueRef, cast_to: Optio
signed = ity.is_signed(); signed = ity.is_signed();
} }
General(ity, ref cases, _) => { General(ity, ref cases, _) => {
let ptr = GEPi(bcx, scrutinee, [0, 0]); let ptr = GEPi(bcx, scrutinee, &[0, 0]);
val = load_discr(bcx, ity, ptr, 0, (cases.len() - 1) as Disr); val = load_discr(bcx, ity, ptr, 0, (cases.len() - 1) as Disr);
signed = ity.is_signed(); signed = ity.is_signed();
} }
@ -663,8 +663,8 @@ pub fn trans_get_discr(bcx: Block, r: &Repr, scrutinee: ValueRef, cast_to: Optio
fn struct_wrapped_nullable_bitdiscr(bcx: Block, nndiscr: Disr, ptrfield: PointerField, fn struct_wrapped_nullable_bitdiscr(bcx: Block, nndiscr: Disr, ptrfield: PointerField,
scrutinee: ValueRef) -> ValueRef { scrutinee: ValueRef) -> ValueRef {
let llptrptr = match ptrfield { let llptrptr = match ptrfield {
ThinPointer(field) => GEPi(bcx, scrutinee, [0, field]), ThinPointer(field) => GEPi(bcx, scrutinee, &[0, field]),
FatPointer(field) => GEPi(bcx, scrutinee, [0, field, slice_elt_base]) FatPointer(field) => GEPi(bcx, scrutinee, &[0, field, slice_elt_base])
}; };
let llptr = Load(bcx, llptrptr); let llptr = Load(bcx, llptrptr);
let cmp = if nndiscr == 0 { IntEQ } else { IntNE }; let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
@ -739,13 +739,13 @@ pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) {
Store(bcx, C_u8(bcx.ccx(), 1), ptr); Store(bcx, C_u8(bcx.ccx(), 1), ptr);
} }
Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr as u64, true), Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr as u64, true),
GEPi(bcx, val, [0, 0])) GEPi(bcx, val, &[0, 0]))
} }
Univariant(ref st, dtor) => { Univariant(ref st, dtor) => {
assert_eq!(discr, 0); assert_eq!(discr, 0);
if dtor { if dtor {
Store(bcx, C_u8(bcx.ccx(), 1), Store(bcx, C_u8(bcx.ccx(), 1),
GEPi(bcx, val, [0, st.fields.len() - 1])); GEPi(bcx, val, &[0, st.fields.len() - 1]));
} }
} }
RawNullablePointer { nndiscr, nnty, ..} => { RawNullablePointer { nndiscr, nnty, ..} => {
@ -758,10 +758,10 @@ pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) {
if discr != nndiscr { if discr != nndiscr {
let (llptrptr, llptrty) = match ptrfield { let (llptrptr, llptrty) = match ptrfield {
ThinPointer(field) => ThinPointer(field) =>
(GEPi(bcx, val, [0, field]), (GEPi(bcx, val, &[0, field]),
type_of::type_of(bcx.ccx(), nonnull.fields[field])), type_of::type_of(bcx.ccx(), nonnull.fields[field])),
FatPointer(field) => { FatPointer(field) => {
let v = GEPi(bcx, val, [0, field, slice_elt_base]); let v = GEPi(bcx, val, &[0, field, slice_elt_base]);
(v, val_ty(v).element_type()) (v, val_ty(v).element_type())
} }
}; };
@ -853,7 +853,7 @@ pub fn struct_field_ptr(bcx: Block, st: &Struct, val: ValueRef,
val val
}; };
GEPi(bcx, val, [0, ix]) GEPi(bcx, val, &[0, ix])
} }
pub fn fold_variants<'blk, 'tcx>( pub fn fold_variants<'blk, 'tcx>(
@ -902,7 +902,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr, val
let ptr_ty = ty::mk_imm_ptr(bcx.tcx(), ty::mk_bool()); let ptr_ty = ty::mk_imm_ptr(bcx.tcx(), ty::mk_bool());
match *r { match *r {
Univariant(ref st, true) => { Univariant(ref st, true) => {
let flag_ptr = GEPi(bcx, val, [0, st.fields.len() - 1]); let flag_ptr = GEPi(bcx, val, &[0, st.fields.len() - 1]);
datum::immediate_rvalue_bcx(bcx, flag_ptr, ptr_ty).to_expr_datumblock() datum::immediate_rvalue_bcx(bcx, flag_ptr, ptr_ty).to_expr_datumblock()
} }
General(_, _, true) => { General(_, _, true) => {
@ -961,7 +961,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
let mut f = vec![lldiscr]; let mut f = vec![lldiscr];
f.push_all(vals); f.push_all(vals);
let mut contents = build_const_struct(ccx, case, f.as_slice()); let mut contents = build_const_struct(ccx, case, f.as_slice());
contents.push_all([padding(ccx, max_sz - case.size)]); contents.push_all(&[padding(ccx, max_sz - case.size)]);
C_struct(ccx, contents.as_slice(), false) C_struct(ccx, contents.as_slice(), false)
} }
Univariant(ref st, _dro) => { Univariant(ref st, _dro) => {
@ -1079,8 +1079,8 @@ pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef)
} }
General(ity, _, _) => { General(ity, _, _) => {
match ity { match ity {
attr::SignedInt(..) => const_to_int(const_get_elt(ccx, val, [0])) as Disr, attr::SignedInt(..) => const_to_int(const_get_elt(ccx, val, &[0])) as Disr,
attr::UnsignedInt(..) => const_to_uint(const_get_elt(ccx, val, [0])) as Disr attr::UnsignedInt(..) => const_to_uint(const_get_elt(ccx, val, &[0])) as Disr
} }
} }
Univariant(..) => 0, Univariant(..) => 0,
@ -1138,8 +1138,8 @@ fn const_struct_field(ccx: &CrateContext, val: ValueRef, ix: uint, sub_idx: Opti
loop { loop {
loop { loop {
field = match sub_idx { field = match sub_idx {
Some(si) => const_get_elt(ccx, val, [real_ix, si as u32]), Some(si) => const_get_elt(ccx, val, &[real_ix, si as u32]),
None => const_get_elt(ccx, val, [real_ix]) None => const_get_elt(ccx, val, &[real_ix])
}; };
if !is_undef(field) { if !is_undef(field) {
break; break;

View file

@ -337,7 +337,7 @@ pub fn at_box_body(bcx: Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef {
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let ty = Type::at_box(ccx, type_of(ccx, body_t)); let ty = Type::at_box(ccx, type_of(ccx, body_t));
let boxptr = PointerCast(bcx, boxptr, ty.ptr_to()); let boxptr = PointerCast(bcx, boxptr, ty.ptr_to());
GEPi(bcx, boxptr, [0u, abi::box_field_body]) GEPi(bcx, boxptr, &[0u, abi::box_field_body])
} }
fn require_alloc_fn(bcx: Block, info_ty: ty::t, it: LangItem) -> ast::DefId { fn require_alloc_fn(bcx: Block, info_ty: ty::t, it: LangItem) -> ast::DefId {
@ -365,7 +365,7 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Allocate space: // Allocate space:
let r = callee::trans_lang_call(bcx, let r = callee::trans_lang_call(bcx,
require_alloc_fn(bcx, info_ty, ExchangeMallocFnLangItem), require_alloc_fn(bcx, info_ty, ExchangeMallocFnLangItem),
[size, align], &[size, align],
None); None);
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr)) Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
@ -385,7 +385,7 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu
// Allocate space and store the destructor pointer: // Allocate space and store the destructor pointer:
let Result {bcx, val: llbox} = malloc_raw_dyn(bcx, ptr_llty, t, size, llalign); let Result {bcx, val: llbox} = malloc_raw_dyn(bcx, ptr_llty, t, size, llalign);
let dtor_ptr = GEPi(bcx, llbox, [0u, abi::box_field_drop_glue]); let dtor_ptr = GEPi(bcx, llbox, &[0u, abi::box_field_drop_glue]);
let drop_glue_field_ty = type_of(ccx, ty::mk_nil_ptr(bcx.tcx())); let drop_glue_field_ty = type_of(ccx, ty::mk_nil_ptr(bcx.tcx()));
let drop_glue = PointerCast(bcx, glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t)), let drop_glue = PointerCast(bcx, glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t)),
drop_glue_field_ty); drop_glue_field_ty);
@ -517,7 +517,7 @@ pub fn get_res_dtor(ccx: &CrateContext,
let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs); let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs);
let llty = type_of_dtor(ccx, class_ty); let llty = type_of_dtor(ccx, class_ty);
let dtor_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID, let dtor_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID,
[glue::get_drop_glue_type(ccx, t)], ty::mk_nil(ccx.tcx())); &[glue::get_drop_glue_type(ccx, t)], ty::mk_nil(ccx.tcx()));
get_extern_fn(ccx, get_extern_fn(ccx,
&mut *ccx.externs().borrow_mut(), &mut *ccx.externs().borrow_mut(),
name.as_slice(), name.as_slice(),
@ -694,8 +694,8 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
let (data_ptr, info) = if ty::type_is_sized(cx.tcx(), t) { let (data_ptr, info) = if ty::type_is_sized(cx.tcx(), t) {
(av, None) (av, None)
} else { } else {
let data = GEPi(cx, av, [0, abi::slice_elt_base]); let data = GEPi(cx, av, &[0, abi::slice_elt_base]);
let info = GEPi(cx, av, [0, abi::slice_elt_len]); let info = GEPi(cx, av, &[0, abi::slice_elt_len]);
(Load(cx, data), Some(Load(cx, info))) (Load(cx, data), Some(Load(cx, info)))
}; };
@ -713,8 +713,8 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
} else { } else {
let boxed_ty = ty::mk_open(cx.tcx(), field_ty); let boxed_ty = ty::mk_open(cx.tcx(), field_ty);
let scratch = datum::rvalue_scratch_datum(cx, boxed_ty, "__fat_ptr_iter"); let scratch = datum::rvalue_scratch_datum(cx, boxed_ty, "__fat_ptr_iter");
Store(cx, llfld_a, GEPi(cx, scratch.val, [0, abi::slice_elt_base])); Store(cx, llfld_a, GEPi(cx, scratch.val, &[0, abi::slice_elt_base]));
Store(cx, info.unwrap(), GEPi(cx, scratch.val, [0, abi::slice_elt_len])); Store(cx, info.unwrap(), GEPi(cx, scratch.val, &[0, abi::slice_elt_len]));
scratch.val scratch.val
}; };
cx = f(cx, val, field_ty); cx = f(cx, val, field_ty);
@ -1110,7 +1110,7 @@ pub fn call_lifetime_start(cx: Block, ptr: ValueRef) {
let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type())); let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
let ptr = PointerCast(cx, ptr, Type::i8p(ccx)); let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
let lifetime_start = ccx.get_intrinsic(&"llvm.lifetime.start"); let lifetime_start = ccx.get_intrinsic(&"llvm.lifetime.start");
Call(cx, lifetime_start, [llsize, ptr], None); Call(cx, lifetime_start, &[llsize, ptr], None);
} }
pub fn call_lifetime_end(cx: Block, ptr: ValueRef) { pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
@ -1124,7 +1124,7 @@ pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type())); let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
let ptr = PointerCast(cx, ptr, Type::i8p(ccx)); let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
let lifetime_end = ccx.get_intrinsic(&"llvm.lifetime.end"); let lifetime_end = ccx.get_intrinsic(&"llvm.lifetime.end");
Call(cx, lifetime_end, [llsize, ptr], None); Call(cx, lifetime_end, &[llsize, ptr], None);
} }
pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) { pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
@ -1141,7 +1141,7 @@ pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, a
let size = IntCast(cx, n_bytes, ccx.int_type()); let size = IntCast(cx, n_bytes, ccx.int_type());
let align = C_i32(ccx, align as i32); let align = C_i32(ccx, align as i32);
let volatile = C_bool(ccx, false); let volatile = C_bool(ccx, false);
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], None); Call(cx, memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
} }
pub fn memcpy_ty(bcx: Block, dst: ValueRef, src: ValueRef, t: ty::t) { pub fn memcpy_ty(bcx: Block, dst: ValueRef, src: ValueRef, t: ty::t) {
@ -1187,7 +1187,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: ty::t) {
let size = machine::llsize_of(ccx, llty); let size = machine::llsize_of(ccx, llty);
let align = C_i32(ccx, type_of::align_of(ccx, ty) as i32); let align = C_i32(ccx, type_of::align_of(ccx, ty) as i32);
let volatile = C_bool(ccx, false); let volatile = C_bool(ccx, false);
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], None); b.call(llintrinsicfn, &[llptr, llzeroval, size, align, volatile], None);
} }
pub fn alloc_ty(bcx: Block, t: ty::t, name: &str) -> ValueRef { pub fn alloc_ty(bcx: Block, t: ty::t, name: &str) -> ValueRef {
@ -1563,7 +1563,7 @@ fn create_datums_for_fn_args_under_call_abi(
let llarg = let llarg =
get_param(bcx.fcx.llfn, get_param(bcx.fcx.llfn,
bcx.fcx.arg_pos(i + j) as c_uint); bcx.fcx.arg_pos(i + j) as c_uint);
let lldest = GEPi(bcx, llval, [0, j]); let lldest = GEPi(bcx, llval, &[0, j]);
let datum = datum::Datum::new( let datum = datum::Datum::new(
llarg, llarg,
tupled_arg_ty, tupled_arg_ty,
@ -1654,7 +1654,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
let tuple_element_datum = let tuple_element_datum =
tuple_datum.get_element(bcx, tuple_datum.get_element(bcx,
tuple_element_type, tuple_element_type,
|llval| GEPi(bcx, llval, [0, j])); |llval| GEPi(bcx, llval, &[0, j]));
let tuple_element_datum = tuple_element_datum.to_expr_datum(); let tuple_element_datum = tuple_element_datum.to_expr_datum();
let tuple_element_datum = let tuple_element_datum =
unpack_datum!(bcx, unpack_datum!(bcx,
@ -2551,7 +2551,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
fn create_entry_fn(ccx: &CrateContext, fn create_entry_fn(ccx: &CrateContext,
rust_main: ValueRef, rust_main: ValueRef,
use_start_lang_item: bool) { use_start_lang_item: bool) {
let llfty = Type::func([ccx.int_type(), Type::i8p(ccx).ptr_to()], let llfty = Type::func(&[ccx.int_type(), Type::i8p(ccx).ptr_to()],
&ccx.int_type()); &ccx.int_type());
let llfn = decl_cdecl_fn(ccx, "main", llfty, ty::mk_nil(ccx.tcx())); let llfn = decl_cdecl_fn(ccx, "main", llfty, ty::mk_nil(ccx.tcx()));
@ -2908,7 +2908,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
None => cx.sess().fatal("failed to compress metadata"), None => cx.sess().fatal("failed to compress metadata"),
}.as_slice()); }.as_slice());
let llmeta = C_bytes_in_context(cx.metadata_llcx(), compressed.as_slice()); let llmeta = C_bytes_in_context(cx.metadata_llcx(), compressed.as_slice());
let llconst = C_struct_in_context(cx.metadata_llcx(), [llmeta], false); let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
let name = format!("rust_metadata_{}_{}", let name = format!("rust_metadata_{}_{}",
cx.link_meta().crate_name, cx.link_meta().crate_name,
cx.link_meta().crate_hash); cx.link_meta().crate_hash);

View file

@ -776,11 +776,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.count_insn("inlineasm"); self.count_insn("inlineasm");
let asm = comment_text.as_slice().with_c_str(|c| { let asm = comment_text.as_slice().with_c_str(|c| {
unsafe { unsafe {
llvm::LLVMConstInlineAsm(Type::func([], &Type::void(self.ccx)).to_ref(), llvm::LLVMConstInlineAsm(Type::func(&[], &Type::void(self.ccx)).to_ref(),
c, noname(), False, False) c, noname(), False, False)
} }
}); });
self.call(asm, [], None); self.call(asm, &[], None);
} }
} }
@ -930,7 +930,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
llvm::LLVMGetNamedFunction(m, buf) llvm::LLVMGetNamedFunction(m, buf)
}); });
assert!((t as int != 0)); assert!((t as int != 0));
let args: &[ValueRef] = []; let args: &[ValueRef] = &[];
self.count_insn("trap"); self.count_insn("trap");
llvm::LLVMBuildCall( llvm::LLVMBuildCall(
self.llbuilder, t, args.as_ptr(), args.len() as c_uint, noname()); self.llbuilder, t, args.as_ptr(), args.len() as c_uint, noname());

View file

@ -721,9 +721,9 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Closures are represented as (llfn, llclosure) pair: // Closures are represented as (llfn, llclosure) pair:
// load the requisite values out. // load the requisite values out.
let pair = d.to_llref(); let pair = d.to_llref();
let llfn = GEPi(bcx, pair, [0u, abi::fn_field_code]); let llfn = GEPi(bcx, pair, &[0u, abi::fn_field_code]);
let llfn = Load(bcx, llfn); let llfn = Load(bcx, llfn);
let llenv = GEPi(bcx, pair, [0u, abi::fn_field_box]); let llenv = GEPi(bcx, pair, &[0u, abi::fn_field_box]);
let llenv = Load(bcx, llenv); let llenv = Load(bcx, llenv);
(llfn, Some(llenv), None) (llfn, Some(llenv), None)
} }

View file

@ -785,7 +785,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
// this represents but it's determined by the personality function and // this represents but it's determined by the personality function and
// this is what the EH proposal example uses. // this is what the EH proposal example uses.
let llretty = Type::struct_(self.ccx, let llretty = Type::struct_(self.ccx,
[Type::i8p(self.ccx), Type::i32(self.ccx)], &[Type::i8p(self.ccx), Type::i32(self.ccx)],
false); false);
// The exception handling personality function. // The exception handling personality function.

View file

@ -207,7 +207,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
bv.to_string(ccx)).as_slice()); bv.to_string(ccx)).as_slice());
} }
let bound_data = GEPi(bcx, llbox, [0u, abi::box_field_body, i]); let bound_data = GEPi(bcx, llbox, &[0u, abi::box_field_body, i]);
match bv.action { match bv.action {
ast::CaptureByValue => { ast::CaptureByValue => {
@ -275,7 +275,7 @@ fn load_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Populate the upvars from the environment // Populate the upvars from the environment
let mut i = 0u; let mut i = 0u;
for freevar in freevars.iter() { for freevar in freevars.iter() {
let mut upvarptr = GEPi(bcx, llcdata, [0u, i]); let mut upvarptr = GEPi(bcx, llcdata, &[0u, i]);
match store { match store {
ty::RegionTraitStore(..) => { upvarptr = Load(bcx, upvarptr); } ty::RegionTraitStore(..) => { upvarptr = Load(bcx, upvarptr); }
ty::UniqTraitStore => {} ty::UniqTraitStore => {}
@ -329,7 +329,7 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
}; };
for (i, freevar) in freevars.iter().enumerate() { for (i, freevar) in freevars.iter().enumerate() {
let mut upvar_ptr = GEPi(bcx, llenv, [0, i]); let mut upvar_ptr = GEPi(bcx, llenv, &[0, i]);
if freevar_mode == ast::CaptureByRef { if freevar_mode == ast::CaptureByRef {
upvar_ptr = Load(bcx, upvar_ptr); upvar_ptr = Load(bcx, upvar_ptr);
} }
@ -347,9 +347,9 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
} }
fn fill_fn_pair(bcx: Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) { fn fill_fn_pair(bcx: Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) {
Store(bcx, llfn, GEPi(bcx, pair, [0u, abi::fn_field_code])); Store(bcx, llfn, GEPi(bcx, pair, &[0u, abi::fn_field_code]));
let llenvptr = PointerCast(bcx, llenvptr, Type::i8p(bcx.ccx())); let llenvptr = PointerCast(bcx, llenvptr, Type::i8p(bcx.ccx()));
Store(bcx, llenvptr, GEPi(bcx, pair, [0u, abi::fn_field_box])); Store(bcx, llenvptr, GEPi(bcx, pair, &[0u, abi::fn_field_box]));
} }
pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
@ -407,7 +407,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
llfn, llfn,
bcx.fcx.param_substs, bcx.fcx.param_substs,
id, id,
[], &[],
ty::ty_fn_ret(fty), ty::ty_fn_ret(fty),
ty::ty_fn_abi(fty), ty::ty_fn_abi(fty),
true, true,
@ -504,7 +504,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
llfn, llfn,
bcx.fcx.param_substs, bcx.fcx.param_substs,
id, id,
[], &[],
ty::ty_fn_ret(function_type), ty::ty_fn_ret(function_type),
ty::ty_fn_abi(function_type), ty::ty_fn_abi(function_type),
true, true,

View file

@ -581,7 +581,7 @@ pub fn C_floating(s: &str, t: Type) -> ValueRef {
} }
pub fn C_nil(ccx: &CrateContext) -> ValueRef { pub fn C_nil(ccx: &CrateContext) -> ValueRef {
C_struct(ccx, [], false) C_struct(ccx, &[], false)
} }
pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef { pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef {
@ -676,7 +676,7 @@ pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
let len = s.get().len(); let len = s.get().len();
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false), let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false),
Type::i8p(cx).to_ref()); Type::i8p(cx).to_ref());
C_named_struct(cx.tn().find_type("str_slice").unwrap(), [cs, C_uint(cx, len)]) C_named_struct(cx.tn().find_type("str_slice").unwrap(), &[cs, C_uint(cx, len)])
} }
} }
@ -694,7 +694,7 @@ pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef {
llvm::SetLinkage(g, llvm::InternalLinkage); llvm::SetLinkage(g, llvm::InternalLinkage);
let cs = llvm::LLVMConstPointerCast(g, Type::i8p(cx).to_ref()); let cs = llvm::LLVMConstPointerCast(g, Type::i8p(cx).to_ref());
C_struct(cx, [cs, C_uint(cx, len)], false) C_struct(cx, &[cs, C_uint(cx, len)], false)
} }
} }

View file

@ -204,7 +204,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) {
def, def,
llconst, llconst,
true); true);
llconst = C_struct(cx, [wrapper, C_null(Type::i8p(cx))], false) llconst = C_struct(cx, &[wrapper, C_null(Type::i8p(cx))], false)
} }
ty::AdjustAddEnv(store) => { ty::AdjustAddEnv(store) => {
cx.sess() cx.sess()
@ -264,7 +264,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) {
let llptr = const_ptrcast(cx, llconst, llunitty); let llptr = const_ptrcast(cx, llconst, llunitty);
assert_eq!(abi::slice_elt_base, 0); assert_eq!(abi::slice_elt_base, 0);
assert_eq!(abi::slice_elt_len, 1); assert_eq!(abi::slice_elt_len, 1);
llconst = C_struct(cx, [ llconst = C_struct(cx, &[
llptr, llptr,
C_uint(cx, len) C_uint(cx, len)
], false); ], false);
@ -444,8 +444,8 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)), ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
ty::ty_open(ty) => match ty::get(ty).sty { ty::ty_open(ty) => match ty::get(ty).sty {
ty::ty_vec(_, None) | ty::ty_str => { ty::ty_vec(_, None) | ty::ty_str => {
let e1 = const_get_elt(cx, bv, [0]); let e1 = const_get_elt(cx, bv, &[0]);
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1])) (const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
}, },
_ => cx.sess().span_bug(base.span, _ => cx.sess().span_bug(base.span,
format!("index-expr base must be a vector \ format!("index-expr base must be a vector \
@ -484,7 +484,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
cx.sess().span_err(e.span, cx.sess().span_err(e.span,
"const index-expr is out of bounds"); "const index-expr is out of bounds");
} }
const_get_elt(cx, arr, [iv as c_uint]) const_get_elt(cx, arr, &[iv as c_uint])
} }
ast::ExprCast(ref base, _) => { ast::ExprCast(ref base, _) => {
let ety = ty::expr_ty(cx.tcx(), e); let ety = ty::expr_ty(cx.tcx(), e);
@ -646,7 +646,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
let vinfo = ty::enum_variant_with_id(cx.tcx(), let vinfo = ty::enum_variant_with_id(cx.tcx(),
enum_did, enum_did,
variant_did); variant_did);
adt::trans_const(cx, &*repr, vinfo.disr_val, []) adt::trans_const(cx, &*repr, vinfo.disr_val, &[])
} }
Some(def::DefStruct(_)) => { Some(def::DefStruct(_)) => {
let ety = ty::expr_ty(cx.tcx(), e); let ety = ty::expr_ty(cx.tcx(), e);

View file

@ -434,7 +434,7 @@ impl LocalCrateContext {
let ccx = local_ccx.dummy_ccx(shared); let ccx = local_ccx.dummy_ccx(shared);
let mut str_slice_ty = Type::named_struct(&ccx, "str_slice"); let mut str_slice_ty = Type::named_struct(&ccx, "str_slice");
str_slice_ty.set_struct_body([Type::i8p(&ccx), ccx.int_type()], false); str_slice_ty.set_struct_body(&[Type::i8p(&ccx), ccx.int_type()], false);
ccx.tn().associate_type("str_slice", &str_slice_ty); ccx.tn().associate_type("str_slice", &str_slice_ty);
ccx.tn().associate_type("tydesc", &Type::tydesc(&ccx, str_slice_ty)); ccx.tn().associate_type("tydesc", &Type::tydesc(&ccx, str_slice_ty));
@ -719,7 +719,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
($name:expr fn() -> $ret:expr) => ( ($name:expr fn() -> $ret:expr) => (
if *key == $name { if *key == $name {
let f = base::decl_cdecl_fn( let f = base::decl_cdecl_fn(
ccx, $name, Type::func([], &$ret), ccx, $name, Type::func(&[], &$ret),
ty::mk_nil(ccx.tcx())); ty::mk_nil(ccx.tcx()));
ccx.intrinsics().borrow_mut().insert($name, f.clone()); ccx.intrinsics().borrow_mut().insert($name, f.clone());
return Some(f); return Some(f);
@ -728,14 +728,14 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
($name:expr fn($($arg:expr),*) -> $ret:expr) => ( ($name:expr fn($($arg:expr),*) -> $ret:expr) => (
if *key == $name { if *key == $name {
let f = base::decl_cdecl_fn(ccx, $name, let f = base::decl_cdecl_fn(ccx, $name,
Type::func([$($arg),*], &$ret), ty::mk_nil(ccx.tcx())); Type::func(&[$($arg),*], &$ret), ty::mk_nil(ccx.tcx()));
ccx.intrinsics().borrow_mut().insert($name, f.clone()); ccx.intrinsics().borrow_mut().insert($name, f.clone());
return Some(f); return Some(f);
} }
) )
) )
macro_rules! mk_struct ( macro_rules! mk_struct (
($($field_ty:expr),*) => (Type::struct_(ccx, [$($field_ty),*], false)) ($($field_ty:expr),*) => (Type::struct_(ccx, &[$($field_ty),*], false))
) )
let i8p = Type::i8p(ccx); let i8p = Type::i8p(ccx);
@ -864,7 +864,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
ifn!($name fn($($arg),*) -> $ret); ifn!($name fn($($arg),*) -> $ret);
} else if *key == $name { } else if *key == $name {
let f = base::decl_cdecl_fn(ccx, stringify!($cname), let f = base::decl_cdecl_fn(ccx, stringify!($cname),
Type::func([$($arg),*], &$ret), Type::func(&[$($arg),*], &$ret),
ty::mk_nil(ccx.tcx())); ty::mk_nil(ccx.tcx()));
ccx.intrinsics().borrow_mut().insert($name, f.clone()); ccx.intrinsics().borrow_mut().insert($name, f.clone());
return Some(f); return Some(f);

View file

@ -189,7 +189,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let else_bcx_in = bcx.fcx.new_id_block("else-block", elexpr.id); let else_bcx_in = bcx.fcx.new_id_block("else-block", elexpr.id);
let else_bcx_out = expr::trans_into(else_bcx_in, &*elexpr, dest); let else_bcx_out = expr::trans_into(else_bcx_in, &*elexpr, dest);
next_bcx = bcx.fcx.join_blocks(if_id, next_bcx = bcx.fcx.join_blocks(if_id,
[then_bcx_out, else_bcx_out]); &[then_bcx_out, else_bcx_out]);
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb); CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
} }
@ -324,7 +324,7 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
None, None,
arg_cleanup_scope) arg_cleanup_scope)
}, },
callee::ArgVals([lliterator]), callee::ArgVals(&[lliterator]),
Some(expr::SaveIn(lloption))); Some(expr::SaveIn(lloption)));
bcx bcx
})); }));

View file

@ -985,7 +985,7 @@ pub fn create_match_binding_metadata(bcx: Block,
}, },
TrByMove => IndirectVariable { TrByMove => IndirectVariable {
alloca: binding.llmatch, alloca: binding.llmatch,
address_operations: aops address_operations: &aops
}, },
TrByRef => DirectVariable { TrByRef => DirectVariable {
alloca: binding.llmatch alloca: binding.llmatch
@ -1368,7 +1368,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
param_substs: &param_substs, param_substs: &param_substs,
error_reporting_span: Span) -> DIArray { error_reporting_span: Span) -> DIArray {
if cx.sess().opts.debuginfo == LimitedDebugInfo { if cx.sess().opts.debuginfo == LimitedDebugInfo {
return create_DIArray(DIB(cx), []); return create_DIArray(DIB(cx), &[]);
} }
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1); let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
@ -1409,7 +1409,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
let has_self_type = self_type.is_some(); let has_self_type = self_type.is_some();
if !generics.is_type_parameterized() && !has_self_type { if !generics.is_type_parameterized() && !has_self_type {
return create_DIArray(DIB(cx), []); return create_DIArray(DIB(cx), &[]);
} }
name_to_append_suffix_to.push('<'); name_to_append_suffix_to.push('<');
@ -2645,7 +2645,7 @@ fn create_struct_stub(cx: &CrateContext,
// LLVMDIBuilderCreateStructType() wants an empty array. A null // LLVMDIBuilderCreateStructType() wants an empty array. A null
// pointer will lead to hard to trace and debug LLVM assertions // pointer will lead to hard to trace and debug LLVM assertions
// later on in llvm/lib/IR/Value.cpp. // later on in llvm/lib/IR/Value.cpp.
let empty_array = create_DIArray(DIB(cx), []); let empty_array = create_DIArray(DIB(cx), &[]);
llvm::LLVMDIBuilderCreateStructType( llvm::LLVMDIBuilderCreateStructType(
DIB(cx), DIB(cx),
@ -2688,7 +2688,7 @@ fn fixed_vec_metadata(cx: &CrateContext,
len as i64) len as i64)
}; };
let subscripts = create_DIArray(DIB(cx), [subrange]); let subscripts = create_DIArray(DIB(cx), &[subrange]);
let metadata = unsafe { let metadata = unsafe {
llvm::LLVMDIBuilderCreateArrayType( llvm::LLVMDIBuilderCreateArrayType(
DIB(cx), DIB(cx),
@ -2749,7 +2749,7 @@ fn vec_slice_metadata(cx: &CrateContext,
slice_llvm_type, slice_llvm_type,
slice_type_name.as_slice(), slice_type_name.as_slice(),
unique_type_id, unique_type_id,
member_descriptions, &member_descriptions,
UNKNOWN_SCOPE_METADATA, UNKNOWN_SCOPE_METADATA,
file_metadata, file_metadata,
span); span);
@ -2835,7 +2835,7 @@ fn trait_pointer_metadata(cx: &CrateContext,
trait_llvm_type, trait_llvm_type,
trait_type_name.as_slice(), trait_type_name.as_slice(),
unique_type_id, unique_type_id,
[], &[],
containing_scope, containing_scope,
UNKNOWN_FILE_METADATA, UNKNOWN_FILE_METADATA,
codemap::DUMMY_SP) codemap::DUMMY_SP)

View file

@ -166,11 +166,11 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
} }
pub fn get_len(bcx: Block, fat_ptr: ValueRef) -> ValueRef { pub fn get_len(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
GEPi(bcx, fat_ptr, [0u, abi::slice_elt_len]) GEPi(bcx, fat_ptr, &[0u, abi::slice_elt_len])
} }
pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef { pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
GEPi(bcx, fat_ptr, [0u, abi::slice_elt_base]) GEPi(bcx, fat_ptr, &[0u, abi::slice_elt_base])
} }
fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
@ -356,7 +356,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
val, val,
type_of::type_of(bcx.ccx(), unsized_ty).ptr_to()), type_of::type_of(bcx.ccx(), unsized_ty).ptr_to()),
&ty::UnsizeLength(..) => &ty::UnsizeLength(..) =>
|bcx, val| GEPi(bcx, val, [0u, 0u]), |bcx, val| GEPi(bcx, val, &[0u, 0u]),
&ty::UnsizeVtable(..) => &ty::UnsizeVtable(..) =>
|_bcx, val| PointerCast(bcx, val, Type::i8p(bcx.ccx())) |_bcx, val| PointerCast(bcx, val, Type::i8p(bcx.ccx()))
}; };
@ -814,7 +814,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let expect = ccx.get_intrinsic(&("llvm.expect.i1")); let expect = ccx.get_intrinsic(&("llvm.expect.i1"));
let expected = Call(bcx, let expected = Call(bcx,
expect, expect,
[bounds_check, C_bool(ccx, false)], &[bounds_check, C_bool(ccx, false)],
None); None);
bcx = with_cond(bcx, expected, |bcx| { bcx = with_cond(bcx, expected, |bcx| {
controlflow::trans_fail_bounds_check(bcx, controlflow::trans_fail_bounds_check(bcx,
@ -822,7 +822,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ix_val, ix_val,
len) len)
}); });
let elt = InBoundsGEP(bcx, base, [ix_val]); let elt = InBoundsGEP(bcx, base, &[ix_val]);
let elt = PointerCast(bcx, elt, vt.llunit_ty.ptr_to()); let elt = PointerCast(bcx, elt, vt.llunit_ty.ptr_to());
Datum::new(elt, vt.unit_ty, LvalueExpr) Datum::new(elt, vt.unit_ty, LvalueExpr)
} }
@ -1758,8 +1758,8 @@ fn trans_lazy_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
} }
Br(past_rhs, join.llbb); Br(past_rhs, join.llbb);
let phi = Phi(join, Type::i1(bcx.ccx()), [lhs, rhs], let phi = Phi(join, Type::i1(bcx.ccx()), &[lhs, rhs],
[past_lhs.llbb, past_rhs.llbb]); &[past_lhs.llbb, past_rhs.llbb]);
return immediate_rvalue_bcx(join, phi, binop_ty).to_expr_datumblock(); return immediate_rvalue_bcx(join, phi, binop_ty).to_expr_datumblock();
} }

View file

@ -610,7 +610,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice()); let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
base::set_llvm_fn_attrs(ccx, attrs, llfn); base::set_llvm_fn_attrs(ccx, attrs, llfn);
base::trans_fn(ccx, decl, body, llfn, param_substs, id, []); base::trans_fn(ccx, decl, body, llfn, param_substs, id, &[]);
llfn llfn
} }

View file

@ -51,7 +51,7 @@ pub fn trans_exchange_free_dyn<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef,
let ccx = cx.ccx(); let ccx = cx.ccx();
callee::trans_lang_call(cx, callee::trans_lang_call(cx,
langcall(cx, None, "", ExchangeFreeFnLangItem), langcall(cx, None, "", ExchangeFreeFnLangItem),
[PointerCast(cx, v, Type::i8p(ccx)), size, align], &[PointerCast(cx, v, Type::i8p(ccx)), size, align],
Some(expr::Ignore)).bcx Some(expr::Ignore)).bcx
} }
@ -124,7 +124,7 @@ pub fn drop_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
None => debuginfo::clear_source_location(bcx.fcx) None => debuginfo::clear_source_location(bcx.fcx)
}; };
Call(bcx, glue, [ptr], None); Call(bcx, glue, &[ptr], None);
} }
bcx bcx
} }
@ -195,7 +195,7 @@ fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let struct_data = if ty::type_is_sized(bcx.tcx(), t) { let struct_data = if ty::type_is_sized(bcx.tcx(), t) {
v0 v0
} else { } else {
let llval = GEPi(bcx, v0, [0, abi::slice_elt_base]); let llval = GEPi(bcx, v0, &[0, abi::slice_elt_base]);
Load(bcx, llval) Load(bcx, llval)
}; };
let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &*repr, struct_data)); let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &*repr, struct_data));
@ -236,8 +236,8 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let (struct_data, info) = if ty::type_is_sized(bcx.tcx(), t) { let (struct_data, info) = if ty::type_is_sized(bcx.tcx(), t) {
(v0, None) (v0, None)
} else { } else {
let data = GEPi(bcx, v0, [0, abi::slice_elt_base]); let data = GEPi(bcx, v0, &[0, abi::slice_elt_base]);
let info = GEPi(bcx, v0, [0, abi::slice_elt_len]); let info = GEPi(bcx, v0, &[0, abi::slice_elt_len]);
(Load(bcx, data), Some(Load(bcx, info))) (Load(bcx, data), Some(Load(bcx, info)))
}; };
@ -254,14 +254,14 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// The dtor expects a fat pointer, so make one, even if we have to fake it. // The dtor expects a fat pointer, so make one, even if we have to fake it.
let boxed_ty = ty::mk_open(bcx.tcx(), t); let boxed_ty = ty::mk_open(bcx.tcx(), t);
let scratch = datum::rvalue_scratch_datum(bcx, boxed_ty, "__fat_ptr_drop_self"); let scratch = datum::rvalue_scratch_datum(bcx, boxed_ty, "__fat_ptr_drop_self");
Store(bcx, value, GEPi(bcx, scratch.val, [0, abi::slice_elt_base])); Store(bcx, value, GEPi(bcx, scratch.val, &[0, abi::slice_elt_base]));
Store(bcx, Store(bcx,
// If we just had a thin pointer, make a fat pointer by sticking // If we just had a thin pointer, make a fat pointer by sticking
// null where we put the unsizing info. This works because t // null where we put the unsizing info. This works because t
// is a sized type, so we will only unpack the fat pointer, never // is a sized type, so we will only unpack the fat pointer, never
// use the fake info. // use the fake info.
info.unwrap_or(C_null(Type::i8p(bcx.ccx()))), info.unwrap_or(C_null(Type::i8p(bcx.ccx()))),
GEPi(bcx, scratch.val, [0, abi::slice_elt_len])); GEPi(bcx, scratch.val, &[0, abi::slice_elt_len]));
PointerCast(variant_cx, scratch.val, params[0]) PointerCast(variant_cx, scratch.val, params[0])
} else { } else {
PointerCast(variant_cx, value, params[0]) PointerCast(variant_cx, value, params[0])
@ -279,8 +279,8 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
} else { } else {
let boxed_ty = ty::mk_open(bcx.tcx(), *ty); let boxed_ty = ty::mk_open(bcx.tcx(), *ty);
let scratch = datum::rvalue_scratch_datum(bcx, boxed_ty, "__fat_ptr_drop_field"); let scratch = datum::rvalue_scratch_datum(bcx, boxed_ty, "__fat_ptr_drop_field");
Store(bcx, llfld_a, GEPi(bcx, scratch.val, [0, abi::slice_elt_base])); Store(bcx, llfld_a, GEPi(bcx, scratch.val, &[0, abi::slice_elt_base]));
Store(bcx, info.unwrap(), GEPi(bcx, scratch.val, [0, abi::slice_elt_len])); Store(bcx, info.unwrap(), GEPi(bcx, scratch.val, &[0, abi::slice_elt_len]));
scratch.val scratch.val
}; };
variant_cx.fcx.schedule_drop_mem(cleanup::CustomScope(field_scope), variant_cx.fcx.schedule_drop_mem(cleanup::CustomScope(field_scope),
@ -288,7 +288,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
} }
let dtor_ty = ty::mk_ctor_fn(variant_cx.tcx(), ast::DUMMY_NODE_ID, let dtor_ty = ty::mk_ctor_fn(variant_cx.tcx(), ast::DUMMY_NODE_ID,
[get_drop_glue_type(bcx.ccx(), t)], ty::mk_nil(bcx.tcx())); &[get_drop_glue_type(bcx.ccx(), t)], ty::mk_nil(bcx.tcx()));
let (_, variant_cx) = invoke(variant_cx, dtor_addr, args, dtor_ty, None, false); let (_, variant_cx) = invoke(variant_cx, dtor_addr, args, dtor_ty, None, false);
variant_cx.fcx.pop_and_trans_custom_cleanup_scope(variant_cx, field_scope); variant_cx.fcx.pop_and_trans_custom_cleanup_scope(variant_cx, field_scope);
@ -335,8 +335,8 @@ fn size_and_align_of_dst(bcx: Block, t :ty::t, info: ValueRef) -> (ValueRef, Val
// info points to the vtable and the second entry in the vtable is the // info points to the vtable and the second entry in the vtable is the
// dynamic size of the object. // dynamic size of the object.
let info = PointerCast(bcx, info, Type::int(bcx.ccx()).ptr_to()); let info = PointerCast(bcx, info, Type::int(bcx.ccx()).ptr_to());
let size_ptr = GEPi(bcx, info, [1u]); let size_ptr = GEPi(bcx, info, &[1u]);
let align_ptr = GEPi(bcx, info, [2u]); let align_ptr = GEPi(bcx, info, &[2u]);
(Load(bcx, size_ptr), Load(bcx, align_ptr)) (Load(bcx, size_ptr), Load(bcx, align_ptr))
} }
ty::ty_vec(unit_ty, None) => { ty::ty_vec(unit_ty, None) => {
@ -366,26 +366,26 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
tvec::make_drop_glue_unboxed(bcx, v0, unit_ty, true) tvec::make_drop_glue_unboxed(bcx, v0, unit_ty, true)
} }
ty::ty_trait(..) => { ty::ty_trait(..) => {
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]); let lluniquevalue = GEPi(bcx, v0, &[0, abi::trt_field_box]);
// Only drop the value when it is non-null // Only drop the value when it is non-null
let concrete_ptr = Load(bcx, lluniquevalue); let concrete_ptr = Load(bcx, lluniquevalue);
with_cond(bcx, IsNotNull(bcx, concrete_ptr), |bcx| { with_cond(bcx, IsNotNull(bcx, concrete_ptr), |bcx| {
let dtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable])); let dtor_ptr = Load(bcx, GEPi(bcx, v0, &[0, abi::trt_field_vtable]));
let dtor = Load(bcx, dtor_ptr); let dtor = Load(bcx, dtor_ptr);
Call(bcx, Call(bcx,
dtor, dtor,
[PointerCast(bcx, lluniquevalue, Type::i8p(bcx.ccx()))], &[PointerCast(bcx, lluniquevalue, Type::i8p(bcx.ccx()))],
None); None);
bcx bcx
}) })
} }
ty::ty_struct(..) if !ty::type_is_sized(bcx.tcx(), content_ty) => { ty::ty_struct(..) if !ty::type_is_sized(bcx.tcx(), content_ty) => {
let llval = GEPi(bcx, v0, [0, abi::slice_elt_base]); let llval = GEPi(bcx, v0, &[0, abi::slice_elt_base]);
let llbox = Load(bcx, llval); let llbox = Load(bcx, llval);
let not_null = IsNotNull(bcx, llbox); let not_null = IsNotNull(bcx, llbox);
with_cond(bcx, not_null, |bcx| { with_cond(bcx, not_null, |bcx| {
let bcx = drop_ty(bcx, v0, content_ty, None); let bcx = drop_ty(bcx, v0, content_ty, None);
let info = GEPi(bcx, v0, [0, abi::slice_elt_len]); let info = GEPi(bcx, v0, &[0, abi::slice_elt_len]);
let info = Load(bcx, info); let info = Load(bcx, info);
let (llsize, llalign) = size_and_align_of_dst(bcx, content_ty, info); let (llsize, llalign) = size_and_align_of_dst(bcx, content_ty, info);
trans_exchange_free_dyn(bcx, llbox, llsize, llalign) trans_exchange_free_dyn(bcx, llbox, llsize, llalign)
@ -437,14 +437,14 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
t, t,
|bb, vv, tt| drop_ty(bb, vv, tt, None)), |bb, vv, tt| drop_ty(bb, vv, tt, None)),
ty::ty_closure(ref f) if f.store == ty::UniqTraitStore => { ty::ty_closure(ref f) if f.store == ty::UniqTraitStore => {
let box_cell_v = GEPi(bcx, v0, [0u, abi::fn_field_box]); let box_cell_v = GEPi(bcx, v0, &[0u, abi::fn_field_box]);
let env = Load(bcx, box_cell_v); let env = Load(bcx, box_cell_v);
let env_ptr_ty = Type::at_box(bcx.ccx(), Type::i8(bcx.ccx())).ptr_to(); let env_ptr_ty = Type::at_box(bcx.ccx(), Type::i8(bcx.ccx())).ptr_to();
let env = PointerCast(bcx, env, env_ptr_ty); let env = PointerCast(bcx, env, env_ptr_ty);
with_cond(bcx, IsNotNull(bcx, env), |bcx| { with_cond(bcx, IsNotNull(bcx, env), |bcx| {
let dtor_ptr = GEPi(bcx, env, [0u, abi::box_field_drop_glue]); let dtor_ptr = GEPi(bcx, env, &[0u, abi::box_field_drop_glue]);
let dtor = Load(bcx, dtor_ptr); let dtor = Load(bcx, dtor_ptr);
Call(bcx, dtor, [PointerCast(bcx, box_cell_v, Type::i8p(bcx.ccx()))], None); Call(bcx, dtor, &[PointerCast(bcx, box_cell_v, Type::i8p(bcx.ccx()))], None);
bcx bcx
}) })
} }
@ -453,12 +453,12 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
// above), because this happens for a trait field in an unsized // above), because this happens for a trait field in an unsized
// struct. If anything is null, it is the whole struct and we won't // struct. If anything is null, it is the whole struct and we won't
// get here. // get here.
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]); let lluniquevalue = GEPi(bcx, v0, &[0, abi::trt_field_box]);
let dtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable])); let dtor_ptr = Load(bcx, GEPi(bcx, v0, &[0, abi::trt_field_vtable]));
let dtor = Load(bcx, dtor_ptr); let dtor = Load(bcx, dtor_ptr);
Call(bcx, Call(bcx,
dtor, dtor,
[PointerCast(bcx, Load(bcx, lluniquevalue), Type::i8p(bcx.ccx()))], &[PointerCast(bcx, Load(bcx, lluniquevalue), Type::i8p(bcx.ccx()))],
None); None);
bcx bcx
} }
@ -578,10 +578,10 @@ pub fn emit_tydescs(ccx: &CrateContext) {
ccx.stats().n_real_glues.set(ccx.stats().n_real_glues.get() + 1); ccx.stats().n_real_glues.set(ccx.stats().n_real_glues.get() + 1);
let tydesc = C_named_struct(ccx.tydesc_type(), let tydesc = C_named_struct(ccx.tydesc_type(),
[ti.size, // size &[ti.size, // size
ti.align, // align ti.align, // align
drop_glue, // drop_glue drop_glue, // drop_glue
ti.name]); // name ti.name]); // name
unsafe { unsafe {
let gvar = ti.tydesc; let gvar = ti.tydesc;

View file

@ -166,7 +166,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
llfn, llfn,
&param_substs::empty(), &param_substs::empty(),
mth.id, mth.id,
[]); &[]);
// Use InternalLinkage so LLVM can optimize more // Use InternalLinkage so LLVM can optimize more
// aggressively. // aggressively.
SetLinkage(llfn, InternalLinkage); SetLinkage(llfn, InternalLinkage);

View file

@ -207,7 +207,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
// These are the only intrinsic functions that diverge. // These are the only intrinsic functions that diverge.
if name.get() == "abort" { if name.get() == "abort" {
let llfn = ccx.get_intrinsic(&("llvm.trap")); let llfn = ccx.get_intrinsic(&("llvm.trap"));
Call(bcx, llfn, [], None); Call(bcx, llfn, &[], None);
Unreachable(bcx); Unreachable(bcx);
return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to())); return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
} else if name.get() == "unreachable" { } else if name.get() == "unreachable" {
@ -242,7 +242,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
} }
(_, "breakpoint") => { (_, "breakpoint") => {
let llfn = ccx.get_intrinsic(&("llvm.debugtrap")); let llfn = ccx.get_intrinsic(&("llvm.debugtrap"));
Call(bcx, llfn, [], None) Call(bcx, llfn, &[], None)
} }
(_, "size_of") => { (_, "size_of") => {
let tp_ty = *substs.types.get(FnSpace, 0); let tp_ty = *substs.types.get(FnSpace, 0);
@ -291,7 +291,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
&ccx.link_meta().crate_hash); &ccx.link_meta().crate_hash);
// NB: This needs to be kept in lockstep with the TypeId struct in // NB: This needs to be kept in lockstep with the TypeId struct in
// the intrinsic module // the intrinsic module
C_named_struct(llret_ty, [C_u64(ccx, hash)]) C_named_struct(llret_ty, &[C_u64(ccx, hash)])
} }
(_, "init") => { (_, "init") => {
let tp_ty = *substs.types.get(FnSpace, 0); let tp_ty = *substs.types.get(FnSpace, 0);
@ -317,7 +317,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
(_, "offset") => { (_, "offset") => {
let ptr = llargs[0]; let ptr = llargs[0];
let offset = llargs[1]; let offset = llargs[1];
InBoundsGEP(bcx, ptr, [offset]) InBoundsGEP(bcx, ptr, &[offset])
} }
(_, "copy_nonoverlapping_memory") => { (_, "copy_nonoverlapping_memory") => {
@ -578,8 +578,8 @@ fn copy_intrinsic(bcx: Block, allow_overlap: bool, volatile: bool,
let src_ptr = PointerCast(bcx, src, Type::i8p(ccx)); let src_ptr = PointerCast(bcx, src, Type::i8p(ccx));
let llfn = ccx.get_intrinsic(&name); let llfn = ccx.get_intrinsic(&name);
Call(bcx, llfn, [dst_ptr, src_ptr, Mul(bcx, size, count), align, Call(bcx, llfn, &[dst_ptr, src_ptr, Mul(bcx, size, count), align,
C_bool(ccx, volatile)], None) C_bool(ccx, volatile)], None)
} }
fn memset_intrinsic(bcx: Block, volatile: bool, tp_ty: ty::t, fn memset_intrinsic(bcx: Block, volatile: bool, tp_ty: ty::t,
@ -597,14 +597,14 @@ fn memset_intrinsic(bcx: Block, volatile: bool, tp_ty: ty::t,
let dst_ptr = PointerCast(bcx, dst, Type::i8p(ccx)); let dst_ptr = PointerCast(bcx, dst, Type::i8p(ccx));
let llfn = ccx.get_intrinsic(&name); let llfn = ccx.get_intrinsic(&name);
Call(bcx, llfn, [dst_ptr, val, Mul(bcx, size, count), align, Call(bcx, llfn, &[dst_ptr, val, Mul(bcx, size, count), align,
C_bool(ccx, volatile)], None) C_bool(ccx, volatile)], None)
} }
fn count_zeros_intrinsic(bcx: Block, name: &'static str, val: ValueRef) -> ValueRef { fn count_zeros_intrinsic(bcx: Block, name: &'static str, val: ValueRef) -> ValueRef {
let y = C_bool(bcx.ccx(), false); let y = C_bool(bcx.ccx(), false);
let llfn = bcx.ccx().get_intrinsic(&name); let llfn = bcx.ccx().get_intrinsic(&name);
Call(bcx, llfn, [val, y], None) Call(bcx, llfn, &[val, y], None)
} }
fn with_overflow_intrinsic(bcx: Block, name: &'static str, t: ty::t, fn with_overflow_intrinsic(bcx: Block, name: &'static str, t: ty::t,
@ -612,7 +612,7 @@ fn with_overflow_intrinsic(bcx: Block, name: &'static str, t: ty::t,
let llfn = bcx.ccx().get_intrinsic(&name); let llfn = bcx.ccx().get_intrinsic(&name);
// Convert `i1` to a `bool`, and write it to the out parameter // Convert `i1` to a `bool`, and write it to the out parameter
let val = Call(bcx, llfn, [a, b], None); let val = Call(bcx, llfn, &[a, b], None);
let result = ExtractValue(bcx, val, 0); let result = ExtractValue(bcx, val, 0);
let overflow = ZExt(bcx, ExtractValue(bcx, val, 1), Type::bool(bcx.ccx())); let overflow = ZExt(bcx, ExtractValue(bcx, val, 1), Type::bool(bcx.ccx()));
let ret = C_undef(type_of::type_of(bcx.ccx(), t)); let ret = C_undef(type_of::type_of(bcx.ccx(), t));

View file

@ -89,7 +89,7 @@ pub fn trans_impl(ccx: &CrateContext,
llfn, llfn,
&param_substs::empty(), &param_substs::empty(),
method.id, method.id,
[]); &[]);
update_linkage(ccx, update_linkage(ccx,
llfn, llfn,
Some(method.id), Some(method.id),
@ -479,7 +479,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Load the data pointer from the object. // Load the data pointer from the object.
debug!("(translating trait callee) loading second index from pair"); debug!("(translating trait callee) loading second index from pair");
let llboxptr = GEPi(bcx, llpair, [0u, abi::trt_field_box]); let llboxptr = GEPi(bcx, llpair, &[0u, abi::trt_field_box]);
let llbox = Load(bcx, llboxptr); let llbox = Load(bcx, llboxptr);
let llself = PointerCast(bcx, llbox, Type::i8p(ccx)); let llself = PointerCast(bcx, llbox, Type::i8p(ccx));
@ -501,9 +501,9 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let llvtable = Load(bcx, let llvtable = Load(bcx,
PointerCast(bcx, PointerCast(bcx,
GEPi(bcx, llpair, GEPi(bcx, llpair,
[0u, abi::trt_field_vtable]), &[0u, abi::trt_field_vtable]),
Type::vtable(ccx).ptr_to().ptr_to())); Type::vtable(ccx).ptr_to().ptr_to()));
let mptr = Load(bcx, GEPi(bcx, llvtable, [0u, n_method + VTABLE_OFFSET])); let mptr = Load(bcx, GEPi(bcx, llvtable, &[0u, n_method + VTABLE_OFFSET]));
let mptr = PointerCast(bcx, mptr, llcallee_ty.ptr_to()); let mptr = PointerCast(bcx, mptr, llcallee_ty.ptr_to());
return Callee { return Callee {
@ -764,13 +764,13 @@ pub fn trans_trait_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let llbox_ty = type_of(bcx.ccx(), datum_ty); let llbox_ty = type_of(bcx.ccx(), datum_ty);
// Store the pointer into the first half of pair. // Store the pointer into the first half of pair.
let llboxdest = GEPi(bcx, lldest, [0u, abi::trt_field_box]); let llboxdest = GEPi(bcx, lldest, &[0u, abi::trt_field_box]);
let llboxdest = PointerCast(bcx, llboxdest, llbox_ty.ptr_to()); let llboxdest = PointerCast(bcx, llboxdest, llbox_ty.ptr_to());
bcx = datum.store_to(bcx, llboxdest); bcx = datum.store_to(bcx, llboxdest);
// Store the vtable into the second half of pair. // Store the vtable into the second half of pair.
let vtable = get_vtable(bcx, datum_ty, trait_ref); let vtable = get_vtable(bcx, datum_ty, trait_ref);
let llvtabledest = GEPi(bcx, lldest, [0u, abi::trt_field_vtable]); let llvtabledest = GEPi(bcx, lldest, &[0u, abi::trt_field_vtable]);
let llvtabledest = PointerCast(bcx, llvtabledest, val_ty(vtable).ptr_to()); let llvtabledest = PointerCast(bcx, llvtabledest, val_ty(vtable).ptr_to());
Store(bcx, vtable, llvtabledest); Store(bcx, vtable, llvtabledest);

View file

@ -179,10 +179,10 @@ pub fn monomorphic_fn(ccx: &CrateContext,
if needs_body { if needs_body {
if abi != abi::Rust { if abi != abi::Rust {
foreign::trans_rust_fn_with_foreign_abi( foreign::trans_rust_fn_with_foreign_abi(
ccx, &**decl, &**body, [], d, &psubsts, fn_id.node, ccx, &**decl, &**body, &[], d, &psubsts, fn_id.node,
Some(hash.as_slice())); Some(hash.as_slice()));
} else { } else {
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, []); trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, &[]);
} }
} }
@ -226,7 +226,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
d, d,
&psubsts, &psubsts,
mth.id, mth.id,
[]); &[]);
} }
d d
} }
@ -242,7 +242,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
let needs_body = setup_lldecl(d, mth.attrs.as_slice()); let needs_body = setup_lldecl(d, mth.attrs.as_slice());
if needs_body { if needs_body {
trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d, trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d,
&psubsts, mth.id, []); &psubsts, mth.id, &[]);
} }
d d
} }

View file

@ -47,7 +47,7 @@ pub fn pointer_add_byte(bcx: Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef
let _icx = push_ctxt("tvec::pointer_add_byte"); let _icx = push_ctxt("tvec::pointer_add_byte");
let old_ty = val_ty(ptr); let old_ty = val_ty(ptr);
let bptr = PointerCast(bcx, ptr, Type::i8p(bcx.ccx())); let bptr = PointerCast(bcx, ptr, Type::i8p(bcx.ccx()));
return PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]), old_ty); return PointerCast(bcx, InBoundsGEP(bcx, bptr, &[bytes]), old_ty);
} }
pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
@ -128,7 +128,7 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
SaveIn(lldest) => { SaveIn(lldest) => {
// lldest will have type *[T x N], but we want the type *T, // lldest will have type *[T x N], but we want the type *T,
// so use GEP to convert: // so use GEP to convert:
let lldest = GEPi(bcx, lldest, [0, 0]); let lldest = GEPi(bcx, lldest, &[0, 0]);
write_content(bcx, &vt, expr, expr, SaveIn(lldest)) write_content(bcx, &vt, expr, expr, SaveIn(lldest))
} }
}; };
@ -231,8 +231,8 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let llbytes = C_uint(bcx.ccx(), bytes); let llbytes = C_uint(bcx.ccx(), bytes);
let llcstr = C_cstr(bcx.ccx(), str_lit, false); let llcstr = C_cstr(bcx.ccx(), str_lit, false);
let llcstr = llvm::LLVMConstPointerCast(llcstr, Type::i8p(bcx.ccx()).to_ref()); let llcstr = llvm::LLVMConstPointerCast(llcstr, Type::i8p(bcx.ccx()).to_ref());
Store(bcx, llcstr, GEPi(bcx, lldest, [0u, abi::slice_elt_base])); Store(bcx, llcstr, GEPi(bcx, lldest, &[0u, abi::slice_elt_base]));
Store(bcx, llbytes, GEPi(bcx, lldest, [0u, abi::slice_elt_len])); Store(bcx, llbytes, GEPi(bcx, lldest, &[0u, abi::slice_elt_len]));
bcx bcx
} }
} }
@ -290,7 +290,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
SaveIn(lldest) => { SaveIn(lldest) => {
let temp_scope = fcx.push_custom_cleanup_scope(); let temp_scope = fcx.push_custom_cleanup_scope();
for (i, element) in elements.iter().enumerate() { for (i, element) in elements.iter().enumerate() {
let lleltptr = GEPi(bcx, lldest, [i]); let lleltptr = GEPi(bcx, lldest, &[i]);
debug!("writing index {} with lleltptr={}", debug!("writing index {} with lleltptr={}",
i, bcx.val_to_string(lleltptr)); i, bcx.val_to_string(lleltptr));
bcx = expr::trans_into(bcx, &**element, bcx = expr::trans_into(bcx, &**element,
@ -397,8 +397,8 @@ pub fn get_fixed_base_and_len(bcx: Block,
fn get_slice_base_and_len(bcx: Block, fn get_slice_base_and_len(bcx: Block,
llval: ValueRef) llval: ValueRef)
-> (ValueRef, ValueRef) { -> (ValueRef, ValueRef) {
let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base])); let base = Load(bcx, GEPi(bcx, llval, &[0u, abi::slice_elt_base]));
let len = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len])); let len = Load(bcx, GEPi(bcx, llval, &[0u, abi::slice_elt_len]));
(base, len) (base, len)
} }
@ -427,7 +427,7 @@ pub fn get_base_and_len(bcx: Block,
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty { ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
ty::ty_vec(_, None) | ty::ty_str => get_slice_base_and_len(bcx, llval), ty::ty_vec(_, None) | ty::ty_str => get_slice_base_and_len(bcx, llval),
ty::ty_vec(_, Some(n)) => { ty::ty_vec(_, Some(n)) => {
let base = GEPi(bcx, Load(bcx, llval), [0u, 0u]); let base = GEPi(bcx, Load(bcx, llval), &[0u, 0u]);
(base, C_uint(ccx, n)) (base, C_uint(ccx, n))
} }
_ => ccx.sess().bug("unexpected type in get_base_and_len"), _ => ccx.sess().bug("unexpected type in get_base_and_len"),
@ -477,7 +477,7 @@ pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let lleltptr = if vt.llunit_alloc_size == 0 { let lleltptr = if vt.llunit_alloc_size == 0 {
data_ptr data_ptr
} else { } else {
InBoundsGEP(body_bcx, data_ptr, [i]) InBoundsGEP(body_bcx, data_ptr, &[i])
}; };
let body_bcx = f(body_bcx, lleltptr, vt.unit_ty); let body_bcx = f(body_bcx, lleltptr, vt.unit_ty);
@ -521,7 +521,7 @@ pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let header_bcx = fcx.new_temp_block("iter_vec_loop_header"); let header_bcx = fcx.new_temp_block("iter_vec_loop_header");
Br(bcx, header_bcx.llbb); Br(bcx, header_bcx.llbb);
let data_ptr = let data_ptr =
Phi(header_bcx, val_ty(data_ptr), [data_ptr], [bcx.llbb]); Phi(header_bcx, val_ty(data_ptr), &[data_ptr], &[bcx.llbb]);
let not_yet_at_end = let not_yet_at_end =
ICmp(header_bcx, llvm::IntULT, data_ptr, data_end_ptr); ICmp(header_bcx, llvm::IntULT, data_ptr, data_end_ptr);
let body_bcx = fcx.new_temp_block("iter_vec_loop_body"); let body_bcx = fcx.new_temp_block("iter_vec_loop_body");
@ -529,7 +529,7 @@ pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
CondBr(header_bcx, not_yet_at_end, body_bcx.llbb, next_bcx.llbb); CondBr(header_bcx, not_yet_at_end, body_bcx.llbb, next_bcx.llbb);
let body_bcx = f(body_bcx, data_ptr, vt.unit_ty); let body_bcx = f(body_bcx, data_ptr, vt.unit_ty);
AddIncomingToPhi(data_ptr, InBoundsGEP(body_bcx, data_ptr, AddIncomingToPhi(data_ptr, InBoundsGEP(body_bcx, data_ptr,
[C_int(bcx.ccx(), 1i)]), &[C_int(bcx.ccx(), 1i)]),
body_bcx.llbb); body_bcx.llbb);
Br(body_bcx, header_bcx.llbb); Br(body_bcx, header_bcx.llbb);
next_bcx next_bcx

View file

@ -162,7 +162,7 @@ impl Type {
} }
pub fn empty_struct(ccx: &CrateContext) -> Type { pub fn empty_struct(ccx: &CrateContext) -> Type {
Type::struct_(ccx, [], false) Type::struct_(ccx, &[], false)
} }
pub fn vtable(ccx: &CrateContext) -> Type { pub fn vtable(ccx: &CrateContext) -> Type {
@ -182,7 +182,7 @@ impl Type {
} }
pub fn glue_fn(ccx: &CrateContext, t: Type) -> Type { pub fn glue_fn(ccx: &CrateContext, t: Type) -> Type {
Type::func([t], &Type::void(ccx)) Type::func(&[t], &Type::void(ccx))
} }
pub fn tydesc(ccx: &CrateContext, str_slice_ty: Type) -> Type { pub fn tydesc(ccx: &CrateContext, str_slice_ty: Type) -> Type {
@ -199,7 +199,7 @@ impl Type {
int_ty, // align int_ty, // align
glue_fn_ty, // drop glue_fn_ty, // drop
str_slice_ty]; // name str_slice_ty]; // name
tydesc.set_struct_body(elems, false); tydesc.set_struct_body(&elems, false);
tydesc tydesc
} }
@ -214,7 +214,7 @@ impl Type {
pub fn vec(ccx: &CrateContext, ty: &Type) -> Type { pub fn vec(ccx: &CrateContext, ty: &Type) -> Type {
Type::struct_(ccx, Type::struct_(ccx,
[Type::array(ty, 0), Type::int(ccx)], &[Type::array(ty, 0), Type::int(ccx)],
false) false)
} }
@ -224,7 +224,7 @@ impl Type {
// The box pointed to by @T. // The box pointed to by @T.
pub fn at_box(ccx: &CrateContext, ty: Type) -> Type { pub fn at_box(ccx: &CrateContext, ty: Type) -> Type {
Type::struct_(ccx, [ Type::struct_(ccx, &[
ccx.int_type(), Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to(), ccx.int_type(), Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to(),
Type::i8p(ccx), Type::i8p(ccx), ty Type::i8p(ccx), Type::i8p(ccx), ty
], false) ], false)
@ -235,7 +235,7 @@ impl Type {
} }
pub fn opaque_trait(ccx: &CrateContext) -> Type { pub fn opaque_trait(ccx: &CrateContext) -> Type {
Type::struct_(ccx, [Type::opaque_trait_data(ccx).ptr_to(), Type::vtable_ptr(ccx)], false) Type::struct_(ccx, &[Type::opaque_trait_data(ccx).ptr_to(), Type::vtable_ptr(ccx)], false)
} }
pub fn opaque_trait_data(ccx: &CrateContext) -> Type { pub fn opaque_trait_data(ccx: &CrateContext) -> Type {

View file

@ -195,12 +195,12 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
if ty::type_is_sized(cx.tcx(), ty) { if ty::type_is_sized(cx.tcx(), ty) {
Type::i8p(cx) Type::i8p(cx)
} else { } else {
Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false) Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false)
} }
} }
ty::ty_bare_fn(..) => Type::i8p(cx), ty::ty_bare_fn(..) => Type::i8p(cx),
ty::ty_closure(..) => Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false), ty::ty_closure(..) => Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false),
ty::ty_vec(ty, Some(size)) => { ty::ty_vec(ty, Some(size)) => {
let llty = sizing_type_of(cx, ty); let llty = sizing_type_of(cx, ty);
@ -231,7 +231,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
} }
ty::ty_open(_) => { ty::ty_open(_) => {
Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false) Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false)
} }
ty::ty_infer(..) | ty::ty_param(..) | ty::ty_err(..) => { ty::ty_infer(..) | ty::ty_param(..) | ty::ty_err(..) => {
@ -337,7 +337,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
ty::ty_trait(..) => Type::opaque_trait(cx), ty::ty_trait(..) => Type::opaque_trait(cx),
_ if !ty::type_is_sized(cx.tcx(), ty) => { _ if !ty::type_is_sized(cx.tcx(), ty) => {
let p_ty = type_of(cx, ty).ptr_to(); let p_ty = type_of(cx, ty).ptr_to();
Type::struct_(cx, [p_ty, type_of_unsize_info(cx, ty)], false) Type::struct_(cx, &[p_ty, type_of_unsize_info(cx, ty)], false)
} }
_ => type_of(cx, ty).ptr_to(), _ => type_of(cx, ty).ptr_to(),
} }
@ -364,7 +364,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
} }
ty::ty_closure(_) => { ty::ty_closure(_) => {
let fn_ty = type_of_fn_from_ty(cx, t).ptr_to(); let fn_ty = type_of_fn_from_ty(cx, t).ptr_to();
Type::struct_(cx, [fn_ty, Type::i8p(cx)], false) Type::struct_(cx, &[fn_ty, Type::i8p(cx)], false)
} }
ty::ty_tup(ref tys) if tys.is_empty() => Type::nil(cx), ty::ty_tup(ref tys) if tys.is_empty() => Type::nil(cx),
ty::ty_tup(..) => { ty::ty_tup(..) => {
@ -391,15 +391,15 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
ty::ty_open(t) => match ty::get(t).sty { ty::ty_open(t) => match ty::get(t).sty {
ty::ty_struct(..) => { ty::ty_struct(..) => {
let p_ty = type_of(cx, t).ptr_to(); let p_ty = type_of(cx, t).ptr_to();
Type::struct_(cx, [p_ty, type_of_unsize_info(cx, t)], false) Type::struct_(cx, &[p_ty, type_of_unsize_info(cx, t)], false)
} }
ty::ty_vec(ty, None) => { ty::ty_vec(ty, None) => {
let p_ty = type_of(cx, ty).ptr_to(); let p_ty = type_of(cx, ty).ptr_to();
Type::struct_(cx, [p_ty, type_of_unsize_info(cx, t)], false) Type::struct_(cx, &[p_ty, type_of_unsize_info(cx, t)], false)
} }
ty::ty_str => { ty::ty_str => {
let p_ty = Type::i8p(cx); let p_ty = Type::i8p(cx);
Type::struct_(cx, [p_ty, type_of_unsize_info(cx, t)], false) Type::struct_(cx, &[p_ty, type_of_unsize_info(cx, t)], false)
} }
ty::ty_trait(..) => Type::opaque_trait(cx), ty::ty_trait(..) => Type::opaque_trait(cx),
_ => cx.sess().bug(format!("ty_open with sized type: {}", _ => cx.sess().bug(format!("ty_open with sized type: {}",
@ -472,5 +472,5 @@ pub fn llvm_type_name(cx: &CrateContext,
pub fn type_of_dtor(ccx: &CrateContext, self_ty: ty::t) -> Type { pub fn type_of_dtor(ccx: &CrateContext, self_ty: ty::t) -> Type {
let self_ty = type_of(ccx, self_ty).ptr_to(); let self_ty = type_of(ccx, self_ty).ptr_to();
Type::func([self_ty], &Type::void(ccx)) Type::func(&[self_ty], &Type::void(ccx))
} }

View file

@ -2656,7 +2656,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
bounds: ExistentialBounds) bounds: ExistentialBounds)
-> TypeContents { -> TypeContents {
// These are the type contents of the (opaque) interior // These are the type contents of the (opaque) interior
kind_bounds_to_contents(cx, bounds.builtin_bounds, []) kind_bounds_to_contents(cx, bounds.builtin_bounds, &[])
} }
fn kind_bounds_to_contents(cx: &ctxt, fn kind_bounds_to_contents(cx: &ctxt,
@ -4850,7 +4850,7 @@ pub fn required_region_bounds(tcx: &ctxt,
all_bounds.push_all(region_bounds); all_bounds.push_all(region_bounds);
push_region_bounds([], push_region_bounds(&[],
builtin_bounds, builtin_bounds,
&mut all_bounds); &mut all_bounds);

View file

@ -1442,7 +1442,7 @@ pub fn compute_opt_region_bound(tcx: &ty::ctxt,
let derived_region_bounds = let derived_region_bounds =
ty::required_region_bounds( ty::required_region_bounds(
tcx, tcx,
[], &[],
builtin_bounds, builtin_bounds,
trait_bounds); trait_bounds);

View file

@ -1064,7 +1064,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
// First try to borrow to a slice // First try to borrow to a slice
let entry = self.search_for_some_kind_of_autorefd_method( let entry = self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, m, None), autoderefs, [MutImmutable, MutMutable], |r, m| AutoPtr(r, m, None), autoderefs, &[MutImmutable, MutMutable],
|m,r| ty::mk_slice(tcx, r, |m,r| ty::mk_slice(tcx, r,
ty::mt {ty:ty, mutbl:m})); ty::mt {ty:ty, mutbl:m}));
@ -1075,7 +1075,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
// Then try to borrow to a slice *and* borrow a pointer. // Then try to borrow to a slice *and* borrow a pointer.
self.search_for_some_kind_of_autorefd_method( self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, ast::MutImmutable, Some( box AutoPtr(r, m, None))), |r, m| AutoPtr(r, ast::MutImmutable, Some( box AutoPtr(r, m, None))),
autoderefs, [MutImmutable, MutMutable], autoderefs, &[MutImmutable, MutMutable],
|m, r| { |m, r| {
let slice_ty = ty::mk_slice(tcx, r, let slice_ty = ty::mk_slice(tcx, r,
ty::mt {ty:ty, mutbl:m}); ty::mt {ty:ty, mutbl:m});
@ -1096,7 +1096,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
// First try to borrow to an unsized vec. // First try to borrow to an unsized vec.
let entry = self.search_for_some_kind_of_autorefd_method( let entry = self.search_for_some_kind_of_autorefd_method(
|_r, _m| AutoUnsize(ty::UnsizeLength(len)), |_r, _m| AutoUnsize(ty::UnsizeLength(len)),
autoderefs, [MutImmutable, MutMutable], autoderefs, &[MutImmutable, MutMutable],
|_m, _r| ty::mk_vec(tcx, ty, None)); |_m, _r| ty::mk_vec(tcx, ty, None));
if entry.is_some() { if entry.is_some() {
@ -1106,7 +1106,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
// Then try to borrow to a slice. // Then try to borrow to a slice.
let entry = self.search_for_some_kind_of_autorefd_method( let entry = self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, m, Some(box AutoUnsize(ty::UnsizeLength(len)))), |r, m| AutoPtr(r, m, Some(box AutoUnsize(ty::UnsizeLength(len)))),
autoderefs, [MutImmutable, MutMutable], autoderefs, &[MutImmutable, MutMutable],
|m, r| ty::mk_slice(tcx, r, ty::mt {ty:ty, mutbl:m})); |m, r| ty::mk_slice(tcx, r, ty::mt {ty:ty, mutbl:m}));
if entry.is_some() { if entry.is_some() {
@ -1118,7 +1118,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
|r, m| AutoPtr(r, m, |r, m| AutoPtr(r, m,
Some(box AutoPtr(r, m, Some(box AutoPtr(r, m,
Some(box AutoUnsize(ty::UnsizeLength(len)))))), Some(box AutoUnsize(ty::UnsizeLength(len)))))),
autoderefs, [MutImmutable, MutMutable], autoderefs, &[MutImmutable, MutMutable],
|m, r| { |m, r| {
let slice_ty = ty::mk_slice(tcx, r, ty::mt {ty:ty, mutbl:m}); let slice_ty = ty::mk_slice(tcx, r, ty::mt {ty:ty, mutbl:m});
ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:MutImmutable}) ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:MutImmutable})
@ -1130,7 +1130,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
debug!("auto_slice_str"); debug!("auto_slice_str");
let entry = self.search_for_some_kind_of_autorefd_method( let entry = self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, m, None), autoderefs, [MutImmutable], |r, m| AutoPtr(r, m, None), autoderefs, &[MutImmutable],
|_m, r| ty::mk_str_slice(tcx, r, MutImmutable)); |_m, r| ty::mk_str_slice(tcx, r, MutImmutable));
if entry.is_some() { if entry.is_some() {
@ -1139,7 +1139,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
self.search_for_some_kind_of_autorefd_method( self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, ast::MutImmutable, Some( box AutoPtr(r, m, None))), |r, m| AutoPtr(r, ast::MutImmutable, Some( box AutoPtr(r, m, None))),
autoderefs, [MutImmutable], autoderefs, &[MutImmutable],
|m, r| { |m, r| {
let slice_ty = ty::mk_str_slice(tcx, r, m); let slice_ty = ty::mk_str_slice(tcx, r, m);
ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m}) ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m})
@ -1158,7 +1158,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
let tcx = self.tcx(); let tcx = self.tcx();
self.search_for_some_kind_of_autorefd_method( self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, m, None), |r, m| AutoPtr(r, m, None),
autoderefs, [MutImmutable, MutMutable], autoderefs, &[MutImmutable, MutMutable],
|m, r| { |m, r| {
let principal = ty::TraitRef::new(trt_did, let principal = ty::TraitRef::new(trt_did,
trt_substs.clone()); trt_substs.clone());
@ -1220,7 +1220,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
ty_unboxed_closure(..) | ty_tup(..) | ty_open(..) | ty_unboxed_closure(..) | ty_tup(..) | ty_open(..) |
ty_str | ty_vec(..) | ty_trait(..) | ty_closure(..) => { ty_str | ty_vec(..) | ty_trait(..) | ty_closure(..) => {
self.search_for_some_kind_of_autorefd_method( self.search_for_some_kind_of_autorefd_method(
|r, m| AutoPtr(r, m, None), autoderefs, [MutImmutable, MutMutable], |r, m| AutoPtr(r, m, None), autoderefs, &[MutImmutable, MutMutable],
|m,r| ty::mk_rptr(tcx, r, ty::mt {ty:self_ty, mutbl:m})) |m,r| ty::mk_rptr(tcx, r, ty::mt {ty:self_ty, mutbl:m}))
} }

View file

@ -412,9 +412,9 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
// region bounds required from all of the trait types: // region bounds required from all of the trait types:
let required_region_bounds = let required_region_bounds =
ty::required_region_bounds(self.tcx, ty::required_region_bounds(self.tcx,
[], &[],
bounds.builtin_bounds, bounds.builtin_bounds,
[]); &[]);
for &r_d in required_region_bounds.iter() { for &r_d in required_region_bounds.iter() {
// Each of these is an instance of the `'c <= 'b` // Each of these is an instance of the `'c <= 'b`
// constraint above // constraint above

View file

@ -152,9 +152,9 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
ItemImpl(_, ref opt_trait, _, _) => { ItemImpl(_, ref opt_trait, _, _) => {
match opt_trait.clone() { match opt_trait.clone() {
Some(opt_trait) => { Some(opt_trait) => {
self.cc.check_implementation(item, [opt_trait]); self.cc.check_implementation(item, &[opt_trait]);
} }
None => self.cc.check_implementation(item, []) None => self.cc.check_implementation(item, &[])
} }
} }
_ => { _ => {

View file

@ -376,7 +376,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
#[test] #[test]
fn contravariant_region_ptr_ok() { fn contravariant_region_ptr_ok() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
env.create_simple_region_hierarchy(); env.create_simple_region_hierarchy();
let t_rptr1 = env.t_rptr_scope(1); let t_rptr1 = env.t_rptr_scope(1);
let t_rptr10 = env.t_rptr_scope(10); let t_rptr10 = env.t_rptr_scope(10);
@ -390,7 +390,7 @@ fn contravariant_region_ptr_ok() {
fn contravariant_region_ptr_err() { fn contravariant_region_ptr_err() {
test_env("contravariant_region_ptr", test_env("contravariant_region_ptr",
EMPTY_SOURCE_STR, EMPTY_SOURCE_STR,
errors(["lifetime mismatch"]), errors(&["lifetime mismatch"]),
|env| { |env| {
env.create_simple_region_hierarchy(); env.create_simple_region_hierarchy();
let t_rptr1 = env.t_rptr_scope(1); let t_rptr1 = env.t_rptr_scope(1);
@ -405,114 +405,114 @@ fn contravariant_region_ptr_err() {
#[test] #[test]
fn lub_bound_bound() { fn lub_bound_bound() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_bound2 = env.t_rptr_late_bound(22, 2); let t_rptr_bound2 = env.t_rptr_late_bound(22, 2);
env.check_lub(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_lub(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_bound2], env.t_int()), env.t_fn(22, &[t_rptr_bound2], env.t_int()),
env.t_fn(22, [t_rptr_bound1], env.t_int())); env.t_fn(22, &[t_rptr_bound1], env.t_int()));
}) })
} }
#[test] #[test]
fn lub_bound_free() { fn lub_bound_free() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_free1 = env.t_rptr_free(0, 1); let t_rptr_free1 = env.t_rptr_free(0, 1);
env.check_lub(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_lub(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_free1], env.t_int()), env.t_fn(22, &[t_rptr_free1], env.t_int()),
env.t_fn(22, [t_rptr_free1], env.t_int())); env.t_fn(22, &[t_rptr_free1], env.t_int()));
}) })
} }
#[test] #[test]
fn lub_bound_static() { fn lub_bound_static() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_static = env.t_rptr_static(); let t_rptr_static = env.t_rptr_static();
env.check_lub(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_lub(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_static], env.t_int()), env.t_fn(22, &[t_rptr_static], env.t_int()),
env.t_fn(22, [t_rptr_static], env.t_int())); env.t_fn(22, &[t_rptr_static], env.t_int()));
}) })
} }
#[test] #[test]
fn lub_bound_bound_inverse_order() { fn lub_bound_bound_inverse_order() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_bound2 = env.t_rptr_late_bound(22, 2); let t_rptr_bound2 = env.t_rptr_late_bound(22, 2);
env.check_lub(env.t_fn(22, [t_rptr_bound1, t_rptr_bound2], t_rptr_bound1), env.check_lub(env.t_fn(22, &[t_rptr_bound1, t_rptr_bound2], t_rptr_bound1),
env.t_fn(22, [t_rptr_bound2, t_rptr_bound1], t_rptr_bound1), env.t_fn(22, &[t_rptr_bound2, t_rptr_bound1], t_rptr_bound1),
env.t_fn(22, [t_rptr_bound1, t_rptr_bound1], t_rptr_bound1)); env.t_fn(22, &[t_rptr_bound1, t_rptr_bound1], t_rptr_bound1));
}) })
} }
#[test] #[test]
fn lub_free_free() { fn lub_free_free() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_free1 = env.t_rptr_free(0, 1); let t_rptr_free1 = env.t_rptr_free(0, 1);
let t_rptr_free2 = env.t_rptr_free(0, 2); let t_rptr_free2 = env.t_rptr_free(0, 2);
let t_rptr_static = env.t_rptr_static(); let t_rptr_static = env.t_rptr_static();
env.check_lub(env.t_fn(22, [t_rptr_free1], env.t_int()), env.check_lub(env.t_fn(22, &[t_rptr_free1], env.t_int()),
env.t_fn(22, [t_rptr_free2], env.t_int()), env.t_fn(22, &[t_rptr_free2], env.t_int()),
env.t_fn(22, [t_rptr_static], env.t_int())); env.t_fn(22, &[t_rptr_static], env.t_int()));
}) })
} }
#[test] #[test]
fn lub_returning_scope() { fn lub_returning_scope() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, test_env("contravariant_region_ptr", EMPTY_SOURCE_STR,
errors(["cannot infer an appropriate lifetime"]), |env| { errors(&["cannot infer an appropriate lifetime"]), |env| {
let t_rptr_scope10 = env.t_rptr_scope(10); let t_rptr_scope10 = env.t_rptr_scope(10);
let t_rptr_scope11 = env.t_rptr_scope(11); let t_rptr_scope11 = env.t_rptr_scope(11);
// this should generate an error when regions are resolved // this should generate an error when regions are resolved
env.make_lub_ty(env.t_fn(22, [], t_rptr_scope10), env.make_lub_ty(env.t_fn(22, &[], t_rptr_scope10),
env.t_fn(22, [], t_rptr_scope11)); env.t_fn(22, &[], t_rptr_scope11));
}) })
} }
#[test] #[test]
fn glb_free_free_with_common_scope() { fn glb_free_free_with_common_scope() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_free1 = env.t_rptr_free(0, 1); let t_rptr_free1 = env.t_rptr_free(0, 1);
let t_rptr_free2 = env.t_rptr_free(0, 2); let t_rptr_free2 = env.t_rptr_free(0, 2);
let t_rptr_scope = env.t_rptr_scope(0); let t_rptr_scope = env.t_rptr_scope(0);
env.check_glb(env.t_fn(22, [t_rptr_free1], env.t_int()), env.check_glb(env.t_fn(22, &[t_rptr_free1], env.t_int()),
env.t_fn(22, [t_rptr_free2], env.t_int()), env.t_fn(22, &[t_rptr_free2], env.t_int()),
env.t_fn(22, [t_rptr_scope], env.t_int())); env.t_fn(22, &[t_rptr_scope], env.t_int()));
}) })
} }
#[test] #[test]
fn glb_bound_bound() { fn glb_bound_bound() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_bound2 = env.t_rptr_late_bound(22, 2); let t_rptr_bound2 = env.t_rptr_late_bound(22, 2);
env.check_glb(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_glb(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_bound2], env.t_int()), env.t_fn(22, &[t_rptr_bound2], env.t_int()),
env.t_fn(22, [t_rptr_bound1], env.t_int())); env.t_fn(22, &[t_rptr_bound1], env.t_int()));
}) })
} }
#[test] #[test]
fn glb_bound_free() { fn glb_bound_free() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_free1 = env.t_rptr_free(0, 1); let t_rptr_free1 = env.t_rptr_free(0, 1);
env.check_glb(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_glb(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_free1], env.t_int()), env.t_fn(22, &[t_rptr_free1], env.t_int()),
env.t_fn(22, [t_rptr_bound1], env.t_int())); env.t_fn(22, &[t_rptr_bound1], env.t_int()));
}) })
} }
#[test] #[test]
fn glb_bound_static() { fn glb_bound_static() {
test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors([]), |env| { test_env("contravariant_region_ptr", EMPTY_SOURCE_STR, errors(&[]), |env| {
let t_rptr_bound1 = env.t_rptr_late_bound(22, 1); let t_rptr_bound1 = env.t_rptr_late_bound(22, 1);
let t_rptr_static = env.t_rptr_static(); let t_rptr_static = env.t_rptr_static();
env.check_glb(env.t_fn(22, [t_rptr_bound1], env.t_int()), env.check_glb(env.t_fn(22, &[t_rptr_bound1], env.t_int()),
env.t_fn(22, [t_rptr_static], env.t_int()), env.t_fn(22, &[t_rptr_static], env.t_int()),
env.t_fn(22, [t_rptr_bound1], env.t_int())); env.t_fn(22, &[t_rptr_bound1], env.t_int()));
}) })
} }

View file

@ -141,12 +141,12 @@ impl<'a> Archive<'a> {
/// Removes a file from this archive /// Removes a file from this archive
pub fn remove_file(&mut self, file: &str) { pub fn remove_file(&mut self, file: &str) {
run_ar(self.handler, &self.maybe_ar_prog, "d", None, [&self.dst, &Path::new(file)]); run_ar(self.handler, &self.maybe_ar_prog, "d", None, &[&self.dst, &Path::new(file)]);
} }
/// Lists all files in an archive /// Lists all files in an archive
pub fn files(&self) -> Vec<String> { pub fn files(&self) -> Vec<String> {
let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, [&self.dst]); let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, &[&self.dst]);
let output = str::from_utf8(output.output.as_slice()).unwrap(); let output = str::from_utf8(output.output.as_slice()).unwrap();
// use lines_any because windows delimits output with `\r\n` instead of // use lines_any because windows delimits output with `\r\n` instead of
// just `\n` // just `\n`
@ -288,7 +288,7 @@ impl<'a> ArchiveBuilder<'a> {
// of filename collisions. // of filename collisions.
let archive = os::make_absolute(archive); let archive = os::make_absolute(archive);
run_ar(self.archive.handler, &self.archive.maybe_ar_prog, run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
"x", Some(loc.path()), [&archive]); "x", Some(loc.path()), &[&archive]);
// Next, we must rename all of the inputs to "guaranteed unique names". // Next, we must rename all of the inputs to "guaranteed unique names".
// We move each file into `self.work_dir` under its new unique name. // We move each file into `self.work_dir` under its new unique name.

View file

@ -140,7 +140,7 @@ mod test {
#[test] #[test]
fn test_rpaths_to_flags() { fn test_rpaths_to_flags() {
let flags = rpaths_to_flags([ let flags = rpaths_to_flags(&[
"path1".to_string(), "path1".to_string(),
"path2".to_string() "path2".to_string()
]); ]);
@ -151,12 +151,12 @@ mod test {
#[test] #[test]
fn test_minimize1() { fn test_minimize1() {
let res = minimize_rpaths([ let res = minimize_rpaths(&[
"rpath1".to_string(), "rpath1".to_string(),
"rpath2".to_string(), "rpath2".to_string(),
"rpath1".to_string() "rpath1".to_string()
]); ]);
assert!(res.as_slice() == [ assert!(res.as_slice() == &[
"rpath1".to_string(), "rpath1".to_string(),
"rpath2".to_string() "rpath2".to_string()
]); ]);
@ -164,7 +164,7 @@ mod test {
#[test] #[test]
fn test_minimize2() { fn test_minimize2() {
let res = minimize_rpaths([ let res = minimize_rpaths(&[
"1a".to_string(), "1a".to_string(),
"2".to_string(), "2".to_string(),
"2".to_string(), "2".to_string(),
@ -176,7 +176,7 @@ mod test {
"4a".to_string(), "4a".to_string(),
"3".to_string() "3".to_string()
]); ]);
assert!(res.as_slice() == [ assert!(res.as_slice() == &[
"1a".to_string(), "1a".to_string(),
"2".to_string(), "2".to_string(),
"4a".to_string(), "4a".to_string(),

View file

@ -139,7 +139,7 @@ impl FixedBuffer for FixedBuffer64 {
self.buffer[mut self.buffer_idx..size], self.buffer[mut self.buffer_idx..size],
input[..buffer_remaining]); input[..buffer_remaining]);
self.buffer_idx = 0; self.buffer_idx = 0;
func(self.buffer); func(&self.buffer);
i += buffer_remaining; i += buffer_remaining;
} else { } else {
copy_memory( copy_memory(
@ -657,7 +657,7 @@ mod bench {
let mut sh = Sha256::new(); let mut sh = Sha256::new();
let bytes = [1u8, ..10]; let bytes = [1u8, ..10];
b.iter(|| { b.iter(|| {
sh.input(bytes); sh.input(&bytes);
}); });
b.bytes = bytes.len() as u64; b.bytes = bytes.len() as u64;
} }
@ -667,7 +667,7 @@ mod bench {
let mut sh = Sha256::new(); let mut sh = Sha256::new();
let bytes = [1u8, ..1024]; let bytes = [1u8, ..1024];
b.iter(|| { b.iter(|| {
sh.input(bytes); sh.input(&bytes);
}); });
b.bytes = bytes.len() as u64; b.bytes = bytes.len() as u64;
} }
@ -677,7 +677,7 @@ mod bench {
let mut sh = Sha256::new(); let mut sh = Sha256::new();
let bytes = [1u8, ..65536]; let bytes = [1u8, ..65536];
b.iter(|| { b.iter(|| {
sh.input(bytes); sh.input(&bytes);
}); });
b.bytes = bytes.len() as u64; b.bytes = bytes.len() as u64;
} }

View file

@ -432,7 +432,7 @@ unsafe fn with_c_str<T>(v: &[u8], checked: bool,
f: |*const libc::c_char| -> T) -> T { f: |*const libc::c_char| -> T) -> T {
let c_str = if v.len() < BUF_LEN { let c_str = if v.len() < BUF_LEN {
let mut buf: [u8, .. BUF_LEN] = mem::uninitialized(); let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
slice::bytes::copy_memory(buf, v); slice::bytes::copy_memory(&mut buf, v);
buf[v.len()] = 0; buf[v.len()] = 0;
let buf = buf.as_mut_ptr(); let buf = buf.as_mut_ptr();
@ -554,7 +554,7 @@ mod tests {
#[test] #[test]
fn test_vec_to_c_str() { fn test_vec_to_c_str() {
let b: &[u8] = []; let b: &[u8] = &[];
let c_str = b.to_c_str(); let c_str = b.to_c_str();
unsafe { unsafe {
assert_eq!(*c_str.as_ptr().offset(0), 0); assert_eq!(*c_str.as_ptr().offset(0), 0);
@ -646,7 +646,7 @@ mod tests {
let c_str = "hello".to_c_str(); let c_str = "hello".to_c_str();
assert_eq!(c_str.as_bytes_no_nul(), b"hello"); assert_eq!(c_str.as_bytes_no_nul(), b"hello");
let c_str = "".to_c_str(); let c_str = "".to_c_str();
let exp: &[u8] = []; let exp: &[u8] = &[];
assert_eq!(c_str.as_bytes_no_nul(), exp); assert_eq!(c_str.as_bytes_no_nul(), exp);
let c_str = b"foo\xFF".to_c_str(); let c_str = b"foo\xFF".to_c_str();
assert_eq!(c_str.as_bytes_no_nul(), b"foo\xFF"); assert_eq!(c_str.as_bytes_no_nul(), b"foo\xFF");

View file

@ -74,7 +74,7 @@ pub fn abort(args: &fmt::Arguments) -> ! {
// Convert the arguments into a stack-allocated string // Convert the arguments into a stack-allocated string
let mut msg = [0u8, ..512]; let mut msg = [0u8, ..512];
let mut w = BufWriter { buf: msg, pos: 0 }; let mut w = BufWriter { buf: &mut msg, pos: 0 };
let _ = write!(&mut w, "{}", args); let _ = write!(&mut w, "{}", args);
let msg = str::from_utf8(w.buf[mut ..w.pos]).unwrap_or("aborted"); let msg = str::from_utf8(w.buf[mut ..w.pos]).unwrap_or("aborted");
let msg = if msg.is_empty() {"aborted"} else {msg}; let msg = if msg.is_empty() {"aborted"} else {msg};

View file

@ -361,8 +361,8 @@ fn escape_str(writer: &mut io::Writer, v: &str) -> Result<(), io::IoError> {
fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> { fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
let mut buf = [0, .. 4]; let mut buf = [0, .. 4];
v.encode_utf8(buf); v.encode_utf8(&mut buf);
escape_bytes(writer, buf) escape_bytes(writer, &mut buf)
} }
fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> { fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
@ -370,7 +370,7 @@ fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
static BUF: [u8, ..LEN] = [b' ', ..LEN]; static BUF: [u8, ..LEN] = [b' ', ..LEN];
while n >= LEN { while n >= LEN {
try!(wr.write(BUF)); try!(wr.write(&BUF));
n -= LEN; n -= LEN;
} }
@ -2584,27 +2584,27 @@ mod tests {
#[test] #[test]
fn test_write_object() { fn test_write_object() {
assert_eq!(mk_object([]).to_string().into_string(), "{}".to_string()); assert_eq!(mk_object(&[]).to_string().into_string(), "{}".to_string());
assert_eq!(mk_object([]).to_pretty_str().into_string(), "{}".to_string()); assert_eq!(mk_object(&[]).to_pretty_str().into_string(), "{}".to_string());
assert_eq!( assert_eq!(
mk_object([ mk_object(&[
("a".to_string(), Boolean(true)) ("a".to_string(), Boolean(true))
]).to_string().into_string(), ]).to_string().into_string(),
"{\"a\":true}".to_string() "{\"a\":true}".to_string()
); );
assert_eq!( assert_eq!(
mk_object([("a".to_string(), Boolean(true))]).to_pretty_str(), mk_object(&[("a".to_string(), Boolean(true))]).to_pretty_str(),
"\ "\
{\n \ {\n \
\"a\": true\n\ \"a\": true\n\
}".to_string() }".to_string()
); );
let complex_obj = mk_object([ let complex_obj = mk_object(&[
("b".to_string(), List(vec![ ("b".to_string(), List(vec![
mk_object([("c".to_string(), String("\x0c\r".to_string()))]), mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
mk_object([("d".to_string(), String("".to_string()))]) mk_object(&[("d".to_string(), String("".to_string()))])
])) ]))
]); ]);
@ -2632,11 +2632,11 @@ mod tests {
}".to_string() }".to_string()
); );
let a = mk_object([ let a = mk_object(&[
("a".to_string(), Boolean(true)), ("a".to_string(), Boolean(true)),
("b".to_string(), List(vec![ ("b".to_string(), List(vec![
mk_object([("c".to_string(), String("\x0c\r".to_string()))]), mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
mk_object([("d".to_string(), String("".to_string()))]) mk_object(&[("d".to_string(), String("".to_string()))])
])) ]))
]); ]);
@ -2941,22 +2941,22 @@ mod tests {
assert_eq!(from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax, 1, 8))); assert_eq!(from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax, 1, 8)));
assert_eq!(from_str("{\"a\":1,"), Err(SyntaxError(EOFWhileParsingObject, 1, 8))); assert_eq!(from_str("{\"a\":1,"), Err(SyntaxError(EOFWhileParsingObject, 1, 8)));
assert_eq!(from_str("{}").unwrap(), mk_object([])); assert_eq!(from_str("{}").unwrap(), mk_object(&[]));
assert_eq!(from_str("{\"a\": 3}").unwrap(), assert_eq!(from_str("{\"a\": 3}").unwrap(),
mk_object([("a".to_string(), U64(3))])); mk_object(&[("a".to_string(), U64(3))]));
assert_eq!(from_str( assert_eq!(from_str(
"{ \"a\": null, \"b\" : true }").unwrap(), "{ \"a\": null, \"b\" : true }").unwrap(),
mk_object([ mk_object(&[
("a".to_string(), Null), ("a".to_string(), Null),
("b".to_string(), Boolean(true))])); ("b".to_string(), Boolean(true))]));
assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(), assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(),
mk_object([ mk_object(&[
("a".to_string(), Null), ("a".to_string(), Null),
("b".to_string(), Boolean(true))])); ("b".to_string(), Boolean(true))]));
assert_eq!(from_str( assert_eq!(from_str(
"{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(), "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(),
mk_object([ mk_object(&[
("a".to_string(), F64(1.0)), ("a".to_string(), F64(1.0)),
("b".to_string(), List(vec![Boolean(true)])) ("b".to_string(), List(vec![Boolean(true)]))
])); ]));
@ -2969,13 +2969,13 @@ mod tests {
{ \"c\": {\"d\": null} } \ { \"c\": {\"d\": null} } \
]\ ]\
}").unwrap(), }").unwrap(),
mk_object([ mk_object(&[
("a".to_string(), F64(1.0)), ("a".to_string(), F64(1.0)),
("b".to_string(), List(vec![ ("b".to_string(), List(vec![
Boolean(true), Boolean(true),
String("foo\nbar".to_string()), String("foo\nbar".to_string()),
mk_object([ mk_object(&[
("c".to_string(), mk_object([("d".to_string(), Null)])) ("c".to_string(), mk_object(&[("d".to_string(), Null)]))
]) ])
])) ]))
])); ]));
@ -3639,20 +3639,20 @@ mod tests {
stack.bump_index(); stack.bump_index();
assert!(stack.len() == 1); assert!(stack.len() == 1);
assert!(stack.is_equal_to([Index(1)])); assert!(stack.is_equal_to(&[Index(1)]));
assert!(stack.starts_with([Index(1)])); assert!(stack.starts_with(&[Index(1)]));
assert!(stack.ends_with([Index(1)])); assert!(stack.ends_with(&[Index(1)]));
assert!(stack.last_is_index()); assert!(stack.last_is_index());
assert!(stack.get(0) == Index(1)); assert!(stack.get(0) == Index(1));
stack.push_key("foo".to_string()); stack.push_key("foo".to_string());
assert!(stack.len() == 2); assert!(stack.len() == 2);
assert!(stack.is_equal_to([Index(1), Key("foo")])); assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
assert!(stack.starts_with([Index(1), Key("foo")])); assert!(stack.starts_with(&[Index(1), Key("foo")]));
assert!(stack.starts_with([Index(1)])); assert!(stack.starts_with(&[Index(1)]));
assert!(stack.ends_with([Index(1), Key("foo")])); assert!(stack.ends_with(&[Index(1), Key("foo")]));
assert!(stack.ends_with([Key("foo")])); assert!(stack.ends_with(&[Key("foo")]));
assert!(!stack.last_is_index()); assert!(!stack.last_is_index());
assert!(stack.get(0) == Index(1)); assert!(stack.get(0) == Index(1));
assert!(stack.get(1) == Key("foo")); assert!(stack.get(1) == Key("foo"));
@ -3660,13 +3660,13 @@ mod tests {
stack.push_key("bar".to_string()); stack.push_key("bar".to_string());
assert!(stack.len() == 3); assert!(stack.len() == 3);
assert!(stack.is_equal_to([Index(1), Key("foo"), Key("bar")])); assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")]));
assert!(stack.starts_with([Index(1)])); assert!(stack.starts_with(&[Index(1)]));
assert!(stack.starts_with([Index(1), Key("foo")])); assert!(stack.starts_with(&[Index(1), Key("foo")]));
assert!(stack.starts_with([Index(1), Key("foo"), Key("bar")])); assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")]));
assert!(stack.ends_with([Key("bar")])); assert!(stack.ends_with(&[Key("bar")]));
assert!(stack.ends_with([Key("foo"), Key("bar")])); assert!(stack.ends_with(&[Key("foo"), Key("bar")]));
assert!(stack.ends_with([Index(1), Key("foo"), Key("bar")])); assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")]));
assert!(!stack.last_is_index()); assert!(!stack.last_is_index());
assert!(stack.get(0) == Index(1)); assert!(stack.get(0) == Index(1));
assert!(stack.get(1) == Key("foo")); assert!(stack.get(1) == Key("foo"));
@ -3675,11 +3675,11 @@ mod tests {
stack.pop(); stack.pop();
assert!(stack.len() == 2); assert!(stack.len() == 2);
assert!(stack.is_equal_to([Index(1), Key("foo")])); assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
assert!(stack.starts_with([Index(1), Key("foo")])); assert!(stack.starts_with(&[Index(1), Key("foo")]));
assert!(stack.starts_with([Index(1)])); assert!(stack.starts_with(&[Index(1)]));
assert!(stack.ends_with([Index(1), Key("foo")])); assert!(stack.ends_with(&[Index(1), Key("foo")]));
assert!(stack.ends_with([Key("foo")])); assert!(stack.ends_with(&[Key("foo")]));
assert!(!stack.last_is_index()); assert!(!stack.last_is_index());
assert!(stack.get(0) == Index(1)); assert!(stack.get(0) == Index(1));
assert!(stack.get(1) == Key("foo")); assert!(stack.get(1) == Key("foo"));

View file

@ -38,7 +38,7 @@ use vec::Vec;
/// let mut reader = BufferedReader::new(file); /// let mut reader = BufferedReader::new(file);
/// ///
/// let mut buf = [0, ..100]; /// let mut buf = [0, ..100];
/// match reader.read(buf) { /// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread), /// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("error reading: {}", e) /// Err(e) => println!("error reading: {}", e)
/// } /// }
@ -300,7 +300,7 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
/// stream.flush(); /// stream.flush();
/// ///
/// let mut buf = [0, ..100]; /// let mut buf = [0, ..100];
/// match stream.read(buf) { /// match stream.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread), /// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("error reading: {}", e) /// Err(e) => println!("error reading: {}", e)
/// } /// }
@ -414,35 +414,35 @@ mod test {
let mut reader = BufferedReader::with_capacity(2, inner); let mut reader = BufferedReader::with_capacity(2, inner);
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let nread = reader.read(buf); let nread = reader.read(&mut buf);
assert_eq!(Ok(3), nread); assert_eq!(Ok(3), nread);
let b: &[_] = &[5, 6, 7]; let b: &[_] = &[5, 6, 7];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let mut buf = [0, 0]; let mut buf = [0, 0];
let nread = reader.read(buf); let nread = reader.read(&mut buf);
assert_eq!(Ok(2), nread); assert_eq!(Ok(2), nread);
let b: &[_] = &[0, 1]; let b: &[_] = &[0, 1];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let mut buf = [0]; let mut buf = [0];
let nread = reader.read(buf); let nread = reader.read(&mut buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
let b: &[_] = &[2]; let b: &[_] = &[2];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let nread = reader.read(buf); let nread = reader.read(&mut buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
let b: &[_] = &[3, 0, 0]; let b: &[_] = &[3, 0, 0];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let nread = reader.read(buf); let nread = reader.read(&mut buf);
assert_eq!(Ok(1), nread); assert_eq!(Ok(1), nread);
let b: &[_] = &[4, 0, 0]; let b: &[_] = &[4, 0, 0];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
} }
#[test] #[test]
@ -450,36 +450,36 @@ mod test {
let inner = MemWriter::new(); let inner = MemWriter::new();
let mut writer = BufferedWriter::with_capacity(2, inner); let mut writer = BufferedWriter::with_capacity(2, inner);
writer.write([0, 1]).unwrap(); writer.write(&[0, 1]).unwrap();
let b: &[_] = &[]; let b: &[_] = &[];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.write([2]).unwrap(); writer.write(&[2]).unwrap();
let b: &[_] = &[0, 1]; let b: &[_] = &[0, 1];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.write([3]).unwrap(); writer.write(&[3]).unwrap();
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.flush().unwrap(); writer.flush().unwrap();
let a: &[_] = &[0, 1, 2, 3]; let a: &[_] = &[0, 1, 2, 3];
assert_eq!(a, writer.get_ref().get_ref()); assert_eq!(a, writer.get_ref().get_ref());
writer.write([4]).unwrap(); writer.write(&[4]).unwrap();
writer.write([5]).unwrap(); writer.write(&[5]).unwrap();
assert_eq!(a, writer.get_ref().get_ref()); assert_eq!(a, writer.get_ref().get_ref());
writer.write([6]).unwrap(); writer.write(&[6]).unwrap();
let a: &[_] = &[0, 1, 2, 3, 4, 5]; let a: &[_] = &[0, 1, 2, 3, 4, 5];
assert_eq!(a, assert_eq!(a,
writer.get_ref().get_ref()); writer.get_ref().get_ref());
writer.write([7, 8]).unwrap(); writer.write(&[7, 8]).unwrap();
let a: &[_] = &[0, 1, 2, 3, 4, 5, 6]; let a: &[_] = &[0, 1, 2, 3, 4, 5, 6];
assert_eq!(a, assert_eq!(a,
writer.get_ref().get_ref()); writer.get_ref().get_ref());
writer.write([9, 10, 11]).unwrap(); writer.write(&[9, 10, 11]).unwrap();
let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
assert_eq!(a, assert_eq!(a,
writer.get_ref().get_ref()); writer.get_ref().get_ref());
@ -492,7 +492,7 @@ mod test {
#[test] #[test]
fn test_buffered_writer_inner_flushes() { fn test_buffered_writer_inner_flushes() {
let mut w = BufferedWriter::with_capacity(3, MemWriter::new()); let mut w = BufferedWriter::with_capacity(3, MemWriter::new());
w.write([0, 1]).unwrap(); w.write(&[0, 1]).unwrap();
let a: &[_] = &[]; let a: &[_] = &[];
assert_eq!(a, w.get_ref().get_ref()); assert_eq!(a, w.get_ref().get_ref());
let w = w.unwrap(); let w = w.unwrap();
@ -518,8 +518,8 @@ mod test {
let mut stream = BufferedStream::new(S); let mut stream = BufferedStream::new(S);
let mut buf = []; let mut buf = [];
assert!(stream.read(buf).is_err()); assert!(stream.read(&mut buf).is_err());
stream.write(buf).unwrap(); stream.write(&buf).unwrap();
stream.flush().unwrap(); stream.flush().unwrap();
} }
@ -537,21 +537,21 @@ mod test {
#[test] #[test]
fn test_line_buffer() { fn test_line_buffer() {
let mut writer = LineBufferedWriter::new(MemWriter::new()); let mut writer = LineBufferedWriter::new(MemWriter::new());
writer.write([0]).unwrap(); writer.write(&[0]).unwrap();
let b: &[_] = &[]; let b: &[_] = &[];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.write([1]).unwrap(); writer.write(&[1]).unwrap();
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.flush().unwrap(); writer.flush().unwrap();
let b: &[_] = &[0, 1]; let b: &[_] = &[0, 1];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.write([0, b'\n', 1, b'\n', 2]).unwrap(); writer.write(&[0, b'\n', 1, b'\n', 2]).unwrap();
let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n']; let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n'];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.flush().unwrap(); writer.flush().unwrap();
let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2]; let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
writer.write([3, b'\n']).unwrap(); writer.write(&[3, b'\n']).unwrap();
let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n']; let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n'];
assert_eq!(writer.get_ref().get_ref(), b); assert_eq!(writer.get_ref().get_ref(), b);
} }
@ -582,26 +582,26 @@ mod test {
let inner = ShortReader{lengths: vec![0, 1, 2, 0, 1, 0]}; let inner = ShortReader{lengths: vec![0, 1, 2, 0, 1, 0]};
let mut reader = BufferedReader::new(inner); let mut reader = BufferedReader::new(inner);
let mut buf = [0, 0]; let mut buf = [0, 0];
assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(&mut buf), Ok(1));
assert_eq!(reader.read(buf), Ok(2)); assert_eq!(reader.read(&mut buf), Ok(2));
assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(&mut buf), Ok(1));
assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(&mut buf), Ok(0));
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
} }
#[test] #[test]
fn read_char_buffered() { fn read_char_buffered() {
let buf = [195u8, 159u8]; let buf = [195u8, 159u8];
let mut reader = BufferedReader::with_capacity(1, BufReader::new(buf)); let mut reader = BufferedReader::with_capacity(1, BufReader::new(&buf));
assert_eq!(reader.read_char(), Ok('ß')); assert_eq!(reader.read_char(), Ok('ß'));
} }
#[test] #[test]
fn test_chars() { fn test_chars() {
let buf = [195u8, 159u8, b'a']; let buf = [195u8, 159u8, b'a'];
let mut reader = BufferedReader::with_capacity(1, BufReader::new(buf)); let mut reader = BufferedReader::with_capacity(1, BufReader::new(&buf));
let mut it = reader.chars(); let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß'))); assert_eq!(it.next(), Some(Ok('ß')));
assert_eq!(it.next(), Some(Ok('a'))); assert_eq!(it.next(), Some(Ok('a')));

View file

@ -30,7 +30,7 @@ use vec::Vec;
/// let mut reader = ChanReader::new(rx); /// let mut reader = ChanReader::new(rx);
/// ///
/// let mut buf = [0u8, ..100]; /// let mut buf = [0u8, ..100];
/// match reader.read(buf) { /// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread), /// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("read error: {}", e), /// Err(e) => println!("read error: {}", e),
/// } /// }
@ -172,17 +172,17 @@ mod test {
let mut reader = ChanReader::new(rx); let mut reader = ChanReader::new(rx);
let mut buf = [0u8, ..3]; let mut buf = [0u8, ..3];
assert_eq!(Ok(0), reader.read([])); assert_eq!(Ok(0), reader.read(&mut []));
assert_eq!(Ok(3), reader.read(buf)); assert_eq!(Ok(3), reader.read(&mut buf));
let a: &[u8] = &[1,2,3]; let a: &[u8] = &[1,2,3];
assert_eq!(a, buf.as_slice()); assert_eq!(a, buf.as_slice());
assert_eq!(Ok(3), reader.read(buf)); assert_eq!(Ok(3), reader.read(&mut buf));
let a: &[u8] = &[4,5,6]; let a: &[u8] = &[4,5,6];
assert_eq!(a, buf.as_slice()); assert_eq!(a, buf.as_slice());
assert_eq!(Ok(2), reader.read(buf)); assert_eq!(Ok(2), reader.read(&mut buf));
let a: &[u8] = &[7,8,6]; let a: &[u8] = &[7,8,6];
assert_eq!(a, buf.as_slice()); assert_eq!(a, buf.as_slice());

View file

@ -82,9 +82,9 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
assert!(size <= 8u); assert!(size <= 8u);
match size { match size {
1u => f(&[n as u8]), 1u => f(&[n as u8]),
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_le()) }), 2u => f(unsafe { & transmute::<_, [u8, ..2]>((n as u16).to_le()) }),
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_le()) }), 4u => f(unsafe { & transmute::<_, [u8, ..4]>((n as u32).to_le()) }),
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_le()) }), 8u => f(unsafe { & transmute::<_, [u8, ..8]>(n.to_le()) }),
_ => { _ => {
let mut bytes = vec!(); let mut bytes = vec!();
@ -121,9 +121,9 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
assert!(size <= 8u); assert!(size <= 8u);
match size { match size {
1u => f(&[n as u8]), 1u => f(&[n as u8]),
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_be()) }), 2u => f(unsafe { & transmute::<_, [u8, ..2]>((n as u16).to_be()) }),
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_be()) }), 4u => f(unsafe { & transmute::<_, [u8, ..4]>((n as u32).to_be()) }),
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_be()) }), 8u => f(unsafe { & transmute::<_, [u8, ..8]>(n.to_be()) }),
_ => { _ => {
let mut bytes = vec!(); let mut bytes = vec!();
let mut i = size; let mut i = size;
@ -474,26 +474,26 @@ mod test {
let buf = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]; let buf = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09];
// Aligned access // Aligned access
assert_eq!(u64_from_be_bytes(buf, 0, 0), 0); assert_eq!(u64_from_be_bytes(&buf, 0, 0), 0);
assert_eq!(u64_from_be_bytes(buf, 0, 1), 0x01); assert_eq!(u64_from_be_bytes(&buf, 0, 1), 0x01);
assert_eq!(u64_from_be_bytes(buf, 0, 2), 0x0102); assert_eq!(u64_from_be_bytes(&buf, 0, 2), 0x0102);
assert_eq!(u64_from_be_bytes(buf, 0, 3), 0x010203); assert_eq!(u64_from_be_bytes(&buf, 0, 3), 0x010203);
assert_eq!(u64_from_be_bytes(buf, 0, 4), 0x01020304); assert_eq!(u64_from_be_bytes(&buf, 0, 4), 0x01020304);
assert_eq!(u64_from_be_bytes(buf, 0, 5), 0x0102030405); assert_eq!(u64_from_be_bytes(&buf, 0, 5), 0x0102030405);
assert_eq!(u64_from_be_bytes(buf, 0, 6), 0x010203040506); assert_eq!(u64_from_be_bytes(&buf, 0, 6), 0x010203040506);
assert_eq!(u64_from_be_bytes(buf, 0, 7), 0x01020304050607); assert_eq!(u64_from_be_bytes(&buf, 0, 7), 0x01020304050607);
assert_eq!(u64_from_be_bytes(buf, 0, 8), 0x0102030405060708); assert_eq!(u64_from_be_bytes(&buf, 0, 8), 0x0102030405060708);
// Unaligned access // Unaligned access
assert_eq!(u64_from_be_bytes(buf, 1, 0), 0); assert_eq!(u64_from_be_bytes(&buf, 1, 0), 0);
assert_eq!(u64_from_be_bytes(buf, 1, 1), 0x02); assert_eq!(u64_from_be_bytes(&buf, 1, 1), 0x02);
assert_eq!(u64_from_be_bytes(buf, 1, 2), 0x0203); assert_eq!(u64_from_be_bytes(&buf, 1, 2), 0x0203);
assert_eq!(u64_from_be_bytes(buf, 1, 3), 0x020304); assert_eq!(u64_from_be_bytes(&buf, 1, 3), 0x020304);
assert_eq!(u64_from_be_bytes(buf, 1, 4), 0x02030405); assert_eq!(u64_from_be_bytes(&buf, 1, 4), 0x02030405);
assert_eq!(u64_from_be_bytes(buf, 1, 5), 0x0203040506); assert_eq!(u64_from_be_bytes(&buf, 1, 5), 0x0203040506);
assert_eq!(u64_from_be_bytes(buf, 1, 6), 0x020304050607); assert_eq!(u64_from_be_bytes(&buf, 1, 6), 0x020304050607);
assert_eq!(u64_from_be_bytes(buf, 1, 7), 0x02030405060708); assert_eq!(u64_from_be_bytes(&buf, 1, 7), 0x02030405060708);
assert_eq!(u64_from_be_bytes(buf, 1, 8), 0x0203040506070809); assert_eq!(u64_from_be_bytes(&buf, 1, 8), 0x0203040506070809);
} }
} }

View file

@ -384,7 +384,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
let mut buf = [0, ..io::DEFAULT_BUF_SIZE]; let mut buf = [0, ..io::DEFAULT_BUF_SIZE];
loop { loop {
let amt = match reader.read(buf) { let amt = match reader.read(&mut buf) {
Ok(n) => n, Ok(n) => n,
Err(ref e) if e.kind == io::EndOfFile => { break } Err(ref e) if e.kind == io::EndOfFile => { break }
Err(e) => return update_err(Err(e), from, to) Err(e) => return update_err(Err(e), from, to)
@ -881,7 +881,7 @@ mod test {
{ {
let mut read_stream = File::open_mode(filename, Open, Read); let mut read_stream = File::open_mode(filename, Open, Read);
let mut read_buf = [0, .. 1028]; let mut read_buf = [0, .. 1028];
let read_str = match check!(read_stream.read(read_buf)) { let read_str = match check!(read_stream.read(&mut read_buf)) {
-1|0 => panic!("shouldn't happen"), -1|0 => panic!("shouldn't happen"),
n => str::from_utf8(read_buf[..n]).unwrap().to_string() n => str::from_utf8(read_buf[..n]).unwrap().to_string()
}; };
@ -939,7 +939,7 @@ mod test {
} }
} }
check!(unlink(filename)); check!(unlink(filename));
let read_str = str::from_utf8(read_mem).unwrap(); let read_str = str::from_utf8(&read_mem).unwrap();
assert_eq!(read_str, message); assert_eq!(read_str, message);
} }
@ -960,11 +960,11 @@ mod test {
let mut read_stream = File::open_mode(filename, Open, Read); let mut read_stream = File::open_mode(filename, Open, Read);
check!(read_stream.seek(set_cursor as i64, SeekSet)); check!(read_stream.seek(set_cursor as i64, SeekSet));
tell_pos_pre_read = check!(read_stream.tell()); tell_pos_pre_read = check!(read_stream.tell());
check!(read_stream.read(read_mem)); check!(read_stream.read(&mut read_mem));
tell_pos_post_read = check!(read_stream.tell()); tell_pos_post_read = check!(read_stream.tell());
} }
check!(unlink(filename)); check!(unlink(filename));
let read_str = str::from_utf8(read_mem).unwrap(); let read_str = str::from_utf8(&read_mem).unwrap();
assert_eq!(read_str, message.slice(4, 8)); assert_eq!(read_str, message.slice(4, 8));
assert_eq!(tell_pos_pre_read, set_cursor); assert_eq!(tell_pos_pre_read, set_cursor);
assert_eq!(tell_pos_post_read, message.len() as u64); assert_eq!(tell_pos_post_read, message.len() as u64);
@ -987,10 +987,10 @@ mod test {
} }
{ {
let mut read_stream = File::open_mode(filename, Open, Read); let mut read_stream = File::open_mode(filename, Open, Read);
check!(read_stream.read(read_mem)); check!(read_stream.read(&mut read_mem));
} }
check!(unlink(filename)); check!(unlink(filename));
let read_str = str::from_utf8(read_mem).unwrap(); let read_str = str::from_utf8(&read_mem).unwrap();
assert!(read_str.as_slice() == final_msg.as_slice()); assert!(read_str.as_slice() == final_msg.as_slice());
} }
@ -1012,16 +1012,16 @@ mod test {
let mut read_stream = File::open_mode(filename, Open, Read); let mut read_stream = File::open_mode(filename, Open, Read);
check!(read_stream.seek(-4, SeekEnd)); check!(read_stream.seek(-4, SeekEnd));
check!(read_stream.read(read_mem)); check!(read_stream.read(&mut read_mem));
assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_three); assert_eq!(str::from_utf8(&read_mem).unwrap(), chunk_three);
check!(read_stream.seek(-9, SeekCur)); check!(read_stream.seek(-9, SeekCur));
check!(read_stream.read(read_mem)); check!(read_stream.read(&mut read_mem));
assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_two); assert_eq!(str::from_utf8(&read_mem).unwrap(), chunk_two);
check!(read_stream.seek(0, SeekSet)); check!(read_stream.seek(0, SeekSet));
check!(read_stream.read(read_mem)); check!(read_stream.read(&mut read_mem));
assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_one); assert_eq!(str::from_utf8(&read_mem).unwrap(), chunk_one);
} }
check!(unlink(filename)); check!(unlink(filename));
} }
@ -1107,8 +1107,8 @@ mod test {
for f in files.iter() { for f in files.iter() {
{ {
let n = f.filestem_str(); let n = f.filestem_str();
check!(File::open(f).read(mem)); check!(File::open(f).read(&mut mem));
let read_str = str::from_utf8(mem).unwrap(); let read_str = str::from_utf8(&mem).unwrap();
let expected = match n { let expected = match n {
None|Some("") => panic!("really shouldn't happen.."), None|Some("") => panic!("really shouldn't happen.."),
Some(n) => format!("{}{}", prefix, n), Some(n) => format!("{}{}", prefix, n),
@ -1532,13 +1532,13 @@ mod test {
use rand::{StdRng, Rng}; use rand::{StdRng, Rng};
let mut bytes = [0, ..1024]; let mut bytes = [0, ..1024];
StdRng::new().ok().unwrap().fill_bytes(bytes); StdRng::new().ok().unwrap().fill_bytes(&mut bytes);
let tmpdir = tmpdir(); let tmpdir = tmpdir();
check!(File::create(&tmpdir.join("test")).write(bytes)); check!(File::create(&tmpdir.join("test")).write(&bytes));
let actual = check!(File::open(&tmpdir.join("test")).read_to_end()); let actual = check!(File::open(&tmpdir.join("test")).read_to_end());
assert!(actual.as_slice() == bytes); assert!(actual.as_slice() == &bytes);
} }
#[test] #[test]

View file

@ -50,7 +50,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64>
/// use std::io::MemWriter; /// use std::io::MemWriter;
/// ///
/// let mut w = MemWriter::new(); /// let mut w = MemWriter::new();
/// w.write([0, 1, 2]); /// w.write(&[0, 1, 2]);
/// ///
/// assert_eq!(w.unwrap(), vec!(0, 1, 2)); /// assert_eq!(w.unwrap(), vec!(0, 1, 2));
/// ``` /// ```
@ -200,8 +200,8 @@ impl Buffer for MemReader {
/// ///
/// let mut buf = [0, ..4]; /// let mut buf = [0, ..4];
/// { /// {
/// let mut w = BufWriter::new(buf); /// let mut w = BufWriter::new(&mut buf);
/// w.write([0, 1, 2]); /// w.write(&[0, 1, 2]);
/// } /// }
/// assert!(buf == [0, 1, 2, 0]); /// assert!(buf == [0, 1, 2, 0]);
/// ``` /// ```
@ -262,7 +262,7 @@ impl<'a> Seek for BufWriter<'a> {
/// use std::io::BufReader; /// use std::io::BufReader;
/// ///
/// let mut buf = [0, 1, 2, 3]; /// let mut buf = [0, 1, 2, 3];
/// let mut r = BufReader::new(buf); /// let mut r = BufReader::new(&mut buf);
/// ///
/// assert_eq!(r.read_to_end().unwrap(), vec!(0, 1, 2, 3)); /// assert_eq!(r.read_to_end().unwrap(), vec!(0, 1, 2, 3));
/// ``` /// ```
@ -346,9 +346,9 @@ mod test {
#[test] #[test]
fn test_mem_writer() { fn test_mem_writer() {
let mut writer = MemWriter::new(); let mut writer = MemWriter::new();
writer.write([0]).unwrap(); writer.write(&[0]).unwrap();
writer.write([1, 2, 3]).unwrap(); writer.write(&[1, 2, 3]).unwrap();
writer.write([4, 5, 6, 7]).unwrap(); writer.write(&[4, 5, 6, 7]).unwrap();
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
assert_eq!(writer.get_ref(), b); assert_eq!(writer.get_ref(), b);
} }
@ -357,14 +357,14 @@ mod test {
fn test_buf_writer() { fn test_buf_writer() {
let mut buf = [0 as u8, ..8]; let mut buf = [0 as u8, ..8];
{ {
let mut writer = BufWriter::new(buf); let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
writer.write([0]).unwrap(); writer.write(&[0]).unwrap();
assert_eq!(writer.tell(), Ok(1)); assert_eq!(writer.tell(), Ok(1));
writer.write([1, 2, 3]).unwrap(); writer.write(&[1, 2, 3]).unwrap();
writer.write([4, 5, 6, 7]).unwrap(); writer.write(&[4, 5, 6, 7]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
writer.write([]).unwrap(); writer.write(&[]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
} }
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
@ -375,24 +375,24 @@ mod test {
fn test_buf_writer_seek() { fn test_buf_writer_seek() {
let mut buf = [0 as u8, ..8]; let mut buf = [0 as u8, ..8];
{ {
let mut writer = BufWriter::new(buf); let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
writer.write([1]).unwrap(); writer.write(&[1]).unwrap();
assert_eq!(writer.tell(), Ok(1)); assert_eq!(writer.tell(), Ok(1));
writer.seek(2, SeekSet).unwrap(); writer.seek(2, SeekSet).unwrap();
assert_eq!(writer.tell(), Ok(2)); assert_eq!(writer.tell(), Ok(2));
writer.write([2]).unwrap(); writer.write(&[2]).unwrap();
assert_eq!(writer.tell(), Ok(3)); assert_eq!(writer.tell(), Ok(3));
writer.seek(-2, SeekCur).unwrap(); writer.seek(-2, SeekCur).unwrap();
assert_eq!(writer.tell(), Ok(1)); assert_eq!(writer.tell(), Ok(1));
writer.write([3]).unwrap(); writer.write(&[3]).unwrap();
assert_eq!(writer.tell(), Ok(2)); assert_eq!(writer.tell(), Ok(2));
writer.seek(-1, SeekEnd).unwrap(); writer.seek(-1, SeekEnd).unwrap();
assert_eq!(writer.tell(), Ok(7)); assert_eq!(writer.tell(), Ok(7));
writer.write([4]).unwrap(); writer.write(&[4]).unwrap();
assert_eq!(writer.tell(), Ok(8)); assert_eq!(writer.tell(), Ok(8));
} }
@ -403,10 +403,10 @@ mod test {
#[test] #[test]
fn test_buf_writer_error() { fn test_buf_writer_error() {
let mut buf = [0 as u8, ..2]; let mut buf = [0 as u8, ..2];
let mut writer = BufWriter::new(buf); let mut writer = BufWriter::new(&mut buf);
writer.write([0]).unwrap(); writer.write(&[0]).unwrap();
match writer.write([0, 0]) { match writer.write(&[0, 0]) {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(e) => assert_eq!(e.kind, io::OtherIoError), Err(e) => assert_eq!(e.kind, io::OtherIoError),
} }
@ -416,26 +416,26 @@ mod test {
fn test_mem_reader() { fn test_mem_reader() {
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7)); let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut buf = []; let mut buf = [];
assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.tell(), Ok(0)); assert_eq!(reader.tell(), Ok(0));
let mut buf = [0]; let mut buf = [0];
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(&mut buf), Ok(1));
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0]; let b: &[_] = &[0];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let mut buf = [0, ..4]; let mut buf = [0, ..4];
assert_eq!(reader.read(buf), Ok(4)); assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.tell(), Ok(5)); assert_eq!(reader.tell(), Ok(5));
let b: &[_] = &[1, 2, 3, 4]; let b: &[_] = &[1, 2, 3, 4];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert_eq!(reader.read(buf), Ok(3)); assert_eq!(reader.read(&mut buf), Ok(3));
let b: &[_] = &[5, 6, 7]; let b: &[_] = &[5, 6, 7];
assert_eq!(buf[0..3], b); assert_eq!(buf[0..3], b);
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7)); let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3)); assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7)); assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
} }
#[test] #[test]
@ -443,26 +443,26 @@ mod test {
let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7]; let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = BufReader::new(in_buf.as_slice()); let mut reader = BufReader::new(in_buf.as_slice());
let mut buf = []; let mut buf = [];
assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.tell(), Ok(0)); assert_eq!(reader.tell(), Ok(0));
let mut buf = [0]; let mut buf = [0];
assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(&mut buf), Ok(1));
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0]; let b: &[_] = &[0];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
let mut buf = [0, ..4]; let mut buf = [0, ..4];
assert_eq!(reader.read(buf), Ok(4)); assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.tell(), Ok(5)); assert_eq!(reader.tell(), Ok(5));
let b: &[_] = &[1, 2, 3, 4]; let b: &[_] = &[1, 2, 3, 4];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert_eq!(reader.read(buf), Ok(3)); assert_eq!(reader.read(&mut buf), Ok(3));
let b: &[_] = &[5, 6, 7]; let b: &[_] = &[5, 6, 7];
assert_eq!(buf[0..3], b); assert_eq!(buf[0..3], b);
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
let mut reader = BufReader::new(in_buf.as_slice()); let mut reader = BufReader::new(in_buf.as_slice());
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3)); assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7)); assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
assert!(reader.read(buf).is_err()); assert!(reader.read(&mut buf).is_err());
} }
#[test] #[test]
@ -506,7 +506,7 @@ mod test {
#[test] #[test]
fn test_read_whole_string_bad() { fn test_read_whole_string_bad() {
let buf = [0xff]; let buf = [0xff];
let mut r = BufReader::new(buf); let mut r = BufReader::new(&buf);
match r.read_to_string() { match r.read_to_string() {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(..) => {} Err(..) => {}
@ -516,7 +516,7 @@ mod test {
#[test] #[test]
fn seek_past_end() { fn seek_past_end() {
let buf = [0xff]; let buf = [0xff];
let mut r = BufReader::new(buf); let mut r = BufReader::new(&buf);
r.seek(10, SeekSet).unwrap(); r.seek(10, SeekSet).unwrap();
assert!(r.read(&mut []).is_err()); assert!(r.read(&mut []).is_err());
@ -525,22 +525,22 @@ mod test {
assert!(r.read(&mut []).is_err()); assert!(r.read(&mut []).is_err());
let mut buf = [0]; let mut buf = [0];
let mut r = BufWriter::new(buf); let mut r = BufWriter::new(&mut buf);
r.seek(10, SeekSet).unwrap(); r.seek(10, SeekSet).unwrap();
assert!(r.write([3]).is_err()); assert!(r.write(&[3]).is_err());
} }
#[test] #[test]
fn seek_before_0() { fn seek_before_0() {
let buf = [0xff]; let buf = [0xff];
let mut r = BufReader::new(buf); let mut r = BufReader::new(&buf);
assert!(r.seek(-1, SeekSet).is_err()); assert!(r.seek(-1, SeekSet).is_err());
let mut r = MemReader::new(vec!(10)); let mut r = MemReader::new(vec!(10));
assert!(r.seek(-1, SeekSet).is_err()); assert!(r.seek(-1, SeekSet).is_err());
let mut buf = [0]; let mut buf = [0];
let mut r = BufWriter::new(buf); let mut r = BufWriter::new(&mut buf);
assert!(r.seek(-1, SeekSet).is_err()); assert!(r.seek(-1, SeekSet).is_err());
} }
@ -548,15 +548,15 @@ mod test {
fn io_read_at_least() { fn io_read_at_least() {
let mut r = MemReader::new(vec![1, 2, 3, 4, 5, 6, 7, 8]); let mut r = MemReader::new(vec![1, 2, 3, 4, 5, 6, 7, 8]);
let mut buf = [0, ..3]; let mut buf = [0, ..3];
assert!(r.read_at_least(buf.len(), buf).is_ok()); assert!(r.read_at_least(buf.len(), &mut buf).is_ok());
let b: &[_] = &[1, 2, 3]; let b: &[_] = &[1, 2, 3];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert!(r.read_at_least(0, buf[mut ..0]).is_ok()); assert!(r.read_at_least(0, buf[mut ..0]).is_ok());
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert!(r.read_at_least(buf.len(), buf).is_ok()); assert!(r.read_at_least(buf.len(), &mut buf).is_ok());
let b: &[_] = &[4, 5, 6]; let b: &[_] = &[4, 5, 6];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
assert!(r.read_at_least(buf.len(), buf).is_err()); assert!(r.read_at_least(buf.len(), &mut buf).is_err());
let b: &[_] = &[7, 8, 6]; let b: &[_] = &[7, 8, 6];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
} }
@ -625,7 +625,7 @@ mod test {
let mut rdr = MemReader::new(buf); let mut rdr = MemReader::new(buf);
for _i in range(0u, 10) { for _i in range(0u, 10) {
let mut buf = [0 as u8, .. 10]; let mut buf = [0 as u8, .. 10];
rdr.read(buf).unwrap(); rdr.read(&mut buf).unwrap();
assert_eq!(buf.as_slice(), [5, .. 10].as_slice()); assert_eq!(buf.as_slice(), [5, .. 10].as_slice());
} }
} }
@ -637,9 +637,9 @@ mod test {
b.iter(|| { b.iter(|| {
let mut buf = [0 as u8, ..100]; let mut buf = [0 as u8, ..100];
{ {
let mut wr = BufWriter::new(buf); let mut wr = BufWriter::new(&mut buf);
for _i in range(0u, 10) { for _i in range(0u, 10) {
wr.write([5, .. 10]).unwrap(); wr.write(&[5, .. 10]).unwrap();
} }
} }
assert_eq!(buf.as_slice(), [5, .. 100].as_slice()); assert_eq!(buf.as_slice(), [5, .. 100].as_slice());
@ -651,10 +651,10 @@ mod test {
b.iter(|| { b.iter(|| {
let buf = [5 as u8, ..100]; let buf = [5 as u8, ..100];
{ {
let mut rdr = BufReader::new(buf); let mut rdr = BufReader::new(&buf);
for _i in range(0u, 10) { for _i in range(0u, 10) {
let mut buf = [0 as u8, .. 10]; let mut buf = [0 as u8, .. 10];
rdr.read(buf).unwrap(); rdr.read(&mut buf).unwrap();
assert_eq!(buf.as_slice(), [5, .. 10].as_slice()); assert_eq!(buf.as_slice(), [5, .. 10].as_slice());
} }
} }

View file

@ -521,7 +521,7 @@ pub trait Reader {
/// Reads a single byte. Returns `Err` on EOF. /// Reads a single byte. Returns `Err` on EOF.
fn read_byte(&mut self) -> IoResult<u8> { fn read_byte(&mut self) -> IoResult<u8> {
let mut buf = [0]; let mut buf = [0];
try!(self.read_at_least(1, buf)); try!(self.read_at_least(1, &mut buf));
Ok(buf[0]) Ok(buf[0])
} }
@ -1061,7 +1061,7 @@ pub trait Writer {
/// that the `write` method is used specifically instead. /// that the `write` method is used specifically instead.
#[inline] #[inline]
fn write_line(&mut self, s: &str) -> IoResult<()> { fn write_line(&mut self, s: &str) -> IoResult<()> {
self.write_str(s).and_then(|()| self.write([b'\n'])) self.write_str(s).and_then(|()| self.write(&[b'\n']))
} }
/// Write a single char, encoded as UTF-8. /// Write a single char, encoded as UTF-8.
@ -1217,13 +1217,13 @@ pub trait Writer {
/// Write a u8 (1 byte). /// Write a u8 (1 byte).
#[inline] #[inline]
fn write_u8(&mut self, n: u8) -> IoResult<()> { fn write_u8(&mut self, n: u8) -> IoResult<()> {
self.write([n]) self.write(&[n])
} }
/// Write an i8 (1 byte). /// Write an i8 (1 byte).
#[inline] #[inline]
fn write_i8(&mut self, n: i8) -> IoResult<()> { fn write_i8(&mut self, n: i8) -> IoResult<()> {
self.write([n as u8]) self.write(&[n as u8])
} }
} }
@ -1949,7 +1949,7 @@ mod tests {
fn test_read_at_least() { fn test_read_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(uint::MAX)]); vec![GoodBehavior(uint::MAX)]);
let mut buf = [0u8, ..5]; let buf = &mut [0u8, ..5];
assert!(r.read_at_least(1, buf).unwrap() >= 1); assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
assert!(r.read_at_least(0, buf).is_ok()); assert!(r.read_at_least(0, buf).is_ok());

View file

@ -53,7 +53,7 @@ impl UnixStream {
/// ///
/// let server = Path::new("path/to/my/socket"); /// let server = Path::new("path/to/my/socket");
/// let mut stream = UnixStream::connect(&server); /// let mut stream = UnixStream::connect(&server);
/// stream.write([1, 2, 3]); /// stream.write(&[1, 2, 3]);
/// ``` /// ```
pub fn connect<P: ToCStr>(path: &P) -> IoResult<UnixStream> { pub fn connect<P: ToCStr>(path: &P) -> IoResult<UnixStream> {
UnixStreamImp::connect(&path.to_c_str(), None) UnixStreamImp::connect(&path.to_c_str(), None)
@ -169,7 +169,7 @@ impl UnixListener {
/// let server = Path::new("/path/to/my/socket"); /// let server = Path::new("/path/to/my/socket");
/// let stream = UnixListener::bind(&server); /// let stream = UnixListener::bind(&server);
/// for mut client in stream.listen().incoming() { /// for mut client in stream.listen().incoming() {
/// client.write([1, 2, 3, 4]); /// client.write(&[1, 2, 3, 4]);
/// } /// }
/// # } /// # }
/// ``` /// ```
@ -307,10 +307,10 @@ mod tests {
fn smoke() { fn smoke() {
smalltest(proc(mut server) { smalltest(proc(mut server) {
let mut buf = [0]; let mut buf = [0];
server.read(buf).unwrap(); server.read(&mut buf).unwrap();
assert!(buf[0] == 99); assert!(buf[0] == 99);
}, proc(mut client) { }, proc(mut client) {
client.write([99]).unwrap(); client.write(&[99]).unwrap();
}) })
} }
@ -319,8 +319,8 @@ mod tests {
fn read_eof() { fn read_eof() {
smalltest(proc(mut server) { smalltest(proc(mut server) {
let mut buf = [0]; let mut buf = [0];
assert!(server.read(buf).is_err()); assert!(server.read(&mut buf).is_err());
assert!(server.read(buf).is_err()); assert!(server.read(&mut buf).is_err());
}, proc(_client) { }, proc(_client) {
// drop the client // drop the client
}) })
@ -331,7 +331,7 @@ mod tests {
smalltest(proc(mut server) { smalltest(proc(mut server) {
let buf = [0]; let buf = [0];
loop { loop {
match server.write(buf) { match server.write(&buf) {
Ok(..) => {} Ok(..) => {}
Err(e) => { Err(e) => {
assert!(e.kind == BrokenPipe || assert!(e.kind == BrokenPipe ||
@ -361,7 +361,7 @@ mod tests {
spawn(proc() { spawn(proc() {
for _ in range(0u, times) { for _ in range(0u, times) {
let mut stream = UnixStream::connect(&path2); let mut stream = UnixStream::connect(&path2);
match stream.write([100]) { match stream.write(&[100]) {
Ok(..) => {} Ok(..) => {}
Err(e) => panic!("failed write: {}", e) Err(e) => panic!("failed write: {}", e)
} }
@ -371,7 +371,7 @@ mod tests {
for _ in range(0, times) { for _ in range(0, times) {
let mut client = acceptor.accept(); let mut client = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
match client.read(buf) { match client.read(&mut buf) {
Ok(..) => {} Ok(..) => {}
Err(e) => panic!("failed read/accept: {}", e), Err(e) => panic!("failed read/accept: {}", e),
} }
@ -396,10 +396,10 @@ mod tests {
let mut s = UnixStream::connect(&addr); let mut s = UnixStream::connect(&addr);
let mut buf = [0, 0]; let mut buf = [0, 0];
debug!("client reading"); debug!("client reading");
assert_eq!(s.read(buf), Ok(1)); assert_eq!(s.read(&mut buf), Ok(1));
assert_eq!(buf[0], 1); assert_eq!(buf[0], 1);
debug!("client writing"); debug!("client writing");
s.write([2]).unwrap(); s.write(&[2]).unwrap();
debug!("client dropping"); debug!("client dropping");
}); });
@ -412,14 +412,14 @@ mod tests {
let mut s2 = s2; let mut s2 = s2;
rx1.recv(); rx1.recv();
debug!("writer writing"); debug!("writer writing");
s2.write([1]).unwrap(); s2.write(&[1]).unwrap();
debug!("writer done"); debug!("writer done");
tx2.send(()); tx2.send(());
}); });
tx1.send(()); tx1.send(());
let mut buf = [0, 0]; let mut buf = [0, 0];
debug!("reader reading"); debug!("reader reading");
assert_eq!(s1.read(buf), Ok(1)); assert_eq!(s1.read(&mut buf), Ok(1));
debug!("reader done"); debug!("reader done");
rx2.recv(); rx2.recv();
} }
@ -433,9 +433,9 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s = UnixStream::connect(&addr); let mut s = UnixStream::connect(&addr);
s.write([1]).unwrap(); s.write(&[1]).unwrap();
rx.recv(); rx.recv();
s.write([2]).unwrap(); s.write(&[2]).unwrap();
rx.recv(); rx.recv();
}); });
@ -446,12 +446,12 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
let mut buf = [0, 0]; let mut buf = [0, 0];
s2.read(buf).unwrap(); s2.read(&mut buf).unwrap();
tx2.send(()); tx2.send(());
done.send(()); done.send(());
}); });
let mut buf = [0, 0]; let mut buf = [0, 0];
s1.read(buf).unwrap(); s1.read(&mut buf).unwrap();
tx1.send(()); tx1.send(());
rx.recv(); rx.recv();
@ -464,7 +464,7 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s = UnixStream::connect(&addr); let mut s = UnixStream::connect(&addr);
let mut buf = [0, 1]; let buf = &mut [0, 1];
s.read(buf).unwrap(); s.read(buf).unwrap();
s.read(buf).unwrap(); s.read(buf).unwrap();
}); });
@ -475,10 +475,10 @@ mod tests {
let (tx, rx) = channel(); let (tx, rx) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
s2.write([1]).unwrap(); s2.write(&[1]).unwrap();
tx.send(()); tx.send(());
}); });
s1.write([2]).unwrap(); s1.write(&[2]).unwrap();
rx.recv(); rx.recv();
} }
@ -588,18 +588,18 @@ mod tests {
// closing should prevent reads/writes // closing should prevent reads/writes
s.close_write().unwrap(); s.close_write().unwrap();
assert!(s.write([0]).is_err()); assert!(s.write(&[0]).is_err());
s.close_read().unwrap(); s.close_read().unwrap();
assert!(s.read(b).is_err()); assert!(s.read(&mut b).is_err());
// closing should affect previous handles // closing should affect previous handles
assert!(s2.write([0]).is_err()); assert!(s2.write(&[0]).is_err());
assert!(s2.read(b).is_err()); assert!(s2.read(&mut b).is_err());
// closing should affect new handles // closing should affect new handles
let mut s3 = s.clone(); let mut s3 = s.clone();
assert!(s3.write([0]).is_err()); assert!(s3.write(&[0]).is_err());
assert!(s3.read(b).is_err()); assert!(s3.read(&mut b).is_err());
// make sure these don't die // make sure these don't die
let _ = s2.close_read(); let _ = s2.close_read();
@ -624,7 +624,7 @@ mod tests {
let (tx, rx) = channel(); let (tx, rx) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
assert!(s2.read([0]).is_err()); assert!(s2.read(&mut [0]).is_err());
tx.send(()); tx.send(());
}); });
// this should wake up the child task // this should wake up the child task
@ -642,18 +642,18 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s = UnixStream::connect(&addr).unwrap(); let mut s = UnixStream::connect(&addr).unwrap();
rx.recv(); rx.recv();
assert!(s.write([0]).is_ok()); assert!(s.write(&[0]).is_ok());
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_timeout(Some(20)); s.set_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
s.set_timeout(Some(20)); s.set_timeout(Some(20));
for i in range(0u, 1001) { for i in range(0u, 1001) {
match s.write([0, .. 128 * 1024]) { match s.write(&[0, .. 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
@ -664,12 +664,12 @@ mod tests {
// I'm not sure as to why, but apparently the write on windows always // I'm not sure as to why, but apparently the write on windows always
// succeeds after the previous timeout. Who knows? // succeeds after the previous timeout. Who knows?
if !cfg!(windows) { if !cfg!(windows) {
assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); assert_eq!(s.write(&[0]).err().unwrap().kind, TimedOut);
} }
tx.send(()); tx.send(());
s.set_timeout(None); s.set_timeout(None);
assert_eq!(s.read([0, 0]), Ok(1)); assert_eq!(s.read(&mut [0, 0]), Ok(1));
} }
#[test] #[test]
@ -682,7 +682,7 @@ mod tests {
rx.recv(); rx.recv();
let mut amt = 0; let mut amt = 0;
while amt < 100 * 128 * 1024 { while amt < 100 * 128 * 1024 {
match s.read([0, ..128 * 1024]) { match s.read(&mut [0, ..128 * 1024]) {
Ok(n) => { amt += n; } Ok(n) => { amt += n; }
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
} }
@ -692,12 +692,12 @@ mod tests {
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_read_timeout(Some(20)); s.set_read_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
for _ in range(0u, 100) { for _ in range(0u, 100) {
assert!(s.write([0, ..128 * 1024]).is_ok()); assert!(s.write(&[0, ..128 * 1024]).is_ok());
} }
} }
@ -709,14 +709,14 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s = UnixStream::connect(&addr).unwrap(); let mut s = UnixStream::connect(&addr).unwrap();
rx.recv(); rx.recv();
assert!(s.write([0]).is_ok()); assert!(s.write(&[0]).is_ok());
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20)); s.set_write_timeout(Some(20));
for i in range(0u, 1001) { for i in range(0u, 1001) {
match s.write([0, .. 128 * 1024]) { match s.write(&[0, .. 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
@ -725,7 +725,7 @@ mod tests {
} }
tx.send(()); tx.send(());
assert!(s.read([0]).is_ok()); assert!(s.read(&mut [0]).is_ok());
} }
#[test] #[test]
@ -736,7 +736,7 @@ mod tests {
spawn(proc() { spawn(proc() {
let mut s = UnixStream::connect(&addr).unwrap(); let mut s = UnixStream::connect(&addr).unwrap();
rx.recv(); rx.recv();
assert!(s.write([0]).is_ok()); assert!(s.write(&[0]).is_ok());
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
@ -745,12 +745,12 @@ mod tests {
let (tx2, rx2) = channel(); let (tx2, rx2) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
assert!(s2.read([0]).is_ok()); assert!(s2.read(&mut [0]).is_ok());
tx2.send(()); tx2.send(());
}); });
s.set_read_timeout(Some(20)); s.set_read_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
rx2.recv(); rx2.recv();

View file

@ -42,9 +42,9 @@ use sys::tcp::TcpAcceptor as TcpAcceptorImp;
/// ///
/// let mut stream = TcpStream::connect("127.0.0.1:34254"); /// let mut stream = TcpStream::connect("127.0.0.1:34254");
/// ///
/// stream.write([1]); /// stream.write(&[1]);
/// let mut buf = [0]; /// let mut buf = [0];
/// stream.read(buf); /// stream.read(&mut buf);
/// drop(stream); // close the connection /// drop(stream); // close the connection
/// ``` /// ```
pub struct TcpStream { pub struct TcpStream {
@ -143,7 +143,7 @@ impl TcpStream {
/// ///
/// // wait for some data, will get canceled after one second /// // wait for some data, will get canceled after one second
/// let mut buf = [0]; /// let mut buf = [0];
/// stream.read(buf); /// stream.read(&mut buf);
/// ``` /// ```
/// ///
/// Note that this method affects all cloned handles associated with this /// Note that this method affects all cloned handles associated with this
@ -487,12 +487,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(("localhost", socket_addr.port)); let mut stream = TcpStream::connect(("localhost", socket_addr.port));
stream.write([144]).unwrap(); stream.write(&[144]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 144); assert!(buf[0] == 144);
} }
@ -503,12 +503,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(("localhost", addr.port)); let mut stream = TcpStream::connect(("localhost", addr.port));
stream.write([64]).unwrap(); stream.write(&[64]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 64); assert!(buf[0] == 64);
} }
@ -519,12 +519,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(("127.0.0.1", addr.port)); let mut stream = TcpStream::connect(("127.0.0.1", addr.port));
stream.write([44]).unwrap(); stream.write(&[44]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 44); assert!(buf[0] == 44);
} }
@ -535,12 +535,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(("::1", addr.port)); let mut stream = TcpStream::connect(("::1", addr.port));
stream.write([66]).unwrap(); stream.write(&[66]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 66); assert!(buf[0] == 66);
} }
@ -551,12 +551,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(addr); let mut stream = TcpStream::connect(addr);
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 99); assert!(buf[0] == 99);
} }
@ -567,12 +567,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = TcpStream::connect(addr); let mut stream = TcpStream::connect(addr);
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
}); });
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 99); assert!(buf[0] == 99);
} }
@ -588,7 +588,7 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
let nread = stream.read(buf); let nread = stream.read(&mut buf);
assert!(nread.is_err()); assert!(nread.is_err());
} }
@ -604,7 +604,7 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
let nread = stream.read(buf); let nread = stream.read(&mut buf);
assert!(nread.is_err()); assert!(nread.is_err());
} }
@ -620,10 +620,10 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
let nread = stream.read(buf); let nread = stream.read(&mut buf);
assert!(nread.is_err()); assert!(nread.is_err());
match stream.read(buf) { match stream.read(&mut buf) {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(ref e) => { Err(ref e) => {
assert!(e.kind == NotConnected || e.kind == EndOfFile, assert!(e.kind == NotConnected || e.kind == EndOfFile,
@ -644,10 +644,10 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
let mut buf = [0]; let mut buf = [0];
let nread = stream.read(buf); let nread = stream.read(&mut buf);
assert!(nread.is_err()); assert!(nread.is_err());
match stream.read(buf) { match stream.read(&mut buf) {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(ref e) => { Err(ref e) => {
assert!(e.kind == NotConnected || e.kind == EndOfFile, assert!(e.kind == NotConnected || e.kind == EndOfFile,
@ -670,7 +670,7 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
rx.recv(); rx.recv();
let buf = [0]; let buf = [0];
match stream.write(buf) { match stream.write(&buf) {
Ok(..) => {} Ok(..) => {}
Err(e) => { Err(e) => {
assert!(e.kind == ConnectionReset || assert!(e.kind == ConnectionReset ||
@ -695,7 +695,7 @@ mod test {
let mut stream = acceptor.accept(); let mut stream = acceptor.accept();
rx.recv(); rx.recv();
let buf = [0]; let buf = [0];
match stream.write(buf) { match stream.write(&buf) {
Ok(..) => {} Ok(..) => {}
Err(e) => { Err(e) => {
assert!(e.kind == ConnectionReset || assert!(e.kind == ConnectionReset ||
@ -715,13 +715,13 @@ mod test {
spawn(proc() { spawn(proc() {
for _ in range(0, max) { for _ in range(0, max) {
let mut stream = TcpStream::connect(addr); let mut stream = TcpStream::connect(addr);
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
} }
}); });
for ref mut stream in acceptor.incoming().take(max) { for ref mut stream in acceptor.incoming().take(max) {
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
} }
} }
@ -735,13 +735,13 @@ mod test {
spawn(proc() { spawn(proc() {
for _ in range(0, max) { for _ in range(0, max) {
let mut stream = TcpStream::connect(addr); let mut stream = TcpStream::connect(addr);
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
} }
}); });
for ref mut stream in acceptor.incoming().take(max) { for ref mut stream in acceptor.incoming().take(max) {
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
} }
} }
@ -759,7 +759,7 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = stream; let mut stream = stream;
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == i as u8); assert!(buf[0] == i as u8);
debug!("read"); debug!("read");
}); });
@ -777,7 +777,7 @@ mod test {
// Connect again before writing // Connect again before writing
connect(i + 1, addr); connect(i + 1, addr);
debug!("writing"); debug!("writing");
stream.write([i as u8]).unwrap(); stream.write(&[i as u8]).unwrap();
}); });
} }
} }
@ -795,7 +795,7 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = stream; let mut stream = stream;
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == i as u8); assert!(buf[0] == i as u8);
debug!("read"); debug!("read");
}); });
@ -813,7 +813,7 @@ mod test {
// Connect again before writing // Connect again before writing
connect(i + 1, addr); connect(i + 1, addr);
debug!("writing"); debug!("writing");
stream.write([i as u8]).unwrap(); stream.write(&[i as u8]).unwrap();
}); });
} }
} }
@ -831,7 +831,7 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = stream; let mut stream = stream;
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 99); assert!(buf[0] == 99);
debug!("read"); debug!("read");
}); });
@ -849,7 +849,7 @@ mod test {
// Connect again before writing // Connect again before writing
connect(i + 1, addr); connect(i + 1, addr);
debug!("writing"); debug!("writing");
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
}); });
} }
} }
@ -867,7 +867,7 @@ mod test {
spawn(proc() { spawn(proc() {
let mut stream = stream; let mut stream = stream;
let mut buf = [0]; let mut buf = [0];
stream.read(buf).unwrap(); stream.read(&mut buf).unwrap();
assert!(buf[0] == 99); assert!(buf[0] == 99);
debug!("read"); debug!("read");
}); });
@ -885,7 +885,7 @@ mod test {
// Connect again before writing // Connect again before writing
connect(i + 1, addr); connect(i + 1, addr);
debug!("writing"); debug!("writing");
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
}); });
} }
} }
@ -941,17 +941,17 @@ mod test {
let mut srv = TcpListener::bind(addr).listen().unwrap(); let mut srv = TcpListener::bind(addr).listen().unwrap();
tx.send(()); tx.send(());
let mut cl = srv.accept().unwrap(); let mut cl = srv.accept().unwrap();
cl.write([10]).unwrap(); cl.write(&[10]).unwrap();
let mut b = [0]; let mut b = [0];
cl.read(b).unwrap(); cl.read(&mut b).unwrap();
tx.send(()); tx.send(());
}); });
rx.recv(); rx.recv();
let mut c = TcpStream::connect(addr).unwrap(); let mut c = TcpStream::connect(addr).unwrap();
let mut b = [0, ..10]; let mut b = [0, ..10];
assert_eq!(c.read(b), Ok(1)); assert_eq!(c.read(&mut b), Ok(1));
c.write([1]).unwrap(); c.write(&[1]).unwrap();
rx.recv(); rx.recv();
} }
@ -1002,9 +1002,9 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr); let mut s = TcpStream::connect(addr);
let mut buf = [0, 0]; let mut buf = [0, 0];
assert_eq!(s.read(buf), Ok(1)); assert_eq!(s.read(&mut buf), Ok(1));
assert_eq!(buf[0], 1); assert_eq!(buf[0], 1);
s.write([2]).unwrap(); s.write(&[2]).unwrap();
}); });
let mut s1 = acceptor.accept().unwrap(); let mut s1 = acceptor.accept().unwrap();
@ -1015,12 +1015,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
rx1.recv(); rx1.recv();
s2.write([1]).unwrap(); s2.write(&[1]).unwrap();
tx2.send(()); tx2.send(());
}); });
tx1.send(()); tx1.send(());
let mut buf = [0, 0]; let mut buf = [0, 0];
assert_eq!(s1.read(buf), Ok(1)); assert_eq!(s1.read(&mut buf), Ok(1));
rx2.recv(); rx2.recv();
} }
@ -1033,9 +1033,9 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr); let mut s = TcpStream::connect(addr);
s.write([1]).unwrap(); s.write(&[1]).unwrap();
rx.recv(); rx.recv();
s.write([2]).unwrap(); s.write(&[2]).unwrap();
rx.recv(); rx.recv();
}); });
@ -1046,12 +1046,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
let mut buf = [0, 0]; let mut buf = [0, 0];
s2.read(buf).unwrap(); s2.read(&mut buf).unwrap();
tx2.send(()); tx2.send(());
done.send(()); done.send(());
}); });
let mut buf = [0, 0]; let mut buf = [0, 0];
s1.read(buf).unwrap(); s1.read(&mut buf).unwrap();
tx1.send(()); tx1.send(());
rx.recv(); rx.recv();
@ -1065,8 +1065,8 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr); let mut s = TcpStream::connect(addr);
let mut buf = [0, 1]; let mut buf = [0, 1];
s.read(buf).unwrap(); s.read(&mut buf).unwrap();
s.read(buf).unwrap(); s.read(&mut buf).unwrap();
}); });
let mut s1 = acceptor.accept().unwrap(); let mut s1 = acceptor.accept().unwrap();
@ -1075,10 +1075,10 @@ mod test {
let (done, rx) = channel(); let (done, rx) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
s2.write([1]).unwrap(); s2.write(&[1]).unwrap();
done.send(()); done.send(());
}); });
s1.write([2]).unwrap(); s1.write(&[2]).unwrap();
rx.recv(); rx.recv();
} }
@ -1091,12 +1091,12 @@ mod test {
let mut a = a; let mut a = a;
let mut c = a.accept().unwrap(); let mut c = a.accept().unwrap();
assert_eq!(c.read_to_end(), Ok(vec!())); assert_eq!(c.read_to_end(), Ok(vec!()));
c.write([1]).unwrap(); c.write(&[1]).unwrap();
}); });
let mut s = TcpStream::connect(addr).unwrap(); let mut s = TcpStream::connect(addr).unwrap();
assert!(s.inner.close_write().is_ok()); assert!(s.inner.close_write().is_ok());
assert!(s.write([1]).is_err()); assert!(s.write(&[1]).is_err());
assert_eq!(s.read_to_end(), Ok(vec!(1))); assert_eq!(s.read_to_end(), Ok(vec!(1)));
} }
@ -1161,18 +1161,18 @@ mod test {
// closing should prevent reads/writes // closing should prevent reads/writes
s.close_write().unwrap(); s.close_write().unwrap();
assert!(s.write([0]).is_err()); assert!(s.write(&[0]).is_err());
s.close_read().unwrap(); s.close_read().unwrap();
assert!(s.read(b).is_err()); assert!(s.read(&mut b).is_err());
// closing should affect previous handles // closing should affect previous handles
assert!(s2.write([0]).is_err()); assert!(s2.write(&[0]).is_err());
assert!(s2.read(b).is_err()); assert!(s2.read(&mut b).is_err());
// closing should affect new handles // closing should affect new handles
let mut s3 = s.clone(); let mut s3 = s.clone();
assert!(s3.write([0]).is_err()); assert!(s3.write(&[0]).is_err());
assert!(s3.read(b).is_err()); assert!(s3.read(&mut b).is_err());
// make sure these don't die // make sure these don't die
let _ = s2.close_read(); let _ = s2.close_read();
@ -1197,7 +1197,7 @@ mod test {
let (tx, rx) = channel(); let (tx, rx) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
assert!(s2.read([0]).is_err()); assert!(s2.read(&mut [0]).is_err());
tx.send(()); tx.send(());
}); });
// this should wake up the child task // this should wake up the child task
@ -1215,29 +1215,29 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr).unwrap(); let mut s = TcpStream::connect(addr).unwrap();
rx.recv(); rx.recv();
assert!(s.write([0]).is_ok()); assert!(s.write(&[0]).is_ok());
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_timeout(Some(20)); s.set_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
s.set_timeout(Some(20)); s.set_timeout(Some(20));
for i in range(0i, 1001) { for i in range(0i, 1001) {
match s.write([0, .. 128 * 1024]) { match s.write(&[0, .. 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
} }
if i == 1000 { panic!("should have filled up?!"); } if i == 1000 { panic!("should have filled up?!"); }
} }
assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); assert_eq!(s.write(&[0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
s.set_timeout(None); s.set_timeout(None);
assert_eq!(s.read([0, 0]), Ok(1)); assert_eq!(s.read(&mut [0, 0]), Ok(1));
} }
#[test] #[test]
@ -1250,7 +1250,7 @@ mod test {
rx.recv(); rx.recv();
let mut amt = 0; let mut amt = 0;
while amt < 100 * 128 * 1024 { while amt < 100 * 128 * 1024 {
match s.read([0, ..128 * 1024]) { match s.read(&mut [0, ..128 * 1024]) {
Ok(n) => { amt += n; } Ok(n) => { amt += n; }
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
} }
@ -1260,12 +1260,12 @@ mod test {
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_read_timeout(Some(20)); s.set_read_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
for _ in range(0i, 100) { for _ in range(0i, 100) {
assert!(s.write([0, ..128 * 1024]).is_ok()); assert!(s.write(&[0, ..128 * 1024]).is_ok());
} }
} }
@ -1277,24 +1277,24 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr).unwrap(); let mut s = TcpStream::connect(addr).unwrap();
rx.recv(); rx.recv();
assert!(s.write([0]).is_ok()); assert!(s.write(&[0]).is_ok());
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20)); s.set_write_timeout(Some(20));
for i in range(0i, 1001) { for i in range(0i, 1001) {
match s.write([0, .. 128 * 1024]) { match s.write(&[0, .. 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
} }
if i == 1000 { panic!("should have filled up?!"); } if i == 1000 { panic!("should have filled up?!"); }
} }
assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); assert_eq!(s.write(&[0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
assert!(s.read([0]).is_ok()); assert!(s.read(&mut [0]).is_ok());
} }
#[test] #[test]
@ -1305,7 +1305,7 @@ mod test {
spawn(proc() { spawn(proc() {
let mut s = TcpStream::connect(addr).unwrap(); let mut s = TcpStream::connect(addr).unwrap();
rx.recv(); rx.recv();
assert_eq!(s.write([0]), Ok(())); assert_eq!(s.write(&[0]), Ok(()));
let _ = rx.recv_opt(); let _ = rx.recv_opt();
}); });
@ -1314,12 +1314,12 @@ mod test {
let (tx2, rx2) = channel(); let (tx2, rx2) = channel();
spawn(proc() { spawn(proc() {
let mut s2 = s2; let mut s2 = s2;
assert_eq!(s2.read([0]), Ok(1)); assert_eq!(s2.read(&mut [0]), Ok(1));
tx2.send(()); tx2.send(());
}); });
s.set_read_timeout(Some(20)); s.set_read_timeout(Some(20));
assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
tx.send(()); tx.send(());
rx2.recv(); rx2.recv();

View file

@ -44,7 +44,7 @@ use sys::udp::UdpSocket as UdpSocketImp;
/// }; /// };
/// ///
/// let mut buf = [0, ..10]; /// let mut buf = [0, ..10];
/// match socket.recv_from(buf) { /// match socket.recv_from(&mut buf) {
/// Ok((amt, src)) => { /// Ok((amt, src)) => {
/// // Send a reply to the socket we received data from /// // Send a reply to the socket we received data from
/// let buf = buf[mut ..amt]; /// let buf = buf[mut ..amt];
@ -266,7 +266,7 @@ mod test {
match UdpSocket::bind(client_ip) { match UdpSocket::bind(client_ip) {
Ok(ref mut client) => { Ok(ref mut client) => {
rx1.recv(); rx1.recv();
client.send_to([99], server_ip).unwrap() client.send_to(&[99], server_ip).unwrap()
} }
Err(..) => panic!() Err(..) => panic!()
} }
@ -277,7 +277,7 @@ mod test {
Ok(ref mut server) => { Ok(ref mut server) => {
tx1.send(()); tx1.send(());
let mut buf = [0]; let mut buf = [0];
match server.recv_from(buf) { match server.recv_from(&mut buf) {
Ok((nread, src)) => { Ok((nread, src)) => {
assert_eq!(nread, 1); assert_eq!(nread, 1);
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
@ -301,7 +301,7 @@ mod test {
match UdpSocket::bind(client_ip) { match UdpSocket::bind(client_ip) {
Ok(ref mut client) => { Ok(ref mut client) => {
rx.recv(); rx.recv();
client.send_to([99], server_ip).unwrap() client.send_to(&[99], server_ip).unwrap()
} }
Err(..) => panic!() Err(..) => panic!()
} }
@ -311,7 +311,7 @@ mod test {
Ok(ref mut server) => { Ok(ref mut server) => {
tx.send(()); tx.send(());
let mut buf = [0]; let mut buf = [0];
match server.recv_from(buf) { match server.recv_from(&mut buf) {
Ok((nread, src)) => { Ok((nread, src)) => {
assert_eq!(nread, 1); assert_eq!(nread, 1);
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
@ -345,8 +345,8 @@ mod test {
} }
}; };
rx1.recv(); rx1.recv();
send_as(dummy_ip, [98]); send_as(dummy_ip, &[98]);
send_as(client_ip, [99]); send_as(client_ip, &[99]);
tx2.send(()); tx2.send(());
}); });
@ -356,7 +356,7 @@ mod test {
let mut stream = server.connect(client_ip); let mut stream = server.connect(client_ip);
tx1.send(()); tx1.send(());
let mut buf = [0]; let mut buf = [0];
match stream.read(buf) { match stream.read(&mut buf) {
Ok(nread) => { Ok(nread) => {
assert_eq!(nread, 1); assert_eq!(nread, 1);
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
@ -383,7 +383,7 @@ mod test {
let client = box client; let client = box client;
let mut stream = client.connect(server_ip); let mut stream = client.connect(server_ip);
rx1.recv(); rx1.recv();
stream.write([99]).unwrap(); stream.write(&[99]).unwrap();
} }
Err(..) => panic!() Err(..) => panic!()
} }
@ -396,7 +396,7 @@ mod test {
let mut stream = server.connect(client_ip); let mut stream = server.connect(client_ip);
tx1.send(()); tx1.send(());
let mut buf = [0]; let mut buf = [0];
match stream.read(buf) { match stream.read(&mut buf) {
Ok(nread) => { Ok(nread) => {
assert_eq!(nread, 1); assert_eq!(nread, 1);
assert_eq!(buf[0], 99); assert_eq!(buf[0], 99);
@ -442,9 +442,9 @@ mod test {
spawn(proc() { spawn(proc() {
let mut sock2 = sock2; let mut sock2 = sock2;
let mut buf = [0, 0]; let mut buf = [0, 0];
assert_eq!(sock2.recv_from(buf), Ok((1, addr1))); assert_eq!(sock2.recv_from(&mut buf), Ok((1, addr1)));
assert_eq!(buf[0], 1); assert_eq!(buf[0], 1);
sock2.send_to([2], addr1).unwrap(); sock2.send_to(&[2], addr1).unwrap();
}); });
let sock3 = sock1.clone(); let sock3 = sock1.clone();
@ -454,12 +454,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut sock3 = sock3; let mut sock3 = sock3;
rx1.recv(); rx1.recv();
sock3.send_to([1], addr2).unwrap(); sock3.send_to(&[1], addr2).unwrap();
tx2.send(()); tx2.send(());
}); });
tx1.send(()); tx1.send(());
let mut buf = [0, 0]; let mut buf = [0, 0];
assert_eq!(sock1.recv_from(buf), Ok((1, addr2))); assert_eq!(sock1.recv_from(&mut buf), Ok((1, addr2)));
rx2.recv(); rx2.recv();
} }
@ -474,9 +474,9 @@ mod test {
spawn(proc() { spawn(proc() {
let mut sock2 = sock2; let mut sock2 = sock2;
sock2.send_to([1], addr1).unwrap(); sock2.send_to(&[1], addr1).unwrap();
rx.recv(); rx.recv();
sock2.send_to([2], addr1).unwrap(); sock2.send_to(&[2], addr1).unwrap();
rx.recv(); rx.recv();
}); });
@ -486,12 +486,12 @@ mod test {
spawn(proc() { spawn(proc() {
let mut sock3 = sock3; let mut sock3 = sock3;
let mut buf = [0, 0]; let mut buf = [0, 0];
sock3.recv_from(buf).unwrap(); sock3.recv_from(&mut buf).unwrap();
tx2.send(()); tx2.send(());
done.send(()); done.send(());
}); });
let mut buf = [0, 0]; let mut buf = [0, 0];
sock1.recv_from(buf).unwrap(); sock1.recv_from(&mut buf).unwrap();
tx1.send(()); tx1.send(());
rx.recv(); rx.recv();
@ -512,7 +512,7 @@ mod test {
let mut buf = [0, 1]; let mut buf = [0, 1];
rx.recv(); rx.recv();
match sock2.recv_from(buf) { match sock2.recv_from(&mut buf) {
Ok(..) => {} Ok(..) => {}
Err(e) => panic!("failed receive: {}", e), Err(e) => panic!("failed receive: {}", e),
} }
@ -525,13 +525,13 @@ mod test {
let tx2 = tx.clone(); let tx2 = tx.clone();
spawn(proc() { spawn(proc() {
let mut sock3 = sock3; let mut sock3 = sock3;
match sock3.send_to([1], addr2) { match sock3.send_to(&[1], addr2) {
Ok(..) => { let _ = tx2.send_opt(()); } Ok(..) => { let _ = tx2.send_opt(()); }
Err(..) => {} Err(..) => {}
} }
done.send(()); done.send(());
}); });
match sock1.send_to([2], addr2) { match sock1.send_to(&[2], addr2) {
Ok(..) => { let _ = tx.send_opt(()); } Ok(..) => { let _ = tx.send_opt(()); }
Err(..) => {} Err(..) => {}
} }
@ -552,28 +552,28 @@ mod test {
let (tx2, rx2) = channel(); let (tx2, rx2) = channel();
spawn(proc() { spawn(proc() {
let mut a = UdpSocket::bind(addr2).unwrap(); let mut a = UdpSocket::bind(addr2).unwrap();
assert_eq!(a.recv_from([0]), Ok((1, addr1))); assert_eq!(a.recv_from(&mut [0]), Ok((1, addr1)));
assert_eq!(a.send_to([0], addr1), Ok(())); assert_eq!(a.send_to(&[0], addr1), Ok(()));
rx.recv(); rx.recv();
assert_eq!(a.send_to([0], addr1), Ok(())); assert_eq!(a.send_to(&[0], addr1), Ok(()));
tx2.send(()); tx2.send(());
}); });
// Make sure that reads time out, but writes can continue // Make sure that reads time out, but writes can continue
a.set_read_timeout(Some(20)); a.set_read_timeout(Some(20));
assert_eq!(a.recv_from([0]).err().unwrap().kind, TimedOut); assert_eq!(a.recv_from(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(a.recv_from([0]).err().unwrap().kind, TimedOut); assert_eq!(a.recv_from(&mut [0]).err().unwrap().kind, TimedOut);
assert_eq!(a.send_to([0], addr2), Ok(())); assert_eq!(a.send_to(&[0], addr2), Ok(()));
// Cloned handles should be able to block // Cloned handles should be able to block
let mut a2 = a.clone(); let mut a2 = a.clone();
assert_eq!(a2.recv_from([0]), Ok((1, addr2))); assert_eq!(a2.recv_from(&mut [0]), Ok((1, addr2)));
// Clearing the timeout should allow for receiving // Clearing the timeout should allow for receiving
a.set_timeout(None); a.set_timeout(None);
tx.send(()); tx.send(());
assert_eq!(a2.recv_from([0]), Ok((1, addr2))); assert_eq!(a2.recv_from(&mut [0]), Ok((1, addr2)));
// Make sure the child didn't die // Make sure the child didn't die
rx2.recv(); rx2.recv();
@ -588,7 +588,7 @@ mod test {
a.set_write_timeout(Some(1000)); a.set_write_timeout(Some(1000));
for _ in range(0u, 100) { for _ in range(0u, 100) {
match a.send_to([0, ..4*1024], addr2) { match a.send_to(&[0, ..4*1024], addr2) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("other error: {}", e), Err(e) => panic!("other error: {}", e),

View file

@ -125,12 +125,12 @@ mod test {
let (tx, rx) = channel(); let (tx, rx) = channel();
spawn(proc() { spawn(proc() {
let mut out = out; let mut out = out;
out.write([10]).unwrap(); out.write(&[10]).unwrap();
rx.recv(); // don't close the pipe until the other read has finished rx.recv(); // don't close the pipe until the other read has finished
}); });
let mut buf = [0, ..10]; let mut buf = [0, ..10];
input.read(buf).unwrap(); input.read(&mut buf).unwrap();
tx.send(()); tx.send(());
} }
} }

View file

@ -85,7 +85,7 @@ mod test {
#[test] #[test]
fn test_option_writer() { fn test_option_writer() {
let mut writer: io::IoResult<MemWriter> = Ok(MemWriter::new()); let mut writer: io::IoResult<MemWriter> = Ok(MemWriter::new());
writer.write([0, 1, 2]).unwrap(); writer.write(&[0, 1, 2]).unwrap();
writer.flush().unwrap(); writer.flush().unwrap();
assert_eq!(writer.unwrap().unwrap(), vec!(0, 1, 2)); assert_eq!(writer.unwrap().unwrap(), vec!(0, 1, 2));
} }
@ -95,7 +95,7 @@ mod test {
let mut writer: io::IoResult<MemWriter> = let mut writer: io::IoResult<MemWriter> =
Err(io::standard_error(io::EndOfFile)); Err(io::standard_error(io::EndOfFile));
match writer.write([0, 0, 0]) { match writer.write(&[0, 0, 0]) {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(e) => assert_eq!(e.kind, io::EndOfFile), Err(e) => assert_eq!(e.kind, io::EndOfFile),
} }
@ -110,7 +110,7 @@ mod test {
let mut reader: io::IoResult<MemReader> = let mut reader: io::IoResult<MemReader> =
Ok(MemReader::new(vec!(0, 1, 2, 3))); Ok(MemReader::new(vec!(0, 1, 2, 3)));
let mut buf = [0, 0]; let mut buf = [0, 0];
reader.read(buf).unwrap(); reader.read(&mut buf).unwrap();
let b: &[_] = &[0, 1]; let b: &[_] = &[0, 1];
assert_eq!(buf.as_slice(), b); assert_eq!(buf.as_slice(), b);
} }
@ -121,7 +121,7 @@ mod test {
Err(io::standard_error(io::EndOfFile)); Err(io::standard_error(io::EndOfFile));
let mut buf = []; let mut buf = [];
match reader.read(buf) { match reader.read(&mut buf) {
Ok(..) => panic!(), Ok(..) => panic!(),
Err(e) => assert_eq!(e.kind, io::EndOfFile), Err(e) => assert_eq!(e.kind, io::EndOfFile),
} }

View file

@ -237,7 +237,7 @@ pub fn print(s: &str) {
/// `\n` character is printed to the console after the string. /// `\n` character is printed to the console after the string.
pub fn println(s: &str) { pub fn println(s: &str) {
with_task_stdout(|io| { with_task_stdout(|io| {
io.write(s.as_bytes()).and_then(|()| io.write([b'\n'])) io.write(s.as_bytes()).and_then(|()| io.write(&[b'\n']))
}) })
} }

View file

@ -225,7 +225,7 @@ impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> { pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> {
let mut buf = [0, ..super::DEFAULT_BUF_SIZE]; let mut buf = [0, ..super::DEFAULT_BUF_SIZE];
loop { loop {
let len = match r.read(buf) { let len = match r.read(&mut buf) {
Ok(len) => len, Ok(len) => len,
Err(ref e) if e.kind == io::EndOfFile => return Ok(()), Err(ref e) if e.kind == io::EndOfFile => return Ok(()),
Err(e) => return Err(e), Err(e) => return Err(e),
@ -352,7 +352,7 @@ mod test {
let mut multi = MultiWriter::new(vec!(box TestWriter as Box<Writer>, let mut multi = MultiWriter::new(vec!(box TestWriter as Box<Writer>,
box TestWriter as Box<Writer>)); box TestWriter as Box<Writer>));
multi.write([1, 2, 3]).unwrap(); multi.write(&[1, 2, 3]).unwrap();
assert_eq!(2, unsafe { writes }); assert_eq!(2, unsafe { writes });
assert_eq!(0, unsafe { flushes }); assert_eq!(0, unsafe { flushes });
multi.flush().unwrap(); multi.flush().unwrap();
@ -413,25 +413,25 @@ mod test {
fn test_iter_reader() { fn test_iter_reader() {
let mut r = IterReader::new(range(0u8, 8)); let mut r = IterReader::new(range(0u8, 8));
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let len = r.read(buf).unwrap(); let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3); assert_eq!(len, 3);
assert!(buf == [0, 1, 2]); assert!(buf == [0, 1, 2]);
let len = r.read(buf).unwrap(); let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3); assert_eq!(len, 3);
assert!(buf == [3, 4, 5]); assert!(buf == [3, 4, 5]);
let len = r.read(buf).unwrap(); let len = r.read(&mut buf).unwrap();
assert_eq!(len, 2); assert_eq!(len, 2);
assert!(buf == [6, 7, 5]); assert!(buf == [6, 7, 5]);
assert_eq!(r.read(buf).unwrap_err().kind, io::EndOfFile); assert_eq!(r.read(&mut buf).unwrap_err().kind, io::EndOfFile);
} }
#[test] #[test]
fn iter_reader_zero_length() { fn iter_reader_zero_length() {
let mut r = IterReader::new(range(0u8, 8)); let mut r = IterReader::new(range(0u8, 8));
let mut buf = []; let mut buf = [];
assert_eq!(Ok(0), r.read(buf)); assert_eq!(Ok(0), r.read(&mut buf));
} }
} }

View file

@ -38,7 +38,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
// base 2 number, and then we need another for a possible '-' character. // base 2 number, and then we need another for a possible '-' character.
let mut buf = [0u8, ..65]; let mut buf = [0u8, ..65];
let amt = { let amt = {
let mut wr = ::io::BufWriter::new(buf); let mut wr = ::io::BufWriter::new(&mut buf);
(write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap(); (write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap();
wr.tell().unwrap() as uint wr.tell().unwrap() as uint
}; };

View file

@ -1936,7 +1936,7 @@ mod tests {
fn memory_map_rw() { fn memory_map_rw() {
use result::{Ok, Err}; use result::{Ok, Err};
let chunk = match os::MemoryMap::new(16, [ let chunk = match os::MemoryMap::new(16, &[
os::MapReadable, os::MapReadable,
os::MapWritable os::MapWritable
]) { ]) {
@ -1983,7 +1983,7 @@ mod tests {
"x".with_c_str(|x| assert!(write(fd, x as *const c_void, 1) == 1)); "x".with_c_str(|x| assert!(write(fd, x as *const c_void, 1) == 1));
fd fd
}; };
let chunk = match MemoryMap::new(size / 2, [ let chunk = match MemoryMap::new(size / 2, &[
MapReadable, MapReadable,
MapWritable, MapWritable,
MapFd(fd), MapFd(fd),
@ -2012,16 +2012,16 @@ mod tests {
parsed.iter().map(|s| Path::new(*s)).collect() parsed.iter().map(|s| Path::new(*s)).collect()
} }
assert!(check_parse("", [""])); assert!(check_parse("", &mut [""]));
assert!(check_parse(r#""""#, [""])); assert!(check_parse(r#""""#, &mut [""]));
assert!(check_parse(";;", ["", "", ""])); assert!(check_parse(";;", &mut ["", "", ""]));
assert!(check_parse(r"c:\", [r"c:\"])); assert!(check_parse(r"c:\", &mut [r"c:\"]));
assert!(check_parse(r"c:\;", [r"c:\", ""])); assert!(check_parse(r"c:\;", &mut [r"c:\", ""]));
assert!(check_parse(r"c:\;c:\Program Files\", assert!(check_parse(r"c:\;c:\Program Files\",
[r"c:\", r"c:\Program Files\"])); &mut [r"c:\", r"c:\Program Files\"]));
assert!(check_parse(r#"c:\;c:\"foo"\"#, [r"c:\", r"c:\foo\"])); assert!(check_parse(r#"c:\;c:\"foo"\"#, &mut [r"c:\", r"c:\foo\"]));
assert!(check_parse(r#"c:\;c:\"foo;bar"\;c:\baz"#, assert!(check_parse(r#"c:\;c:\"foo;bar"\;c:\baz"#,
[r"c:\", r"c:\foo;bar\", r"c:\baz"])); &mut [r"c:\", r"c:\foo;bar\", r"c:\baz"]));
} }
#[test] #[test]
@ -2032,11 +2032,11 @@ mod tests {
parsed.iter().map(|s| Path::new(*s)).collect() parsed.iter().map(|s| Path::new(*s)).collect()
} }
assert!(check_parse("", [""])); assert!(check_parse("", &mut [""]));
assert!(check_parse("::", ["", "", ""])); assert!(check_parse("::", &mut ["", "", ""]));
assert!(check_parse("/", ["/"])); assert!(check_parse("/", &mut ["/"]));
assert!(check_parse("/:", ["/", ""])); assert!(check_parse("/:", &mut ["/", ""]));
assert!(check_parse("/:/usr/local", ["/", "/usr/local"])); assert!(check_parse("/:/usr/local", &mut ["/", "/usr/local"]));
} }
#[test] #[test]
@ -2046,12 +2046,12 @@ mod tests {
join_paths(input).unwrap().as_slice() == output.as_bytes() join_paths(input).unwrap().as_slice() == output.as_bytes()
} }
assert!(test_eq([], "")); assert!(test_eq(&[], ""));
assert!(test_eq(["/bin", "/usr/bin", "/usr/local/bin"], assert!(test_eq(&["/bin", "/usr/bin", "/usr/local/bin"],
"/bin:/usr/bin:/usr/local/bin")); "/bin:/usr/bin:/usr/local/bin"));
assert!(test_eq(["", "/bin", "", "", "/usr/bin", ""], assert!(test_eq(&["", "/bin", "", "", "/usr/bin", ""],
":/bin:::/usr/bin:")); ":/bin:::/usr/bin:"));
assert!(join_paths(["/te:st"]).is_err()); assert!(join_paths(&["/te:st"]).is_err());
} }
#[test] #[test]
@ -2068,7 +2068,7 @@ mod tests {
r";c:\windows;;;c:\;")); r";c:\windows;;;c:\;"));
assert!(test_eq([r"c:\te;st", r"c:\"], assert!(test_eq([r"c:\te;st", r"c:\"],
r#""c:\te;st";c:\"#)); r#""c:\te;st";c:\"#));
assert!(join_paths([r#"c:\te"st"#]).is_err()); assert!(join_paths(&[r#"c:\te"st"#]).is_err());
} }
// More recursive_mkdir tests are in extra::tempfile // More recursive_mkdir tests are in extra::tempfile

View file

@ -462,7 +462,7 @@ mod tests {
#[test] #[test]
fn test_paths() { fn test_paths() {
let empty: &[u8] = []; let empty: &[u8] = &[];
t!(v: Path::new(empty), b"."); t!(v: Path::new(empty), b".");
t!(v: Path::new(b"/"), b"/"); t!(v: Path::new(b"/"), b"/");
t!(v: Path::new(b"a/b/c"), b"a/b/c"); t!(v: Path::new(b"a/b/c"), b"a/b/c");
@ -731,14 +731,14 @@ mod tests {
(s: $path:expr, $push:expr, $exp:expr) => ( (s: $path:expr, $push:expr, $exp:expr) => (
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many(&$push);
assert!(p.as_str() == Some($exp)); assert!(p.as_str() == Some($exp));
} }
); );
(v: $path:expr, $push:expr, $exp:expr) => ( (v: $path:expr, $push:expr, $exp:expr) => (
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many(&$push);
assert!(p.as_vec() == $exp); assert!(p.as_vec() == $exp);
} }
) )
@ -836,14 +836,14 @@ mod tests {
(s: $path:expr, $join:expr, $exp:expr) => ( (s: $path:expr, $join:expr, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many(&$join);
assert!(res.as_str() == Some($exp)); assert!(res.as_str() == Some($exp));
} }
); );
(v: $path:expr, $join:expr, $exp:expr) => ( (v: $path:expr, $join:expr, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many(&$join);
assert!(res.as_vec() == $exp); assert!(res.as_vec() == $exp);
} }
) )
@ -859,7 +859,7 @@ mod tests {
#[test] #[test]
fn test_with_helpers() { fn test_with_helpers() {
let empty: &[u8] = []; let empty: &[u8] = &[];
t!(v: Path::new(b"a/b/c").with_filename(b"d"), b"a/b/d"); t!(v: Path::new(b"a/b/c").with_filename(b"d"), b"a/b/d");
t!(v: Path::new(b"a/b/c\xFF").with_filename(b"\x80"), b"a/b/\x80"); t!(v: Path::new(b"a/b/c\xFF").with_filename(b"\x80"), b"a/b/\x80");
@ -1173,7 +1173,7 @@ mod tests {
{ {
let path = Path::new($path); let path = Path::new($path);
let comps = path.components().collect::<Vec<&[u8]>>(); let comps = path.components().collect::<Vec<&[u8]>>();
let exp: &[&str] = $exp; let exp: &[&str] = &$exp;
let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>(); let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>();
assert!(comps == exps, "components: Expected {}, found {}", assert!(comps == exps, "components: Expected {}, found {}",
comps, exps); comps, exps);
@ -1187,7 +1187,7 @@ mod tests {
{ {
let path = Path::new($arg); let path = Path::new($arg);
let comps = path.components().collect::<Vec<&[u8]>>(); let comps = path.components().collect::<Vec<&[u8]>>();
let exp: &[&[u8]] = [$($exp),*]; let exp: &[&[u8]] = &[$($exp),*];
assert_eq!(comps.as_slice(), exp); assert_eq!(comps.as_slice(), exp);
let comps = path.components().rev().collect::<Vec<&[u8]>>(); let comps = path.components().rev().collect::<Vec<&[u8]>>();
let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>();
@ -1219,7 +1219,7 @@ mod tests {
{ {
let path = Path::new($arg); let path = Path::new($arg);
let comps = path.str_components().collect::<Vec<Option<&str>>>(); let comps = path.str_components().collect::<Vec<Option<&str>>>();
let exp: &[Option<&str>] = $exp; let exp: &[Option<&str>] = &$exp;
assert_eq!(comps.as_slice(), exp); assert_eq!(comps.as_slice(), exp);
let comps = path.str_components().rev().collect::<Vec<Option<&str>>>(); let comps = path.str_components().rev().collect::<Vec<Option<&str>>>();
let exp = exp.iter().rev().map(|&x|x).collect::<Vec<Option<&str>>>(); let exp = exp.iter().rev().map(|&x|x).collect::<Vec<Option<&str>>>();

View file

@ -1195,7 +1195,7 @@ mod tests {
#[test] #[test]
fn test_paths() { fn test_paths() {
let empty: &[u8] = []; let empty: &[u8] = &[];
t!(v: Path::new(empty), b"."); t!(v: Path::new(empty), b".");
t!(v: Path::new(b"\\"), b"\\"); t!(v: Path::new(b"\\"), b"\\");
t!(v: Path::new(b"a\\b\\c"), b"a\\b\\c"); t!(v: Path::new(b"a\\b\\c"), b"a\\b\\c");
@ -1571,14 +1571,14 @@ mod tests {
(s: $path:expr, $push:expr, $exp:expr) => ( (s: $path:expr, $push:expr, $exp:expr) => (
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many(&$push);
assert_eq!(p.as_str(), Some($exp)); assert_eq!(p.as_str(), Some($exp));
} }
); );
(v: $path:expr, $push:expr, $exp:expr) => ( (v: $path:expr, $push:expr, $exp:expr) => (
{ {
let mut p = Path::new($path); let mut p = Path::new($path);
p.push_many($push); p.push_many(&$push);
assert_eq!(p.as_vec(), $exp); assert_eq!(p.as_vec(), $exp);
} }
) )
@ -1712,14 +1712,14 @@ mod tests {
(s: $path:expr, $join:expr, $exp:expr) => ( (s: $path:expr, $join:expr, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many(&$join);
assert_eq!(res.as_str(), Some($exp)); assert_eq!(res.as_str(), Some($exp));
} }
); );
(v: $path:expr, $join:expr, $exp:expr) => ( (v: $path:expr, $join:expr, $exp:expr) => (
{ {
let path = Path::new($path); let path = Path::new($path);
let res = path.join_many($join); let res = path.join_many(&$join);
assert_eq!(res.as_vec(), $exp); assert_eq!(res.as_vec(), $exp);
} }
) )
@ -2252,7 +2252,7 @@ mod tests {
let path = Path::new($path); let path = Path::new($path);
let comps = path.str_components().map(|x|x.unwrap()) let comps = path.str_components().map(|x|x.unwrap())
.collect::<Vec<&str>>(); .collect::<Vec<&str>>();
let exp: &[&str] = $exp; let exp: &[&str] = &$exp;
assert_eq!(comps.as_slice(), exp); assert_eq!(comps.as_slice(), exp);
let comps = path.str_components().rev().map(|x|x.unwrap()) let comps = path.str_components().rev().map(|x|x.unwrap())
.collect::<Vec<&str>>(); .collect::<Vec<&str>>();
@ -2309,7 +2309,7 @@ mod tests {
{ {
let path = Path::new($path); let path = Path::new($path);
let comps = path.components().collect::<Vec<&[u8]>>(); let comps = path.components().collect::<Vec<&[u8]>>();
let exp: &[&[u8]] = $exp; let exp: &[&[u8]] = &$exp;
assert_eq!(comps.as_slice(), exp); assert_eq!(comps.as_slice(), exp);
let comps = path.components().rev().collect::<Vec<&[u8]>>(); let comps = path.components().rev().collect::<Vec<&[u8]>>();
let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>();

View file

@ -522,7 +522,7 @@ mod test {
#[test] #[test]
fn test_choose() { fn test_choose() {
let mut r = task_rng(); let mut r = task_rng();
assert_eq!(r.choose([1i, 1, 1]).map(|&x|x), Some(1)); assert_eq!(r.choose(&[1i, 1, 1]).map(|&x|x), Some(1));
let v: &[int] = &[]; let v: &[int] = &[];
assert_eq!(r.choose(v), None); assert_eq!(r.choose(v), None);
@ -534,16 +534,16 @@ mod test {
let empty: &mut [int] = &mut []; let empty: &mut [int] = &mut [];
r.shuffle(empty); r.shuffle(empty);
let mut one = [1i]; let mut one = [1i];
r.shuffle(one); r.shuffle(&mut one);
let b: &[_] = &[1]; let b: &[_] = &[1];
assert_eq!(one.as_slice(), b); assert_eq!(one.as_slice(), b);
let mut two = [1i, 2]; let mut two = [1i, 2];
r.shuffle(two); r.shuffle(&mut two);
assert!(two == [1, 2] || two == [2, 1]); assert!(two == [1, 2] || two == [2, 1]);
let mut x = [1i, 1, 1]; let mut x = [1i, 1, 1];
r.shuffle(x); r.shuffle(&mut x);
let b: &[_] = &[1, 1, 1]; let b: &[_] = &[1, 1, 1];
assert_eq!(x.as_slice(), b); assert_eq!(x.as_slice(), b);
} }
@ -553,7 +553,7 @@ mod test {
let mut r = task_rng(); let mut r = task_rng();
r.gen::<int>(); r.gen::<int>();
let mut v = [1i, 1, 1]; let mut v = [1i, 1, 1];
r.shuffle(v); r.shuffle(&mut v);
let b: &[_] = &[1, 1, 1]; let b: &[_] = &[1, 1, 1];
assert_eq!(v.as_slice(), b); assert_eq!(v.as_slice(), b);
assert_eq!(r.gen_range(0u, 1u), 0u); assert_eq!(r.gen_range(0u, 1u), 0u);
@ -673,7 +673,7 @@ mod bench {
#[bench] #[bench]
fn rand_shuffle_100(b: &mut Bencher) { fn rand_shuffle_100(b: &mut Bencher) {
let mut rng = weak_rng(); let mut rng = weak_rng();
let x : &mut[uint] = [1,..100]; let x : &mut[uint] = &mut [1,..100];
b.iter(|| { b.iter(|| {
rng.shuffle(x); rng.shuffle(x);
}) })

View file

@ -343,7 +343,7 @@ mod test {
r.next_u64(); r.next_u64();
let mut v = [0u8, .. 1000]; let mut v = [0u8, .. 1000];
r.fill_bytes(v); r.fill_bytes(&mut v);
} }
#[test] #[test]
@ -368,7 +368,7 @@ mod test {
task::deschedule(); task::deschedule();
r.next_u64(); r.next_u64();
task::deschedule(); task::deschedule();
r.fill_bytes(v); r.fill_bytes(&mut v);
task::deschedule(); task::deschedule();
} }
}) })

View file

@ -108,7 +108,7 @@ mod test {
let mut w = [0u8, .. 8]; let mut w = [0u8, .. 8];
let mut rng = ReaderRng::new(MemReader::new(v.as_slice().to_vec())); let mut rng = ReaderRng::new(MemReader::new(v.as_slice().to_vec()));
rng.fill_bytes(w); rng.fill_bytes(&mut w);
assert!(v == w); assert!(v == w);
} }
@ -118,6 +118,6 @@ mod test {
fn test_reader_rng_insufficient_bytes() { fn test_reader_rng_insufficient_bytes() {
let mut rng = ReaderRng::new(MemReader::new(vec!())); let mut rng = ReaderRng::new(MemReader::new(vec!()));
let mut v = [0u8, .. 3]; let mut v = [0u8, .. 3];
rng.fill_bytes(v); rng.fill_bytes(&mut v);
} }
} }

View file

@ -527,7 +527,7 @@ mod imp {
Some(string) => try!(super::demangle(w, string)), Some(string) => try!(super::demangle(w, string)),
None => try!(write!(w, "<unknown>")), None => try!(write!(w, "<unknown>")),
} }
w.write(['\n' as u8]) w.write(&['\n' as u8])
} }
/// Unwind library interface used for backtraces /// Unwind library interface used for backtraces

View file

@ -359,7 +359,7 @@ pub fn read<T>(fd: sock_t,
// With a timeout, first we wait for the socket to become // With a timeout, first we wait for the socket to become
// readable using select(), specifying the relevant timeout for // readable using select(), specifying the relevant timeout for
// our previously set deadline. // our previously set deadline.
try!(await([fd], deadline, Readable)); try!(await(&[fd], deadline, Readable));
// At this point, we're still within the timeout, and we've // At this point, we're still within the timeout, and we've
// determined that the socket is readable (as returned by // determined that the socket is readable (as returned by
@ -411,7 +411,7 @@ pub fn write<T>(fd: sock_t,
while written < buf.len() && (write_everything || written == 0) { while written < buf.len() && (write_everything || written == 0) {
// As with read(), first wait for the socket to be ready for // As with read(), first wait for the socket to be ready for
// the I/O operation. // the I/O operation.
match await([fd], deadline, Writable) { match await(&[fd], deadline, Writable) {
Err(ref e) if e.kind == io::EndOfFile && written > 0 => { Err(ref e) if e.kind == io::EndOfFile && written > 0 => {
assert!(deadline.is_some()); assert!(deadline.is_some());
return Err(short_write(written, "short write")) return Err(short_write(written, "short write"))

View file

@ -376,7 +376,7 @@ mod tests {
writer.write(b"test").ok().unwrap(); writer.write(b"test").ok().unwrap();
let mut buf = [0u8, ..4]; let mut buf = [0u8, ..4];
match reader.read(buf) { match reader.read(&mut buf) {
Ok(4) => { Ok(4) => {
assert_eq!(buf[0], 't' as u8); assert_eq!(buf[0], 't' as u8);
assert_eq!(buf[1], 'e' as u8); assert_eq!(buf[1], 'e' as u8);
@ -386,7 +386,7 @@ mod tests {
r => panic!("invalid read: {}", r), r => panic!("invalid read: {}", r),
} }
assert!(writer.read(buf).is_err()); assert!(writer.read(&mut buf).is_err());
assert!(reader.write(buf).is_err()); assert!(reader.write(&buf).is_err());
} }
} }

View file

@ -21,7 +21,7 @@ pub fn new() -> (signal, signal) {
} }
pub fn signal(fd: libc::c_int) { pub fn signal(fd: libc::c_int) {
FileDesc::new(fd, false).write([0]).ok().unwrap(); FileDesc::new(fd, false).write(&[0]).ok().unwrap();
} }
pub fn close(fd: libc::c_int) { pub fn close(fd: libc::c_int) {

Some files were not shown because too many files have changed in this diff Show more