Skip to content

Commit 7763b40

Browse files
gmfawcettbrson
authored andcommitted
issue #1352: change param order on vec::init_elt, putting block in final position.
To match the init_fn() and init_fn_mut() changes.
1 parent 35d12be commit 7763b40

27 files changed

+56
-56
lines changed

Diff for: src/comp/lib/llvm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
972972
let s = "fn(";
973973
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
974974
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
975-
let args: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_args);
975+
let args: [TypeRef] = vec::init_elt::<TypeRef>(n_args, 0 as TypeRef);
976976
unsafe {
977977
llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
978978
}
@@ -984,7 +984,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
984984
10 {
985985
let s: str = "{";
986986
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
987-
let elts: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_elts);
987+
let elts: [TypeRef] = vec::init_elt::<TypeRef>(n_elts, 0 as TypeRef);
988988
unsafe {
989989
llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
990990
}
@@ -1027,8 +1027,8 @@ fn float_width(llt: TypeRef) -> uint {
10271027
}
10281028

10291029
fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] unsafe {
1030-
let args = vec::init_elt(0 as TypeRef,
1031-
llvm::LLVMCountParamTypes(fn_ty) as uint);
1030+
let args = vec::init_elt(llvm::LLVMCountParamTypes(fn_ty) as uint,
1031+
0 as TypeRef);
10321032
llvm::LLVMGetParamTypes(fn_ty, vec::to_ptr(args));
10331033
ret args;
10341034
}

Diff for: src/comp/middle/trans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ fn get_simple_extern_fn(cx: @block_ctxt,
338338
llmod: ModuleRef,
339339
name: str, n_args: int) -> ValueRef {
340340
let ccx = cx.fcx.lcx.ccx;
341-
let inputs = vec::init_elt::<TypeRef>(ccx.int_type, n_args as uint);
341+
let inputs = vec::init_elt::<TypeRef>(n_args as uint, ccx.int_type);
342342
let output = ccx.int_type;
343343
let t = T_fn(inputs, output);
344344
ret get_extern_fn(externs, llmod, name,
@@ -2842,7 +2842,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, ty: ty::t) -> lval_result {
28422842
alt c.generic {
28432843
some(gi) {
28442844
let n_args = vec::len(ty::ty_fn_args(bcx_tcx(c.bcx), ty));
2845-
let args = vec::init_elt(none::<@ast::expr>, n_args);
2845+
let args = vec::init_elt(n_args, none::<@ast::expr>);
28462846
let space = alloc_ty(c.bcx, ty);
28472847
let bcx = trans_closure::trans_bind_1(space.bcx, ty, c, args, ty,
28482848
save_in(space.val));

Diff for: src/comp/middle/trans_alt.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn enter_opt(ccx: @crate_ctxt, m: match, opt: opt, col: uint, tag_size: uint,
175175
ast::pat_range(l1, l2) {
176176
ret if opt_eq(range(l1, l2), opt) { some([]) } else { none };
177177
}
178-
_ { ret some(vec::init_elt(dummy, size)); }
178+
_ { ret some(vec::init_elt(size, dummy)); }
179179
}
180180
}
181181
ret enter_match(m, col, val, bind e(ccx, dummy, opt, tag_size, _));
@@ -198,7 +198,7 @@ fn enter_rec(m: match, col: uint, fields: [ast::ident], val: ValueRef) ->
198198
}
199199
ret some(pats);
200200
}
201-
_ { ret some(vec::init_elt(dummy, vec::len(fields))); }
201+
_ { ret some(vec::init_elt(vec::len(fields), dummy)); }
202202
}
203203
}
204204
ret enter_match(m, col, val, bind e(dummy, fields, _));
@@ -210,7 +210,7 @@ fn enter_tup(m: match, col: uint, val: ValueRef, n_elts: uint) -> match {
210210
option::t<[@ast::pat]> {
211211
alt p.node {
212212
ast::pat_tup(elts) { ret some(elts); }
213-
_ { ret some(vec::init_elt(dummy, n_elts)); }
213+
_ { ret some(vec::init_elt(n_elts, dummy)); }
214214
}
215215
}
216216
ret enter_match(m, col, val, bind e(dummy, n_elts, _));
@@ -344,7 +344,7 @@ fn pick_col(m: match) -> uint {
344344
_ { 0u }
345345
}
346346
}
347-
let scores = vec::init_elt_mut(0u, vec::len(m[0].pats));
347+
let scores = vec::init_elt_mut(vec::len(m[0].pats), 0u);
348348
for br: match_branch in m {
349349
let i = 0u;
350350
for p: @ast::pat in br.pats { scores[i] += score(p); i += 1u; }

Diff for: src/comp/middle/trans_common.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); }
413413
fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe {
414414
let elt_count = llvm::LLVMCountStructElementTypes(llstructty) as uint;
415415
assert (n < elt_count);
416-
let elt_tys = vec::init_elt(T_nil(), elt_count);
416+
let elt_tys = vec::init_elt(elt_count, T_nil());
417417
llvm::LLVMGetStructElementTypes(llstructty, to_ptr(elt_tys));
418418
ret llvm::LLVMGetElementType(elt_tys[n]);
419419
}
@@ -594,8 +594,8 @@ fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
594594
// Bit of a kludge: pick the fn typeref out of the tydesc..
595595

596596
let tydesc_elts: [TypeRef] =
597-
vec::init_elt::<TypeRef>(T_nil(),
598-
abi::n_tydesc_fields as uint);
597+
vec::init_elt::<TypeRef>(abi::n_tydesc_fields as uint,
598+
T_nil());
599599
llvm::LLVMGetStructElementTypes(cx.tydesc_type,
600600
to_ptr::<TypeRef>(tydesc_elts));
601601
let t = llvm::LLVMGetElementType(tydesc_elts[field]);
@@ -729,7 +729,7 @@ fn T_opaque_tag_ptr(cx: @crate_ctxt) -> TypeRef {
729729
}
730730

731731
fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef {
732-
ret T_struct(vec::init_elt::<TypeRef>(T_ptr(cx.tydesc_type), n));
732+
ret T_struct(vec::init_elt::<TypeRef>(n, T_ptr(cx.tydesc_type)));
733733
}
734734

735735
fn T_opaque_iface_ptr(cx: @crate_ctxt) -> TypeRef {

Diff for: src/comp/middle/trans_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn trans_iface_callee(bcx: @block_ctxt, fld_expr: @ast::expr,
139139
fn llfn_arg_tys(ft: TypeRef) -> {inputs: [TypeRef], output: TypeRef} {
140140
let out_ty = llvm::LLVMGetReturnType(ft);
141141
let n_args = llvm::LLVMCountParamTypes(ft);
142-
let args = vec::init_elt(0 as TypeRef, n_args as uint);
142+
let args = vec::init_elt(n_args as uint, 0 as TypeRef);
143143
unsafe { llvm::LLVMGetParamTypes(ft, vec::to_ptr(args)); }
144144
{inputs: args, output: out_ty}
145145
}

Diff for: src/comp/middle/tstate/states.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
360360
alt e.node {
361361
expr_vec(elts, _) {
362362
ret find_pre_post_state_exprs(fcx, pres, e.id,
363-
vec::init_elt(init_assign,
364-
vec::len(elts)), elts,
363+
vec::init_elt(vec::len(elts),
364+
init_assign), elts,
365365
return_val);
366366
}
367367
expr_call(operator, operands, _) {
@@ -404,8 +404,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
404404
let exs = field_exprs(fields);
405405
let changed =
406406
find_pre_post_state_exprs(fcx, pres, e.id,
407-
vec::init_elt(init_assign,
408-
vec::len(fields)),
407+
vec::init_elt(vec::len(fields),
408+
init_assign),
409409
exs, return_val);
410410

411411
let base_pres = alt vec::last(exs) { none { pres }
@@ -418,8 +418,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
418418
}
419419
expr_tup(elts) {
420420
ret find_pre_post_state_exprs(fcx, pres, e.id,
421-
vec::init_elt(init_assign,
422-
vec::len(elts)), elts,
421+
vec::init_elt(vec::len(elts),
422+
init_assign), elts,
423423
return_val);
424424
}
425425
expr_copy(a) { ret find_pre_post_state_sub(fcx, pres, a, e.id, none); }

Diff for: src/comp/middle/typeck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
16501650
// HACK: build an arguments list with dummy arguments to
16511651
// check against
16521652
let dummy = {mode: ast::by_ref, ty: ty::mk_bot(fcx.ccx.tcx)};
1653-
arg_tys = vec::init_elt(dummy, supplied_arg_count);
1653+
arg_tys = vec::init_elt(supplied_arg_count, dummy);
16541654
}
16551655

16561656
// Check the arguments.

Diff for: src/comp/syntax/print/pp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
102102
// fall behind.
103103
let n: uint = 3u * linewidth;
104104
#debug("mk_printer %u", linewidth);
105-
let token: [mutable token] = vec::init_elt_mut(EOF, n);
106-
let size: [mutable int] = vec::init_elt_mut(0, n);
107-
let scan_stack: [mutable uint] = vec::init_elt_mut(0u, n);
105+
let token: [mutable token] = vec::init_elt_mut(n, EOF);
106+
let size: [mutable int] = vec::init_elt_mut(n, 0);
107+
let scan_stack: [mutable uint] = vec::init_elt_mut(n, 0u);
108108
let print_stack: [print_stack_elt] = [];
109109
@{out: out,
110110
buf_len: n,

Diff for: src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
230230
procres: procres) {
231231

232232
// true if we found the error in question
233-
let found_flags = vec::init_elt_mut(false, vec::len(expected_errors));
233+
let found_flags = vec::init_elt_mut(vec::len(expected_errors), false);
234234

235235
if procres.status == 0 {
236236
fatal("process did not return an error status");

Diff for: src/libcore/extfmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ mod rt {
388388

389389
// FIXME: This might be useful in str: but needs to be utf8 safe first
390390
fn str_init_elt(c: char, n_elts: uint) -> str {
391-
let svec = vec::init_elt::<u8>(c as u8, n_elts);
391+
let svec = vec::init_elt::<u8>(n_elts, c as u8);
392392

393393
ret str::unsafe_from_bytes(svec);
394394
}

Diff for: src/libcore/vec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Creates and initializes an immutable vector.
121121
Creates an immutable vector of size `n_elts` and initializes the elements
122122
to the value `t`.
123123
*/
124-
fn init_elt<T: copy>(t: T, n_elts: uint) -> [T] {
124+
fn init_elt<T: copy>(n_elts: uint, t: T) -> [T] {
125125
let v = [];
126126
reserve(v, n_elts);
127127
let i: uint = 0u;
@@ -138,7 +138,7 @@ Creates and initializes a mutable vector.
138138
Creates a mutable vector of size `n_elts` and initializes the elements
139139
to the value `t`.
140140
*/
141-
fn init_elt_mut<T: copy>(t: T, n_elts: uint) -> [mutable T] {
141+
fn init_elt_mut<T: copy>(n_elts: uint, t: T) -> [mutable T] {
142142
let v = [mutable];
143143
reserve(v, n_elts);
144144
let i: uint = 0u;
@@ -1045,13 +1045,13 @@ mod tests {
10451045
#[test]
10461046
fn test_init_elt() {
10471047
// Test on-stack init_elt.
1048-
let v = init_elt(10u, 2u);
1048+
let v = init_elt(2u, 10u);
10491049
assert (len(v) == 2u);
10501050
assert (v[0] == 10u);
10511051
assert (v[1] == 10u);
10521052

10531053
// Test on-heap init_elt.
1054-
v = init_elt(20u, 6u);
1054+
v = init_elt(6u, 20u);
10551055
assert (v[0] == 20u);
10561056
assert (v[1] == 20u);
10571057
assert (v[2] == 20u);

Diff for: src/libstd/bitv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ init - If true then the bits are initialized to 1, otherwise 0
4949
*/
5050
fn create(nbits: uint, init: bool) -> t {
5151
let elt = if init { !0u } else { 0u };
52-
let storage = vec::init_elt_mut::<uint>(elt, nbits / uint_bits + 1u);
52+
let storage = vec::init_elt_mut::<uint>(nbits / uint_bits + 1u, elt);
5353
ret @{storage: storage, nbits: nbits};
5454
}
5555

@@ -117,7 +117,7 @@ Function: clone
117117
Makes a copy of a bitvector
118118
*/
119119
fn clone(v: t) -> t {
120-
let storage = vec::init_elt_mut::<uint>(0u, v.nbits / uint_bits + 1u);
120+
let storage = vec::init_elt_mut::<uint>(v.nbits / uint_bits + 1u, 0u);
121121
let len = vec::len(v.storage);
122122
uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
123123
ret @{storage: storage, nbits: v.nbits};

Diff for: src/libstd/deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn create<T: copy>() -> t<T> {
127127
mutable nelts: 0u,
128128
mutable lo: 0u,
129129
mutable hi: 0u,
130-
mutable elts: vec::init_elt_mut(none, initial_capacity)
130+
mutable elts: vec::init_elt_mut(initial_capacity, none)
131131
};
132132
repr as t::<T>
133133
}

Diff for: src/libstd/extfmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ mod rt {
380380

381381
// FIXME: This might be useful in str: but needs to be utf8 safe first
382382
fn str_init_elt(c: char, n_elts: uint) -> str {
383-
let svec = vec::init_elt::<u8>(c as u8, n_elts);
383+
let svec = vec::init_elt::<u8>(n_elts, c as u8);
384384

385385
ret str::unsafe_from_bytes(svec);
386386
}

Diff for: src/libstd/freebsd_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
129129
/// followed by a path separator
130130
fn get_exe_path() -> option::t<fs::path> unsafe {
131131
let bufsize = 1023u;
132-
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
132+
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
133133
let mib = [libc_constants::CTL_KERN,
134134
libc_constants::KERN_PROC,
135135
libc_constants::KERN_PROC_PATHNAME, -1i32];

Diff for: src/libstd/linux_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
125125
/// followed by a path separator
126126
fn get_exe_path() -> option::t<fs::path> {
127127
let bufsize = 1023u;
128-
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
128+
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
129129
ret str::as_buf("/proc/self/exe", { |proc_self_buf|
130130
str::as_buf(path, { |path_buf|
131131
if libc::readlink(proc_self_buf, path_buf, bufsize) != -1 {

Diff for: src/libstd/macos_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
134134
fn get_exe_path() -> option::t<fs::path> {
135135
// FIXME: This doesn't handle the case where the buffer is too small
136136
let bufsize = 1023u32;
137-
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize as uint));
137+
let path = str::unsafe_from_bytes(vec::init_elt(bufsize as uint, 0u8));
138138
ret str::as_buf(path, { |path_buf|
139139
if mac_libc::_NSGetExecutablePath(path_buf,
140140
ptr::mut_addr_of(bufsize)) == 0i32 {

Diff for: src/libstd/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ mod chained {
242242
}
243243

244244
fn chains<K: copy, V: copy>(nchains: uint) -> [mutable chain<K,V>] {
245-
ret vec::init_elt_mut(absent, nchains);
245+
ret vec::init_elt_mut(nchains, absent);
246246
}
247247

248248
fn foreach_entry<K: copy, V: copy>(chain0: chain<K,V>,

Diff for: src/libstd/md4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} {
2525
}
2626

2727
let i = 0u, e = vec::len(msg);
28-
let x = vec::init_elt_mut(0u32, 16u);
28+
let x = vec::init_elt_mut(16u, 0u32);
2929
while i < e {
3030
let aa = a, bb = b, cc = c, dd = d;
3131

Diff for: src/libstd/rope.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn concat(v: [rope]) -> rope {
181181
//Copy `v` into a mutable vector
182182
let len = vec::len(v);
183183
if len == 0u { ret node::empty; }
184-
let ropes = vec::init_elt_mut(v[0], len);
184+
let ropes = vec::init_elt_mut(len, v[0]);
185185
uint::range(1u, len) {|i|
186186
ropes[i] = v[i];
187187
}
@@ -779,7 +779,7 @@ mod node {
779779
//Firstly, split `str` in slices of hint_max_leaf_char_len
780780
let leaves = uint::div_ceil(char_len, hint_max_leaf_char_len);
781781
//Number of leaves
782-
let nodes = vec::init_elt_mut(candidate, leaves);
782+
let nodes = vec::init_elt_mut(leaves, candidate);
783783

784784
let i = 0u;
785785
let offset = byte_start;
@@ -892,7 +892,7 @@ mod node {
892892
}
893893

894894
fn serialize_node(node: @node) -> str unsafe {
895-
let buf = vec::init_elt_mut(0u8, byte_len(node));
895+
let buf = vec::init_elt_mut(byte_len(node), 0u8);
896896
let offset = 0u;//Current position in the buffer
897897
let it = leaf_iterator::start(node);
898898
while true {
@@ -1223,7 +1223,7 @@ mod node {
12231223
}
12241224

12251225
fn start(node: @node) -> t {
1226-
let stack = vec::init_elt_mut(node, height(node)+1u);
1226+
let stack = vec::init_elt_mut(height(node)+1u, node);
12271227
ret {
12281228
stack: stack,
12291229
mutable stackpos: 0
@@ -1490,7 +1490,7 @@ mod tests {
14901490
}
14911491

14921492
//Same rope, obtained with rope::concat
1493-
let r2 = concat(vec::init_elt(chunk, 10u));
1493+
let r2 = concat(vec::init_elt(10u, chunk));
14941494

14951495
assert eq(r, r2);
14961496
}

Diff for: src/libstd/sha1.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ fn mk_sha1() -> sha1 {
274274
}
275275
}
276276
let st = {
277-
h: vec::init_elt_mut(0u32, digest_buf_len),
277+
h: vec::init_elt_mut(digest_buf_len, 0u32),
278278
mutable len_low: 0u32,
279279
mutable len_high: 0u32,
280-
msg_block: vec::init_elt_mut(0u8, msg_block_len),
280+
msg_block: vec::init_elt_mut(msg_block_len, 0u8),
281281
mutable msg_block_idx: 0u,
282282
mutable computed: false,
283-
work_buf: vec::init_elt_mut(0u32, work_buf_len)
283+
work_buf: vec::init_elt_mut(work_buf_len, 0u32)
284284
};
285285
let sh = st as sha1;
286286
sh.reset();

Diff for: src/libstd/win32_os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn getcwd() -> str { ret rustrt::rust_getcwd(); }
114114
fn get_exe_path() -> option::t<fs::path> {
115115
// FIXME: This doesn't handle the case where the buffer is too small
116116
let bufsize = 1023u;
117-
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
117+
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
118118
ret str::as_buf(path, { |path_buf|
119119
if kernel32::GetModuleFileNameA(0u, path_buf,
120120
bufsize as u32) != 0u32 {

Diff for: src/rustdoc/gen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum hlvl {
3939
}
4040

4141
fn write_header(ctxt: ctxt, lvl: hlvl, title: str) {
42-
let hashes = str::from_chars(vec::init_elt('#', lvl as uint));
42+
let hashes = str::from_chars(vec::init_elt(lvl as uint, '#'));
4343
ctxt.w.write_line(#fmt("%s %s", hashes, title));
4444
ctxt.w.write_line("");
4545
}

0 commit comments

Comments
 (0)