auto merge of #6487 : recrack/rust/vec_len, r=thestinger

Rename vec::len(var) to var.len()

```
libcore, libfuzzer, librustc, librustdoc, libstd, libsyntax
test/auxiliary
test/bench
test/run-pass
```
This commit is contained in:
bors 2013-05-15 07:38:07 -07:00
commit 4e82610099
58 changed files with 128 additions and 134 deletions

View file

@ -137,8 +137,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
abs1.to_str(), abs2.to_str());
let split1: &[~str] = abs1.components;
let split2: &[~str] = abs2.components;
let len1 = vec::len(split1);
let len2 = vec::len(split2);
let len1 = split1.len();
let len2 = split2.len();
assert!(len1 > 0);
assert!(len2 > 0);

View file

@ -905,7 +905,6 @@ mod test {
use driver::driver::{build_configuration, build_session};
use driver::driver::{build_session_options, optgroups, str_input};
use core::vec;
use std::getopts::groups::getopts;
use std::getopts;
use syntax::attr;
@ -942,6 +941,6 @@ mod test {
let sess = build_session(sessopts, diagnostic::emit);
let cfg = build_configuration(sess, @~"whatever", &str_input(~""));
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
assert!((vec::len(test_items) == 1u));
assert!(test_items.len() == 1u);
}
}

View file

@ -206,7 +206,7 @@ fn is_bench_fn(i: @ast::item) -> bool {
fn has_test_signature(i: @ast::item) -> bool {
match i.node {
ast::item_fn(ref decl, _, _, ref generics, _) => {
let input_cnt = vec::len(decl.inputs);
let input_cnt = decl.inputs.len();
let no_output = match decl.output.node {
ast::ty_nil => true,
_ => false

View file

@ -1063,7 +1063,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
let meta_items = get_meta_items(attr_doc);
// Currently it's only possible to have a single meta item on
// an attribute
assert!((vec::len(meta_items) == 1u));
assert!(meta_items.len() == 1u);
let meta_item = meta_items[0];
attrs.push(
codemap::spanned {

View file

@ -171,7 +171,7 @@ pub fn metadata_matches(extern_metas: &[@ast::meta_item],
local_metas: &[@ast::meta_item]) -> bool {
debug!("matching %u metadata requirements against %u items",
vec::len(local_metas), vec::len(extern_metas));
local_metas.len(), extern_metas.len());
for local_metas.each |needed| {
if !attr::contains(extern_metas, *needed) {

View file

@ -507,7 +507,7 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
// Rust metadata parsing
pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
let mut colon_idx = 0u;
let len = vec::len(buf);
let len = buf.len();
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
if colon_idx == len {
error!("didn't find ':' when parsing def id");

View file

@ -360,7 +360,7 @@ fn is_nullary_variant(cx: Context, ex: @expr) -> bool {
expr_path(_) => {
match cx.tcx.def_map.get_copy(&ex.id) {
def_variant(edid, vdid) => {
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
}
_ => false
}

View file

@ -283,8 +283,8 @@ pub impl RegionMaps {
let a_ancestors = ancestors_of(self, scope_a);
let b_ancestors = ancestors_of(self, scope_b);
let mut a_index = vec::len(a_ancestors) - 1u;
let mut b_index = vec::len(b_ancestors) - 1u;
let mut a_index = a_ancestors.len() - 1u;
let mut b_index = b_ancestors.len() - 1u;
// Here, ~[ab]_ancestors is a vector going from narrow to broad.
// The end of each vector will be the item where the scope is

View file

@ -4706,7 +4706,7 @@ pub impl Resolver {
}
}
if vec::len(values) > 0 &&
if values.len() > 0 &&
values[smallest] != uint::max_value &&
values[smallest] < str::len(name) + 2 &&
values[smallest] <= max_distance &&

View file

@ -4720,7 +4720,7 @@ pub impl Resolver {
}
}
if vec::len(values) > 0 &&
if values.len() > 0 &&
values[smallest] != uint::max_value &&
values[smallest] < str::len(name) + 2 &&
values[smallest] <= max_distance &&

View file

@ -65,7 +65,7 @@ pub impl FnType {
let mut llargvals = ~[];
let mut i = 0u;
let n = vec::len(arg_tys);
let n = arg_tys.len();
if self.sret {
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
@ -113,7 +113,7 @@ pub impl FnType {
if self.sret || !ret_def {
return;
}
let n = vec::len(arg_tys);
let n = arg_tys.len();
// R** llretptr = &args->r;
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
// R* llretloc = *llretptr; /* (args->r) */
@ -149,7 +149,7 @@ pub impl FnType {
};
let mut i = 0u;
let n = vec::len(atys);
let n = atys.len();
while i < n {
let mut argval = get_param(llwrapfn, i + j);
if attrs[i].is_some() {

View file

@ -50,7 +50,7 @@ fn is_sse(c: x86_64_reg_class) -> bool {
}
fn is_ymm(cls: &[x86_64_reg_class]) -> bool {
let len = vec::len(cls);
let len = cls.len();
return (len > 2u &&
is_sse(cls[0]) &&
cls[1] == sseup_class &&
@ -223,8 +223,8 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
unsafe {
let mut i = 0u;
let llty = llvm::LLVMGetTypeKind(ty) as int;
let e = vec::len(cls);
if vec::len(cls) > 2u &&
let e = cls.len();
if cls.len() > 2u &&
(llty == 10 /* struct */ ||
llty == 11 /* array */) {
if is_sse(cls[i]) {
@ -295,7 +295,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef {
unsafe {
let mut tys = ~[];
let mut i = 0u;
let e = vec::len(cls);
let e = cls.len();
while i < e {
match cls[i] {
integer_class => {

View file

@ -509,7 +509,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("foreign::wrap::build_args");
let ccx = bcx.ccx();
let n = vec::len(tys.llsig.llarg_tys);
let n = tys.llsig.llarg_tys.len();
let implicit_args = first_real_arg; // return + env
for uint::range(0, n) |i| {
let mut llargval = get_param(llwrapfn, i + implicit_args);

View file

@ -93,7 +93,7 @@ pub impl Reflector {
let mth_ty =
ty::mk_bare_fn(tcx, copy self.visitor_methods[mth_idx].fty);
let v = self.visitor_val;
debug!("passing %u args:", vec::len(args));
debug!("passing %u args:", args.len());
let bcx = self.bcx;
for args.eachi |i, a| {
debug!("arg %u: %s", i, val_str(bcx.ccx().tn, *a));
@ -224,7 +224,7 @@ pub impl Reflector {
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = ~[self.c_uint(pureval),
self.c_uint(sigilval),
self.c_uint(vec::len(fty.sig.inputs)),
self.c_uint(fty.sig.inputs.len()),
self.c_uint(retval)];
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
self.visit_sig(retval, &fty.sig);
@ -239,7 +239,7 @@ pub impl Reflector {
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = ~[self.c_uint(pureval),
self.c_uint(sigilval),
self.c_uint(vec::len(fty.sig.inputs)),
self.c_uint(fty.sig.inputs.len()),
self.c_uint(retval)];
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
self.visit_sig(retval, &fty.sig);
@ -304,13 +304,13 @@ pub impl Reflector {
llfdecl
};
let enum_args = ~[self.c_uint(vec::len(variants)), make_get_disr()]
let enum_args = ~[self.c_uint(variants.len()), make_get_disr()]
+ self.c_size_and_align(t);
do self.bracketed(~"enum", enum_args) |this| {
for variants.eachi |i, v| {
let variant_args = ~[this.c_uint(i),
this.c_int(v.disr_val),
this.c_uint(vec::len(v.args)),
this.c_uint(v.args.len()),
this.c_slice(ccx.sess.str_of(v.name))];
do this.bracketed(~"enum_variant", variant_args) |this| {
for v.args.eachi |j, a| {

View file

@ -18,7 +18,6 @@ use middle::trans::common::*;
use middle::trans;
use core::str;
use core::vec;
pub struct Ctxt {
next_tag_id: u16,
@ -71,6 +70,6 @@ pub fn add_u16(dest: &mut ~[u8], val: u16) {
}
pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
add_u16(&mut *dest, vec::len(src) as u16);
add_u16(&mut *dest, src.len() as u16);
*dest += src;
}

View file

@ -2634,7 +2634,7 @@ pub fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option<mt> {
ty_enum(did, ref substs) => {
let variants = enum_variants(cx, did);
if vec::len(*variants) == 1u && vec::len(variants[0].args) == 1u {
if (*variants).len() == 1u && variants[0].args.len() == 1u {
let v_t = subst(cx, substs, variants[0].args[0]);
Some(mt {ty: v_t, mutbl: ast::m_imm})
} else {

View file

@ -3276,7 +3276,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
debug!(">>> instantiate_path");
let ty_param_count = tpt.generics.type_param_defs.len();
let ty_substs_len = vec::len(pth.types);
let ty_substs_len = pth.types.len();
debug!("ty_param_count=%? ty_substs_len=%?",
ty_param_count,

View file

@ -499,15 +499,15 @@ pub fn compare_impl_method(tcx: ty::ctxt,
return;
}
if vec::len(impl_m.fty.sig.inputs) != vec::len(trait_m.fty.sig.inputs) {
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
tcx.sess.span_err(
cm.span,
fmt!("method `%s` has %u parameter%s \
but the trait has %u",
*tcx.sess.str_of(trait_m.ident),
vec::len(impl_m.fty.sig.inputs),
if vec::len(impl_m.fty.sig.inputs) == 1 { "" } else { "s" },
vec::len(trait_m.fty.sig.inputs)));
impl_m.fty.sig.inputs.len(),
if impl_m.fty.sig.inputs.len() == 1 { "" } else { "s" },
trait_m.fty.sig.inputs.len()));
return;
}

View file

@ -310,7 +310,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
_ => ()
}
let mut ok = ty::type_is_nil(fn_ty.sig.output);
let num_args = vec::len(fn_ty.sig.inputs);
let num_args = fn_ty.sig.inputs.len();
ok &= num_args == 0u;
if !ok {
tcx.sess.span_err(

View file

@ -470,7 +470,7 @@ pub fn parameterized(cx: ctxt,
}
};
if vec::len(tps) > 0u {
if tps.len() > 0u {
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
fmt!("%s%s<%s>", base, r_str, str::connect(strs, ","))
} else {