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

@ -24,8 +24,8 @@ fn gradient(orig: Vec2, grad: Vec2, p: Vec2) -> f32 {
}
struct Noise2DContext {
rgradients: [Vec2 * 256],
permutations: [int * 256],
rgradients: [Vec2, ..256],
permutations: [int, ..256],
}
fn Noise2DContext() -> ~Noise2DContext {
@ -50,7 +50,7 @@ pub impl Noise2DContext {
}
#[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 y0f = f32::floor(y);
let x0 = x0f as int;

View file

@ -44,7 +44,7 @@ pub impl Sudoku {
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| {
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 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8],
/* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8],
@ -197,7 +197,7 @@ static default_sudoku: [[u8 * 9] * 9] = [
];
#[cfg(test)]
static default_solution: [[u8 * 9] * 9] = [
static default_solution: [[u8, ..9], ..9] = [
/* 0 1 2 3 4 5 6 7 8 */
/* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8],
/* 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
// 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
fn main() {

View file

@ -10,7 +10,7 @@
fn wants_box(x: @[uint]) { }
fn wants_uniq(x: ~[uint]) { }
fn wants_three(x: [uint * 3]) { }
fn wants_three(x: [uint, ..3]) { }
fn has_box(x: @[uint]) {
wants_box(x);
@ -24,13 +24,13 @@ fn has_uniq(x: ~[uint]) {
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_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3
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_uniq(x); //~ ERROR [] storage differs: expected ~ 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 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)
}

View file

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// 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 C: &'static &'static &'static &'static [u8 * 1] = & & & &A;
static C: &'static &'static &'static &'static [u8, ..1] = & & & &A;
static D: u8 = (&C)[0];
pub fn main() {

View file

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

View file

@ -14,6 +14,6 @@
fn main() {
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
// 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 y : &'static [int] = &[1,2,3,4];
static q : int = y[2];

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type Big = [u64 * 8];
type Big = [u64, ..8];
struct Pair { a: int, b: &'self Big }
static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
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
// except according to those terms.
static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8];
static c: &'static [u8 * 3] = &a;
static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
static c: &'static [u8, ..3] = &a;
static b: *u8 = c as *u8;
fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// 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];
pub fn main() {

View file

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

View file

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

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// 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() {
let arr = [1,2,3];

View file

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

View file

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

View file

@ -9,7 +9,7 @@
// except according to those terms.
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]));
}