auto merge of #20387 : nick29581/rust/arrays-2, r=alexcrichton

Closes #19999
This commit is contained in:
bors 2015-01-02 02:31:12 +00:00
commit cd614164e6
97 changed files with 414 additions and 387 deletions

View File

@ -1606,18 +1606,18 @@ things. The most basic is the **array**, a fixed-size list of elements of the
same type. By default, arrays are immutable. same type. By default, arrays are immutable.
```{rust} ```{rust}
let a = [1i, 2i, 3i]; // a: [int, ..3] let a = [1i, 2i, 3i]; // a: [int; 3]
let mut m = [1i, 2i, 3i]; // mut m: [int, ..3] let mut m = [1i, 2i, 3i]; // mut m: [int; 3]
``` ```
There's a shorthand for initializing each element of an array to the same There's a shorthand for initializing each element of an array to the same
value. In this example, each element of `a` will be initialized to `0i`: value. In this example, each element of `a` will be initialized to `0i`:
```{rust} ```{rust}
let a = [0i, ..20]; // a: [int, ..20] let a = [0i; 20]; // a: [int; 20]
``` ```
Arrays have type `[T,..N]`. We'll talk about this `T` notation later, when we Arrays have type `[T; N]`. We'll talk about this `T` notation later, when we
cover generics. cover generics.
You can get the number of elements in an array `a` with `a.len()`, and use You can get the number of elements in an array `a` with `a.len()`, and use

View File

@ -1438,11 +1438,11 @@ the `static` lifetime, fixed-size arrays, tuples, enum variants, and structs.
const BIT1: uint = 1 << 0; const BIT1: uint = 1 << 0;
const BIT2: uint = 1 << 1; const BIT2: uint = 1 << 1;
const BITS: [uint, ..2] = [BIT1, BIT2]; const BITS: [uint; 2] = [BIT1, BIT2];
const STRING: &'static str = "bitstring"; const STRING: &'static str = "bitstring";
struct BitsNStrings<'a> { struct BitsNStrings<'a> {
mybits: [uint, ..2], mybits: [uint; 2],
mystring: &'a str mystring: &'a str
} }
@ -2923,7 +2923,7 @@ constant expression that can be evaluated at compile time, such as a
``` ```
[1i, 2, 3, 4]; [1i, 2, 3, 4];
["a", "b", "c", "d"]; ["a", "b", "c", "d"];
[0i, ..128]; // array with 128 zeros [0i; 128]; // array with 128 zeros
[0u8, 0u8, 0u8, 0u8]; [0u8, 0u8, 0u8, 0u8];
``` ```
@ -3691,7 +3691,7 @@ An example of each kind:
```{rust} ```{rust}
let vec: Vec<int> = vec![1, 2, 3]; let vec: Vec<int> = vec![1, 2, 3];
let arr: [int, ..3] = [1, 2, 3]; let arr: [int; 3] = [1, 2, 3];
let s: &[int] = vec.as_slice(); let s: &[int] = vec.as_slice();
``` ```

View File

@ -1322,7 +1322,7 @@ mod tests {
#[bench] #[bench]
fn bench_collect_into(b: &mut test::Bencher) { fn bench_collect_into(b: &mut test::Bencher) {
let v = &[0i, ..64]; let v = &[0i; 64];
b.iter(|| { b.iter(|| {
let _: DList<int> = v.iter().map(|x| *x).collect(); let _: DList<int> = v.iter().map(|x| *x).collect();
}) })
@ -1384,7 +1384,7 @@ mod tests {
#[bench] #[bench]
fn bench_iter(b: &mut test::Bencher) { fn bench_iter(b: &mut test::Bencher) {
let v = &[0i, ..128]; let v = &[0i; 128];
let m: DList<int> = v.iter().map(|&x|x).collect(); let m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| { b.iter(|| {
assert!(m.iter().count() == 128); assert!(m.iter().count() == 128);
@ -1392,7 +1392,7 @@ mod tests {
} }
#[bench] #[bench]
fn bench_iter_mut(b: &mut test::Bencher) { fn bench_iter_mut(b: &mut test::Bencher) {
let v = &[0i, ..128]; let v = &[0i; 128];
let mut m: DList<int> = v.iter().map(|&x|x).collect(); let mut m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| { b.iter(|| {
assert!(m.iter_mut().count() == 128); assert!(m.iter_mut().count() == 128);
@ -1400,7 +1400,7 @@ mod tests {
} }
#[bench] #[bench]
fn bench_iter_rev(b: &mut test::Bencher) { fn bench_iter_rev(b: &mut test::Bencher) {
let v = &[0i, ..128]; let v = &[0i; 128];
let m: DList<int> = v.iter().map(|&x|x).collect(); let m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| { b.iter(|| {
assert!(m.iter().rev().count() == 128); assert!(m.iter().rev().count() == 128);
@ -1408,7 +1408,7 @@ mod tests {
} }
#[bench] #[bench]
fn bench_iter_mut_rev(b: &mut test::Bencher) { fn bench_iter_mut_rev(b: &mut test::Bencher) {
let v = &[0i, ..128]; let v = &[0i; 128];
let mut m: DList<int> = v.iter().map(|&x|x).collect(); let mut m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| { b.iter(|| {
assert!(m.iter_mut().rev().count() == 128); assert!(m.iter_mut().rev().count() == 128);

View File

@ -382,7 +382,7 @@ pub trait SliceExt<T> for Sized? {
fn get_mut(&mut self, index: uint) -> Option<&mut T>; fn get_mut(&mut self, index: uint) -> Option<&mut T>;
/// Work with `self` as a mut slice. /// Work with `self` as a mut slice.
/// Primarily intended for getting a &mut [T] from a [T, ..N]. /// Primarily intended for getting a &mut [T] from a [T; N].
#[stable] #[stable]
fn as_mut_slice(&mut self) -> &mut [T]; fn as_mut_slice(&mut self) -> &mut [T];
@ -861,6 +861,7 @@ pub trait CloneSliceExt<T> for Sized? {
fn clone_from_slice(&mut self, &[T]) -> uint; fn clone_from_slice(&mut self, &[T]) -> uint;
} }
#[unstable = "trait is unstable"] #[unstable = "trait is unstable"]
impl<T: Clone> CloneSliceExt<T> for [T] { impl<T: Clone> CloneSliceExt<T> for [T] {
/// Returns a copy of `v`. /// Returns a copy of `v`.
@ -1482,14 +1483,14 @@ mod tests {
#[test] #[test]
fn test_is_empty() { fn test_is_empty() {
let xs: [int, ..0] = []; let xs: [int; 0] = [];
assert!(xs.is_empty()); assert!(xs.is_empty());
assert!(![0i].is_empty()); assert!(![0i].is_empty());
} }
#[test] #[test]
fn test_len_divzero() { fn test_len_divzero() {
type Z = [i8, ..0]; type Z = [i8; 0];
let v0 : &[Z] = &[]; let v0 : &[Z] = &[];
let v1 : &[Z] = &[[]]; let v1 : &[Z] = &[[]];
let v2 : &[Z] = &[[], []]; let v2 : &[Z] = &[[], []];
@ -1856,7 +1857,7 @@ mod tests {
#[test] #[test]
fn test_permutations() { fn test_permutations() {
{ {
let v: [int, ..0] = []; let v: [int; 0] = [];
let mut it = v.permutations(); let mut it = v.permutations();
let (min_size, max_opt) = it.size_hint(); let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1); assert_eq!(min_size, 1);
@ -2059,7 +2060,7 @@ mod tests {
} }
// shouldn't panic // shouldn't panic
let mut v: [uint, .. 0] = []; let mut v: [uint; 0] = [];
v.sort(); v.sort();
let mut v = [0xDEADBEEFu]; let mut v = [0xDEADBEEFu];
@ -2071,7 +2072,7 @@ mod tests {
fn test_sort_stability() { fn test_sort_stability() {
for len in range(4i, 25) { for len in range(4i, 25) {
for _ in range(0u, 10) { for _ in range(0u, 10) {
let mut counts = [0i, .. 10]; let mut counts = [0i; 10];
// create a vector like [(6, 1), (5, 1), (6, 2), ...], // create a vector like [(6, 1), (5, 1), (6, 2), ...],
// where the first item of each tuple is random, but // where the first item of each tuple is random, but
@ -2116,28 +2117,28 @@ mod tests {
#[test] #[test]
fn test_concat() { fn test_concat() {
let v: [Vec<int>, ..0] = []; let v: [Vec<int>; 0] = [];
let c: Vec<int> = v.concat(); let c: Vec<int> = v.concat();
assert_eq!(c, []); assert_eq!(c, []);
let d: Vec<int> = [vec![1i], vec![2i,3i]].concat(); let d: Vec<int> = [vec![1i], vec![2i,3i]].concat();
assert_eq!(d, vec![1i, 2, 3]); assert_eq!(d, vec![1i, 2, 3]);
let v: [&[int], ..2] = [&[1], &[2, 3]]; let v: [&[int]; 2] = [&[1], &[2, 3]];
assert_eq!(v.connect(&0), vec![1i, 0, 2, 3]); assert_eq!(v.connect(&0), vec![1i, 0, 2, 3]);
let v: [&[int], ..3] = [&[1i], &[2], &[3]]; let v: [&[int]; 3] = [&[1i], &[2], &[3]];
assert_eq!(v.connect(&0), vec![1i, 0, 2, 0, 3]); assert_eq!(v.connect(&0), vec![1i, 0, 2, 0, 3]);
} }
#[test] #[test]
fn test_connect() { fn test_connect() {
let v: [Vec<int>, ..0] = []; let v: [Vec<int>; 0] = [];
assert_eq!(v.connect_vec(&0), vec![]); assert_eq!(v.connect_vec(&0), vec![]);
assert_eq!([vec![1i], vec![2i, 3]].connect_vec(&0), vec![1, 0, 2, 3]); assert_eq!([vec![1i], vec![2i, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
assert_eq!([vec![1i], vec![2i], vec![3i]].connect_vec(&0), vec![1, 0, 2, 0, 3]); assert_eq!([vec![1i], vec![2i], vec![3i]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
let v: [&[int], ..2] = [&[1], &[2, 3]]; let v: [&[int]; 2] = [&[1], &[2, 3]];
assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 3]); assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 3]);
let v: [&[int], ..3] = [&[1], &[2], &[3]]; let v: [&[int]; 3] = [&[1], &[2], &[3]];
assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 0, 3]); assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 0, 3]);
} }
@ -2710,7 +2711,7 @@ mod tests {
} }
assert_eq!(cnt, 11); assert_eq!(cnt, 11);
let xs: [Foo, ..3] = [Foo, Foo, Foo]; let xs: [Foo; 3] = [Foo, Foo, Foo];
cnt = 0; cnt = 0;
for f in xs.iter() { for f in xs.iter() {
assert!(*f == Foo); assert!(*f == Foo);

View File

@ -2517,7 +2517,7 @@ mod tests {
#[test] #[test]
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(&mut 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();
@ -2529,7 +2529,7 @@ mod tests {
#[test] #[test]
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(&mut 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();
@ -2743,7 +2743,7 @@ mod tests {
use core::iter::order; use core::iter::order;
// official Unicode test data // official Unicode test data
// from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt // from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
let test_same: [(_, &[_]), .. 325] = [ let test_same: [(_, &[_]); 325] = [
("\u{20}\u{20}", &["\u{20}", "\u{20}"]), ("\u{20}\u{20}", &["\u{20}", "\u{20}"]),
("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]), ("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]),
("\u{20}\u{D}", &["\u{20}", "\u{D}"]), ("\u{20}\u{D}", &["\u{20}", "\u{D}"]),
@ -3075,7 +3075,7 @@ mod tests {
("\u{646}\u{200D}\u{20}", &["\u{646}\u{200D}", "\u{20}"]), ("\u{646}\u{200D}\u{20}", &["\u{646}\u{200D}", "\u{20}"]),
]; ];
let test_diff: [(_, &[_], &[_]), .. 23] = [ let test_diff: [(_, &[_], &[_]); 23] = [
("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}", ("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}",
&["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{D}\u{308}\u{903}", &["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{D}\u{308}\u{903}",
&["\u{D}", "\u{308}\u{903}"], &["\u{D}", "\u{308}", "\u{903}"]), ("\u{A}\u{308}\u{903}", &["\u{D}", "\u{308}\u{903}"], &["\u{D}", "\u{308}", "\u{903}"]), ("\u{A}\u{308}\u{903}",

View File

@ -675,7 +675,7 @@ impl String {
assert!(idx <= len); assert!(idx <= len);
assert!(self.is_char_boundary(idx)); assert!(self.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(&mut bits).unwrap(); let amt = ch.encode_utf8(&mut bits).unwrap();
unsafe { unsafe {

View File

@ -26,33 +26,33 @@ macro_rules! array_impls {
($($N:expr)+) => { ($($N:expr)+) => {
$( $(
#[stable] #[stable]
impl<T:Copy> Clone for [T, ..$N] { impl<T:Copy> Clone for [T; $N] {
fn clone(&self) -> [T, ..$N] { fn clone(&self) -> [T; $N] {
*self *self
} }
} }
#[unstable = "waiting for Show to stabilize"] #[unstable = "waiting for Show to stabilize"]
impl<T:fmt::Show> fmt::Show for [T, ..$N] { impl<T:fmt::Show> fmt::Show for [T; $N] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Show::fmt(&self[], f) fmt::Show::fmt(&self[], f)
} }
} }
#[stable] #[stable]
impl<A, B> PartialEq<[B, ..$N]> for [A, ..$N] where A: PartialEq<B> { impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
#[inline] #[inline]
fn eq(&self, other: &[B, ..$N]) -> bool { fn eq(&self, other: &[B; $N]) -> bool {
self[] == other[] self[] == other[]
} }
#[inline] #[inline]
fn ne(&self, other: &[B, ..$N]) -> bool { fn ne(&self, other: &[B; $N]) -> bool {
self[] != other[] self[] != other[]
} }
} }
#[stable] #[stable]
impl<'a, A, B, Rhs> PartialEq<Rhs> for [A, ..$N] where impl<'a, A, B, Rhs> PartialEq<Rhs> for [A; $N] where
A: PartialEq<B>, A: PartialEq<B>,
Rhs: Deref<[B]>, Rhs: Deref<[B]>,
{ {
@ -63,47 +63,47 @@ macro_rules! array_impls {
} }
#[stable] #[stable]
impl<'a, A, B, Lhs> PartialEq<[B, ..$N]> for Lhs where impl<'a, A, B, Lhs> PartialEq<[B; $N]> for Lhs where
A: PartialEq<B>, A: PartialEq<B>,
Lhs: Deref<[A]> Lhs: Deref<[A]>
{ {
#[inline(always)] #[inline(always)]
fn eq(&self, other: &[B, ..$N]) -> bool { PartialEq::eq(&**self, other[]) } fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other[]) }
#[inline(always)] #[inline(always)]
fn ne(&self, other: &[B, ..$N]) -> bool { PartialEq::ne(&**self, other[]) } fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other[]) }
} }
#[stable] #[stable]
impl<T:Eq> Eq for [T, ..$N] { } impl<T:Eq> Eq for [T; $N] { }
#[stable] #[stable]
impl<T:PartialOrd> PartialOrd for [T, ..$N] { impl<T:PartialOrd> PartialOrd for [T; $N] {
#[inline] #[inline]
fn partial_cmp(&self, other: &[T, ..$N]) -> Option<Ordering> { fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> {
PartialOrd::partial_cmp(&self[], &other[]) PartialOrd::partial_cmp(&self[], &other[])
} }
#[inline] #[inline]
fn lt(&self, other: &[T, ..$N]) -> bool { fn lt(&self, other: &[T; $N]) -> bool {
PartialOrd::lt(&self[], &other[]) PartialOrd::lt(&self[], &other[])
} }
#[inline] #[inline]
fn le(&self, other: &[T, ..$N]) -> bool { fn le(&self, other: &[T; $N]) -> bool {
PartialOrd::le(&self[], &other[]) PartialOrd::le(&self[], &other[])
} }
#[inline] #[inline]
fn ge(&self, other: &[T, ..$N]) -> bool { fn ge(&self, other: &[T; $N]) -> bool {
PartialOrd::ge(&self[], &other[]) PartialOrd::ge(&self[], &other[])
} }
#[inline] #[inline]
fn gt(&self, other: &[T, ..$N]) -> bool { fn gt(&self, other: &[T; $N]) -> bool {
PartialOrd::gt(&self[], &other[]) PartialOrd::gt(&self[], &other[])
} }
} }
#[stable] #[stable]
impl<T:Ord> Ord for [T, ..$N] { impl<T:Ord> Ord for [T; $N] {
#[inline] #[inline]
fn cmp(&self, other: &[T, ..$N]) -> Ordering { fn cmp(&self, other: &[T; $N]) -> Ordering {
Ord::cmp(&self[], &other[]) Ord::cmp(&self[], &other[])
} }
} }

View File

@ -123,7 +123,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
// For an f64 the exponent is in the range of [-1022, 1023] for base 2, so // For an f64 the exponent is in the range of [-1022, 1023] for base 2, so
// we may have up to that many digits. Give ourselves some extra wiggle room // we may have up to that many digits. Give ourselves some extra wiggle room
// otherwise as well. // otherwise as well.
let mut buf = [0u8, ..1536]; let mut buf = [0u8; 1536];
let mut end = 0; let mut end = 0;
let radix_gen: T = cast(radix as int).unwrap(); let radix_gen: T = cast(radix as int).unwrap();

View File

@ -400,7 +400,7 @@ impl<'a> Formatter<'a> {
// Writes the sign if it exists, and then the prefix if it was requested // Writes the sign if it exists, and then the prefix if it was requested
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(&mut 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]));
} }
@ -505,7 +505,7 @@ impl<'a> Formatter<'a> {
rt::AlignCenter => (padding / 2, (padding + 1) / 2), rt::AlignCenter => (padding / 2, (padding + 1) / 2),
}; };
let mut fill = [0u8, ..4]; let mut fill = [0u8; 4];
let len = self.fill.encode_utf8(&mut 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) {
@ -606,7 +606,7 @@ impl Show for char {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
use char::Char; use char::Char;
let mut utf8 = [0u8, ..4]; let mut utf8 = [0u8; 4];
let amt = self.encode_utf8(&mut 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]) };
Show::fmt(s, f) Show::fmt(s, f)

View File

@ -37,7 +37,7 @@ trait GenericRadix {
// characters for a base 2 number. // characters for a base 2 number.
let zero = Int::zero(); let zero = Int::zero();
let is_positive = x >= zero; let is_positive = x >= zero;
let mut buf = [0u8, ..64]; let mut buf = [0u8; 64];
let mut curr = buf.len(); let mut curr = buf.len();
let base = cast(self.base()).unwrap(); let base = cast(self.base()).unwrap();
if is_positive { if is_positive {

View File

@ -100,7 +100,7 @@ macro_rules! impl_hash {
impl<S: Writer> Hash<S> for $ty { impl<S: Writer> Hash<S> for $ty {
#[inline] #[inline]
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
let a: [u8, ..::$ty::BYTES] = unsafe { let a: [u8; ::$ty::BYTES] = unsafe {
mem::transmute((*self as $uty).to_le() as $ty) mem::transmute((*self as $uty).to_le() as $ty)
}; };
state.write(a.as_slice()) state.write(a.as_slice())

View File

@ -292,7 +292,7 @@ mod tests {
#[test] #[test]
#[allow(unused_must_use)] #[allow(unused_must_use)]
fn test_siphash() { fn test_siphash() {
let vecs : [[u8, ..8], ..64] = [ let vecs : [[u8; 8]; 64] = [
[ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ], [ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ],
[ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ], [ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ],
[ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ], [ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ],
@ -366,7 +366,7 @@ mod tests {
let mut state_inc = SipState::new_with_keys(k0, k1); let mut state_inc = SipState::new_with_keys(k0, k1);
let mut state_full = SipState::new_with_keys(k0, k1); let mut state_full = SipState::new_with_keys(k0, k1);
fn to_hex_str(r: &[u8, ..8]) -> String { fn to_hex_str(r: &[u8; 8]) -> String {
let mut s = String::new(); let mut s = String::new();
for b in r.iter() { for b in r.iter() {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice()); s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());

View File

@ -1037,7 +1037,7 @@ pub trait IteratorOrdExt<A> {
/// ```rust /// ```rust
/// use std::iter::{NoElements, OneElement, MinMax}; /// use std::iter::{NoElements, OneElement, MinMax};
/// ///
/// let v: [int, ..0] = []; /// let v: [int; 0] = [];
/// assert_eq!(v.iter().min_max(), NoElements); /// assert_eq!(v.iter().min_max(), NoElements);
/// ///
/// let v = [1i]; /// let v = [1i];

View File

@ -1027,7 +1027,7 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
} }
// https://tools.ietf.org/html/rfc3629 // https://tools.ietf.org/html/rfc3629
static UTF8_CHAR_WIDTH: [u8, ..256] = [ static UTF8_CHAR_WIDTH: [u8; 256] = [
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

View File

@ -113,10 +113,10 @@ fn any_downcast_mut() {
#[test] #[test]
fn any_fixed_vec() { fn any_fixed_vec() {
let test = [0u, ..8]; let test = [0u; 8];
let test = &test as &Any; let test = &test as &Any;
assert!(test.is::<[uint, ..8]>()); assert!(test.is::<[uint; 8]>());
assert!(!test.is::<[uint, ..10]>()); assert!(!test.is::<[uint; 10]>());
} }

View File

@ -169,7 +169,7 @@ fn test_escape_unicode() {
#[test] #[test]
fn test_encode_utf8() { fn test_encode_utf8() {
fn check(input: char, expect: &[u8]) { fn check(input: char, expect: &[u8]) {
let mut buf = [0u8, ..4]; let mut buf = [0u8; 4];
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0); let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
assert_eq!(buf[..n], expect); assert_eq!(buf[..n], expect);
} }
@ -183,7 +183,7 @@ fn test_encode_utf8() {
#[test] #[test]
fn test_encode_utf16() { fn test_encode_utf16() {
fn check(input: char, expect: &[u16]) { fn check(input: char, expect: &[u16]) {
let mut buf = [0u16, ..2]; let mut buf = [0u16; 2];
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0); let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
assert_eq!(buf[..n], expect); assert_eq!(buf[..n], expect);
} }

View File

@ -33,7 +33,7 @@ impl<'a, S: Writer> Hash<S> for Bytes<'a> {
#[test] #[test]
#[allow(unused_must_use)] #[allow(unused_must_use)]
fn test_siphash() { fn test_siphash() {
let vecs : [[u8, ..8], ..64] = [ let vecs : [[u8; 8]; 64] = [
[ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ], [ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ],
[ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ], [ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ],
[ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ], [ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ],
@ -107,7 +107,7 @@ fn test_siphash() {
let mut state_inc = SipState::new_with_keys(k0, k1); let mut state_inc = SipState::new_with_keys(k0, k1);
let mut state_full = SipState::new_with_keys(k0, k1); let mut state_full = SipState::new_with_keys(k0, k1);
fn to_hex_str(r: &[u8, ..8]) -> String { fn to_hex_str(r: &[u8; 8]) -> String {
let mut s = String::new(); let mut s = String::new();
for b in r.iter() { for b in r.iter() {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice()); s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());

View File

@ -19,7 +19,7 @@ use test::Bencher;
#[test] #[test]
fn test_lt() { fn test_lt() {
let empty: [int, ..0] = []; let empty: [int; 0] = [];
let xs = [1i,2,3]; let xs = [1i,2,3];
let ys = [1i,2,0]; let ys = [1i,2,0];
@ -781,7 +781,7 @@ fn test_peekable_is_empty() {
#[test] #[test]
fn test_min_max() { fn test_min_max() {
let v: [int, ..0] = []; let v: [int; 0] = [];
assert_eq!(v.iter().min_max(), NoElements); assert_eq!(v.iter().min_max(), NoElements);
let v = [1i]; let v = [1i];

View File

@ -165,8 +165,8 @@ fn test_ptr_subtraction() {
#[test] #[test]
fn test_set_memory() { fn test_set_memory() {
let mut xs = [0u8, ..20]; let mut xs = [0u8; 20];
let ptr = xs.as_mut_ptr(); let ptr = xs.as_mut_ptr();
unsafe { set_memory(ptr, 5u8, xs.len()); } unsafe { set_memory(ptr, 5u8, xs.len()); }
assert!(xs == [5u8, ..20]); assert!(xs == [5u8; 20]);
} }

View File

@ -425,20 +425,20 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr { #[deriving(Copy)] pub struct sockaddr {
pub sa_family: sa_family_t, pub sa_family: sa_family_t,
pub sa_data: [u8, ..14], pub sa_data: [u8; 14],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage { #[deriving(Copy)] pub struct sockaddr_storage {
pub ss_family: sa_family_t, pub ss_family: sa_family_t,
pub __ss_align: i64, pub __ss_align: i64,
pub __ss_pad2: [u8, ..112], pub __ss_pad2: [u8; 112],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in { #[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t, pub sin_family: sa_family_t,
pub sin_port: in_port_t, pub sin_port: in_port_t,
pub sin_addr: in_addr, pub sin_addr: in_addr,
pub sin_zero: [u8, ..8], pub sin_zero: [u8; 8],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in_addr { #[deriving(Copy)] pub struct in_addr {
@ -454,7 +454,7 @@ pub mod types {
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in6_addr { #[deriving(Copy)] pub struct in6_addr {
pub s6_addr: [u16, ..8] pub s6_addr: [u16; 8]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ip_mreq { #[deriving(Copy)] pub struct ip_mreq {
@ -491,7 +491,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_un { #[deriving(Copy)] pub struct sockaddr_un {
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
pub sun_path: [c_char, ..108] pub sun_path: [c_char; 108]
} }
#[repr(C)] #[repr(C)]
@ -609,7 +609,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __size: [u32, ..9] pub __size: [u32; 9]
} }
} }
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
@ -625,14 +625,14 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct stat { #[deriving(Copy)] pub struct stat {
pub st_dev: c_ulonglong, pub st_dev: c_ulonglong,
pub __pad0: [c_uchar, ..4], pub __pad0: [c_uchar; 4],
pub __st_ino: ino_t, pub __st_ino: ino_t,
pub st_mode: c_uint, pub st_mode: c_uint,
pub st_nlink: c_uint, pub st_nlink: c_uint,
pub st_uid: uid_t, pub st_uid: uid_t,
pub st_gid: gid_t, pub st_gid: gid_t,
pub st_rdev: c_ulonglong, pub st_rdev: c_ulonglong,
pub __pad3: [c_uchar, ..4], pub __pad3: [c_uchar; 4],
pub st_size: c_longlong, pub st_size: c_longlong,
pub st_blksize: blksize_t, pub st_blksize: blksize_t,
pub st_blocks: c_ulonglong, pub st_blocks: c_ulonglong,
@ -653,7 +653,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __size: [u32, ..9] pub __size: [u32; 9]
} }
} }
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))] #[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
@ -670,14 +670,14 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct stat { #[deriving(Copy)] pub struct stat {
pub st_dev: c_ulong, pub st_dev: c_ulong,
pub st_pad1: [c_long, ..3], pub st_pad1: [c_long; 3],
pub st_ino: ino_t, pub st_ino: ino_t,
pub st_mode: mode_t, pub st_mode: mode_t,
pub st_nlink: nlink_t, pub st_nlink: nlink_t,
pub st_uid: uid_t, pub st_uid: uid_t,
pub st_gid: gid_t, pub st_gid: gid_t,
pub st_rdev: c_ulong, pub st_rdev: c_ulong,
pub st_pad2: [c_long, ..2], pub st_pad2: [c_long; 2],
pub st_size: off_t, pub st_size: off_t,
pub st_pad3: c_long, pub st_pad3: c_long,
pub st_atime: time_t, pub st_atime: time_t,
@ -688,7 +688,7 @@ pub mod types {
pub st_ctime_nsec: c_long, pub st_ctime_nsec: c_long,
pub st_blksize: blksize_t, pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t, pub st_blocks: blkcnt_t,
pub st_pad5: [c_long, ..14], pub st_pad5: [c_long; 14],
} }
#[repr(C)] #[repr(C)]
@ -699,7 +699,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __size: [u32, ..9] pub __size: [u32; 9]
} }
} }
pub mod posix08 {} pub mod posix08 {}
@ -714,7 +714,7 @@ pub mod types {
pub sll_hatype: c_ushort, pub sll_hatype: c_ushort,
pub sll_pkttype: c_uchar, pub sll_pkttype: c_uchar,
pub sll_halen: c_uchar, pub sll_halen: c_uchar,
pub sll_addr: [c_uchar, ..8] pub sll_addr: [c_uchar; 8]
} }
} }
@ -788,7 +788,7 @@ pub mod types {
pub st_mtime_nsec: c_long, pub st_mtime_nsec: c_long,
pub st_ctime: time_t, pub st_ctime: time_t,
pub st_ctime_nsec: c_long, pub st_ctime_nsec: c_long,
pub __unused: [c_long, ..3], pub __unused: [c_long; 3],
} }
#[repr(C)] #[repr(C)]
@ -799,7 +799,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __size: [u64, ..7] pub __size: [u64; 7]
} }
} }
pub mod posix08 { pub mod posix08 {
@ -815,7 +815,7 @@ pub mod types {
pub sll_hatype: c_ushort, pub sll_hatype: c_ushort,
pub sll_pkttype: c_uchar, pub sll_pkttype: c_uchar,
pub sll_halen: c_uchar, pub sll_halen: c_uchar,
pub sll_addr: [c_uchar, ..8] pub sll_addr: [c_uchar; 8]
} }
} }
@ -878,15 +878,15 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr { #[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8, pub sa_len: u8,
pub sa_family: sa_family_t, pub sa_family: sa_family_t,
pub sa_data: [u8, ..14], pub sa_data: [u8; 14],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage { #[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8, pub ss_len: u8,
pub ss_family: sa_family_t, pub ss_family: sa_family_t,
pub __ss_pad1: [u8, ..6], pub __ss_pad1: [u8; 6],
pub __ss_align: i64, pub __ss_align: i64,
pub __ss_pad2: [u8, ..112], pub __ss_pad2: [u8; 112],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in { #[deriving(Copy)] pub struct sockaddr_in {
@ -894,7 +894,7 @@ pub mod types {
pub sin_family: sa_family_t, pub sin_family: sa_family_t,
pub sin_port: in_port_t, pub sin_port: in_port_t,
pub sin_addr: in_addr, pub sin_addr: in_addr,
pub sin_zero: [u8, ..8], pub sin_zero: [u8; 8],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in_addr { #[deriving(Copy)] pub struct in_addr {
@ -911,7 +911,7 @@ pub mod types {
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in6_addr { #[deriving(Copy)] pub struct in6_addr {
pub s6_addr: [u16, ..8] pub s6_addr: [u16; 8]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ip_mreq { #[deriving(Copy)] pub struct ip_mreq {
@ -938,7 +938,7 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr_un { #[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8, pub sun_len: u8,
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
pub sun_path: [c_char, ..104] pub sun_path: [c_char; 104]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ifaddrs { #[deriving(Copy)] pub struct ifaddrs {
@ -1030,7 +1030,7 @@ pub mod types {
pub st_lspare: int32_t, pub st_lspare: int32_t,
pub st_birthtime: time_t, pub st_birthtime: time_t,
pub st_birthtime_nsec: c_long, pub st_birthtime_nsec: c_long,
pub __unused: [uint8_t, ..2], pub __unused: [uint8_t; 2],
} }
#[repr(C)] #[repr(C)]
@ -1106,15 +1106,15 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr { #[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8, pub sa_len: u8,
pub sa_family: sa_family_t, pub sa_family: sa_family_t,
pub sa_data: [u8, ..14], pub sa_data: [u8; 14],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage { #[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8, pub ss_len: u8,
pub ss_family: sa_family_t, pub ss_family: sa_family_t,
pub __ss_pad1: [u8, ..6], pub __ss_pad1: [u8; 6],
pub __ss_align: i64, pub __ss_align: i64,
pub __ss_pad2: [u8, ..112], pub __ss_pad2: [u8; 112],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in { #[deriving(Copy)] pub struct sockaddr_in {
@ -1122,7 +1122,7 @@ pub mod types {
pub sin_family: sa_family_t, pub sin_family: sa_family_t,
pub sin_port: in_port_t, pub sin_port: in_port_t,
pub sin_addr: in_addr, pub sin_addr: in_addr,
pub sin_zero: [u8, ..8], pub sin_zero: [u8; 8],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in_addr { #[deriving(Copy)] pub struct in_addr {
@ -1139,7 +1139,7 @@ pub mod types {
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in6_addr { #[deriving(Copy)] pub struct in6_addr {
pub s6_addr: [u16, ..8] pub s6_addr: [u16; 8]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ip_mreq { #[deriving(Copy)] pub struct ip_mreq {
@ -1166,7 +1166,7 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr_un { #[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8, pub sun_len: u8,
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
pub sun_path: [c_char, ..104] pub sun_path: [c_char; 104]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ifaddrs { #[deriving(Copy)] pub struct ifaddrs {
@ -1337,21 +1337,21 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr { #[deriving(Copy)] pub struct sockaddr {
pub sa_family: sa_family_t, pub sa_family: sa_family_t,
pub sa_data: [u8, ..14], pub sa_data: [u8; 14],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage { #[deriving(Copy)] pub struct sockaddr_storage {
pub ss_family: sa_family_t, pub ss_family: sa_family_t,
pub __ss_pad1: [u8, ..6], pub __ss_pad1: [u8; 6],
pub __ss_align: i64, pub __ss_align: i64,
pub __ss_pad2: [u8, ..112], pub __ss_pad2: [u8; 112],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in { #[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t, pub sin_family: sa_family_t,
pub sin_port: in_port_t, pub sin_port: in_port_t,
pub sin_addr: in_addr, pub sin_addr: in_addr,
pub sin_zero: [u8, ..8], pub sin_zero: [u8; 8],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in_addr { #[deriving(Copy)] pub struct in_addr {
@ -1367,7 +1367,7 @@ pub mod types {
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in6_addr { #[deriving(Copy)] pub struct in6_addr {
pub s6_addr: [u16, ..8] pub s6_addr: [u16; 8]
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct ip_mreq { #[deriving(Copy)] pub struct ip_mreq {
@ -1393,7 +1393,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_un { #[deriving(Copy)] pub struct sockaddr_un {
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
pub sun_path: [c_char, ..108] pub sun_path: [c_char; 108]
} }
} }
} }
@ -1626,13 +1626,13 @@ pub mod types {
pub Data1: DWORD, pub Data1: DWORD,
pub Data2: WORD, pub Data2: WORD,
pub Data3: WORD, pub Data3: WORD,
pub Data4: [BYTE, ..8], pub Data4: [BYTE; 8],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct WSAPROTOCOLCHAIN { #[deriving(Copy)] pub struct WSAPROTOCOLCHAIN {
pub ChainLen: c_int, pub ChainLen: c_int,
pub ChainEntries: [DWORD, ..MAX_PROTOCOL_CHAIN as uint], pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as uint],
} }
pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
@ -1658,7 +1658,7 @@ pub mod types {
pub iSecurityScheme: c_int, pub iSecurityScheme: c_int,
pub dwMessageSize: DWORD, pub dwMessageSize: DWORD,
pub dwProviderReserved: DWORD, pub dwProviderReserved: DWORD,
pub szProtocol: [u8, ..(WSAPROTOCOL_LEN as uint) + 1u], pub szProtocol: [u8; (WSAPROTOCOL_LEN as uint) + 1u],
} }
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
@ -1675,8 +1675,8 @@ pub mod types {
pub nFileSizeLow: DWORD, pub nFileSizeLow: DWORD,
pub dwReserved0: DWORD, pub dwReserved0: DWORD,
pub dwReserved1: DWORD, pub dwReserved1: DWORD,
pub cFileName: [wchar_t, ..260], // #define MAX_PATH 260 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
pub cAlternateFileName: [wchar_t, ..14], pub cAlternateFileName: [wchar_t; 14],
} }
pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
@ -1741,16 +1741,16 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr { #[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8, pub sa_len: u8,
pub sa_family: sa_family_t, pub sa_family: sa_family_t,
pub sa_data: [u8, ..14], pub sa_data: [u8; 14],
} }
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage { #[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8, pub ss_len: u8,
pub ss_family: sa_family_t, pub ss_family: sa_family_t,
pub __ss_pad1: [u8, ..6], pub __ss_pad1: [u8; 6],
pub __ss_align: i64, pub __ss_align: i64,
pub __ss_pad2: [u8, ..112], pub __ss_pad2: [u8; 112],
} }
#[repr(C)] #[repr(C)]
@ -1759,7 +1759,7 @@ pub mod types {
pub sin_family: sa_family_t, pub sin_family: sa_family_t,
pub sin_port: in_port_t, pub sin_port: in_port_t,
pub sin_addr: in_addr, pub sin_addr: in_addr,
pub sin_zero: [u8, ..8], pub sin_zero: [u8; 8],
} }
#[repr(C)] #[repr(C)]
@ -1779,7 +1779,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct in6_addr { #[deriving(Copy)] pub struct in6_addr {
pub s6_addr: [u16, ..8] pub s6_addr: [u16; 8]
} }
#[repr(C)] #[repr(C)]
@ -1810,7 +1810,7 @@ pub mod types {
#[deriving(Copy)] pub struct sockaddr_un { #[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8, pub sun_len: u8,
pub sun_family: sa_family_t, pub sun_family: sa_family_t,
pub sun_path: [c_char, ..104] pub sun_path: [c_char; 104]
} }
#[repr(C)] #[repr(C)]
@ -1899,7 +1899,7 @@ pub mod types {
pub st_flags: uint32_t, pub st_flags: uint32_t,
pub st_gen: uint32_t, pub st_gen: uint32_t,
pub st_lspare: int32_t, pub st_lspare: int32_t,
pub st_qspare: [int64_t, ..2], pub st_qspare: [int64_t; 2],
} }
#[repr(C)] #[repr(C)]
@ -1911,7 +1911,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __sig: c_long, pub __sig: c_long,
pub __opaque: [c_char, ..36] pub __opaque: [c_char; 36]
} }
} }
pub mod posix08 { pub mod posix08 {
@ -2003,7 +2003,7 @@ pub mod types {
pub st_flags: uint32_t, pub st_flags: uint32_t,
pub st_gen: uint32_t, pub st_gen: uint32_t,
pub st_lspare: int32_t, pub st_lspare: int32_t,
pub st_qspare: [int64_t, ..2], pub st_qspare: [int64_t; 2],
} }
#[repr(C)] #[repr(C)]
@ -2015,7 +2015,7 @@ pub mod types {
#[repr(C)] #[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t { #[deriving(Copy)] pub struct pthread_attr_t {
pub __sig: c_long, pub __sig: c_long,
pub __opaque: [c_char, ..56] pub __opaque: [c_char; 56]
} }
} }
pub mod posix08 { pub mod posix08 {

View File

@ -18,7 +18,7 @@ pub struct LogDirective {
pub level: u32, pub level: u32,
} }
pub static LOG_LEVEL_NAMES: [&'static str, ..4] = ["ERROR", "WARN", "INFO", pub static LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
"DEBUG"]; "DEBUG"];
/// Parse an individual log level that is either a number or a symbolic log level /// Parse an individual log level that is either a number or a symbolic log level

View File

@ -31,14 +31,14 @@ const CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of
#[deriving(Copy)] #[deriving(Copy)]
pub struct ChaChaRng { pub struct ChaChaRng {
buffer: [u32, ..STATE_WORDS], // Internal buffer of output buffer: [u32; STATE_WORDS], // Internal buffer of output
state: [u32, ..STATE_WORDS], // Initial state state: [u32; STATE_WORDS], // Initial state
index: uint, // Index into state index: uint, // Index into state
} }
static EMPTY: ChaChaRng = ChaChaRng { static EMPTY: ChaChaRng = ChaChaRng {
buffer: [0, ..STATE_WORDS], buffer: [0; STATE_WORDS],
state: [0, ..STATE_WORDS], state: [0; STATE_WORDS],
index: STATE_WORDS index: STATE_WORDS
}; };
@ -68,7 +68,7 @@ macro_rules! double_round{
} }
#[inline] #[inline]
fn core(output: &mut [u32, ..STATE_WORDS], input: &[u32, ..STATE_WORDS]) { fn core(output: &mut [u32; STATE_WORDS], input: &[u32; STATE_WORDS]) {
*output = *input; *output = *input;
for _ in range(0, CHACHA_ROUNDS / 2) { for _ in range(0, CHACHA_ROUNDS / 2) {
@ -86,7 +86,7 @@ impl ChaChaRng {
/// fixed key of 8 zero words. /// fixed key of 8 zero words.
pub fn new_unseeded() -> ChaChaRng { pub fn new_unseeded() -> ChaChaRng {
let mut rng = EMPTY; let mut rng = EMPTY;
rng.init(&[0, ..KEY_WORDS]); rng.init(&[0; KEY_WORDS]);
rng rng
} }
@ -124,7 +124,7 @@ impl ChaChaRng {
/// ``` /// ```
/// [1]: Daniel J. Bernstein. [*Extending the Salsa20 /// [1]: Daniel J. Bernstein. [*Extending the Salsa20
/// nonce.*](http://cr.yp.to/papers.html#xsalsa) /// nonce.*](http://cr.yp.to/papers.html#xsalsa)
fn init(&mut self, key: &[u32, ..KEY_WORDS]) { fn init(&mut self, key: &[u32; KEY_WORDS]) {
self.state[0] = 0x61707865; self.state[0] = 0x61707865;
self.state[1] = 0x3320646E; self.state[1] = 0x3320646E;
self.state[2] = 0x79622D32; self.state[2] = 0x79622D32;
@ -174,7 +174,7 @@ impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
fn reseed(&mut self, seed: &'a [u32]) { fn reseed(&mut self, seed: &'a [u32]) {
// reset state // reset state
self.init(&[0u32, ..KEY_WORDS]); self.init(&[0u32; KEY_WORDS]);
// set key in place // set key in place
let key = self.state.slice_mut(4, 4+KEY_WORDS); let key = self.state.slice_mut(4, 4+KEY_WORDS);
for (k, s) in key.iter_mut().zip(seed.iter()) { for (k, s) in key.iter_mut().zip(seed.iter()) {
@ -195,7 +195,7 @@ impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
impl Rand for ChaChaRng { impl Rand for ChaChaRng {
fn rand<R: Rng>(other: &mut R) -> ChaChaRng { fn rand<R: Rng>(other: &mut R) -> ChaChaRng {
let mut key : [u32, ..KEY_WORDS] = [0, ..KEY_WORDS]; let mut key : [u32; KEY_WORDS] = [0; KEY_WORDS];
for word in key.iter_mut() { for word in key.iter_mut() {
*word = other.gen(); *word = other.gen();
} }
@ -246,7 +246,7 @@ mod test {
fn test_rng_true_values() { fn test_rng_true_values() {
// Test vectors 1 and 2 from // Test vectors 1 and 2 from
// http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 // http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
let seed : &[_] = &[0u32, ..8]; let seed : &[_] = &[0u32; 8];
let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
let v = Vec::from_fn(16, |_| ra.next_u32()); let v = Vec::from_fn(16, |_| ra.next_u32());

View File

@ -11,9 +11,9 @@
// Tables for distributions which are sampled using the ziggurat // Tables for distributions which are sampled using the ziggurat
// algorithm. Autogenerated by `ziggurat_tables.py`. // algorithm. Autogenerated by `ziggurat_tables.py`.
pub type ZigTable = &'static [f64, .. 257]; pub type ZigTable = &'static [f64; 257];
pub static ZIG_NORM_R: f64 = 3.654152885361008796; pub static ZIG_NORM_R: f64 = 3.654152885361008796;
pub static ZIG_NORM_X: [f64, .. 257] = pub static ZIG_NORM_X: [f64; 257] =
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074, [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434, 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548, 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548,
@ -79,7 +79,7 @@ pub static ZIG_NORM_X: [f64, .. 257] =
0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746, 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806, 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
0.000000000000000000]; 0.000000000000000000];
pub static ZIG_NORM_F: [f64, .. 257] = pub static ZIG_NORM_F: [f64; 257] =
[0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872, [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100, 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839, 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839,
@ -146,7 +146,7 @@ pub static ZIG_NORM_F: [f64, .. 257] =
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328, 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
1.000000000000000000]; 1.000000000000000000];
pub static ZIG_EXP_R: f64 = 7.697117470131050077; pub static ZIG_EXP_R: f64 = 7.697117470131050077;
pub static ZIG_EXP_X: [f64, .. 257] = pub static ZIG_EXP_X: [f64; 257] =
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696, [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488, 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530, 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530,
@ -212,7 +212,7 @@ pub static ZIG_EXP_X: [f64, .. 257] =
0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842, 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570, 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
0.000000000000000000]; 0.000000000000000000];
pub static ZIG_EXP_F: [f64, .. 257] = pub static ZIG_EXP_F: [f64; 257] =
[0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573, [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797, 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991, 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991,

View File

@ -32,8 +32,8 @@ const RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint);
#[deriving(Copy)] #[deriving(Copy)]
pub struct IsaacRng { pub struct IsaacRng {
cnt: u32, cnt: u32,
rsl: [u32, ..RAND_SIZE_UINT], rsl: [u32; RAND_SIZE_UINT],
mem: [u32, ..RAND_SIZE_UINT], mem: [u32; RAND_SIZE_UINT],
a: u32, a: u32,
b: u32, b: u32,
c: u32 c: u32
@ -41,8 +41,8 @@ pub struct IsaacRng {
static EMPTY: IsaacRng = IsaacRng { static EMPTY: IsaacRng = IsaacRng {
cnt: 0, cnt: 0,
rsl: [0, ..RAND_SIZE_UINT], rsl: [0; RAND_SIZE_UINT],
mem: [0, ..RAND_SIZE_UINT], mem: [0; RAND_SIZE_UINT],
a: 0, b: 0, c: 0 a: 0, b: 0, c: 0
}; };
@ -267,8 +267,8 @@ const RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN;
#[deriving(Copy)] #[deriving(Copy)]
pub struct Isaac64Rng { pub struct Isaac64Rng {
cnt: uint, cnt: uint,
rsl: [u64, .. RAND_SIZE_64], rsl: [u64; RAND_SIZE_64],
mem: [u64, .. RAND_SIZE_64], mem: [u64; RAND_SIZE_64],
a: u64, a: u64,
b: u64, b: u64,
c: u64, c: u64,
@ -276,8 +276,8 @@ pub struct Isaac64Rng {
static EMPTY_64: Isaac64Rng = Isaac64Rng { static EMPTY_64: Isaac64Rng = Isaac64Rng {
cnt: 0, cnt: 0,
rsl: [0, .. RAND_SIZE_64], rsl: [0; RAND_SIZE_64],
mem: [0, .. RAND_SIZE_64], mem: [0; RAND_SIZE_64],
a: 0, b: 0, c: 0, a: 0, b: 0, c: 0,
}; };
@ -358,7 +358,7 @@ impl Isaac64Rng {
let mut a = self.a; let mut a = self.a;
let mut b = self.b + self.c; let mut b = self.b + self.c;
const MIDPOINT: uint = RAND_SIZE_64 / 2; const MIDPOINT: uint = RAND_SIZE_64 / 2;
const MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; const MP_VEC: [(uint, uint); 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
macro_rules! ind ( macro_rules! ind (
($x:expr) => { ($x:expr) => {
*self.mem.get_unchecked(($x as uint >> 3) & (RAND_SIZE_64 - 1)) *self.mem.get_unchecked(($x as uint >> 3) & (RAND_SIZE_64 - 1))

View File

@ -140,7 +140,7 @@ pub trait Rng {
/// ```rust /// ```rust
/// use std::rand::{thread_rng, Rng}; /// use std::rand::{thread_rng, Rng};
/// ///
/// let mut v = [0u8, .. 13579]; /// let mut v = [0u8; 13579];
/// thread_rng().fill_bytes(&mut v); /// thread_rng().fill_bytes(&mut v);
/// println!("{}", v.as_slice()); /// println!("{}", v.as_slice());
/// ``` /// ```
@ -429,9 +429,9 @@ impl Rng for XorShiftRng {
} }
} }
impl SeedableRng<[u32, .. 4]> for XorShiftRng { impl SeedableRng<[u32; 4]> for XorShiftRng {
/// Reseed an XorShiftRng. This will panic if `seed` is entirely 0. /// Reseed an XorShiftRng. This will panic if `seed` is entirely 0.
fn reseed(&mut self, seed: [u32, .. 4]) { fn reseed(&mut self, seed: [u32; 4]) {
assert!(!seed.iter().all(|&x| x == 0), assert!(!seed.iter().all(|&x| x == 0),
"XorShiftRng.reseed called with an all zero seed."); "XorShiftRng.reseed called with an all zero seed.");
@ -442,7 +442,7 @@ impl SeedableRng<[u32, .. 4]> for XorShiftRng {
} }
/// Create a new XorShiftRng. This will panic if `seed` is entirely 0. /// Create a new XorShiftRng. This will panic if `seed` is entirely 0.
fn from_seed(seed: [u32, .. 4]) -> XorShiftRng { fn from_seed(seed: [u32; 4]) -> XorShiftRng {
assert!(!seed.iter().all(|&x| x == 0), assert!(!seed.iter().all(|&x| x == 0),
"XorShiftRng::from_seed called with an all zero seed."); "XorShiftRng::from_seed called with an all zero seed.");

View File

@ -200,7 +200,7 @@ pub mod reader {
// the most significant bit is set, the second most significant bit is set etc. we can // the most significant bit is set, the second most significant bit is set etc. we can
// replace up to three "and+branch" with a single table lookup which gives us a measured // replace up to three "and+branch" with a single table lookup which gives us a measured
// speedup of around 2x on x86_64. // speedup of around 2x on x86_64.
static SHIFT_MASK_TABLE: [(uint, u32), ..16] = [ static SHIFT_MASK_TABLE: [(uint, u32); 16] = [
(0, 0x0), (0, 0x0fffffff), (0, 0x0), (0, 0x0fffffff),
(8, 0x1fffff), (8, 0x1fffff), (8, 0x1fffff), (8, 0x1fffff),
(16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff),

View File

@ -169,7 +169,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
chars: CharReader::new(input), chars: CharReader::new(input),
}.run(start, end); }.run(start, end);
type Captures = [Option<uint>, ..$num_cap_locs]; type Captures = [Option<uint>; $num_cap_locs];
struct Nfa<'t> { struct Nfa<'t> {
which: MatchKind, which: MatchKind,
@ -250,8 +250,8 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
struct Threads { struct Threads {
which: MatchKind, which: MatchKind,
queue: [Thread, ..$num_insts], queue: [Thread; $num_insts],
sparse: [uint, ..$num_insts], sparse: [uint; $num_insts],
size: uint, size: uint,
} }

View File

@ -1085,7 +1085,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// Note: We declare here that the borrow // Note: We declare here that the borrow
// occurs upon entering the `[...]` // occurs upon entering the `[...]`
// pattern. This implies that something like // pattern. This implies that something like
// `[a, ..b]` where `a` is a move is illegal, // `[a; b]` where `a` is a move is illegal,
// because the borrow is already in effect. // because the borrow is already in effect.
// In fact such a move would be safe-ish, but // In fact such a move would be safe-ish, but
// it effectively *requires* that we use the // it effectively *requires* that we use the

View File

@ -42,12 +42,12 @@ pub struct Graph<N,E> {
} }
pub struct Node<N> { pub struct Node<N> {
first_edge: [EdgeIndex, ..2], // see module comment first_edge: [EdgeIndex; 2], // see module comment
pub data: N, pub data: N,
} }
pub struct Edge<E> { pub struct Edge<E> {
next_edge: [EdgeIndex, ..2], // see module comment next_edge: [EdgeIndex; 2], // see module comment
source: NodeIndex, source: NodeIndex,
target: NodeIndex, target: NodeIndex,
pub data: E, pub data: E,

View File

@ -188,7 +188,7 @@ pub enum ParamSpace {
} }
impl ParamSpace { impl ParamSpace {
pub fn all() -> [ParamSpace, ..3] { pub fn all() -> [ParamSpace; 3] {
[TypeSpace, SelfSpace, FnSpace] [TypeSpace, SelfSpace, FnSpace]
} }

View File

@ -111,7 +111,7 @@ trait FixedBuffer {
/// A FixedBuffer of 64 bytes useful for implementing Sha256 which has a 64 byte blocksize. /// A FixedBuffer of 64 bytes useful for implementing Sha256 which has a 64 byte blocksize.
struct FixedBuffer64 { struct FixedBuffer64 {
buffer: [u8, ..64], buffer: [u8; 64],
buffer_idx: uint, buffer_idx: uint,
} }
@ -119,7 +119,7 @@ impl FixedBuffer64 {
/// Create a new FixedBuffer64 /// Create a new FixedBuffer64
fn new() -> FixedBuffer64 { fn new() -> FixedBuffer64 {
return FixedBuffer64 { return FixedBuffer64 {
buffer: [0u8, ..64], buffer: [0u8; 64],
buffer_idx: 0 buffer_idx: 0
}; };
} }
@ -284,7 +284,7 @@ struct Engine256State {
} }
impl Engine256State { impl Engine256State {
fn new(h: &[u32, ..8]) -> Engine256State { fn new(h: &[u32; 8]) -> Engine256State {
return Engine256State { return Engine256State {
h0: h[0], h0: h[0],
h1: h[1], h1: h[1],
@ -297,7 +297,7 @@ impl Engine256State {
}; };
} }
fn reset(&mut self, h: &[u32, ..8]) { fn reset(&mut self, h: &[u32; 8]) {
self.h0 = h[0]; self.h0 = h[0];
self.h1 = h[1]; self.h1 = h[1];
self.h2 = h[2]; self.h2 = h[2];
@ -342,7 +342,7 @@ impl Engine256State {
let mut g = self.h6; let mut g = self.h6;
let mut h = self.h7; let mut h = self.h7;
let mut w = [0u32, ..64]; let mut w = [0u32; 64];
// Sha-512 and Sha-256 use basically the same calculations which are implemented // Sha-512 and Sha-256 use basically the same calculations which are implemented
// by these macros. Inlining the calculations seems to result in better generated code. // by these macros. Inlining the calculations seems to result in better generated code.
@ -408,7 +408,7 @@ impl Engine256State {
} }
} }
static K32: [u32, ..64] = [ static K32: [u32; 64] = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
@ -437,7 +437,7 @@ struct Engine256 {
} }
impl Engine256 { impl Engine256 {
fn new(h: &[u32, ..8]) -> Engine256 { fn new(h: &[u32; 8]) -> Engine256 {
return Engine256 { return Engine256 {
length_bits: 0, length_bits: 0,
buffer: FixedBuffer64::new(), buffer: FixedBuffer64::new(),
@ -446,7 +446,7 @@ impl Engine256 {
} }
} }
fn reset(&mut self, h: &[u32, ..8]) { fn reset(&mut self, h: &[u32; 8]) {
self.length_bits = 0; self.length_bits = 0;
self.buffer.reset(); self.buffer.reset();
self.state.reset(h); self.state.reset(h);
@ -515,7 +515,7 @@ impl Digest for Sha256 {
fn output_bits(&self) -> uint { 256 } fn output_bits(&self) -> uint { 256 }
} }
static H256: [u32, ..8] = [ static H256: [u32; 8] = [
0x6a09e667, 0x6a09e667,
0xbb67ae85, 0xbb67ae85,
0x3c6ef372, 0x3c6ef372,
@ -658,7 +658,7 @@ mod bench {
#[bench] #[bench]
pub fn sha256_10(b: &mut Bencher) { pub fn sha256_10(b: &mut Bencher) {
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);
}); });
@ -668,7 +668,7 @@ mod bench {
#[bench] #[bench]
pub fn sha256_1k(b: &mut Bencher) { pub fn sha256_1k(b: &mut Bencher) {
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);
}); });
@ -678,7 +678,7 @@ mod bench {
#[bench] #[bench]
pub fn sha256_64k(b: &mut Bencher) { pub fn sha256_64k(b: &mut Bencher) {
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);
}); });

View File

@ -1152,7 +1152,7 @@
//! the following: //! the following:
//! //!
//! ```rust //! ```rust
//! fn foo(a: [D, ..10], i: uint) -> D { //! fn foo(a: [D; 10], i: uint) -> D {
//! a[i] //! a[i]
//! } //! }
//! ``` //! ```
@ -1168,7 +1168,7 @@
//! would arise is the following: //! would arise is the following:
//! //!
//! ```rust //! ```rust
//! fn foo(a: [D, ..10], b: [D, ..10], i: uint, t: bool) -> D { //! fn foo(a: [D; 10], b: [D; 10], i: uint, t: bool) -> D {
//! if t { //! if t {
//! a[i] //! a[i]
//! } else { //! } else {
@ -1182,7 +1182,7 @@
//! ``` //! ```
//! //!
//! There are a number of ways that the trans backend could choose to //! There are a number of ways that the trans backend could choose to
//! compile this (e.g. a `[bool, ..10]` array for each such moved array; //! compile this (e.g. a `[bool; 10]` array for each such moved array;
//! or an `Option<uint>` for each moved array). From the viewpoint of the //! or an `Option<uint>` for each moved array). From the viewpoint of the
//! borrow-checker, the important thing is to record what kind of fragment //! borrow-checker, the important thing is to record what kind of fragment
//! is implied by the relevant moves. //! is implied by the relevant moves.

View File

@ -547,7 +547,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Small vector optimization. This should catch 100% of the cases that // Small vector optimization. This should catch 100% of the cases that
// we care about. // we care about.
if ixs.len() < 16 { if ixs.len() < 16 {
let mut small_vec = [ C_i32(self.ccx, 0), ..16 ]; let mut small_vec = [ C_i32(self.ccx, 0); 16 ];
for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) { for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
*small_vec_e = C_i32(self.ccx, ix as i32); *small_vec_e = C_i32(self.ccx, ix as i32);
} }

View File

@ -63,7 +63,7 @@ pub const EXIT_MAX: uint = 2;
pub enum CleanupScopeKind<'blk, 'tcx: 'blk> { pub enum CleanupScopeKind<'blk, 'tcx: 'blk> {
CustomScopeKind, CustomScopeKind,
AstScopeKind(ast::NodeId), AstScopeKind(ast::NodeId),
LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>, ..EXIT_MAX]) LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>; EXIT_MAX])
} }
impl<'blk, 'tcx: 'blk> fmt::Show for CleanupScopeKind<'blk, 'tcx> { impl<'blk, 'tcx: 'blk> fmt::Show for CleanupScopeKind<'blk, 'tcx> {
@ -146,7 +146,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
fn push_loop_cleanup_scope(&self, fn push_loop_cleanup_scope(&self,
id: ast::NodeId, id: ast::NodeId,
exits: [Block<'blk, 'tcx>, ..EXIT_MAX]) { exits: [Block<'blk, 'tcx>; EXIT_MAX]) {
debug!("push_loop_cleanup_scope({})", debug!("push_loop_cleanup_scope({})",
self.ccx.tcx().map.node_to_string(id)); self.ccx.tcx().map.node_to_string(id));
assert_eq!(Some(id), self.top_ast_scope()); assert_eq!(Some(id), self.top_ast_scope());
@ -1058,7 +1058,7 @@ pub trait CleanupMethods<'blk, 'tcx> {
fn push_ast_cleanup_scope(&self, id: NodeInfo); fn push_ast_cleanup_scope(&self, id: NodeInfo);
fn push_loop_cleanup_scope(&self, fn push_loop_cleanup_scope(&self,
id: ast::NodeId, id: ast::NodeId,
exits: [Block<'blk, 'tcx>, ..EXIT_MAX]); exits: [Block<'blk, 'tcx>; EXIT_MAX]);
fn push_custom_cleanup_scope(&self) -> CustomScopeIndex; fn push_custom_cleanup_scope(&self) -> CustomScopeIndex;
fn push_custom_cleanup_scope_with_debug_loc(&self, fn push_custom_cleanup_scope_with_debug_loc(&self,
debug_loc: NodeInfo) debug_loc: NodeInfo)

View File

@ -53,12 +53,12 @@
//! The first thing that the probe phase does is to create a series of //! The first thing that the probe phase does is to create a series of
//! *steps*. This is done by progressively dereferencing the receiver type //! *steps*. This is done by progressively dereferencing the receiver type
//! until it cannot be deref'd anymore, as well as applying an optional //! until it cannot be deref'd anymore, as well as applying an optional
//! "unsize" step. So if the receiver has type `Rc<Box<[T, ..3]>>`, this //! "unsize" step. So if the receiver has type `Rc<Box<[T; 3]>>`, this
//! might yield: //! might yield:
//! //!
//! Rc<Box<[T, ..3]>> //! Rc<Box<[T; 3]>>
//! Box<[T, ..3]> //! Box<[T; 3]>
//! [T, ..3] //! [T; 3]
//! [T] //! [T]
//! //!
//! ### Candidate assembly //! ### Candidate assembly
@ -96,13 +96,13 @@
//! method. //! method.
//! //!
//! So, let's continue our example. Imagine that we were calling a method //! So, let's continue our example. Imagine that we were calling a method
//! `foo` with the receiver `Rc<Box<[T, ..3]>>` and there is a trait `Foo` //! `foo` with the receiver `Rc<Box<[T; 3]>>` and there is a trait `Foo`
//! that defines it with `&self` for the type `Rc<U>` as well as a method //! that defines it with `&self` for the type `Rc<U>` as well as a method
//! on the type `Box` that defines `Foo` but with `&mut self`. Then we //! on the type `Box` that defines `Foo` but with `&mut self`. Then we
//! might have two candidates: //! might have two candidates:
//! //!
//! &Rc<Box<[T, ..3]>> from the impl of `Foo` for `Rc<U>` where `U=Box<T, ..3]> //! &Rc<Box<[T; 3]>> from the impl of `Foo` for `Rc<U>` where `U=Box<T; 3]>
//! &mut Box<[T, ..3]>> from the inherent impl on `Box<U>` where `U=[T, ..3]` //! &mut Box<[T; 3]>> from the inherent impl on `Box<U>` where `U=[T; 3]`
//! //!
//! ### Candidate search //! ### Candidate search
//! //!
@ -112,9 +112,9 @@
//! that makes any of the candidates match. We pick the first step where //! that makes any of the candidates match. We pick the first step where
//! we find a match. //! we find a match.
//! //!
//! In the case of our example, the first step is `Rc<Box<[T, ..3]>>`, //! In the case of our example, the first step is `Rc<Box<[T; 3]>>`,
//! which does not itself match any candidate. But when we autoref it, we //! which does not itself match any candidate. But when we autoref it, we
//! get the type `&Rc<Box<[T, ..3]>>` which does match. We would then //! get the type `&Rc<Box<[T; 3]>>` which does match. We would then
//! recursively consider all where-clauses that appear on the impl: if //! recursively consider all where-clauses that appear on the impl: if
//! those match (or we cannot rule out that they do), then this is the //! those match (or we cannot rule out that they do), then this is the
//! method we would pick. Otherwise, we would continue down the series of //! method we would pick. Otherwise, we would continue down the series of

View File

@ -4544,7 +4544,7 @@ impl<'tcx> Expectation<'tcx> {
/// In this case, the expected type for the `&[1, 2, 3]` expression is /// In this case, the expected type for the `&[1, 2, 3]` expression is
/// `&[int]`. If however we were to say that `[1, 2, 3]` has the /// `&[int]`. If however we were to say that `[1, 2, 3]` has the
/// expectation `ExpectHasType([int])`, that would be too strong -- /// expectation `ExpectHasType([int])`, that would be too strong --
/// `[1, 2, 3]` does not have the type `[int]` but rather `[int, ..3]`. /// `[1, 2, 3]` does not have the type `[int]` but rather `[int; 3]`.
/// It is only the `&[1, 2, 3]` expression as a whole that can be coerced /// It is only the `&[1, 2, 3]` expression as a whole that can be coerced
/// to the type `&[int]`. Therefore, we propagate this more limited hint, /// to the type `&[int]`. Therefore, we propagate this more limited hint,
/// which still is useful, because it informs integer literals and the like. /// which still is useful, because it informs integer literals and the like.

View File

@ -407,9 +407,9 @@ struct ConstraintContext<'a, 'tcx: 'a> {
// are indexed by the `ParamKind` (type, lifetime, self). Note // are indexed by the `ParamKind` (type, lifetime, self). Note
// that there are no marker types for self, so the entries for // that there are no marker types for self, so the entries for
// self are always None. // self are always None.
invariant_lang_items: [Option<ast::DefId>, ..2], invariant_lang_items: [Option<ast::DefId>; 2],
covariant_lang_items: [Option<ast::DefId>, ..2], covariant_lang_items: [Option<ast::DefId>; 2],
contravariant_lang_items: [Option<ast::DefId>, ..2], contravariant_lang_items: [Option<ast::DefId>; 2],
unsafe_lang_item: Option<ast::DefId>, unsafe_lang_item: Option<ast::DefId>,
// These are pointers to common `ConstantTerm` instances // These are pointers to common `ConstantTerm` instances
@ -432,9 +432,9 @@ struct Constraint<'a> {
fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>, fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
krate: &ast::Crate) krate: &ast::Crate)
-> ConstraintContext<'a, 'tcx> { -> ConstraintContext<'a, 'tcx> {
let mut invariant_lang_items = [None, ..2]; let mut invariant_lang_items = [None; 2];
let mut covariant_lang_items = [None, ..2]; let mut covariant_lang_items = [None; 2];
let mut contravariant_lang_items = [None, ..2]; let mut contravariant_lang_items = [None; 2];
covariant_lang_items[TypeParam as uint] = covariant_lang_items[TypeParam as uint] =
terms_cx.tcx.lang_items.covariant_type(); terms_cx.tcx.lang_items.covariant_type();

View File

@ -80,7 +80,7 @@ struct hoedown_renderer {
blockhtml: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer, blockhtml: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*mut libc::c_void)>, *mut libc::c_void)>,
header: Option<headerfn>, header: Option<headerfn>,
other: [libc::size_t, ..28], other: [libc::size_t; 28],
} }
#[repr(C)] #[repr(C)]

View File

@ -314,7 +314,7 @@ mod tests {
#[test] #[test]
fn test_to_base64_crlf_line_break() { fn test_to_base64_crlf_line_break() {
assert!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD}) assert!(![0u8; 1000].to_base64(Config {line_length: None, ..STANDARD})
.contains("\r\n")); .contains("\r\n"));
assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), assert_eq!(b"foobar".to_base64(Config {line_length: Some(4),
..STANDARD}), ..STANDARD}),
@ -323,7 +323,7 @@ mod tests {
#[test] #[test]
fn test_to_base64_lf_line_break() { fn test_to_base64_lf_line_break() {
assert!(![0u8, ..1000].to_base64(Config {line_length: None, assert!(![0u8; 1000].to_base64(Config {line_length: None,
newline: Newline::LF, newline: Newline::LF,
..STANDARD}) ..STANDARD})
.as_slice() .as_slice()

View File

@ -392,14 +392,14 @@ 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];
let len = v.encode_utf8(&mut buf).unwrap(); let len = v.encode_utf8(&mut buf).unwrap();
escape_bytes(writer, buf[mut ..len]) escape_bytes(writer, buf[mut ..len])
} }
fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> { fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
const LEN: uint = 16; const LEN: uint = 16;
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));

View File

@ -234,7 +234,7 @@ pub fn escape_default<F>(c: u8, mut f: F) where
} }
} }
static ASCII_LOWERCASE_MAP: [u8, ..256] = [ static ASCII_LOWERCASE_MAP: [u8; 256] = [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@ -273,7 +273,7 @@ static ASCII_LOWERCASE_MAP: [u8, ..256] = [
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
]; ];
static ASCII_UPPERCASE_MAP: [u8, ..256] = [ static ASCII_UPPERCASE_MAP: [u8; 256] = [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,

View File

@ -454,7 +454,7 @@ unsafe fn with_c_str<T, F>(v: &[u8], checked: bool, f: F) -> T where
F: FnOnce(*const libc::c_char) -> T, F: FnOnce(*const libc::c_char) -> 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(&mut buf, v); slice::bytes::copy_memory(&mut buf, v);
buf[v.len()] = 0; buf[v.len()] = 0;

View File

@ -39,7 +39,7 @@ use kinds::{Send,Sync};
/// let file = File::open(&Path::new("message.txt")); /// let file = File::open(&Path::new("message.txt"));
/// 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(&mut 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)
@ -326,7 +326,7 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
/// stream.write("hello, world".as_bytes()); /// stream.write("hello, world".as_bytes());
/// stream.flush(); /// stream.flush();
/// ///
/// let mut buf = [0, ..100]; /// let mut buf = [0; 100];
/// match stream.read(&mut 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)

View File

@ -29,7 +29,7 @@ use vec::Vec;
/// # drop(tx); /// # drop(tx);
/// 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(&mut 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),
@ -171,7 +171,7 @@ mod test {
}).detach(); }).detach();
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(&mut [])); assert_eq!(Ok(0), reader.read(&mut []));

View File

@ -86,9 +86,9 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where
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!();
@ -127,9 +127,9 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where
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;
@ -164,7 +164,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
panic!("index out of bounds"); panic!("index out of bounds");
} }
let mut buf = [0u8, ..8]; let mut buf = [0u8; 8];
unsafe { unsafe {
let ptr = data.as_ptr().offset(start as int); let ptr = data.as_ptr().offset(start as int);
let out = buf.as_mut_ptr(); let out = buf.as_mut_ptr();

View File

@ -882,7 +882,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(&mut 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()
@ -922,7 +922,7 @@ mod test {
#[test] #[test]
fn file_test_io_non_positional_read() { fn file_test_io_non_positional_read() {
let message: &str = "ten-four"; let message: &str = "ten-four";
let mut read_mem = [0, .. 8]; let mut read_mem = [0; 8];
let tmpdir = tmpdir(); let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_positional.txt"); let filename = &tmpdir.join("file_rt_io_file_test_positional.txt");
{ {
@ -948,7 +948,7 @@ mod test {
#[test] #[test]
fn file_test_io_seek_and_tell_smoke_test() { fn file_test_io_seek_and_tell_smoke_test() {
let message = "ten-four"; let message = "ten-four";
let mut read_mem = [0, .. 4]; let mut read_mem = [0; 4];
let set_cursor = 4 as u64; let set_cursor = 4 as u64;
let mut tell_pos_pre_read; let mut tell_pos_pre_read;
let mut tell_pos_post_read; let mut tell_pos_post_read;
@ -978,7 +978,7 @@ mod test {
let overwrite_msg = "-the-bar!!"; let overwrite_msg = "-the-bar!!";
let final_msg = "foo-the-bar!!"; let final_msg = "foo-the-bar!!";
let seek_idx = 3i; let seek_idx = 3i;
let mut read_mem = [0, .. 13]; let mut read_mem = [0; 13];
let tmpdir = tmpdir(); let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt"); let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt");
{ {
@ -1003,7 +1003,7 @@ mod test {
let chunk_one: &str = "qwer"; let chunk_one: &str = "qwer";
let chunk_two: &str = "asdf"; let chunk_two: &str = "asdf";
let chunk_three: &str = "zxcv"; let chunk_three: &str = "zxcv";
let mut read_mem = [0, .. 4]; let mut read_mem = [0; 4];
let tmpdir = tmpdir(); let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt"); let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt");
{ {
@ -1105,7 +1105,7 @@ mod test {
check!(w.write(msg)); check!(w.write(msg));
} }
let files = check!(readdir(dir)); let files = check!(readdir(dir));
let mut mem = [0u8, .. 4]; let mut mem = [0u8; 4];
for f in files.iter() { for f in files.iter() {
{ {
let n = f.filestem_str(); let n = f.filestem_str();
@ -1137,7 +1137,7 @@ mod test {
check!(File::create(&dir2.join("14"))); check!(File::create(&dir2.join("14")));
let mut files = check!(walk_dir(dir)); let mut files = check!(walk_dir(dir));
let mut cur = [0u8, .. 2]; let mut cur = [0u8; 2];
for f in files { for f in files {
let stem = f.filestem_str().unwrap(); let stem = f.filestem_str().unwrap();
let root = stem.as_bytes()[0] - b'0'; let root = stem.as_bytes()[0] - b'0';
@ -1546,7 +1546,7 @@ mod test {
fn binary_file() { fn binary_file() {
use rand::{StdRng, Rng}; use rand::{StdRng, Rng};
let mut bytes = [0, ..1024]; let mut bytes = [0; 1024];
StdRng::new().ok().unwrap().fill_bytes(&mut bytes); StdRng::new().ok().unwrap().fill_bytes(&mut bytes);
let tmpdir = tmpdir(); let tmpdir = tmpdir();

View File

@ -252,7 +252,7 @@ impl<'a> Buffer for &'a [u8] {
/// # #![allow(unused_must_use)] /// # #![allow(unused_must_use)]
/// use std::io::BufWriter; /// use std::io::BufWriter;
/// ///
/// let mut buf = [0, ..4]; /// let mut buf = [0; 4];
/// { /// {
/// let mut w = BufWriter::new(&mut buf); /// let mut w = BufWriter::new(&mut buf);
/// w.write(&[0, 1, 2]); /// w.write(&[0, 1, 2]);
@ -427,7 +427,7 @@ mod test {
#[test] #[test]
fn test_buf_writer() { fn test_buf_writer() {
let mut buf = [0 as u8, ..9]; let mut buf = [0 as u8; 9];
{ {
let mut writer = BufWriter::new(&mut buf); let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
@ -448,7 +448,7 @@ mod test {
#[test] #[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(&mut buf); let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0)); assert_eq!(writer.tell(), Ok(0));
@ -477,7 +477,7 @@ 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(&mut buf); let mut writer = BufWriter::new(&mut buf);
writer.write(&[0]).unwrap(); writer.write(&[0]).unwrap();
@ -498,7 +498,7 @@ mod test {
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0]; let b: &[_] = &[0];
assert_eq!(buf, b); assert_eq!(buf, b);
let mut buf = [0, ..4]; let mut buf = [0; 4];
assert_eq!(reader.read(&mut 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];
@ -524,7 +524,7 @@ mod test {
assert_eq!(reader.len(), 7); assert_eq!(reader.len(), 7);
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(&mut buf), Ok(4)); assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.len(), 3); assert_eq!(reader.len(), 3);
let b: &[_] = &[1, 2, 3, 4]; let b: &[_] = &[1, 2, 3, 4];
@ -551,7 +551,7 @@ mod test {
assert_eq!(reader.tell(), Ok(1)); assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0]; let b: &[_] = &[0];
assert_eq!(buf, b); assert_eq!(buf, b);
let mut buf = [0, ..4]; let mut buf = [0; 4];
assert_eq!(reader.read(&mut 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];
@ -648,7 +648,7 @@ mod test {
#[test] #[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(), &mut 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, b); assert_eq!(buf, b);
@ -721,13 +721,13 @@ mod test {
#[bench] #[bench]
fn bench_mem_reader(b: &mut Bencher) { fn bench_mem_reader(b: &mut Bencher) {
b.iter(|| { b.iter(|| {
let buf = [5 as u8, ..100].to_vec(); let buf = [5 as u8; 100].to_vec();
{ {
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(&mut 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());
} }
} }
}); });
@ -736,27 +736,27 @@ mod test {
#[bench] #[bench]
fn bench_buf_writer(b: &mut Bencher) { fn bench_buf_writer(b: &mut Bencher) {
b.iter(|| { b.iter(|| {
let mut buf = [0 as u8, ..100]; let mut buf = [0 as u8; 100];
{ {
let mut wr = BufWriter::new(&mut 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());
}); });
} }
#[bench] #[bench]
fn bench_buf_reader(b: &mut Bencher) { fn bench_buf_reader(b: &mut Bencher) {
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(&mut buf).unwrap(); rdr.read(&mut buf).unwrap();
assert_eq!(buf, [5, .. 10]); assert_eq!(buf, [5; 10]);
} }
} }
}); });

View File

@ -1081,7 +1081,7 @@ pub trait Writer {
/// Write a single char, encoded as UTF-8. /// Write a single char, encoded as UTF-8.
#[inline] #[inline]
fn write_char(&mut self, c: char) -> IoResult<()> { fn write_char(&mut self, c: char) -> IoResult<()> {
let mut buf = [0u8, ..4]; let mut buf = [0u8; 4];
let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0); let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
self.write(buf[..n]) self.write(buf[..n])
} }
@ -1968,7 +1968,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 buf = &mut [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

@ -223,7 +223,7 @@ impl<'a> Parser<'a> {
} }
fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> { fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
let mut bs = [0u8, ..4]; let mut bs = [0u8; 4];
let mut i = 0; let mut i = 0;
while i < 4 { while i < 4 {
if i != 0 && self.read_given_char('.').is_none() { if i != 0 && self.read_given_char('.').is_none() {
@ -248,13 +248,13 @@ impl<'a> Parser<'a> {
fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> { fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr { fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
assert!(head.len() + tail.len() <= 8); assert!(head.len() + tail.len() <= 8);
let mut gs = [0u16, ..8]; let mut gs = [0u16; 8];
gs.clone_from_slice(head); gs.clone_from_slice(head);
gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail); gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7]) Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
} }
fn read_groups(p: &mut Parser, groups: &mut [u16, ..8], limit: uint) -> (uint, bool) { fn read_groups(p: &mut Parser, groups: &mut [u16; 8], limit: uint) -> (uint, bool) {
let mut i = 0; let mut i = 0;
while i < limit { while i < limit {
if i < limit - 1 { if i < limit - 1 {
@ -291,7 +291,7 @@ impl<'a> Parser<'a> {
(i, false) (i, false)
} }
let mut head = [0u16, ..8]; let mut head = [0u16; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8); let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 { if head_size == 8 {
@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
return None; return None;
} }
let mut tail = [0u16, ..8]; let mut tail = [0u16; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size); let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(head[..head_size], tail[..tail_size])) Some(ipv6_addr_from_head_tail(head[..head_size], tail[..tail_size]))
} }

View File

@ -672,7 +672,7 @@ mod tests {
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),
@ -701,7 +701,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(&mut [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),
} }
@ -716,7 +716,7 @@ mod tests {
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());
} }
} }
@ -735,7 +735,7 @@ mod tests {
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),

View File

@ -979,7 +979,7 @@ mod test {
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(&mut b), Ok(1)); assert_eq!(c.read(&mut b), Ok(1));
c.write(&[1]).unwrap(); c.write(&[1]).unwrap();
rx.recv(); rx.recv();
@ -1256,7 +1256,7 @@ mod test {
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),
@ -1280,7 +1280,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(&mut [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),
} }
@ -1295,7 +1295,7 @@ mod test {
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());
} }
} }
@ -1314,7 +1314,7 @@ mod test {
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),

View File

@ -45,7 +45,7 @@ use sys_common;
/// Err(e) => panic!("couldn't bind socket: {}", e), /// Err(e) => panic!("couldn't bind socket: {}", e),
/// }; /// };
/// ///
/// let mut buf = [0, ..10]; /// let mut buf = [0; 10];
/// match socket.recv_from(&mut 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
@ -599,7 +599,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

@ -129,7 +129,7 @@ mod test {
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(&mut buf).unwrap(); input.read(&mut buf).unwrap();
tx.send(()); tx.send(());
} }

View File

@ -130,7 +130,7 @@ mod darwin_fd_limit {
use os::last_os_error; use os::last_os_error;
// Fetch the kern.maxfilesperproc value // Fetch the kern.maxfilesperproc value
let mut mib: [libc::c_int, ..2] = [CTL_KERN, KERN_MAXFILESPERPROC]; let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
let mut maxfiles: libc::c_int = 0; let mut maxfiles: libc::c_int = 0;
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t; let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size, if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size,

View File

@ -103,7 +103,7 @@ impl Reader for ZeroReader {
impl Buffer for ZeroReader { impl Buffer for ZeroReader {
fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> { fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
static DATA: [u8, ..64] = [0, ..64]; static DATA: [u8; 64] = [0; 64];
Ok(DATA.as_slice()) Ok(DATA.as_slice())
} }
@ -235,7 +235,7 @@ impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
/// Copies all data from a `Reader` to a `Writer`. /// Copies all data from a `Reader` to a `Writer`.
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(&mut buf) { let len = match r.read(&mut buf) {
Ok(len) => len, Ok(len) => len,

View File

@ -104,7 +104,7 @@ fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F
// This is just for integral types, the largest of which is a u64. The // This is just for integral types, the largest of which is a u64. The
// smallest base that we can have is 2, so the most number of digits we're // smallest base that we can have is 2, so the most number of digits we're
// ever going to have is 64 // ever going to have is 64
let mut buf = [0u8, ..64]; let mut buf = [0u8; 64];
let mut cur = 0; let mut cur = 0;
// Loop at least once to make sure at least a `0` gets emitted. // Loop at least once to make sure at least a `0` gets emitted.

View File

@ -38,7 +38,7 @@ pub fn to_str_bytes<U, F>(n: $T, radix: uint, f: F) -> U where
use io::{Writer, Seek}; use io::{Writer, Seek};
// The radix can be as low as 2, so we need at least 64 characters for a // The radix can be as low as 2, so we need at least 64 characters for a
// 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(&mut 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();

View File

@ -669,7 +669,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] = &mut [1,..100]; let x : &mut[uint] = &mut [1; 100];
b.iter(|| { b.iter(|| {
rng.shuffle(x); rng.shuffle(x);
}) })

View File

@ -70,15 +70,15 @@ mod imp {
} }
fn getrandom_next_u32() -> u32 { fn getrandom_next_u32() -> u32 {
let mut buf: [u8, ..4] = [0u8, ..4]; let mut buf: [u8; 4] = [0u8; 4];
getrandom_fill_bytes(&mut buf); getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8, ..4], u32>(buf) } unsafe { mem::transmute::<[u8; 4], u32>(buf) }
} }
fn getrandom_next_u64() -> u64 { fn getrandom_next_u64() -> u64 {
let mut buf: [u8, ..8] = [0u8, ..8]; let mut buf: [u8; 8] = [0u8; 8];
getrandom_fill_bytes(&mut buf); getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8, ..8], u64>(buf) } unsafe { mem::transmute::<[u8; 8], u64>(buf) }
} }
#[cfg(all(target_os = "linux", #[cfg(all(target_os = "linux",
@ -90,7 +90,7 @@ mod imp {
static GETRANDOM_AVAILABLE: AtomicBool = INIT_ATOMIC_BOOL; static GETRANDOM_AVAILABLE: AtomicBool = INIT_ATOMIC_BOOL;
if !GETRANDOM_CHECKED.load(Relaxed) { if !GETRANDOM_CHECKED.load(Relaxed) {
let mut buf: [u8, ..0] = []; let mut buf: [u8; 0] = [];
let result = getrandom(&mut buf); let result = getrandom(&mut buf);
let available = if result == -1 { let available = if result == -1 {
let err = errno() as libc::c_int; let err = errno() as libc::c_int;
@ -217,12 +217,12 @@ mod imp {
impl Rng for OsRng { impl Rng for OsRng {
fn next_u32(&mut self) -> u32 { fn next_u32(&mut self) -> u32 {
let mut v = [0u8, .. 4]; let mut v = [0u8; 4];
self.fill_bytes(&mut v); self.fill_bytes(&mut v);
unsafe { mem::transmute(v) } unsafe { mem::transmute(v) }
} }
fn next_u64(&mut self) -> u64 { fn next_u64(&mut self) -> u64 {
let mut v = [0u8, .. 8]; let mut v = [0u8; 8];
self.fill_bytes(&mut v); self.fill_bytes(&mut v);
unsafe { mem::transmute(v) } unsafe { mem::transmute(v) }
} }
@ -304,12 +304,12 @@ mod imp {
impl Rng for OsRng { impl Rng for OsRng {
fn next_u32(&mut self) -> u32 { fn next_u32(&mut self) -> u32 {
let mut v = [0u8, .. 4]; let mut v = [0u8; 4];
self.fill_bytes(&mut v); self.fill_bytes(&mut v);
unsafe { mem::transmute(v) } unsafe { mem::transmute(v) }
} }
fn next_u64(&mut self) -> u64 { fn next_u64(&mut self) -> u64 {
let mut v = [0u8, .. 8]; let mut v = [0u8; 8];
self.fill_bytes(&mut v); self.fill_bytes(&mut v);
unsafe { mem::transmute(v) } unsafe { mem::transmute(v) }
} }
@ -351,7 +351,7 @@ mod test {
r.next_u32(); r.next_u32();
r.next_u64(); r.next_u64();
let mut v = [0u8, .. 1000]; let mut v = [0u8; 1000];
r.fill_bytes(&mut v); r.fill_bytes(&mut v);
} }
@ -371,7 +371,7 @@ mod test {
// as possible (XXX: is this a good test?) // as possible (XXX: is this a good test?)
let mut r = OsRng::new().unwrap(); let mut r = OsRng::new().unwrap();
Thread::yield_now(); Thread::yield_now();
let mut v = [0u8, .. 1000]; let mut v = [0u8; 1000];
for _ in range(0u, 100) { for _ in range(0u, 100) {
r.next_u32(); r.next_u32();

View File

@ -105,7 +105,7 @@ mod test {
#[test] #[test]
fn test_reader_rng_fill_bytes() { fn test_reader_rng_fill_bytes() {
let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
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(&mut w); rng.fill_bytes(&mut w);
@ -117,7 +117,7 @@ mod test {
#[should_fail] #[should_fail]
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(&mut v); rng.fill_bytes(&mut v);
} }
} }

View File

@ -82,7 +82,7 @@ pub const unwinder_private_data_size: uint = 2;
pub struct _Unwind_Exception { pub struct _Unwind_Exception {
pub exception_class: _Unwind_Exception_Class, pub exception_class: _Unwind_Exception_Class,
pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, pub exception_cleanup: _Unwind_Exception_Cleanup_Fn,
pub private: [_Unwind_Word, ..unwinder_private_data_size], pub private: [_Unwind_Word; unwinder_private_data_size],
} }
pub enum _Unwind_Context {} pub enum _Unwind_Context {}

View File

@ -83,7 +83,7 @@ pub type Callback = fn(msg: &(Any + Send), file: &'static str, line: uint);
// //
// For more information, see below. // For more information, see below.
const MAX_CALLBACKS: uint = 16; const MAX_CALLBACKS: uint = 16;
static CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] = static CALLBACKS: [atomic::AtomicUint; MAX_CALLBACKS] =
[atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, [atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
@ -168,7 +168,7 @@ fn rust_panic(cause: Box<Any + Send>) -> ! {
uwe: uw::_Unwind_Exception { uwe: uw::_Unwind_Exception {
exception_class: rust_exception_class(), exception_class: rust_exception_class(),
exception_cleanup: exception_cleanup, exception_cleanup: exception_cleanup,
private: [0, ..uw::unwinder_private_data_size], private: [0; uw::unwinder_private_data_size],
}, },
cause: Some(cause), cause: Some(cause),
}; };

View File

@ -134,7 +134,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: &mut 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");

View File

@ -310,7 +310,7 @@ pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> {
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
let len = addr_to_sockaddr(addr, &mut storage); let len = addr_to_sockaddr(addr, &mut storage);
let mut hostbuf = [0 as c_char, ..NI_MAXHOST]; let mut hostbuf = [0 as c_char; NI_MAXHOST];
let res = unsafe { let res = unsafe {
getnameinfo(&storage as *const _ as *const libc::sockaddr, len, getnameinfo(&storage as *const _ as *const libc::sockaddr, len,

View File

@ -123,7 +123,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
try!(writeln!(w, "stack backtrace:")); try!(writeln!(w, "stack backtrace:"));
// 100 lines should be enough // 100 lines should be enough
const SIZE: uint = 100; const SIZE: uint = 100;
let mut buf: [*mut libc::c_void, ..SIZE] = unsafe {mem::zeroed()}; let mut buf: [*mut libc::c_void; SIZE] = unsafe {mem::zeroed()};
let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint}; let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint};
// skipping the first one as it is write itself // skipping the first one as it is write itself
@ -320,7 +320,7 @@ fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
// tested if this is required or not. // tested if this is required or not.
unsafe fn init_state() -> *mut backtrace_state { unsafe fn init_state() -> *mut backtrace_state {
static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state; static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state;
static mut LAST_FILENAME: [libc::c_char, ..256] = [0, ..256]; static mut LAST_FILENAME: [libc::c_char; 256] = [0; 256];
if !STATE.is_null() { return STATE } if !STATE.is_null() { return STATE }
let selfname = if cfg!(target_os = "freebsd") || let selfname = if cfg!(target_os = "freebsd") ||
cfg!(target_os = "dragonfly") { cfg!(target_os = "dragonfly") {

View File

@ -94,7 +94,7 @@ mod select {
#[repr(C)] #[repr(C)]
pub struct fd_set { pub struct fd_set {
fds_bits: [i32, ..(FD_SETSIZE / 32)] fds_bits: [i32; (FD_SETSIZE / 32)]
} }
pub fn fd_set(set: &mut fd_set, fd: i32) { pub fn fd_set(set: &mut fd_set, fd: i32) {
@ -115,7 +115,7 @@ mod select {
#[repr(C)] #[repr(C)]
pub struct fd_set { pub struct fd_set {
// FIXME: shouldn't this be a c_ulong? // FIXME: shouldn't this be a c_ulong?
fds_bits: [libc::uintptr_t, ..(FD_SETSIZE / uint::BITS)] fds_bits: [libc::uintptr_t; (FD_SETSIZE / uint::BITS)]
} }
pub fn fd_set(set: &mut fd_set, fd: i32) { pub fn fd_set(set: &mut fd_set, fd: i32) {
@ -168,13 +168,13 @@ mod signal {
#[repr(C)] #[repr(C)]
#[cfg(target_word_size = "32")] #[cfg(target_word_size = "32")]
pub struct sigset_t { pub struct sigset_t {
__val: [libc::c_ulong, ..32], __val: [libc::c_ulong; 32],
} }
#[repr(C)] #[repr(C)]
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
pub struct sigset_t { pub struct sigset_t {
__val: [libc::c_ulong, ..16], __val: [libc::c_ulong; 16],
} }
} }
@ -211,7 +211,7 @@ mod signal {
pub sa_handler: extern fn(libc::c_int), pub sa_handler: extern fn(libc::c_int),
pub sa_mask: sigset_t, pub sa_mask: sigset_t,
sa_restorer: *mut libc::c_void, sa_restorer: *mut libc::c_void,
sa_resv: [libc::c_int, ..1], sa_resv: [libc::c_int; 1],
} }
unsafe impl ::kinds::Send for sigaction { } unsafe impl ::kinds::Send for sigaction { }
@ -219,7 +219,7 @@ mod signal {
#[repr(C)] #[repr(C)]
pub struct sigset_t { pub struct sigset_t {
__val: [libc::c_ulong, ..32], __val: [libc::c_ulong; 32],
} }
} }
@ -244,7 +244,7 @@ mod signal {
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[repr(C)] #[repr(C)]
pub struct sigset_t { pub struct sigset_t {
bits: [u32, ..4], bits: [u32; 4],
} }
// This structure has more fields, but we're not all that interested in // This structure has more fields, but we're not all that interested in

View File

@ -372,7 +372,7 @@ mod tests {
let mut writer = FileDesc::new(writer, true); let mut writer = FileDesc::new(writer, true);
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(&mut buf) { match reader.read(&mut buf) {
Ok(4) => { Ok(4) => {
assert_eq!(buf[0], 't' as u8); assert_eq!(buf[0], 't' as u8);

View File

@ -100,7 +100,7 @@ pub fn error_string(errno: i32) -> String {
} }
} }
let mut buf = [0 as c_char, ..TMPBUF_SZ]; let mut buf = [0 as c_char; TMPBUF_SZ];
let p = buf.as_mut_ptr(); let p = buf.as_mut_ptr();
unsafe { unsafe {
@ -113,7 +113,7 @@ pub fn error_string(errno: i32) -> String {
} }
pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> { pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
let mut fds = [0, ..2]; let mut fds = [0; 2];
if libc::pipe(fds.as_mut_ptr()) == 0 { if libc::pipe(fds.as_mut_ptr()) == 0 {
Ok((FileDesc::new(fds[0], true), FileDesc::new(fds[1], true))) Ok((FileDesc::new(fds[0], true), FileDesc::new(fds[1], true)))
} else { } else {
@ -124,7 +124,7 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
pub fn getcwd() -> IoResult<Path> { pub fn getcwd() -> IoResult<Path> {
use c_str::CString; use c_str::CString;
let mut buf = [0 as c_char, ..BUF_BYTES]; let mut buf = [0 as c_char; BUF_BYTES];
unsafe { unsafe {
if libc::getcwd(buf.as_mut_ptr(), buf.len() as libc::size_t).is_null() { if libc::getcwd(buf.as_mut_ptr(), buf.len() as libc::size_t).is_null() {
Err(IoError::last_error()) Err(IoError::last_error())

View File

@ -120,7 +120,7 @@ impl Process {
let p = Process{ pid: pid }; let p = Process{ pid: pid };
drop(output); drop(output);
let mut bytes = [0, ..8]; let mut bytes = [0; 8];
return match input.read(&mut bytes) { return match input.read(&mut bytes) {
Ok(8) => { Ok(8) => {
assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)), assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
@ -348,7 +348,7 @@ impl Process {
// handler we're going to start receiving signals. // handler we're going to start receiving signals.
fn register_sigchld() -> (libc::c_int, c::sigaction) { fn register_sigchld() -> (libc::c_int, c::sigaction) {
unsafe { unsafe {
let mut pipes = [0, ..2]; let mut pipes = [0; 2];
assert_eq!(libc::pipe(pipes.as_mut_ptr()), 0); assert_eq!(libc::pipe(pipes.as_mut_ptr()), 0);
set_nonblocking(pipes[0], true).ok().unwrap(); set_nonblocking(pipes[0], true).ok().unwrap();
set_nonblocking(pipes[1], true).ok().unwrap(); set_nonblocking(pipes[1], true).ok().unwrap();
@ -482,7 +482,7 @@ impl Process {
fn drain(fd: libc::c_int) -> bool { fn drain(fd: libc::c_int) -> bool {
let mut ret = false; let mut ret = false;
loop { loop {
let mut buf = [0u8, ..1]; let mut buf = [0u8; 1];
match unsafe { match unsafe {
libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void, libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void,
buf.len() as libc::size_t) buf.len() as libc::size_t)

View File

@ -184,12 +184,12 @@ mod imp {
#[cfg(target_word_size = "32")] #[cfg(target_word_size = "32")]
#[repr(C)] #[repr(C)]
pub struct sigset_t { pub struct sigset_t {
__val: [libc::c_ulong, ..32], __val: [libc::c_ulong; 32],
} }
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
#[repr(C)] #[repr(C)]
pub struct sigset_t { pub struct sigset_t {
__val: [libc::c_ulong, ..16], __val: [libc::c_ulong; 16],
} }
#[repr(C)] #[repr(C)]

View File

@ -86,30 +86,30 @@ mod os {
#[repr(C)] #[repr(C)]
pub struct pthread_mutex_t { pub struct pthread_mutex_t {
__sig: libc::c_long, __sig: libc::c_long,
__opaque: [u8, ..__PTHREAD_MUTEX_SIZE__], __opaque: [u8; __PTHREAD_MUTEX_SIZE__],
} }
#[repr(C)] #[repr(C)]
pub struct pthread_cond_t { pub struct pthread_cond_t {
__sig: libc::c_long, __sig: libc::c_long,
__opaque: [u8, ..__PTHREAD_COND_SIZE__], __opaque: [u8; __PTHREAD_COND_SIZE__],
} }
#[repr(C)] #[repr(C)]
pub struct pthread_rwlock_t { pub struct pthread_rwlock_t {
__sig: libc::c_long, __sig: libc::c_long,
__opaque: [u8, ..__PTHREAD_RWLOCK_SIZE__], __opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
} }
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__sig: _PTHREAD_MUTEX_SIG_INIT, __sig: _PTHREAD_MUTEX_SIG_INIT,
__opaque: [0, ..__PTHREAD_MUTEX_SIZE__], __opaque: [0; __PTHREAD_MUTEX_SIZE__],
}; };
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__sig: _PTHREAD_COND_SIG_INIT, __sig: _PTHREAD_COND_SIG_INIT,
__opaque: [0, ..__PTHREAD_COND_SIZE__], __opaque: [0; __PTHREAD_COND_SIZE__],
}; };
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__sig: _PTHREAD_RWLOCK_SIG_INIT, __sig: _PTHREAD_RWLOCK_SIG_INIT,
__opaque: [0, ..__PTHREAD_RWLOCK_SIZE__], __opaque: [0; __PTHREAD_RWLOCK_SIZE__],
}; };
} }
@ -145,30 +145,30 @@ mod os {
#[repr(C)] #[repr(C)]
pub struct pthread_mutex_t { pub struct pthread_mutex_t {
__align: libc::c_longlong, __align: libc::c_longlong,
size: [u8, ..__SIZEOF_PTHREAD_MUTEX_T], size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
} }
#[repr(C)] #[repr(C)]
pub struct pthread_cond_t { pub struct pthread_cond_t {
__align: libc::c_longlong, __align: libc::c_longlong,
size: [u8, ..__SIZEOF_PTHREAD_COND_T], size: [u8; __SIZEOF_PTHREAD_COND_T],
} }
#[repr(C)] #[repr(C)]
pub struct pthread_rwlock_t { pub struct pthread_rwlock_t {
__align: libc::c_longlong, __align: libc::c_longlong,
size: [u8, ..__SIZEOF_PTHREAD_RWLOCK_T], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
} }
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__align: 0, __align: 0,
size: [0, ..__SIZEOF_PTHREAD_MUTEX_T], size: [0; __SIZEOF_PTHREAD_MUTEX_T],
}; };
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__align: 0, __align: 0,
size: [0, ..__SIZEOF_PTHREAD_COND_T], size: [0; __SIZEOF_PTHREAD_COND_T],
}; };
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__align: 0, __align: 0,
size: [0, ..__SIZEOF_PTHREAD_RWLOCK_T], size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
}; };
} }
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
@ -187,7 +187,7 @@ mod os {
writerThreadId: libc::c_int, writerThreadId: libc::c_int,
pendingReaders: libc::c_int, pendingReaders: libc::c_int,
pendingWriters: libc::c_int, pendingWriters: libc::c_int,
reserved: [*mut libc::c_void, ..4], reserved: [*mut libc::c_void; 4],
} }
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
@ -203,6 +203,6 @@ mod os {
writerThreadId: 0, writerThreadId: 0,
pendingReaders: 0, pendingReaders: 0,
pendingWriters: 0, pendingWriters: 0,
reserved: [0 as *mut _, ..4], reserved: [0 as *mut _; 4],
}; };
} }

View File

@ -68,7 +68,7 @@ const IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664;
struct SYMBOL_INFO { struct SYMBOL_INFO {
SizeOfStruct: libc::c_ulong, SizeOfStruct: libc::c_ulong,
TypeIndex: libc::c_ulong, TypeIndex: libc::c_ulong,
Reserved: [u64, ..2], Reserved: [u64; 2],
Index: libc::c_ulong, Index: libc::c_ulong,
Size: libc::c_ulong, Size: libc::c_ulong,
ModBase: u64, ModBase: u64,
@ -83,7 +83,7 @@ struct SYMBOL_INFO {
// note that windows has this as 1, but it basically just means that // note that windows has this as 1, but it basically just means that
// the name is inline at the end of the struct. For us, we just bump // the name is inline at the end of the struct. For us, we just bump
// the struct size up to MAX_SYM_NAME. // the struct size up to MAX_SYM_NAME.
Name: [libc::c_char, ..MAX_SYM_NAME], Name: [libc::c_char; MAX_SYM_NAME],
} }
@ -108,10 +108,10 @@ struct STACKFRAME64 {
AddrStack: ADDRESS64, AddrStack: ADDRESS64,
AddrBStore: ADDRESS64, AddrBStore: ADDRESS64,
FuncTableEntry: *mut libc::c_void, FuncTableEntry: *mut libc::c_void,
Params: [u64, ..4], Params: [u64; 4],
Far: libc::BOOL, Far: libc::BOOL,
Virtual: libc::BOOL, Virtual: libc::BOOL,
Reserved: [u64, ..3], Reserved: [u64; 3],
KdHelp: KDHELP64, KdHelp: KDHELP64,
} }
@ -127,7 +127,7 @@ struct KDHELP64 {
KiUserExceptionDispatcher: u64, KiUserExceptionDispatcher: u64,
StackBase: u64, StackBase: u64,
StackLimit: u64, StackLimit: u64,
Reserved: [u64, ..5], Reserved: [u64; 5],
} }
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
@ -162,7 +162,7 @@ mod arch {
EFlags: libc::DWORD, EFlags: libc::DWORD,
Esp: libc::DWORD, Esp: libc::DWORD,
SegSs: libc::DWORD, SegSs: libc::DWORD,
ExtendedRegisters: [u8, ..MAXIMUM_SUPPORTED_EXTENSION], ExtendedRegisters: [u8; MAXIMUM_SUPPORTED_EXTENSION],
} }
#[repr(C)] #[repr(C)]
@ -174,7 +174,7 @@ mod arch {
ErrorSelector: libc::DWORD, ErrorSelector: libc::DWORD,
DataOffset: libc::DWORD, DataOffset: libc::DWORD,
DataSelector: libc::DWORD, DataSelector: libc::DWORD,
RegisterArea: [u8, ..80], RegisterArea: [u8; 80],
Cr0NpxState: libc::DWORD, Cr0NpxState: libc::DWORD,
} }
@ -198,7 +198,7 @@ mod arch {
#[repr(C)] #[repr(C)]
pub struct CONTEXT { pub struct CONTEXT {
_align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
P1Home: DWORDLONG, P1Home: DWORDLONG,
P2Home: DWORDLONG, P2Home: DWORDLONG,
P3Home: DWORDLONG, P3Home: DWORDLONG,
@ -245,7 +245,7 @@ mod arch {
FltSave: FLOATING_SAVE_AREA, FltSave: FLOATING_SAVE_AREA,
VectorRegister: [M128A, .. 26], VectorRegister: [M128A; 26],
VectorControl: DWORDLONG, VectorControl: DWORDLONG,
DebugControl: DWORDLONG, DebugControl: DWORDLONG,
@ -257,15 +257,15 @@ mod arch {
#[repr(C)] #[repr(C)]
pub struct M128A { pub struct M128A {
_align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
Low: c_ulonglong, Low: c_ulonglong,
High: c_longlong High: c_longlong
} }
#[repr(C)] #[repr(C)]
pub struct FLOATING_SAVE_AREA { pub struct FLOATING_SAVE_AREA {
_align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
_Dummy: [u8, ..512] // FIXME: Fill this out _Dummy: [u8; 512] // FIXME: Fill this out
} }
pub fn init_frame(frame: &mut super::STACKFRAME64, pub fn init_frame(frame: &mut super::STACKFRAME64,

View File

@ -43,8 +43,8 @@ pub const WSA_WAIT_FAILED: libc::DWORD = libc::consts::os::extra::WAIT_FAILED;
pub struct WSADATA { pub struct WSADATA {
pub wVersion: libc::WORD, pub wVersion: libc::WORD,
pub wHighVersion: libc::WORD, pub wHighVersion: libc::WORD,
pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1], pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1], pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
pub iMaxSockets: u16, pub iMaxSockets: u16,
pub iMaxUdpDg: u16, pub iMaxUdpDg: u16,
pub lpVendorInfo: *mut u8, pub lpVendorInfo: *mut u8,
@ -57,8 +57,8 @@ pub struct WSADATA {
pub iMaxSockets: u16, pub iMaxSockets: u16,
pub iMaxUdpDg: u16, pub iMaxUdpDg: u16,
pub lpVendorInfo: *mut u8, pub lpVendorInfo: *mut u8,
pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1], pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1], pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
} }
pub type LPWSADATA = *mut WSADATA; pub type LPWSADATA = *mut WSADATA;
@ -66,7 +66,7 @@ pub type LPWSADATA = *mut WSADATA;
#[repr(C)] #[repr(C)]
pub struct WSANETWORKEVENTS { pub struct WSANETWORKEVENTS {
pub lNetworkEvents: libc::c_long, pub lNetworkEvents: libc::c_long,
pub iErrorCode: [libc::c_int, ..FD_MAX_EVENTS], pub iErrorCode: [libc::c_int; FD_MAX_EVENTS],
} }
pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS; pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS;
@ -76,7 +76,7 @@ pub type WSAEVENT = libc::HANDLE;
#[repr(C)] #[repr(C)]
pub struct fd_set { pub struct fd_set {
fd_count: libc::c_uint, fd_count: libc::c_uint,
fd_array: [libc::SOCKET, ..FD_SETSIZE], fd_array: [libc::SOCKET; FD_SETSIZE],
} }
pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) { pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {

View File

@ -80,7 +80,7 @@ pub fn error_string(errnum: i32) -> String {
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
let langId = 0x0800 as DWORD; let langId = 0x0800 as DWORD;
let mut buf = [0 as WCHAR, ..TMPBUF_SZ]; let mut buf = [0 as WCHAR; TMPBUF_SZ];
unsafe { unsafe {
let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
@ -112,7 +112,7 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
// fully understand. Here we explicitly make the pipe non-inheritable, // fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated // which means to pass it to a subprocess they need to be duplicated
// first, as in std::run. // first, as in std::run.
let mut fds = [0, ..2]; let mut fds = [0; 2];
match libc::pipe(fds.as_mut_ptr(), 1024 as ::libc::c_uint, match libc::pipe(fds.as_mut_ptr(), 1024 as ::libc::c_uint,
(libc::O_BINARY | libc::O_NOINHERIT) as c_int) { (libc::O_BINARY | libc::O_NOINHERIT) as c_int) {
0 => { 0 => {
@ -164,7 +164,7 @@ pub fn getcwd() -> IoResult<Path> {
use libc::GetCurrentDirectoryW; use libc::GetCurrentDirectoryW;
use io::OtherIoError; use io::OtherIoError;
let mut buf = [0 as u16, ..BUF_BYTES]; let mut buf = [0 as u16; BUF_BYTES];
unsafe { unsafe {
if libc::GetCurrentDirectoryW(buf.len() as DWORD, buf.as_mut_ptr()) == 0 as DWORD { if libc::GetCurrentDirectoryW(buf.len() as DWORD, buf.as_mut_ptr()) == 0 as DWORD {
return Err(IoError::last_error()); return Err(IoError::last_error());

View File

@ -90,7 +90,7 @@ pub struct EXCEPTION_RECORD {
pub ExceptionRecord: *mut EXCEPTION_RECORD, pub ExceptionRecord: *mut EXCEPTION_RECORD,
pub ExceptionAddress: LPVOID, pub ExceptionAddress: LPVOID,
pub NumberParameters: DWORD, pub NumberParameters: DWORD,
pub ExceptionInformation: [LPVOID, ..EXCEPTION_MAXIMUM_PARAMETERS] pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
} }
pub struct EXCEPTION_POINTERS { pub struct EXCEPTION_POINTERS {

View File

@ -119,6 +119,6 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
}); });
MacItems::new(vec![quote_item!(ecx, MacItems::new(vec![quote_item!(ecx,
pub static $name: [(&'static str, &'static str), ..$count] = $expr; pub static $name: [(&'static str, &'static str); $count] = $expr;
).unwrap()].into_iter()) ).unwrap()].into_iter())
} }

View File

@ -292,7 +292,7 @@ pub struct Parser<'a> {
pub cfg: CrateConfig, pub cfg: CrateConfig,
/// the previous token or None (only stashed sometimes). /// the previous token or None (only stashed sometimes).
pub last_token: Option<Box<token::Token>>, pub last_token: Option<Box<token::Token>>,
pub buffer: [TokenAndSpan, ..4], pub buffer: [TokenAndSpan; 4],
pub buffer_start: int, pub buffer_start: int,
pub buffer_end: int, pub buffer_end: int,
pub tokens_consumed: uint, pub tokens_consumed: uint,
@ -1716,12 +1716,7 @@ impl<'a> Parser<'a> {
} }
pub fn maybe_parse_fixed_length_of_vec(&mut self) -> Option<P<ast::Expr>> { pub fn maybe_parse_fixed_length_of_vec(&mut self) -> Option<P<ast::Expr>> {
if self.check(&token::Comma) && if self.check(&token::Semi) {
self.look_ahead(1, |t| *t == token::DotDot) {
self.bump();
self.bump();
Some(self.parse_expr_res(RESTRICTION_NO_DOTS))
} else if self.check(&token::Semi) {
self.bump(); self.bump();
Some(self.parse_expr()) Some(self.parse_expr())
} else { } else {
@ -2155,10 +2150,10 @@ impl<'a> Parser<'a> {
} }
pub fn mk_range(&mut self, pub fn mk_range(&mut self,
start: P<Expr>, start: Option<P<Expr>>,
end: Option<P<Expr>>) end: Option<P<Expr>>)
-> ast::Expr_ { -> ast::Expr_ {
ExprRange(Some(start), end) ExprRange(start, end)
} }
pub fn mk_field(&mut self, expr: P<Expr>, ident: ast::SpannedIdent) -> ast::Expr_ { pub fn mk_field(&mut self, expr: P<Expr>, ident: ast::SpannedIdent) -> ast::Expr_ {
@ -2277,15 +2272,7 @@ impl<'a> Parser<'a> {
} else { } else {
// Nonempty vector. // Nonempty vector.
let first_expr = self.parse_expr(); let first_expr = self.parse_expr();
if self.check(&token::Comma) && if self.check(&token::Semi) {
self.look_ahead(1, |t| *t == token::DotDot) {
// Repeating vector syntax: [ 0, ..512 ]
self.bump();
self.bump();
let count = self.parse_expr();
self.expect(&token::CloseDelim(token::Bracket));
ex = ExprRepeat(first_expr, count);
} else if self.check(&token::Semi) {
// Repeating vector syntax: [ 0; 512 ] // Repeating vector syntax: [ 0; 512 ]
self.bump(); self.bump();
let count = self.parse_expr(); let count = self.parse_expr();
@ -2689,7 +2676,7 @@ impl<'a> Parser<'a> {
}; };
let hi = self.span.hi; let hi = self.span.hi;
let range = self.mk_range(e, opt_end); let range = self.mk_range(Some(e), opt_end);
return self.mk_expr(lo, hi, range); return self.mk_expr(lo, hi, range);
} }
_ => return e _ => return e
@ -2902,6 +2889,13 @@ impl<'a> Parser<'a> {
hi = e.span.hi; hi = e.span.hi;
ex = self.mk_unary(UnUniq, e); ex = self.mk_unary(UnUniq, e);
} }
token::DotDot if !self.restrictions.contains(RESTRICTION_NO_DOTS) => {
// A range, closed above: `..expr`.
self.bump();
let e = self.parse_prefix_expr();
hi = e.span.hi;
ex = self.mk_range(None, Some(e));
}
token::Ident(_, _) => { token::Ident(_, _) => {
if !self.token.is_keyword(keywords::Box) { if !self.token.is_keyword(keywords::Box) {
return self.parse_dot_or_call_expr(); return self.parse_dot_or_call_expr();

View File

@ -53,9 +53,9 @@ pub enum Param {
/// Container for static and dynamic variable arrays /// Container for static and dynamic variable arrays
pub struct Variables { pub struct Variables {
/// Static variables A-Z /// Static variables A-Z
sta: [Param, ..26], sta: [Param; 26],
/// Dynamic variables a-z /// Dynamic variables a-z
dyn: [Param, ..26] dyn: [Param; 26]
} }
impl Variables { impl Variables {

View File

@ -32,11 +32,11 @@ pub struct WinConsole<T> {
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[repr(C)] #[repr(C)]
struct CONSOLE_SCREEN_BUFFER_INFO { struct CONSOLE_SCREEN_BUFFER_INFO {
dwSize: [libc::c_short, ..2], dwSize: [libc::c_short; 2],
dwCursorPosition: [libc::c_short, ..2], dwCursorPosition: [libc::c_short; 2],
wAttributes: libc::WORD, wAttributes: libc::WORD,
srWindow: [libc::c_short, ..4], srWindow: [libc::c_short; 4],
dwMaximumWindowSize: [libc::c_short, ..2], dwMaximumWindowSize: [libc::c_short; 2],
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]

View File

@ -1387,7 +1387,7 @@ impl Bencher {
if n == 0 { n = 1; } if n == 0 { n = 1; }
let mut total_run = Duration::nanoseconds(0); let mut total_run = Duration::nanoseconds(0);
let samples : &mut [f64] = &mut [0.0_f64, ..50]; let samples : &mut [f64] = &mut [0.0_f64; 50];
loop { loop {
let mut summ = None; let mut summ = None;
let mut summ5 = None; let mut summ5 = None;

View File

@ -353,7 +353,7 @@ impl<'a> DoubleEndedIterator<&'a str> for Graphemes<'a> {
} }
// https://tools.ietf.org/html/rfc3629 // https://tools.ietf.org/html/rfc3629
static UTF8_CHAR_WIDTH: [u8, ..256] = [ static UTF8_CHAR_WIDTH: [u8; 256] = [
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@ -519,7 +519,7 @@ impl<I> Iterator<u16> for Utf16Encoder<I> where I: Iterator<char> {
return Some(tmp); return Some(tmp);
} }
let mut buf = [0u16, ..2]; let mut buf = [0u16; 2];
self.chars.next().map(|ch| { self.chars.next().map(|ch| {
let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0); let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
if n == 2 { self.extra = buf[1]; } if n == 2 { self.extra = buf[1]; }

View File

@ -0,0 +1,15 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that the old fixed length array syntax is a parsing error.
fn main() {
let _x: [int, ..3] = [0i, 1, 2]; //~ ERROR
}

View File

@ -0,0 +1,15 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that the old repeating array syntax gives an error.
fn main() {
let _ = [0i, ..3]; //~ ERROR
}

View File

@ -9,5 +9,5 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let x: [int 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `3` let x: [int 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `3`
} }

View File

@ -13,13 +13,13 @@
#[cfg(target_word_size = "64")] #[cfg(target_word_size = "64")]
fn main() { fn main() {
let n = 0u; let n = 0u;
let a = box [&n,..0xF000000000000000u]; let a = box [&n; 0xF000000000000000u];
println!("{}", a[0xFFFFFFu]); println!("{}", a[0xFFFFFFu]);
} }
#[cfg(target_word_size = "32")] #[cfg(target_word_size = "32")]
fn main() { fn main() {
let n = 0u; let n = 0u;
let a = box [&n,..0xFFFFFFFFu]; let a = box [&n; 0xFFFFFFFFu];
println!("{}", a[0xFFFFFFu]); println!("{}", a[0xFFFFFFu]);
} }

View File

@ -11,5 +11,5 @@
// Trying to create a fixed-length vector with a negative size // Trying to create a fixed-length vector with a negative size
fn main() { fn main() {
let _x = [0,..-1]; //~ ERROR found negative integer let _x = [0; -1]; //~ ERROR found negative integer
} }

View File

@ -8,4 +8,4 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `*` type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `*`

View File

@ -10,4 +10,4 @@
type v = [mut int]; type v = [mut int];
//~^ ERROR expected identifier, found keyword `mut` //~^ ERROR expected identifier, found keyword `mut`
//~^^ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `int` //~^^ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `int`

View File

@ -14,35 +14,35 @@
// #4264 fixed-length vector types // #4264 fixed-length vector types
pub fn foo(_: [int, ..3]) {} pub fn foo(_: [int; 3]) {}
pub fn bar() { pub fn bar() {
const FOO: uint = 5u - 4u; const FOO: uint = 5u - 4u;
let _: [(), ..FOO] = [()]; let _: [(); FOO] = [()];
let _ : [(), ..1u] = [()]; let _ : [(); 1u] = [()];
let _ = &([1i,2,3]) as *const _ as *const [int, ..3u]; let _ = &([1i,2,3]) as *const _ as *const [int; 3u];
format!("test"); format!("test");
} }
pub type Foo = [int, ..3u]; pub type Foo = [int; 3u];
pub struct Bar { pub struct Bar {
pub x: [int, ..3u] pub x: [int; 3u]
} }
pub struct TupleBar([int, ..4u]); pub struct TupleBar([int; 4u]);
pub enum Baz { pub enum Baz {
BazVariant([int, ..5u]) BazVariant([int; 5u])
} }
pub fn id<T>(x: T) -> T { x } pub fn id<T>(x: T) -> T { x }
pub fn use_id() { pub fn use_id() {
let _ = id::<[int, ..3u]>([1,2,3]); let _ = id::<[int; 3u]>([1,2,3]);
} }

View File

@ -54,7 +54,7 @@ fn main() {
// and tuples // and tuples
assert_eq!(size_of::<(u8, Box<int>)>(), size_of::<Option<(u8, Box<int>)>>()); assert_eq!(size_of::<(u8, Box<int>)>(), size_of::<Option<(u8, Box<int>)>>());
// and fixed-size arrays // and fixed-size arrays
assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>()); assert_eq!(size_of::<[Box<int>; 1]>(), size_of::<Option<[Box<int>; 1]>>());
// Should apply to NonZero // Should apply to NonZero
assert_eq!(size_of::<NonZero<uint>>(), size_of::<Option<NonZero<uint>>>()); assert_eq!(size_of::<NonZero<uint>>(), size_of::<Option<NonZero<uint>>>());

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x = [1i,..100]; let x = [1i; 100];
let mut y = 0i; let mut y = 0i;
for i in x.iter() { for i in x.iter() {
if y > 10 { if y > 10 {

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x = [1i,..100]; let x = [1i; 100];
let mut y = 0i; let mut y = 0i;
for (n,i) in x.iter().enumerate() { for (n,i) in x.iter().enumerate() {
if n < 10 { if n < 10 {

View File

@ -9,8 +9,8 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x = [1i,..100]; let x = [1i; 100];
let y = [2i,..100]; let y = [2i; 100];
let mut p = 0i; let mut p = 0i;
let mut q = 0i; let mut q = 0i;
for i in x.iter() { for i in x.iter() {

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x = [1i,..100]; let x = [1i; 100];
let mut y = 0i; let mut y = 0i;
for i in x.iter() { for i in x.iter() {
y += *i y += *i

View File

@ -41,6 +41,8 @@ pub fn main() {
let _ = 0u..4+4-3; let _ = 0u..4+4-3;
let _ = 0..foo(); let _ = 0..foo();
let _ = ..42u;
// Test we can use two different types with a common supertype. // Test we can use two different types with a common supertype.
let x = &42i; let x = &42i;
{ {

View File

@ -13,6 +13,6 @@
pub fn main() { pub fn main() {
unsafe { unsafe {
::std::mem::transmute::<[int,..1],int>([1]) ::std::mem::transmute::<[int; 1],int>([1])
}; };
} }

View File

@ -26,7 +26,7 @@ enum e2 {
} }
enum e3 { enum e3 {
a([u16, ..0], u8), b a([u16; 0], u8), b
} }
pub fn main() { pub fn main() {