librustc: Remove all uses of the old [T * N] fixed-length vector syntax

This commit is contained in:
Patrick Walton 2013-03-22 18:52:04 -07:00
parent 46d4cc12d1
commit 142dbd65da
29 changed files with 61 additions and 59 deletions

View file

@ -38,12 +38,12 @@ struct MemoryRegion { priv opaque: () }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
#[cfg(target_arch="arm")] #[cfg(target_arch="arm")]
struct Registers { struct Registers {
data: [u32 * 16] data: [u32, ..16]
} }
#[cfg(target_arch="mips")] #[cfg(target_arch="mips")]
struct Registers { struct Registers {
data: [u32 * 32] data: [u32, ..32]
} }
#[cfg(target_arch="x86")] #[cfg(target_arch="x86")]
@ -52,12 +52,12 @@ struct Registers {
struct Context { struct Context {
regs: Registers, regs: Registers,
next: *Context, next: *Context,
pad: [u32 * 3] pad: [u32, ..3]
} }
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
struct Registers { struct Registers {
data: [u64 * 22] data: [u64, ..22]
} }
#[cfg(target_arch="x86_64")] #[cfg(target_arch="x86_64")]
@ -80,7 +80,7 @@ struct Task {
// Public fields // Public fields
refcount: intptr_t, // 0 refcount: intptr_t, // 0
id: TaskID, // 4 id: TaskID, // 4
pad: [u32 * 2], // 8 pad: [u32, ..2], // 8
ctx: Context, // 16 ctx: Context, // 16
stack_segment: *StackSegment, // 96 stack_segment: *StackSegment, // 96
runtime_sp: uintptr_t, // 100 runtime_sp: uintptr_t, // 100

View file

@ -162,7 +162,7 @@ struct SipState {
mut v1: u64, mut v1: u64,
mut v2: u64, mut v2: u64,
mut v3: u64, mut v3: u64,
mut tail: [u8 * 8], // unprocessed bytes mut tail: [u8, ..8], // unprocessed bytes
mut ntail: uint, // how many bytes in tail are valid mut ntail: uint, // how many bytes in tail are valid
} }
@ -369,7 +369,7 @@ impl Streaming for SipState {
#[test] #[test]
pub fn test_siphash() { pub 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, ],
@ -443,7 +443,7 @@ pub fn test_siphash() {
let stream_inc = &State(k0,k1); let stream_inc = &State(k0,k1);
let stream_full = &State(k0,k1); let stream_full = &State(k0,k1);
fn to_hex_str(r: &[u8 * 8]) -> ~str { fn to_hex_str(r: &[u8, ..8]) -> ~str {
let mut s = ~""; let mut s = ~"";
for vec::each(*r) |b| { for vec::each(*r) |b| {
s += uint::to_str_radix(*b as uint, 16u); s += uint::to_str_radix(*b as uint, 16u);

View file

@ -342,7 +342,7 @@ pub mod types {
st_mtime_nsec: c_long, st_mtime_nsec: c_long,
st_ctime: time_t, st_ctime: time_t,
st_ctime_nsec: c_long, st_ctime_nsec: c_long,
__unused: [c_long * 3], __unused: [c_long, ..3],
} }
} }
pub mod posix08 { pub mod posix08 {
@ -430,7 +430,7 @@ pub mod types {
st_lspare: int32_t, st_lspare: int32_t,
st_birthtime: time_t, st_birthtime: time_t,
st_birthtime_nsec: c_long, st_birthtime_nsec: c_long,
__unused: [uint8_t * 2], __unused: [uint8_t, ..2],
} }
} }
pub mod posix08 { pub mod posix08 {
@ -631,7 +631,7 @@ pub mod types {
st_flags: uint32_t, st_flags: uint32_t,
st_gen: uint32_t, st_gen: uint32_t,
st_lspare: int32_t, st_lspare: int32_t,
st_qspare: [int64_t * 2], st_qspare: [int64_t, ..2],
} }
} }
pub mod posix08 { pub mod posix08 {
@ -712,7 +712,7 @@ pub mod types {
st_flags: uint32_t, st_flags: uint32_t,
st_gen: uint32_t, st_gen: uint32_t,
st_lspare: int32_t, st_lspare: int32_t,
st_qspare: [int64_t * 2], st_qspare: [int64_t, ..2],
} }
} }
pub mod posix08 { pub mod posix08 {

View file

@ -132,10 +132,12 @@ impl_NumStrConv_Integer!(u64)
// Special value strings as [u8] consts. // Special value strings as [u8] consts.
static inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; static inf_buf: [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
static positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; static positive_inf_buf: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
static negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; 'f' as u8];
static nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; static negative_inf_buf: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
'f' as u8];
static nan_buf: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
/** /**
* Converts a number to its string representation as a byte vector. * Converts a number to its string representation as a byte vector.

View file

@ -123,7 +123,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
} }
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
type Registers = [uint * 22]; type Registers = [uint, ..22];
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
fn new_regs() -> ~Registers { ~[0, .. 22] } fn new_regs() -> ~Registers { ~[0, .. 22] }
@ -157,7 +157,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
} }
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
type Registers = [uint * 32]; type Registers = [uint, ..32];
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
fn new_regs() -> ~Registers { ~[0, .. 32] } fn new_regs() -> ~Registers { ~[0, .. 32] }
@ -175,7 +175,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
} }
#[cfg(target_arch = "mips")] #[cfg(target_arch = "mips")]
type Registers = [uint * 32]; type Registers = [uint, ..32];
#[cfg(target_arch = "mips")] #[cfg(target_arch = "mips")]
fn new_regs() -> ~Registers { ~[0, .. 32] } fn new_regs() -> ~Registers { ~[0, .. 32] }

View file

@ -194,7 +194,7 @@ pub mod tests {
#[test] #[test]
pub fn nonzero_size_of_basic() { pub fn nonzero_size_of_basic() {
type Z = [i8 * 0]; type Z = [i8, ..0];
fail_unless!(size_of::<Z>() == 0u); fail_unless!(size_of::<Z>() == 0u);
fail_unless!(nonzero_size_of::<Z>() == 1u); fail_unless!(nonzero_size_of::<Z>() == 1u);
fail_unless!(nonzero_size_of::<uint>() == size_of::<uint>()); fail_unless!(nonzero_size_of::<uint>() == size_of::<uint>());

View file

@ -223,7 +223,7 @@ pub impl TrieSet {
struct TrieNode<T> { struct TrieNode<T> {
count: uint, count: uint,
children: [Child<T> * SIZE] children: [Child<T>, ..SIZE]
} }
impl<T> TrieNode<T> { impl<T> TrieNode<T> {

View file

@ -2636,7 +2636,7 @@ mod tests {
#[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] = &[[], []];

View file

@ -1201,11 +1201,11 @@ struct GraphNode {
span: span, span: span,
classification: Classification, classification: Classification,
value: GraphNodeValue, value: GraphNodeValue,
head_edge: [uint * 2], head_edge: [uint, ..2],
} }
struct GraphEdge { struct GraphEdge {
next_edge: [uint * 2], next_edge: [uint, ..2],
constraint: Constraint, constraint: Constraint,
span: span, span: span,
} }

View file

@ -254,7 +254,7 @@ pub trait ByteChan {
fn send(&self, val: ~[u8]); fn send(&self, val: ~[u8]);
} }
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> { impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
fn recv(&self) -> T { fn recv(&self) -> T {
@ -921,7 +921,7 @@ mod test {
} }
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) { fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by garbage // The control word is followed by garbage
let bytes = CONTINUE.to_vec() + ~[0]; let bytes = CONTINUE.to_vec() + ~[0];
let port = loader(bytes); let port = loader(bytes);
@ -940,7 +940,7 @@ mod test {
fn test_try_recv_none4<P:BytePort>(+loader: PortLoader<P>) { fn test_try_recv_none4<P:BytePort>(+loader: PortLoader<P>) {
fail_unless!(do task::try || { fail_unless!(do task::try || {
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by a valid length, // The control word is followed by a valid length,
// then undeserializable garbage // then undeserializable garbage
let len_bytes = do io::u64_to_be_bytes( let len_bytes = do io::u64_to_be_bytes(

View file

@ -251,7 +251,7 @@ pub struct Parser {
token: @mut token::Token, token: @mut token::Token,
span: @mut span, span: @mut span,
last_span: @mut span, last_span: @mut span,
buffer: @mut [TokenAndSpan * 4], buffer: @mut [TokenAndSpan, ..4],
buffer_start: @mut int, buffer_start: @mut int,
buffer_end: @mut int, buffer_end: @mut int,
tokens_consumed: @mut uint, tokens_consumed: @mut uint,

View file

@ -24,8 +24,8 @@ fn gradient(orig: Vec2, grad: Vec2, p: Vec2) -> f32 {
} }
struct Noise2DContext { struct Noise2DContext {
rgradients: [Vec2 * 256], rgradients: [Vec2, ..256],
permutations: [int * 256], permutations: [int, ..256],
} }
fn Noise2DContext() -> ~Noise2DContext { fn Noise2DContext() -> ~Noise2DContext {
@ -50,7 +50,7 @@ pub impl Noise2DContext {
} }
#[inline(always)] #[inline(always)]
fn get_gradients(&self, gradients: &mut [Vec2 * 4], origins: &mut [Vec2 * 4], x: f32, y: f32) { fn get_gradients(&self, gradients: &mut [Vec2, ..4], origins: &mut [Vec2, ..4], x: f32, y: f32) {
let x0f = f32::floor(x); let x0f = f32::floor(x);
let y0f = f32::floor(y); let y0f = f32::floor(y);
let x0 = x0f as int; let x0 = x0f as int;

View file

@ -44,7 +44,7 @@ pub impl Sudoku {
return Sudoku { grid: g } return Sudoku { grid: g }
} }
pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku { pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku {
let mut g = do vec::from_fn(9u) |i| { let mut g = do vec::from_fn(9u) |i| {
do vec::from_fn(9u) |j| { vec[i][j] } do vec::from_fn(9u) |j| { vec[i][j] }
}; };
@ -183,7 +183,7 @@ impl Colors {
} }
} }
static default_sudoku: [[u8 * 9] * 9] = [ static default_sudoku: [[u8, ..9], ..9] = [
/* 0 1 2 3 4 5 6 7 8 */ /* 0 1 2 3 4 5 6 7 8 */
/* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8], /* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8],
/* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8], /* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8],
@ -197,7 +197,7 @@ static default_sudoku: [[u8 * 9] * 9] = [
]; ];
#[cfg(test)] #[cfg(test)]
static default_solution: [[u8 * 9] * 9] = [ static default_solution: [[u8, ..9], ..9] = [
/* 0 1 2 3 4 5 6 7 8 */ /* 0 1 2 3 4 5 6 7 8 */
/* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8], /* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8],
/* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8], /* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8],

View file

@ -8,7 +8,7 @@
// 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.
static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
static b: *i8 = &a as *i8; //~ ERROR mismatched types static b: *i8 = &a as *i8; //~ ERROR mismatched types
fn main() { fn main() {

View file

@ -10,7 +10,7 @@
fn wants_box(x: @[uint]) { } fn wants_box(x: @[uint]) { }
fn wants_uniq(x: ~[uint]) { } fn wants_uniq(x: ~[uint]) { }
fn wants_three(x: [uint * 3]) { } fn wants_three(x: [uint, ..3]) { }
fn has_box(x: @[uint]) { fn has_box(x: @[uint]) {
wants_box(x); wants_box(x);
@ -24,13 +24,13 @@ fn has_uniq(x: ~[uint]) {
wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~ wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~
} }
fn has_three(x: [uint * 3]) { fn has_three(x: [uint, ..3]) {
wants_box(x); //~ ERROR [] storage differs: expected @ but found 3 wants_box(x); //~ ERROR [] storage differs: expected @ but found 3
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3 wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3
wants_three(x); wants_three(x);
} }
fn has_four(x: [uint * 4]) { fn has_four(x: [uint, ..4]) {
wants_box(x); //~ ERROR [] storage differs: expected @ but found 4 wants_box(x); //~ ERROR [] storage differs: expected @ but found 4
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4 wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4
wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4 wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4

View file

@ -1,6 +1,6 @@
fn bar(int_param: int) {} fn bar(int_param: int) {}
fn main() { fn main() {
let foo: [u8 * 4] = [1u8, ..4u8]; let foo: [u8, ..4] = [1u8, ..4u8];
bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8 * 4]` (expected int but found vector) bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8 * 4]` (expected int but found vector)
} }

View file

@ -8,9 +8,9 @@
// 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.
static A: [u8 * 1] = ['h' as u8]; static A: [u8, ..1] = ['h' as u8];
static B: u8 = (&A)[0]; static B: u8 = (&A)[0];
static C: &'static &'static &'static &'static [u8 * 1] = & & & &A; static C: &'static &'static &'static &'static [u8, ..1] = & & & &A;
static D: u8 = (&C)[0]; static D: u8 = (&C)[0];
pub fn main() { pub fn main() {

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
enum E { V1(int), V0 } enum E { V1(int), V0 }
static C: [E * 3] = [V0, V1(0xDEADBEE), V0]; static C: [E, ..3] = [V0, V1(0xDEADBEE), V0];
pub fn main() { pub fn main() {
match C[1] { match C[1] {

View file

@ -14,6 +14,6 @@
fn main() { fn main() {
static FOO: int = 2; static FOO: int = 2;
let _v: [int * FOO*3]; let _v: [int, ..FOO*3];
} }

View file

@ -8,7 +8,7 @@
// 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.
static x : [int * 4] = [1,2,3,4]; static x : [int, ..4] = [1,2,3,4];
static p : int = x[2]; static p : int = x[2];
static y : &'static [int] = &[1,2,3,4]; static y : &'static [int] = &[1,2,3,4];
static q : int = y[2]; static q : int = y[2];

View file

@ -8,7 +8,7 @@
// 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 Big = [u64 * 8]; type Big = [u64, ..8];
struct Pair { a: int, b: &'self Big } struct Pair { a: int, b: &'self Big }
static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
static y: &'static Pair<'static> = &Pair {a: 15, b: x}; static y: &'static Pair<'static> = &Pair {a: 15, b: x};

View file

@ -8,8 +8,8 @@
// 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.
static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
static c: &'static [u8 * 3] = &a; static c: &'static [u8, ..3] = &a;
static b: *u8 = c as *u8; static b: *u8 = c as *u8;
fn main() { fn main() {

View file

@ -8,7 +8,7 @@
// 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.
static x : [int * 4] = [1,2,3,4]; static x : [int, ..4] = [1,2,3,4];
static y : &'static [int] = &[1,2,3,4]; static y : &'static [int] = &[1,2,3,4];
pub fn main() { pub fn main() {

View file

@ -9,8 +9,8 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x : [@int * 5] = [@1,@2,@3,@4,@5]; let x : [@int, ..5] = [@1,@2,@3,@4,@5];
let _y : [@int * 5] = [@1,@2,@3,@4,@5]; let _y : [@int, ..5] = [@1,@2,@3,@4,@5];
let mut z = [@1,@2,@3,@4,@5]; let mut z = [@1,@2,@3,@4,@5];
z = x; z = x;
fail_unless!(*z[0] == 1); fail_unless!(*z[0] == 1);

View file

@ -14,16 +14,16 @@
// Doesn't work; needs a design decision. // Doesn't work; needs a design decision.
pub fn main() { pub fn main() {
let x : [int * 5] = [1,2,3,4,5]; let x : [int, ..5] = [1,2,3,4,5];
let _y : [int * 5] = [1,2,3,4,5]; let _y : [int, ..5] = [1,2,3,4,5];
let mut z = [1,2,3,4,5]; let mut z = [1,2,3,4,5];
z = x; z = x;
fail_unless!(z[0] == 1); fail_unless!(z[0] == 1);
fail_unless!(z[4] == 5); fail_unless!(z[4] == 5);
let a : [int * 5] = [1,1,1,1,1]; let a : [int, ..5] = [1,1,1,1,1];
let b : [int * 5] = [2,2,2,2,2]; let b : [int, ..5] = [2,2,2,2,2];
let c : [int * 5] = [2,2,2,2,3]; let c : [int, ..5] = [2,2,2,2,3];
log(debug, a); log(debug, a);

View file

@ -8,7 +8,7 @@
// 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.
struct Struc { a: u8, b: [int * 3], c: int } struct Struc { a: u8, b: [int, ..3], c: int }
pub fn main() { pub fn main() {
let arr = [1,2,3]; let arr = [1,2,3];

View file

@ -16,7 +16,7 @@
use core::libc::*; use core::libc::*;
struct KEYGEN { struct KEYGEN {
hash_algorithm: [c_uint * 2], hash_algorithm: [c_uint, ..2],
count: uint32_t, count: uint32_t,
salt: *c_void, salt: *c_void,
salt_size: uint32_t, salt_size: uint32_t,

View file

@ -14,7 +14,7 @@ struct A {
struct B { struct B {
v1: int, v1: int,
v2: [int * 3], v2: [int, ..3],
v3: ~[int], v3: ~[int],
v4: C, v4: C,
v5: ~C, v5: ~C,

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
let x: [int*4] = [1, 2, 3, 4]; let x: [int, ..4] = [1, 2, 3, 4];
io::println(fmt!("%d", x[0])); io::println(fmt!("%d", x[0]));
} }