Skip to content

Commit 142dbd6

Browse files
committed
librustc: Remove all uses of the old [T * N] fixed-length vector syntax
1 parent 46d4cc1 commit 142dbd6

29 files changed

+61
-59
lines changed

src/libcore/cleanup.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ struct MemoryRegion { priv opaque: () }
3838
#[cfg(target_arch="x86")]
3939
#[cfg(target_arch="arm")]
4040
struct Registers {
41-
data: [u32 * 16]
41+
data: [u32, ..16]
4242
}
4343

4444
#[cfg(target_arch="mips")]
4545
struct Registers {
46-
data: [u32 * 32]
46+
data: [u32, ..32]
4747
}
4848

4949
#[cfg(target_arch="x86")]
@@ -52,12 +52,12 @@ struct Registers {
5252
struct Context {
5353
regs: Registers,
5454
next: *Context,
55-
pad: [u32 * 3]
55+
pad: [u32, ..3]
5656
}
5757

5858
#[cfg(target_arch="x86_64")]
5959
struct Registers {
60-
data: [u64 * 22]
60+
data: [u64, ..22]
6161
}
6262

6363
#[cfg(target_arch="x86_64")]
@@ -80,7 +80,7 @@ struct Task {
8080
// Public fields
8181
refcount: intptr_t, // 0
8282
id: TaskID, // 4
83-
pad: [u32 * 2], // 8
83+
pad: [u32, ..2], // 8
8484
ctx: Context, // 16
8585
stack_segment: *StackSegment, // 96
8686
runtime_sp: uintptr_t, // 100

src/libcore/hash.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct SipState {
162162
mut v1: u64,
163163
mut v2: u64,
164164
mut v3: u64,
165-
mut tail: [u8 * 8], // unprocessed bytes
165+
mut tail: [u8, ..8], // unprocessed bytes
166166
mut ntail: uint, // how many bytes in tail are valid
167167
}
168168

@@ -369,7 +369,7 @@ impl Streaming for SipState {
369369

370370
#[test]
371371
pub fn test_siphash() {
372-
let vecs : [[u8 * 8] * 64] = [
372+
let vecs : [[u8, ..8], ..64] = [
373373
[ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ],
374374
[ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ],
375375
[ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ],
@@ -443,7 +443,7 @@ pub fn test_siphash() {
443443
let stream_inc = &State(k0,k1);
444444
let stream_full = &State(k0,k1);
445445

446-
fn to_hex_str(r: &[u8 * 8]) -> ~str {
446+
fn to_hex_str(r: &[u8, ..8]) -> ~str {
447447
let mut s = ~"";
448448
for vec::each(*r) |b| {
449449
s += uint::to_str_radix(*b as uint, 16u);

src/libcore/libc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub mod types {
342342
st_mtime_nsec: c_long,
343343
st_ctime: time_t,
344344
st_ctime_nsec: c_long,
345-
__unused: [c_long * 3],
345+
__unused: [c_long, ..3],
346346
}
347347
}
348348
pub mod posix08 {
@@ -430,7 +430,7 @@ pub mod types {
430430
st_lspare: int32_t,
431431
st_birthtime: time_t,
432432
st_birthtime_nsec: c_long,
433-
__unused: [uint8_t * 2],
433+
__unused: [uint8_t, ..2],
434434
}
435435
}
436436
pub mod posix08 {
@@ -631,7 +631,7 @@ pub mod types {
631631
st_flags: uint32_t,
632632
st_gen: uint32_t,
633633
st_lspare: int32_t,
634-
st_qspare: [int64_t * 2],
634+
st_qspare: [int64_t, ..2],
635635
}
636636
}
637637
pub mod posix08 {
@@ -712,7 +712,7 @@ pub mod types {
712712
st_flags: uint32_t,
713713
st_gen: uint32_t,
714714
st_lspare: int32_t,
715-
st_qspare: [int64_t * 2],
715+
st_qspare: [int64_t, ..2],
716716
}
717717
}
718718
pub mod posix08 {

src/libcore/num/strconv.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ impl_NumStrConv_Integer!(u64)
132132

133133

134134
// Special value strings as [u8] consts.
135-
static inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
136-
static positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, 'n' as u8, 'f' as u8];
137-
static negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, 'n' as u8, 'f' as u8];
138-
static nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
135+
static inf_buf: [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
136+
static positive_inf_buf: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
137+
'f' as u8];
138+
static negative_inf_buf: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
139+
'f' as u8];
140+
static nan_buf: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
139141

140142
/**
141143
* Converts a number to its string representation as a byte vector.

src/libcore/rt/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
123123
}
124124

125125
#[cfg(target_arch = "x86_64")]
126-
type Registers = [uint * 22];
126+
type Registers = [uint, ..22];
127127

128128
#[cfg(target_arch = "x86_64")]
129129
fn new_regs() -> ~Registers { ~[0, .. 22] }
@@ -157,7 +157,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
157157
}
158158

159159
#[cfg(target_arch = "arm")]
160-
type Registers = [uint * 32];
160+
type Registers = [uint, ..32];
161161

162162
#[cfg(target_arch = "arm")]
163163
fn new_regs() -> ~Registers { ~[0, .. 32] }
@@ -175,7 +175,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
175175
}
176176

177177
#[cfg(target_arch = "mips")]
178-
type Registers = [uint * 32];
178+
type Registers = [uint, ..32];
179179

180180
#[cfg(target_arch = "mips")]
181181
fn new_regs() -> ~Registers { ~[0, .. 32] }

src/libcore/sys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub mod tests {
194194

195195
#[test]
196196
pub fn nonzero_size_of_basic() {
197-
type Z = [i8 * 0];
197+
type Z = [i8, ..0];
198198
fail_unless!(size_of::<Z>() == 0u);
199199
fail_unless!(nonzero_size_of::<Z>() == 1u);
200200
fail_unless!(nonzero_size_of::<uint>() == size_of::<uint>());

src/libcore/trie.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub impl TrieSet {
223223

224224
struct TrieNode<T> {
225225
count: uint,
226-
children: [Child<T> * SIZE]
226+
children: [Child<T>, ..SIZE]
227227
}
228228

229229
impl<T> TrieNode<T> {

src/libcore/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ mod tests {
26362636

26372637
#[test]
26382638
fn test_len_divzero() {
2639-
type Z = [i8 * 0];
2639+
type Z = [i8, ..0];
26402640
let v0 : &[Z] = &[];
26412641
let v1 : &[Z] = &[[]];
26422642
let v2 : &[Z] = &[[], []];

src/librustc/middle/typeck/infer/region_inference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1201,11 +1201,11 @@ struct GraphNode {
12011201
span: span,
12021202
classification: Classification,
12031203
value: GraphNodeValue,
1204-
head_edge: [uint * 2],
1204+
head_edge: [uint, ..2],
12051205
}
12061206

12071207
struct GraphEdge {
1208-
next_edge: [uint * 2],
1208+
next_edge: [uint, ..2],
12091209
constraint: Constraint,
12101210
span: span,
12111211
}

src/libstd/flatpipes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub trait ByteChan {
254254
fn send(&self, val: ~[u8]);
255255
}
256256

257-
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
257+
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
258258

259259
impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
260260
fn recv(&self) -> T {
@@ -921,7 +921,7 @@ mod test {
921921
}
922922

923923
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
924-
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
924+
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
925925
// The control word is followed by garbage
926926
let bytes = CONTINUE.to_vec() + ~[0];
927927
let port = loader(bytes);
@@ -940,7 +940,7 @@ mod test {
940940

941941
fn test_try_recv_none4<P:BytePort>(+loader: PortLoader<P>) {
942942
fail_unless!(do task::try || {
943-
static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
943+
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
944944
// The control word is followed by a valid length,
945945
// then undeserializable garbage
946946
let len_bytes = do io::u64_to_be_bytes(

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub struct Parser {
251251
token: @mut token::Token,
252252
span: @mut span,
253253
last_span: @mut span,
254-
buffer: @mut [TokenAndSpan * 4],
254+
buffer: @mut [TokenAndSpan, ..4],
255255
buffer_start: @mut int,
256256
buffer_end: @mut int,
257257
tokens_consumed: @mut uint,

src/test/bench/noise.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn gradient(orig: Vec2, grad: Vec2, p: Vec2) -> f32 {
2424
}
2525

2626
struct Noise2DContext {
27-
rgradients: [Vec2 * 256],
28-
permutations: [int * 256],
27+
rgradients: [Vec2, ..256],
28+
permutations: [int, ..256],
2929
}
3030

3131
fn Noise2DContext() -> ~Noise2DContext {
@@ -50,7 +50,7 @@ pub impl Noise2DContext {
5050
}
5151

5252
#[inline(always)]
53-
fn get_gradients(&self, gradients: &mut [Vec2 * 4], origins: &mut [Vec2 * 4], x: f32, y: f32) {
53+
fn get_gradients(&self, gradients: &mut [Vec2, ..4], origins: &mut [Vec2, ..4], x: f32, y: f32) {
5454
let x0f = f32::floor(x);
5555
let y0f = f32::floor(y);
5656
let x0 = x0f as int;

src/test/bench/sudoku.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub impl Sudoku {
4444
return Sudoku { grid: g }
4545
}
4646

47-
pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku {
47+
pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku {
4848
let mut g = do vec::from_fn(9u) |i| {
4949
do vec::from_fn(9u) |j| { vec[i][j] }
5050
};
@@ -183,7 +183,7 @@ impl Colors {
183183
}
184184
}
185185

186-
static default_sudoku: [[u8 * 9] * 9] = [
186+
static default_sudoku: [[u8, ..9], ..9] = [
187187
/* 0 1 2 3 4 5 6 7 8 */
188188
/* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8],
189189
/* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8],
@@ -197,7 +197,7 @@ static default_sudoku: [[u8 * 9] * 9] = [
197197
];
198198

199199
#[cfg(test)]
200-
static default_solution: [[u8 * 9] * 9] = [
200+
static default_solution: [[u8, ..9], ..9] = [
201201
/* 0 1 2 3 4 5 6 7 8 */
202202
/* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8],
203203
/* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8],

src/test/compile-fail/const-cast-wrong-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8];
11+
static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
1212
static b: *i8 = &a as *i8; //~ ERROR mismatched types
1313

1414
fn main() {

src/test/compile-fail/evec-subtyping.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn wants_box(x: @[uint]) { }
1212
fn wants_uniq(x: ~[uint]) { }
13-
fn wants_three(x: [uint * 3]) { }
13+
fn wants_three(x: [uint, ..3]) { }
1414

1515
fn has_box(x: @[uint]) {
1616
wants_box(x);
@@ -24,13 +24,13 @@ fn has_uniq(x: ~[uint]) {
2424
wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~
2525
}
2626

27-
fn has_three(x: [uint * 3]) {
27+
fn has_three(x: [uint, ..3]) {
2828
wants_box(x); //~ ERROR [] storage differs: expected @ but found 3
2929
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3
3030
wants_three(x);
3131
}
3232

33-
fn has_four(x: [uint * 4]) {
33+
fn has_four(x: [uint, ..4]) {
3434
wants_box(x); //~ ERROR [] storage differs: expected @ but found 4
3535
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4
3636
wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4

src/test/compile-fail/issue-4517.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn bar(int_param: int) {}
22

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

src/test/run-pass/const-autoderef.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
static A: [u8 * 1] = ['h' as u8];
11+
static A: [u8, ..1] = ['h' as u8];
1212
static B: u8 = (&A)[0];
13-
static C: &'static &'static &'static &'static [u8 * 1] = & & & &A;
13+
static C: &'static &'static &'static &'static [u8, ..1] = & & & &A;
1414
static D: u8 = (&C)[0];
1515

1616
pub fn main() {

src/test/run-pass/const-enum-vector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
enum E { V1(int), V0 }
12-
static C: [E * 3] = [V0, V1(0xDEADBEE), V0];
12+
static C: [E, ..3] = [V0, V1(0xDEADBEE), V0];
1313

1414
pub fn main() {
1515
match C[1] {

src/test/run-pass/const-expr-in-fixed-length-vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
fn main() {
1515

1616
static FOO: int = 2;
17-
let _v: [int * FOO*3];
17+
let _v: [int, ..FOO*3];
1818

1919
}

src/test/run-pass/const-fields-and-indexing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
static x : [int * 4] = [1,2,3,4];
11+
static x : [int, ..4] = [1,2,3,4];
1212
static p : int = x[2];
1313
static y : &'static [int] = &[1,2,3,4];
1414
static q : int = y[2];

src/test/run-pass/const-region-ptrs-noncopy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
type Big = [u64 * 8];
11+
type Big = [u64, ..8];
1212
struct Pair { a: int, b: &'self Big }
1313
static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
1414
static y: &'static Pair<'static> = &Pair {a: 15, b: x};

src/test/run-pass/const-str-ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8];
12-
static c: &'static [u8 * 3] = &a;
11+
static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
12+
static c: &'static [u8, ..3] = &a;
1313
static b: *u8 = c as *u8;
1414

1515
fn main() {

src/test/run-pass/const-vecs-and-slices.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
static x : [int * 4] = [1,2,3,4];
11+
static x : [int, ..4] = [1,2,3,4];
1212
static y : &'static [int] = &[1,2,3,4];
1313

1414
pub fn main() {

src/test/run-pass/evec-internal-boxes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
let x : [@int * 5] = [@1,@2,@3,@4,@5];
13-
let _y : [@int * 5] = [@1,@2,@3,@4,@5];
12+
let x : [@int, ..5] = [@1,@2,@3,@4,@5];
13+
let _y : [@int, ..5] = [@1,@2,@3,@4,@5];
1414
let mut z = [@1,@2,@3,@4,@5];
1515
z = x;
1616
fail_unless!(*z[0] == 1);

0 commit comments

Comments
 (0)