Skip to content

Commit d2debed

Browse files
committed
core: Change the argument order for vec::contains, vec::count
1 parent 1040b47 commit d2debed

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/cargo/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ fn cmd_search(c: cargo) {
800800
let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free));
801801
for_each_package(c, { |s, p|
802802
if (str::contains(p.name, name) || name == "*") &&
803-
vec::all(tags, { |t| vec::contains(t, p.tags) }) {
803+
vec::all(tags, { |t| vec::contains(p.tags, t) }) {
804804
print_pkg(s, p);
805805
n += 1;
806806
}

src/comp/metadata/cstore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
9797
}
9898

9999
fn add_used_crate_file(cstore: cstore, lib: str) {
100-
if !vec::contains(lib, p(cstore).used_crate_files) {
100+
if !vec::contains(p(cstore).used_crate_files, lib) {
101101
p(cstore).used_crate_files += [lib];
102102
}
103103
}
@@ -109,7 +109,7 @@ fn get_used_crate_files(cstore: cstore) -> [str] {
109109
fn add_used_library(cstore: cstore, lib: str) -> bool {
110110
assert lib != "";
111111

112-
if vec::contains(lib, p(cstore).used_libraries) { ret false; }
112+
if vec::contains(p(cstore).used_libraries, lib) { ret false; }
113113
p(cstore).used_libraries += [lib];
114114
ret true;
115115
}

src/comp/middle/check_alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp:span, scrut_ty:ty::t, pats:[@pat]) {
9898
}
9999
}
100100
fn not_represented(v: [def_id], &&vinfo: variant_info) -> bool {
101-
!vec::contains(vinfo.id, v)
101+
!vec::contains(v, vinfo.id)
102102
}
103103
// Could be more efficient (bitvectors?)
104104
alt vec::find(variants, bind not_represented(represented,_)) {

src/comp/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn check_fn_cap_clause(cx: ctx,
109109
let check_var = fn@(&&cap_item: @capture_item) {
110110
let cap_def = cx.tcx.def_map.get(cap_item.id);
111111
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
112-
if !vec::contains(cap_def_id, freevar_ids) {
112+
if !vec::contains(freevar_ids, cap_def_id) {
113113
let ty = ty::node_id_to_type(cx.tcx, cap_def_id);
114114
checker(cx, ty, cap_item.span);
115115
}

src/comp/middle/resolve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ fn check_unused_imports(e: @env) {
317317
e.imports.items {|k, v|
318318
alt v {
319319
resolved(_, _, _, _, name, sp) {
320-
if !vec::contains(k, e.used_imports.data) {
320+
if !vec::contains(e.used_imports.data, k) {
321321
e.sess.span_warn(sp, "unused import " + name);
322322
}
323323
}
@@ -1279,7 +1279,7 @@ fn found_view_item(e: env, id: node_id) -> def {
12791279

12801280
fn lookup_import(e: env, defid: def_id, ns: namespace) -> option<def> {
12811281
// Imports are simply ignored when resolving themselves.
1282-
if vec::contains(defid.node, e.ignored_imports) { ret none; }
1282+
if vec::contains(e.ignored_imports, defid.node) { ret none; }
12831283
alt e.imports.get(defid.node) {
12841284
todo(node_id, name, path, span, scopes) {
12851285
resolve_import(e, local_def(node_id), name, *path, span, scopes);
@@ -1344,7 +1344,7 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
13441344
ns: namespace, dr: dir) -> option<glob_imp_def> {
13451345
alt def.item.node {
13461346
ast::view_item_import_glob(_, id) {
1347-
if vec::contains(id, e.ignored_imports) { ret none; }
1347+
if vec::contains(e.ignored_imports, id) { ret none; }
13481348
}
13491349
_ {
13501350
e.sess.span_bug(sp, "lookup_in_globs: not a glob");

src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ fn occurs_check_fails(tcx: ctxt, sp: option<span>, vid: int, rt: t) ->
13871387
if !type_has_vars(rt) { ret false; }
13881388

13891389
// Occurs check!
1390-
if vec::contains(vid, vars_in_type(tcx, rt)) {
1390+
if vec::contains(vars_in_type(tcx, rt), vid) {
13911391
alt sp {
13921392
some(s) {
13931393
// Maybe this should be span_err -- however, there's an

src/comp/middle/typeck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ fn check_enum_variants(ccx: @crate_ctxt, sp: span, vs: [ast::variant],
26562656
}
26572657
_ {}
26582658
}
2659-
if vec::contains(disr_val, disr_vals) {
2659+
if vec::contains(disr_vals, disr_val) {
26602660
ccx.tcx.sess.span_err(v.span,
26612661
"discriminator value already exists.");
26622662
}

src/libcore/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ Function: contains
693693
694694
Return true if a vector contains an element with the given value
695695
*/
696-
fn contains<T>(x: T, v: [T]) -> bool {
696+
fn contains<T>(v: [T], x: T) -> bool {
697697
for elt: T in v { if x == elt { ret true; } }
698698
ret false;
699699
}
@@ -703,7 +703,7 @@ Function: count
703703
704704
Returns the number of elements that are equal to a given value
705705
*/
706-
fn count<T>(x: T, v: [const T]) -> uint {
706+
fn count<T>(v: [const T], x: T) -> uint {
707707
let cnt = 0u;
708708
for elt: T in v { if x == elt { cnt += 1u; } }
709709
ret cnt;

0 commit comments

Comments
 (0)