Convert to new closure syntax
This commit is contained in:
parent
13a8f54538
commit
d1fc2b5995
394 changed files with 3253 additions and 3278 deletions
|
|
@ -69,18 +69,16 @@ mod write {
|
|||
output_type_bitcode {
|
||||
if opts.optimize != 0u {
|
||||
let filename = mk_intermediate_name(output, "no-opt.bc");
|
||||
str::as_c_str(filename,
|
||||
{|buf|
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
str::as_c_str(filename, |buf| {
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
}
|
||||
}
|
||||
_ {
|
||||
let filename = mk_intermediate_name(output, "bc");
|
||||
str::as_c_str(filename,
|
||||
{|buf|
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
str::as_c_str(filename, |buf| {
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,18 +149,17 @@ mod write {
|
|||
|
||||
let filename = mk_intermediate_name(output, "opt.bc");
|
||||
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
||||
str::as_c_str(filename,
|
||||
{|buf|
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
str::as_c_str(filename, |buf| {
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||
});
|
||||
pm = mk_pass_manager();
|
||||
// Save the assembly file if -S is used
|
||||
|
||||
if opts.output_type == output_type_assembly {
|
||||
let _: () = str::as_c_str(
|
||||
sess.targ_cfg.target_strs.target_triple,
|
||||
{|buf_t|
|
||||
str::as_c_str(output, {|buf_o|
|
||||
|buf_t| {
|
||||
str::as_c_str(output, |buf_o| {
|
||||
llvm::LLVMRustWriteOutputFile(
|
||||
pm.llpm,
|
||||
llmod,
|
||||
|
|
@ -170,7 +167,9 @@ mod write {
|
|||
buf_o,
|
||||
lib::llvm::AssemblyFile as c_uint,
|
||||
CodeGenOptLevel,
|
||||
true)})});
|
||||
true)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -178,37 +177,39 @@ mod write {
|
|||
// This .o is needed when an exe is built
|
||||
if opts.output_type == output_type_object ||
|
||||
opts.output_type == output_type_exe {
|
||||
let _: () =
|
||||
str::as_c_str(
|
||||
sess.targ_cfg.target_strs.target_triple,
|
||||
{|buf_t|
|
||||
str::as_c_str(output, {|buf_o|
|
||||
llvm::LLVMRustWriteOutputFile(
|
||||
pm.llpm,
|
||||
llmod,
|
||||
buf_t,
|
||||
buf_o,
|
||||
lib::llvm::ObjectFile as c_uint,
|
||||
CodeGenOptLevel,
|
||||
true)})});
|
||||
}
|
||||
} else {
|
||||
// If we aren't saving temps then just output the file
|
||||
// type corresponding to the '-c' or '-S' flag used
|
||||
|
||||
let _: () =
|
||||
str::as_c_str(
|
||||
let _: () = str::as_c_str(
|
||||
sess.targ_cfg.target_strs.target_triple,
|
||||
{|buf_t|
|
||||
str::as_c_str(output, {|buf_o|
|
||||
|buf_t| {
|
||||
str::as_c_str(output, |buf_o| {
|
||||
llvm::LLVMRustWriteOutputFile(
|
||||
pm.llpm,
|
||||
llmod,
|
||||
buf_t,
|
||||
buf_o,
|
||||
FileType as c_uint,
|
||||
lib::llvm::ObjectFile as c_uint,
|
||||
CodeGenOptLevel,
|
||||
true)})});
|
||||
true)
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// If we aren't saving temps then just output the file
|
||||
// type corresponding to the '-c' or '-S' flag used
|
||||
|
||||
let _: () = str::as_c_str(
|
||||
sess.targ_cfg.target_strs.target_triple,
|
||||
|buf_t| {
|
||||
str::as_c_str(output, |buf_o| {
|
||||
llvm::LLVMRustWriteOutputFile(
|
||||
pm.llpm,
|
||||
llmod,
|
||||
buf_t,
|
||||
buf_o,
|
||||
FileType as c_uint,
|
||||
CodeGenOptLevel,
|
||||
true)
|
||||
})
|
||||
});
|
||||
}
|
||||
// Clean up and return
|
||||
|
||||
|
|
@ -219,14 +220,14 @@ mod write {
|
|||
|
||||
if opts.output_type == output_type_llvm_assembly {
|
||||
// Given options "-S --emit-llvm": output LLVM assembly
|
||||
str::as_c_str(output, {|buf_o|
|
||||
str::as_c_str(output, |buf_o| {
|
||||
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o)});
|
||||
} else {
|
||||
// If only a bitcode file is asked for by using the '--emit-llvm'
|
||||
// flag, then output it here
|
||||
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
||||
str::as_c_str(output,
|
||||
{|buf| llvm::LLVMWriteBitcodeToFile(llmod, buf) });
|
||||
|buf| llvm::LLVMWriteBitcodeToFile(llmod, buf) );
|
||||
}
|
||||
|
||||
llvm::LLVMDisposeModule(llmod);
|
||||
|
|
@ -301,7 +302,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
|||
let mut cmh_items: ~[@ast::meta_item] = ~[];
|
||||
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
|
||||
attr::require_unique_names(sess.diagnostic(), linkage_metas);
|
||||
for linkage_metas.each {|meta|
|
||||
for linkage_metas.each |meta| {
|
||||
if *attr::get_meta_item_name(meta) == "name" {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(v) { name = some(v); }
|
||||
|
|
@ -332,7 +333,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
|||
let cmh_items = attr::sort_meta_items(metas.cmh_items);
|
||||
|
||||
sha.reset();
|
||||
for cmh_items.each {|m_|
|
||||
for cmh_items.each |m_| {
|
||||
let m = m_;
|
||||
alt m.node {
|
||||
ast::meta_name_value(key, value) {
|
||||
|
|
@ -347,7 +348,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
|||
}
|
||||
}
|
||||
|
||||
for dep_hashes.each {|dh|
|
||||
for dep_hashes.each |dh| {
|
||||
sha.input_str(len_and_str(*dh));
|
||||
}
|
||||
|
||||
|
|
@ -443,7 +444,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str {
|
|||
// gas doesn't!
|
||||
fn sanitize(s: str) -> str {
|
||||
let mut result = "";
|
||||
do str::chars_iter(s) {|c|
|
||||
do str::chars_iter(s) |c| {
|
||||
alt c {
|
||||
'@' { result += "_sbox_"; }
|
||||
'~' { result += "_ubox_"; }
|
||||
|
|
@ -479,7 +480,7 @@ fn mangle(ss: path) -> str {
|
|||
|
||||
let mut n = "_ZN"; // Begin name-sequence.
|
||||
|
||||
for ss.each {|s|
|
||||
for ss.each |s| {
|
||||
alt s { path_name(s) | path_mod(s) {
|
||||
let sani = sanitize(*s);
|
||||
n += #fmt["%u%s", str::len(sani), sani];
|
||||
|
|
@ -593,7 +594,7 @@ fn link_binary(sess: session,
|
|||
// # Crate linking
|
||||
|
||||
let cstore = sess.cstore;
|
||||
for cstore::get_used_crate_files(cstore).each {|cratepath|
|
||||
for cstore::get_used_crate_files(cstore).each |cratepath| {
|
||||
if str::ends_with(cratepath, ".rlib") {
|
||||
vec::push(cc_args, cratepath);
|
||||
cont;
|
||||
|
|
@ -606,7 +607,7 @@ fn link_binary(sess: session,
|
|||
}
|
||||
|
||||
let ula = cstore::get_used_link_args(cstore);
|
||||
for ula.each {|arg| vec::push(cc_args, arg); }
|
||||
for ula.each |arg| { vec::push(cc_args, arg); }
|
||||
|
||||
// # Native library linking
|
||||
|
||||
|
|
@ -617,11 +618,11 @@ fn link_binary(sess: session,
|
|||
// forces to make sure that library can be found at runtime.
|
||||
|
||||
let addl_paths = sess.opts.addl_lib_search_paths;
|
||||
for addl_paths.each {|path| vec::push(cc_args, "-L" + path); }
|
||||
for addl_paths.each |path| { vec::push(cc_args, "-L" + path); }
|
||||
|
||||
// The names of the native libraries
|
||||
let used_libs = cstore::get_used_libraries(cstore);
|
||||
for used_libs.each {|l| vec::push(cc_args, "-l" + l); }
|
||||
for used_libs.each |l| { vec::push(cc_args, "-l" + l); }
|
||||
|
||||
if sess.building_library {
|
||||
vec::push(cc_args, lib_cmd);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path {
|
|||
}
|
||||
|
||||
fn rpaths_to_flags(rpaths: ~[str]) -> ~[str] {
|
||||
vec::map(rpaths, { |rpath| #fmt("-Wl,-rpath,%s",rpath)})
|
||||
vec::map(rpaths, |rpath| #fmt("-Wl,-rpath,%s",rpath) )
|
||||
}
|
||||
|
||||
fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
|
||||
|
|
@ -55,7 +55,7 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
|
|||
#debug("sysroot: %s", sysroot);
|
||||
#debug("output: %s", output);
|
||||
#debug("libs:");
|
||||
for libs.each {|libpath|
|
||||
for libs.each |libpath| {
|
||||
#debug(" %s", libpath);
|
||||
}
|
||||
#debug("target_triple: %s", target_triple);
|
||||
|
|
@ -74,7 +74,7 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
|
|||
|
||||
fn log_rpaths(desc: str, rpaths: ~[str]) {
|
||||
#debug("%s rpaths:", desc);
|
||||
for rpaths.each {|rpath|
|
||||
for rpaths.each |rpath| {
|
||||
#debug(" %s", rpath);
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ fn get_rpaths_relative_to_output(os: session::os,
|
|||
cwd: path::path,
|
||||
output: path::path,
|
||||
libs: ~[path::path]) -> ~[str] {
|
||||
vec::map(libs, {|a|
|
||||
vec::map(libs, |a| {
|
||||
check not_win32(os);
|
||||
get_rpath_relative_to_output(os, cwd, output, a)
|
||||
})
|
||||
|
|
@ -142,7 +142,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
|
|||
}
|
||||
|
||||
let mut path = ~[];
|
||||
for uint::range(start_idx, len1 - 1u) {|_i| vec::push(path, ".."); };
|
||||
for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ".."); };
|
||||
|
||||
vec::push_all(path, vec::view(split2, start_idx, len2 - 1u));
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
|
|||
}
|
||||
|
||||
fn get_absolute_rpaths(cwd: path::path, libs: ~[path::path]) -> ~[str] {
|
||||
vec::map(libs, {|a|get_absolute_rpath(cwd, a)})
|
||||
vec::map(libs, |a| get_absolute_rpath(cwd, a) )
|
||||
}
|
||||
|
||||
fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> str {
|
||||
|
|
@ -185,7 +185,7 @@ fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str {
|
|||
fn minimize_rpaths(rpaths: ~[str]) -> ~[str] {
|
||||
let set = map::str_hash::<()>();
|
||||
let mut minimized = ~[];
|
||||
for rpaths.each {|rpath|
|
||||
for rpaths.each |rpath| {
|
||||
if !set.contains_key(rpath) {
|
||||
vec::push(minimized, rpath);
|
||||
set.insert(rpath, ());
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ fn declare_upcalls(targ_cfg: @session::config,
|
|||
tys: ~[TypeRef], rv: TypeRef) ->
|
||||
ValueRef {
|
||||
let mut arg_tys: ~[TypeRef] = ~[];
|
||||
for tys.each {|t| vec::push(arg_tys, t); }
|
||||
for tys.each |t| { vec::push(arg_tys, t); }
|
||||
let fn_ty = T_fn(arg_tys, rv);
|
||||
ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty);
|
||||
}
|
||||
fn nothrow(f: ValueRef) -> ValueRef {
|
||||
base::set_no_unwind(f); f
|
||||
}
|
||||
let d = {|a,b,c|decl(llmod, "upcall_", a, b, c)};
|
||||
let dv = {|a,b|decl(llmod, "upcall_", a, b, T_void())};
|
||||
let d = |a,b,c| decl(llmod, "upcall_", a, b, c);
|
||||
let dv = |a,b| decl(llmod, "upcall_", a, b, T_void());
|
||||
|
||||
let int_t = T_int(targ_cfg);
|
||||
let size_t = T_size_t(targ_cfg);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ fn parse_cfgspecs(cfgspecs: ~[str]) -> ast::crate_cfg {
|
|||
// varieties of meta_item here. At the moment we just support the
|
||||
// meta_word variant.
|
||||
let mut words = ~[];
|
||||
for cfgspecs.each {|s| vec::push(words, attr::mk_word_item(@s)); }
|
||||
for cfgspecs.each |s| { vec::push(words, attr::mk_word_item(@s)); }
|
||||
ret words;
|
||||
}
|
||||
|
||||
|
|
@ -131,95 +131,111 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
|||
-> {crate: @ast::crate, tcx: option<ty::ctxt>} {
|
||||
let time_passes = sess.time_passes();
|
||||
let mut crate = time(time_passes, "parsing",
|
||||
{||parse_input(sess, cfg, input)});
|
||||
||parse_input(sess, cfg, input) );
|
||||
if upto == cu_parse { ret {crate: crate, tcx: none}; }
|
||||
|
||||
sess.building_library = session::building_library(
|
||||
sess.opts.crate_type, crate, sess.opts.test);
|
||||
|
||||
crate =
|
||||
time(time_passes, "configuration",
|
||||
{|copy crate|front::config::strip_unconfigured_items(crate)});
|
||||
crate =
|
||||
time(time_passes, "maybe building test harness",
|
||||
{|copy crate|front::test::modify_for_testing(sess, crate)});
|
||||
crate =
|
||||
time(time_passes, "expansion",
|
||||
{|copy crate|syntax::ext::expand::expand_crate(
|
||||
sess.parse_sess, sess.opts.cfg, crate)});
|
||||
crate = time(time_passes, "configuration", |copy crate| {
|
||||
front::config::strip_unconfigured_items(crate)
|
||||
});
|
||||
|
||||
crate = time(time_passes, "maybe building test harness", |copy crate| {
|
||||
front::test::modify_for_testing(sess, crate)
|
||||
});
|
||||
|
||||
crate = time(time_passes, "expansion", |copy crate| {
|
||||
syntax::ext::expand::expand_crate(
|
||||
sess.parse_sess, sess.opts.cfg, crate)
|
||||
});
|
||||
|
||||
if upto == cu_expand { ret {crate: crate, tcx: none}; }
|
||||
|
||||
crate =
|
||||
time(time_passes, "intrinsic injection", {|copy crate|
|
||||
front::intrinsic_inject::inject_intrinsic(sess, crate)
|
||||
});
|
||||
crate = time(time_passes, "intrinsic injection", |copy crate| {
|
||||
front::intrinsic_inject::inject_intrinsic(sess, crate)
|
||||
});
|
||||
|
||||
crate =
|
||||
time(time_passes, "core injection", {|copy crate|
|
||||
front::core_inject::maybe_inject_libcore_ref(sess, crate)
|
||||
});
|
||||
crate = time(time_passes, "core injection", |copy crate| {
|
||||
front::core_inject::maybe_inject_libcore_ref(sess, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "building warning settings table", {|copy crate|
|
||||
time(time_passes, "building warning settings table", |copy crate| {
|
||||
lint::build_settings_crate(sess, crate)
|
||||
});
|
||||
|
||||
let ast_map =
|
||||
time(time_passes, "ast indexing", {|copy crate|
|
||||
let ast_map = time(time_passes, "ast indexing", |copy crate| {
|
||||
syntax::ast_map::map_crate(sess.diagnostic(), *crate)
|
||||
});
|
||||
time(time_passes, "external crate/lib resolution", {|copy crate|
|
||||
|
||||
time(time_passes, "external crate/lib resolution", |copy crate| {
|
||||
creader::read_crates(
|
||||
sess.diagnostic(), *crate, sess.cstore,
|
||||
sess.filesearch,
|
||||
session::sess_os_to_meta_os(sess.targ_cfg.os),
|
||||
sess.opts.static)
|
||||
});
|
||||
let {def_map, exp_map, impl_map} =
|
||||
time(time_passes, "resolution", {|copy crate|
|
||||
resolve::resolve_crate(sess, ast_map, crate)
|
||||
});
|
||||
let freevars =
|
||||
time(time_passes, "freevar finding", {|copy crate|
|
||||
freevars::annotate_freevars(def_map, crate)
|
||||
});
|
||||
let region_map =
|
||||
time(time_passes, "region resolution", {|copy crate|
|
||||
middle::region::resolve_crate(sess, def_map, crate)
|
||||
});
|
||||
|
||||
let { def_map, exp_map, impl_map
|
||||
} = time(time_passes, "resolution", |copy crate| {
|
||||
resolve::resolve_crate(sess, ast_map, crate)
|
||||
});
|
||||
|
||||
let freevars = time(time_passes, "freevar finding", |copy crate| {
|
||||
freevars::annotate_freevars(def_map, crate)
|
||||
});
|
||||
|
||||
let region_map = time(time_passes, "region resolution", |copy crate| {
|
||||
middle::region::resolve_crate(sess, def_map, crate)
|
||||
});
|
||||
|
||||
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars, region_map);
|
||||
let (method_map, vtable_map) =
|
||||
time(time_passes, "typechecking", {|copy crate|
|
||||
typeck::check_crate(ty_cx, impl_map, crate)
|
||||
});
|
||||
time(time_passes, "const checking", {|copy crate|
|
||||
|
||||
let ( method_map, vtable_map
|
||||
) = time(time_passes, "typechecking", |copy crate| {
|
||||
typeck::check_crate(ty_cx, impl_map, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "const checking", |copy crate| {
|
||||
middle::check_const::check_crate(
|
||||
sess, crate, ast_map, def_map, method_map, ty_cx)
|
||||
});
|
||||
|
||||
if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; }
|
||||
|
||||
time(time_passes, "block-use checking",
|
||||
{|copy crate|middle::block_use::check_crate(ty_cx, crate)});
|
||||
time(time_passes, "loop checking",
|
||||
{|copy crate|middle::check_loop::check_crate(ty_cx, crate)});
|
||||
time(time_passes, "alt checking",
|
||||
{|copy crate|middle::check_alt::check_crate(ty_cx, crate)});
|
||||
let last_use_map =
|
||||
time(time_passes, "liveness checking", {|copy crate|
|
||||
middle::liveness::check_crate(ty_cx, method_map, crate)
|
||||
});
|
||||
time(time_passes, "typestate checking",
|
||||
{|copy crate|middle::tstate::ck::check_crate(ty_cx, crate)});
|
||||
let (root_map, mutbl_map) = time(
|
||||
time_passes, "borrow checking",
|
||||
{|copy crate|middle::borrowck::check_crate(ty_cx, method_map,
|
||||
last_use_map, crate)});
|
||||
time(time_passes, "kind checking", {|copy crate|
|
||||
time(time_passes, "block-use checking", |copy crate| {
|
||||
middle::block_use::check_crate(ty_cx, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "loop checking", |copy crate| {
|
||||
middle::check_loop::check_crate(ty_cx, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "alt checking", |copy crate| {
|
||||
middle::check_alt::check_crate(ty_cx, crate)
|
||||
});
|
||||
|
||||
let last_use_map = time(time_passes, "liveness checking", |copy crate| {
|
||||
middle::liveness::check_crate(ty_cx, method_map, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "typestate checking", |copy crate| {
|
||||
middle::tstate::ck::check_crate(ty_cx, crate)
|
||||
});
|
||||
|
||||
let ( root_map, mutbl_map
|
||||
) = time(time_passes, "borrow checking", |copy crate| {
|
||||
middle::borrowck::check_crate(ty_cx, method_map,
|
||||
last_use_map, crate)
|
||||
});
|
||||
|
||||
time(time_passes, "kind checking", |copy crate| {
|
||||
kind::check_crate(ty_cx, method_map, last_use_map, crate)
|
||||
});
|
||||
time(time_passes, "lint checking",
|
||||
{|copy crate|lint::check_crate(ty_cx, crate)});
|
||||
|
||||
time(time_passes, "lint checking", |copy crate| {
|
||||
lint::check_crate(ty_cx, crate)
|
||||
});
|
||||
|
||||
if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; }
|
||||
let outputs = option::get(outputs);
|
||||
|
|
@ -229,13 +245,14 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
|||
impl_map: impl_map, method_map: method_map,
|
||||
vtable_map: vtable_map};
|
||||
|
||||
let (llmod, link_meta) =
|
||||
time(time_passes, "translation",
|
||||
{|copy crate|trans::base::trans_crate(
|
||||
sess, crate, ty_cx, outputs.obj_filename,
|
||||
exp_map, maps)});
|
||||
time(time_passes, "LLVM passes",
|
||||
{||link::write::run_passes(sess, llmod, outputs.obj_filename)});
|
||||
let (llmod, link_meta) = time(time_passes, "translation", |copy crate| {
|
||||
trans::base::trans_crate(sess, crate, ty_cx, outputs.obj_filename,
|
||||
exp_map, maps)
|
||||
});
|
||||
|
||||
time(time_passes, "LLVM passes", || {
|
||||
link::write::run_passes(sess, llmod, outputs.obj_filename)
|
||||
});
|
||||
|
||||
let stop_after_codegen =
|
||||
sess.opts.output_type != link::output_type_exe ||
|
||||
|
|
@ -243,9 +260,11 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
|||
|
||||
if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; }
|
||||
|
||||
time(time_passes, "linking",
|
||||
{||link::link_binary(sess, outputs.obj_filename,
|
||||
outputs.out_filename, link_meta)});
|
||||
time(time_passes, "linking", || {
|
||||
link::link_binary(sess, outputs.obj_filename,
|
||||
outputs.out_filename, link_meta)
|
||||
});
|
||||
|
||||
ret {crate: crate, tcx: some(ty_cx)};
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +332,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
|
|||
let ann = alt ppm {
|
||||
ppm_typed {
|
||||
{pre: ann_paren_for_expr,
|
||||
post: {|a|ann_typed_post(option::get(tcx), a)}}
|
||||
post: |a| ann_typed_post(option::get(tcx), a) }
|
||||
}
|
||||
ppm_identified | ppm_expanded_identified {
|
||||
{pre: ann_paren_for_expr, post: ann_identified_post}
|
||||
|
|
@ -322,7 +341,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
|
|||
};
|
||||
let is_expanded = upto != cu_parse;
|
||||
let src = codemap::get_filemap(sess.codemap, source_name(input)).src;
|
||||
do io::with_str_reader(*src) { |rdr|
|
||||
do io::with_str_reader(*src) |rdr| {
|
||||
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate,
|
||||
source_name(input),
|
||||
rdr, io::stdout(), ann, is_expanded);
|
||||
|
|
@ -417,7 +436,7 @@ fn build_session_options(match: getopts::match,
|
|||
let lint_flags = vec::append(getopts::opt_strs(match, "W"),
|
||||
getopts::opt_strs(match, "warn"));
|
||||
let lint_dict = lint::get_lint_dict();
|
||||
let lint_opts = do vec::map(lint_flags) {|flag|
|
||||
let lint_opts = do vec::map(lint_flags) |flag| {
|
||||
alt lint::lookup_lint(lint_dict, flag) {
|
||||
(flag, none) {
|
||||
early_error(demitter, #fmt("unknown warning: %s", flag))
|
||||
|
|
@ -429,9 +448,9 @@ fn build_session_options(match: getopts::match,
|
|||
let mut debugging_opts = 0u;
|
||||
let debug_flags = getopts::opt_strs(match, "Z");
|
||||
let debug_map = session::debugging_opts_map();
|
||||
for debug_flags.each { |debug_flag|
|
||||
for debug_flags.each |debug_flag| {
|
||||
let mut this_bit = 0u;
|
||||
for debug_map.each { |pair|
|
||||
for debug_map.each |pair| {
|
||||
let (name, _, bit) = pair;
|
||||
if name == debug_flag { this_bit = bit; break; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ Options:
|
|||
fn describe_warnings() {
|
||||
let lint_dict = lint::get_lint_dict();
|
||||
let mut max_key = 0u;
|
||||
for lint_dict.each_key {|k| max_key = uint::max(k.len(), max_key); }
|
||||
for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
|
||||
fn padded(max: uint, s: str) -> str {
|
||||
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ fn describe_warnings() {
|
|||
padded(max_key, "name"), "default", "meaning"));
|
||||
io::println(#fmt(" %s %7.7s %s\n",
|
||||
padded(max_key, "----"), "-------", "-------"));
|
||||
for lint_dict.each {|k, v|
|
||||
for lint_dict.each |k, v| {
|
||||
let k = str::replace(k, "_", "-");
|
||||
io::println(#fmt(" %s %7.7s %s",
|
||||
padded(max_key, k),
|
||||
|
|
@ -103,7 +103,7 @@ fn describe_warnings() {
|
|||
|
||||
fn describe_debug_flags() {
|
||||
io::println(#fmt("\nAvailable debug options:\n"));
|
||||
for session::debugging_opts_map().each { |pair|
|
||||
for session::debugging_opts_map().each |pair| {
|
||||
let (name, desc, _) = pair;
|
||||
io::println(#fmt(" -Z%-20s -- %s", name, desc));
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ fn run_compiler(args: ~[str], demitter: diagnostic::emitter) {
|
|||
let pretty =
|
||||
option::map(getopts::opt_default(match, "pretty",
|
||||
"normal"),
|
||||
{|a|parse_pretty(sess, a)});
|
||||
|a| parse_pretty(sess, a) );
|
||||
alt pretty {
|
||||
some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; }
|
||||
none::<pp_mode> {/* continue */ }
|
||||
|
|
@ -211,7 +211,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
|
|||
let p = comm::port();
|
||||
let ch = comm::chan(p);
|
||||
|
||||
alt do task::try {||
|
||||
alt do task::try || {
|
||||
|
||||
// The 'diagnostics emitter'. Every error, warning, etc. should
|
||||
// go through this function.
|
||||
|
|
@ -248,7 +248,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
|
|||
"try running with RUST_LOG=rustc=0,::rt::backtrace \
|
||||
to get further details and report the results \
|
||||
to github.com/mozilla/rust/issues"
|
||||
]/_.each {|note|
|
||||
]/_.each |note| {
|
||||
diagnostic::emit(none, note, diagnostic::note)
|
||||
}
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
|
|||
}
|
||||
|
||||
fn main(args: ~[str]) {
|
||||
do monitor {|demitter|
|
||||
do monitor |demitter| {
|
||||
run_compiler(args, demitter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ type ctxt = @{
|
|||
// Support conditional compilation by transforming the AST, stripping out
|
||||
// any items that do not belong in the current configuration
|
||||
fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
|
||||
do strip_items(crate) {|attrs|
|
||||
do strip_items(crate) |attrs| {
|
||||
in_cfg(crate.node.config, attrs)
|
||||
}
|
||||
}
|
||||
|
|
@ -24,9 +24,9 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
|
|||
let ctxt = @{in_cfg: in_cfg};
|
||||
|
||||
let precursor =
|
||||
@{fold_mod: {|a,b|fold_mod(ctxt, a, b)},
|
||||
fold_block: fold::wrap({|a,b|fold_block(ctxt, a, b)}),
|
||||
fold_foreign_mod: {|a,b|fold_foreign_mod(ctxt, a, b)}
|
||||
@{fold_mod: |a,b| fold_mod(ctxt, a, b),
|
||||
fold_block: fold::wrap(|a,b| fold_block(ctxt, a, b) ),
|
||||
fold_foreign_mod: |a,b| fold_foreign_mod(ctxt, a, b)
|
||||
with *fold::default_ast_fold()};
|
||||
|
||||
let fold = fold::make_fold(precursor);
|
||||
|
|
@ -41,7 +41,7 @@ fn filter_item(cx: ctxt, &&item: @ast::item) ->
|
|||
|
||||
fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
|
||||
ast::_mod {
|
||||
let filter = {|a|filter_item(cx, a)};
|
||||
let filter = |a| filter_item(cx, a);
|
||||
let filtered_items = vec::filter_map(m.items, filter);
|
||||
ret {view_items: vec::map(m.view_items, fld.fold_view_item),
|
||||
items: vec::map(filtered_items, fld.fold_item)};
|
||||
|
|
@ -56,7 +56,7 @@ fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
|
|||
|
||||
fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
|
||||
fld: fold::ast_fold) -> ast::foreign_mod {
|
||||
let filter = {|a|filter_foreign_item(cx, a)};
|
||||
let filter = |a| filter_foreign_item(cx, a);
|
||||
let filtered_items = vec::filter_map(nm.items, filter);
|
||||
ret {view_items: vec::map(nm.view_items, fld.fold_view_item),
|
||||
items: filtered_items};
|
||||
|
|
@ -81,7 +81,7 @@ fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) ->
|
|||
|
||||
fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
|
||||
ast::blk_ {
|
||||
let filter = {|a|filter_stmt(cx, a)};
|
||||
let filter = |a| filter_stmt(cx, a);
|
||||
let filtered_stmts = vec::filter_map(b.stmts, filter);
|
||||
ret {view_items: b.view_items,
|
||||
stmts: vec::map(filtered_stmts, fld.fold_stmt),
|
||||
|
|
@ -113,12 +113,12 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool {
|
|||
// so we can match against them. This is the list of configurations for
|
||||
// which the item is valid
|
||||
let cfg_metas = vec::concat(vec::filter_map(cfg_metas,
|
||||
{|&&i| attr::get_meta_item_list(i)}));
|
||||
|&&i| attr::get_meta_item_list(i) ));
|
||||
|
||||
let has_cfg_metas = vec::len(cfg_metas) > 0u;
|
||||
if !has_cfg_metas { ret true; }
|
||||
|
||||
for cfg_metas.each {|cfg_mi|
|
||||
for cfg_metas.each |cfg_mi| {
|
||||
if attr::contains(cfg, cfg_mi) { ret true; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ fn generate_test_harness(sess: session::session,
|
|||
testfns: dvec()};
|
||||
|
||||
let precursor =
|
||||
@{fold_crate: fold::wrap({|a,b|fold_crate(cx, a, b)}),
|
||||
fold_item: {|a,b|fold_item(cx, a, b)},
|
||||
fold_mod: {|a,b|fold_mod(cx, a, b)} with *fold::default_ast_fold()};
|
||||
@{fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),
|
||||
fold_item: |a,b| fold_item(cx, a, b),
|
||||
fold_mod: |a,b| fold_mod(cx, a, b) with *fold::default_ast_fold()};
|
||||
|
||||
let fold = fold::make_fold(precursor);
|
||||
let res = @fold.fold_crate(*crate);
|
||||
|
|
@ -57,7 +57,7 @@ fn generate_test_harness(sess: session::session,
|
|||
fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
|
||||
// When not compiling with --test we should not compile the
|
||||
// #[test] functions
|
||||
do config::strip_items(crate) {|attrs|
|
||||
do config::strip_items(crate) |attrs| {
|
||||
!attr::contains_name(attr::attr_metas(attrs), "test")
|
||||
}
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
|
|||
let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore");
|
||||
let ignoreitems = attr::attr_metas(ignoreattrs);
|
||||
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
|
||||
{|&&i| attr::get_meta_item_list(i)}));
|
||||
|&&i| attr::get_meta_item_list(i) ));
|
||||
ret if vec::is_not_empty(ignoreitems) {
|
||||
config::metas_in_cfg(cx.crate.node.config, cfg_metas)
|
||||
} else {
|
||||
|
|
@ -278,7 +278,7 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
|
|||
fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
|
||||
#debug("building test vector from %u tests", cx.testfns.len());
|
||||
let mut descs = ~[];
|
||||
for cx.testfns.each {|test|
|
||||
for cx.testfns.each |test| {
|
||||
vec::push(descs, mk_test_desc_rec(cx, test));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1029,7 +1029,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
|
|||
tys: ~[TypeRef]) -> str {
|
||||
let mut s: str = "";
|
||||
let mut first: bool = true;
|
||||
for tys.each {|t|
|
||||
for tys.each |t| {
|
||||
if first { first = false; } else { s += ", "; }
|
||||
s += type_to_str_inner(names, outer, t);
|
||||
}
|
||||
|
|
@ -1079,7 +1079,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
|
|||
}
|
||||
Pointer {
|
||||
let mut i: uint = 0u;
|
||||
for outer0.each {|tout|
|
||||
for outer0.each |tout| {
|
||||
i += 1u;
|
||||
if tout as int == ty as int {
|
||||
let n: uint = vec::len::<TypeRef>(outer0) - i;
|
||||
|
|
@ -1133,7 +1133,7 @@ type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
|
|||
|
||||
fn mk_target_data(string_rep: str) -> target_data {
|
||||
let lltd =
|
||||
str::as_c_str(string_rep, {|buf| llvm::LLVMCreateTargetData(buf) });
|
||||
str::as_c_str(string_rep, |buf| llvm::LLVMCreateTargetData(buf) );
|
||||
ret {lltd: lltd, dtor: @target_data_res(lltd)};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
|
|||
|
||||
fn hash_path(&&s: str) -> uint {
|
||||
let mut h = 5381u;
|
||||
for str::each(s) {|ch| h = (h << 5u) + h ^ (ch as uint); }
|
||||
for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); }
|
||||
ret h;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ fn read_crates(diag: span_handler, crate: ast::crate,
|
|||
mut next_crate_num: 1};
|
||||
let v =
|
||||
visit::mk_simple_visitor(@{visit_view_item:
|
||||
{|a|visit_view_item(e, a)},
|
||||
visit_item: {|a|visit_item(e, a)}
|
||||
|a| visit_view_item(e, a),
|
||||
visit_item: |a| visit_item(e, a)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(crate, (), v);
|
||||
dump_crates(e.crate_cache);
|
||||
|
|
@ -48,14 +48,14 @@ type cache_entry = {
|
|||
|
||||
fn dump_crates(crate_cache: dvec<cache_entry>) {
|
||||
#debug("resolved crates:");
|
||||
for crate_cache.each {|entry|
|
||||
for crate_cache.each |entry| {
|
||||
#debug("cnum: %?", entry.cnum);
|
||||
#debug("span: %?", entry.span);
|
||||
#debug("hash: %?", entry.hash);
|
||||
let attrs = ~[
|
||||
attr::mk_attr(attr::mk_list_item(@"link", *entry.metas))
|
||||
];
|
||||
for attr::find_linkage_attrs(attrs).each {|attr|
|
||||
for attr::find_linkage_attrs(attrs).each |attr| {
|
||||
#debug("meta: %s", pprust::attr_to_str(attr));
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ fn warn_if_multiple_versions(diag: span_handler,
|
|||
if crate_cache.len() != 0u {
|
||||
let name = loader::crate_name_from_metas(*crate_cache.last().metas);
|
||||
let {lefts: matches, rights: non_matches} =
|
||||
partition(crate_cache.map_to_vec({|entry|
|
||||
partition(crate_cache.map_to_vec(|entry| {
|
||||
let othername = loader::crate_name_from_metas(*entry.metas);
|
||||
if name == othername {
|
||||
left(entry)
|
||||
|
|
@ -82,7 +82,7 @@ fn warn_if_multiple_versions(diag: span_handler,
|
|||
if matches.len() != 1u {
|
||||
diag.handler().warn(
|
||||
#fmt("using multiple versions of crate `%s`", *name));
|
||||
for matches.each {|match|
|
||||
for matches.each |match| {
|
||||
diag.span_note(match.span, "used here");
|
||||
let attrs = ~[
|
||||
attr::mk_attr(attr::mk_list_item(@"link", *match.metas))
|
||||
|
|
@ -147,7 +147,7 @@ fn visit_item(e: env, i: @ast::item) {
|
|||
e.diag.span_fatal(i.span, "library '" + *foreign_name +
|
||||
"' already added: can't specify link_args.");
|
||||
}
|
||||
for link_args.each {|a|
|
||||
for link_args.each |a| {
|
||||
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
|
||||
some(linkarg) {
|
||||
cstore::add_used_link_args(cstore, *linkarg);
|
||||
|
|
@ -178,7 +178,7 @@ fn metas_with_ident(ident: ast::ident,
|
|||
fn existing_match(e: env, metas: ~[@ast::meta_item], hash: str) ->
|
||||
option<int> {
|
||||
|
||||
for e.crate_cache.each {|c|
|
||||
for e.crate_cache.each |c| {
|
||||
if loader::metadata_matches(*c.metas, metas)
|
||||
&& (hash.is_empty() || *c.hash == hash) {
|
||||
ret some(c.cnum);
|
||||
|
|
@ -246,7 +246,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map {
|
|||
// The map from crate numbers in the crate we're resolving to local crate
|
||||
// numbers
|
||||
let cnum_map = int_hash::<ast::crate_num>();
|
||||
for decoder::get_crate_deps(cdata).each {|dep|
|
||||
for decoder::get_crate_deps(cdata).each |dep| {
|
||||
let extrn_cnum = dep.cnum;
|
||||
let cname = dep.name;
|
||||
let cmetas = metas_with(dep.vers, @"vers", ~[]);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num,
|
|||
path: ~[ast::ident]) -> ~[ast::def] {
|
||||
let mut result = ~[];
|
||||
#debug("lookup_defs: path = %? cnum = %?", path, cnum);
|
||||
for resolve_path(cstore, cnum, path).each {|elt|
|
||||
for resolve_path(cstore, cnum, path).each |elt| {
|
||||
let (c, data, def) = elt;
|
||||
vec::push(result, decoder::lookup_def(c, data, def));
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
|
|||
#debug("resolve_path %s in crates[%d]:%s",
|
||||
ast_util::path_name_i(path), cnum, cm.name);
|
||||
let mut result = ~[];
|
||||
for decoder::resolve_path(path, cm.data).each {|def|
|
||||
for decoder::resolve_path(path, cm.data).each |def| {
|
||||
if def.crate == ast::local_crate {
|
||||
vec::push(result, (cnum, cm.data, def));
|
||||
} else {
|
||||
|
|
@ -120,7 +120,7 @@ fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
|
|||
name: option<ast::ident>)
|
||||
-> @~[@decoder::_impl] {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
do decoder::get_impls_for_mod(cdata, def.node, name) {|cnum|
|
||||
do decoder::get_impls_for_mod(cdata, def.node, name) |cnum| {
|
||||
cstore::get_crate_data(cstore, cnum)
|
||||
}
|
||||
}
|
||||
|
|
@ -151,13 +151,13 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
|
|||
#debug("Looking up %?", class_id);
|
||||
let class_doc = expect(tcx.diag,
|
||||
decoder::maybe_find_item(class_id.node, all_items),
|
||||
{|| #fmt("get_field_type: class ID %? not found",
|
||||
class_id)});
|
||||
|| #fmt("get_field_type: class ID %? not found",
|
||||
class_id) );
|
||||
#debug("looking up %? : %?", def, class_doc);
|
||||
let the_field = expect(tcx.diag,
|
||||
decoder::maybe_find_item(def.node, class_doc),
|
||||
{|| #fmt("get_field_type: in class %?, field ID %? not found",
|
||||
class_id, def)});
|
||||
|| #fmt("get_field_type: in class %?, field ID %? not found",
|
||||
class_id, def) );
|
||||
#debug("got field data %?", the_field);
|
||||
let ty = decoder::item_type(def, the_field, tcx, cdata);
|
||||
ret {bounds: @~[], rp: ast::rp_none, ty: ty};
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str {
|
|||
fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
|
||||
data: crate_metadata) {
|
||||
p(cstore).metas.insert(cnum, data);
|
||||
do vec::iter(decoder::get_crate_module_paths(data.data)) {|dp|
|
||||
do vec::iter(decoder::get_crate_module_paths(data.data)) |dp| {
|
||||
let (did, path) = dp;
|
||||
let d = {crate: cnum, node: did.node};
|
||||
p(cstore).mod_path_map.insert(d, @path);
|
||||
|
|
@ -108,7 +108,7 @@ fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool {
|
|||
}
|
||||
|
||||
fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
|
||||
for p(cstore).metas.each {|k,v| i(k, v);};
|
||||
for p(cstore).metas.each |k,v| { i(k, v);};
|
||||
}
|
||||
|
||||
fn add_used_crate_file(cstore: cstore, lib: str) {
|
||||
|
|
@ -157,7 +157,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[@str] {
|
|||
type crate_hash = {name: @str, hash: @str};
|
||||
let mut result = ~[];
|
||||
|
||||
for p(cstore).use_crate_map.each_value {|cnum|
|
||||
for p(cstore).use_crate_map.each_value |cnum| {
|
||||
let cdata = cstore::get_crate_data(cstore, cnum);
|
||||
let hash = decoder::get_crate_hash(cdata.data);
|
||||
#debug("Add hash[%s]: %s", cdata.name, *hash);
|
||||
|
|
@ -168,7 +168,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[@str] {
|
|||
}
|
||||
let sorted = std::sort::merge_sort(lteq, result);
|
||||
#debug("sorted:");
|
||||
for sorted.each {|x|
|
||||
for sorted.each |x| {
|
||||
#debug(" hash[%s]: %s", *x.name, *x.hash);
|
||||
}
|
||||
fn mapper(ch: crate_hash) -> @str { ret ch.hash; }
|
||||
|
|
@ -178,7 +178,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[@str] {
|
|||
fn get_path(cstore: cstore, d: ast::def_id) -> ~[ast::ident] {
|
||||
// let f = bind str::split_str(_, "::");
|
||||
option::map_default(p(cstore).mod_path_map.find(d), ~[],
|
||||
{|ds| str::split_str(*ds, "::").map({|x|@x})})
|
||||
|ds| str::split_str(*ds, "::").map(|x| @x ) )
|
||||
}
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn@(~[u8]) -> bool, hash: uint) ->
|
|||
|
||||
let mut result: ~[ebml::doc] = ~[];
|
||||
let belt = tag_index_buckets_bucket_elt;
|
||||
do ebml::tagged_docs(bucket, belt) {|elt|
|
||||
do ebml::tagged_docs(bucket, belt) |elt| {
|
||||
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
|
||||
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
|
||||
vec::push(result, ebml::doc_at(d.data, pos).doc);
|
||||
|
|
@ -77,7 +77,7 @@ fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> {
|
|||
fn eq_item(bytes: ~[u8], item_id: int) -> bool {
|
||||
ret io::u64_from_be_bytes(bytes, 0u, 4u) as int == item_id;
|
||||
}
|
||||
let eqer = {|a|eq_item(a, item_id)};
|
||||
let eqer = |a| eq_item(a, item_id);
|
||||
let found = lookup_hash(items, eqer, hash_node_id(item_id));
|
||||
if vec::len(found) == 0u {
|
||||
ret option::none::<ebml::doc>;
|
||||
|
|
@ -110,7 +110,7 @@ fn item_symbol(item: ebml::doc) -> str {
|
|||
|
||||
fn item_parent_item(d: ebml::doc) -> option<ast::def_id> {
|
||||
let mut found = none;
|
||||
do ebml::tagged_docs(d, tag_items_data_parent_item) {|did|
|
||||
do ebml::tagged_docs(d, tag_items_data_parent_item) |did| {
|
||||
found = some(parse_def_id(ebml::doc_data(did)));
|
||||
}
|
||||
found
|
||||
|
|
@ -123,25 +123,26 @@ fn class_member_id(d: ebml::doc, cdata: cmd) -> ast::def_id {
|
|||
|
||||
fn field_mutability(d: ebml::doc) -> ast::class_mutability {
|
||||
// Use maybe_get_doc in case it's a method
|
||||
option::map_default(ebml::maybe_get_doc(d, tag_class_mut),
|
||||
ast::class_immutable,
|
||||
{|d|
|
||||
alt ebml::doc_as_u8(d) as char {
|
||||
'm' { ast::class_mutable }
|
||||
_ { ast::class_immutable }
|
||||
}
|
||||
})
|
||||
option::map_default(
|
||||
ebml::maybe_get_doc(d, tag_class_mut),
|
||||
ast::class_immutable,
|
||||
|d| {
|
||||
alt ebml::doc_as_u8(d) as char {
|
||||
'm' { ast::class_mutable }
|
||||
_ { ast::class_immutable }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn variant_disr_val(d: ebml::doc) -> option<int> {
|
||||
do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) {|val_doc|
|
||||
do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
int::parse_buf(ebml::doc_data(val_doc), 10u)
|
||||
}
|
||||
}
|
||||
|
||||
fn doc_type(doc: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let tp = ebml::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx, {|did|
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx, |did| {
|
||||
translate_def_id(cdata, did)
|
||||
})
|
||||
}
|
||||
|
|
@ -157,7 +158,7 @@ fn item_type(item_id: ast::def_id, item: ebml::doc,
|
|||
fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
|
||||
-> option<ty::t> {
|
||||
let mut result = none;
|
||||
do ebml::tagged_docs(item, tag_impl_iface) {|ity|
|
||||
do ebml::tagged_docs(item, tag_impl_iface) |ity| {
|
||||
result = some(doc_type(ity, tcx, cdata));
|
||||
};
|
||||
result
|
||||
|
|
@ -166,8 +167,8 @@ fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
|
|||
fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
|
||||
-> @~[ty::param_bounds] {
|
||||
let mut bounds = ~[];
|
||||
do ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) {|p|
|
||||
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, {|did|
|
||||
do ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| {
|
||||
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, |did| {
|
||||
translate_def_id(cdata, did)
|
||||
});
|
||||
vec::push(bounds, bd);
|
||||
|
|
@ -190,14 +191,14 @@ fn item_ty_region_param(item: ebml::doc) -> ast::region_param {
|
|||
fn item_ty_param_count(item: ebml::doc) -> uint {
|
||||
let mut n = 0u;
|
||||
ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds,
|
||||
{|_p| n += 1u; });
|
||||
|_p| n += 1u );
|
||||
n
|
||||
}
|
||||
|
||||
fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
let mut ids: ~[ast::def_id] = ~[];
|
||||
let v = tag_items_data_item_variant;
|
||||
do ebml::tagged_docs(item, v) {|p|
|
||||
do ebml::tagged_docs(item, v) |p| {
|
||||
let ext = parse_def_id(ebml::doc_data(p));
|
||||
vec::push(ids, {crate: cdata.cnum, node: ext.node});
|
||||
};
|
||||
|
|
@ -213,10 +214,10 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] {
|
|||
let s = ast_util::path_name_i(path);
|
||||
let md = ebml::doc(data);
|
||||
let paths = ebml::get_doc(md, tag_paths);
|
||||
let eqer = {|a|eq_item(a, s)};
|
||||
let eqer = |a| eq_item(a, s);
|
||||
let mut result: ~[ast::def_id] = ~[];
|
||||
#debug("resolve_path: looking up %s", s);
|
||||
for lookup_hash(paths, eqer, hash_path(s)).each {|doc|
|
||||
for lookup_hash(paths, eqer, hash_path(s)).each |doc| {
|
||||
let did_doc = ebml::get_doc(doc, tag_def_id);
|
||||
vec::push(result, parse_def_id(ebml::doc_data(did_doc)));
|
||||
}
|
||||
|
|
@ -232,7 +233,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
|
|||
let mut result = ~[];
|
||||
vec::reserve(result, len);
|
||||
|
||||
do ebml::docs(path_doc) {|tag, elt_doc|
|
||||
do ebml::docs(path_doc) |tag, elt_doc| {
|
||||
if tag == tag_path_elt_mod {
|
||||
let str = ebml::doc_as_str(elt_doc);
|
||||
vec::push(result, ast_map::path_mod(@str));
|
||||
|
|
@ -306,7 +307,7 @@ fn get_impl_method(cdata: cmd, id: ast::node_id,
|
|||
name: ast::ident) -> ast::def_id {
|
||||
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
|
||||
let mut found = none;
|
||||
do ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid|
|
||||
do ebml::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| {
|
||||
let m_did = parse_def_id(ebml::doc_data(mid));
|
||||
if item_name(find_item(m_did.node, items)) == name {
|
||||
found = some(translate_def_id(cdata, m_did));
|
||||
|
|
@ -323,7 +324,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id,
|
|||
some(it) { it }
|
||||
none { fail (#fmt("get_class_method: class id not found \
|
||||
when looking up method %s", *name)) }};
|
||||
do ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid|
|
||||
do ebml::tagged_docs(cls_items, tag_item_iface_method) |mid| {
|
||||
let m_did = class_member_id(mid, cdata);
|
||||
if item_name(mid) == name {
|
||||
found = some(m_did);
|
||||
|
|
@ -343,7 +344,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> {
|
|||
none { fail (#fmt("class_dtor: class id not found \
|
||||
when looking up dtor for %d", id)); }
|
||||
};
|
||||
do ebml::tagged_docs(cls_items, tag_item_dtor) {|doc|
|
||||
do ebml::tagged_docs(cls_items, tag_item_dtor) |doc| {
|
||||
let doc1 = ebml::get_doc(doc, tag_def_id);
|
||||
let did = parse_def_id(ebml::doc_data(doc1));
|
||||
found = some(translate_def_id(cdata, did));
|
||||
|
|
@ -399,7 +400,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
let mut infos: ~[ty::variant_info] = ~[];
|
||||
let variant_ids = enum_variant_ids(item, cdata);
|
||||
let mut disr_val = 0;
|
||||
for variant_ids.each {|did|
|
||||
for variant_ids.each |did| {
|
||||
let item = find_item(did.node, items);
|
||||
let ctor_ty = item_type({crate: cdata.cnum, node: id}, item,
|
||||
tcx, cdata);
|
||||
|
|
@ -407,7 +408,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
let mut arg_tys: ~[ty::t] = ~[];
|
||||
alt ty::get(ctor_ty).struct {
|
||||
ty::ty_fn(f) {
|
||||
for f.inputs.each {|a| vec::push(arg_tys, a.ty); }
|
||||
for f.inputs.each |a| { vec::push(arg_tys, a.ty); }
|
||||
}
|
||||
_ { /* Nullary enum variant. */ }
|
||||
}
|
||||
|
|
@ -429,7 +430,7 @@ type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]};
|
|||
fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint)
|
||||
-> ~[@method_info] {
|
||||
let mut rslt = ~[];
|
||||
do ebml::tagged_docs(item, tag_item_impl_method) {|doc|
|
||||
do ebml::tagged_docs(item, tag_item_impl_method) |doc| {
|
||||
let m_did = parse_def_id(ebml::doc_data(doc));
|
||||
let mth_item = lookup_item(m_did.node, cdata.data);
|
||||
vec::push(rslt, @{did: translate_def_id(cdata, m_did),
|
||||
|
|
@ -447,7 +448,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
|
|||
let data = cdata.data;
|
||||
let mod_item = lookup_item(m_id, data);
|
||||
let mut result = ~[];
|
||||
do ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
|
||||
do ebml::tagged_docs(mod_item, tag_mod_impl) |doc| {
|
||||
let did = parse_def_id(ebml::doc_data(doc));
|
||||
let local_did = translate_def_id(cdata, did);
|
||||
// The impl may be defined in a different crate. Ask the caller
|
||||
|
|
@ -473,7 +474,7 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
let data = cdata.data;
|
||||
let item = lookup_item(id, data);
|
||||
let mut result = ~[];
|
||||
do ebml::tagged_docs(item, tag_item_iface_method) {|mth|
|
||||
do ebml::tagged_docs(item, tag_item_iface_method) |mth| {
|
||||
let bounds = item_ty_param_bounds(mth, tcx, cdata);
|
||||
let name = item_name(mth);
|
||||
let ty = doc_type(mth, tcx, cdata);
|
||||
|
|
@ -498,7 +499,7 @@ fn get_class_members(cdata: cmd, id: ast::node_id,
|
|||
let data = cdata.data;
|
||||
let item = lookup_item(id, data);
|
||||
let mut result = ~[];
|
||||
do ebml::tagged_docs(item, tag_item_field) {|an_item|
|
||||
do ebml::tagged_docs(item, tag_item_field) |an_item| {
|
||||
let f = item_family(an_item);
|
||||
if p(f) {
|
||||
let name = item_name(an_item);
|
||||
|
|
@ -520,7 +521,7 @@ pure fn family_to_visibility(family: char) -> ast::visibility {
|
|||
|
||||
/* 'g' for public field, 'j' for private field */
|
||||
fn get_class_fields(cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] {
|
||||
get_class_members(cdata, id, {|f| f == 'g' || f == 'j'})
|
||||
get_class_members(cdata, id, |f| f == 'g' || f == 'j')
|
||||
}
|
||||
|
||||
fn family_has_type_params(fam_ch: char) -> bool {
|
||||
|
|
@ -578,12 +579,12 @@ fn item_family_to_str(fam: char) -> str {
|
|||
|
||||
fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
|
||||
let mut items: ~[@ast::meta_item] = ~[];
|
||||
do ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc|
|
||||
do ebml::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
vec::push(items, attr::mk_word_item(@n));
|
||||
};
|
||||
do ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc|
|
||||
do ebml::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
|
|
@ -592,7 +593,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
|
|||
// but currently the encoder just drops them
|
||||
vec::push(items, attr::mk_name_value_item_str(@n, v));
|
||||
};
|
||||
do ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc|
|
||||
do ebml::tagged_docs(md, tag_meta_item_list) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
let n = str::from_bytes(ebml::doc_data(nd));
|
||||
let subitems = get_meta_items(meta_item_doc);
|
||||
|
|
@ -605,7 +606,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
|||
let mut attrs: ~[ast::attribute] = ~[];
|
||||
alt ebml::maybe_get_doc(md, tag_attributes) {
|
||||
option::some(attrs_d) {
|
||||
do ebml::tagged_docs(attrs_d, tag_attribute) {|attr_doc|
|
||||
do ebml::tagged_docs(attrs_d, tag_attribute) |attr_doc| {
|
||||
let meta_items = get_meta_items(attr_doc);
|
||||
// Currently it's only possible to have a single meta item on
|
||||
// an attribute
|
||||
|
|
@ -622,7 +623,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
|||
}
|
||||
|
||||
fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
|
||||
for get_meta_items(meta_items).each {|mi|
|
||||
for get_meta_items(meta_items).each |mi| {
|
||||
out.write_str(#fmt["%s\n", pprust::meta_item_to_str(*mi)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -630,7 +631,7 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
|
|||
fn list_crate_attributes(md: ebml::doc, hash: @str, out: io::writer) {
|
||||
out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash));
|
||||
|
||||
for get_attributes(md).each {|attr|
|
||||
for get_attributes(md).each |attr| {
|
||||
out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]);
|
||||
}
|
||||
|
||||
|
|
@ -652,7 +653,7 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] {
|
|||
fn docstr(doc: ebml::doc, tag_: uint) -> str {
|
||||
str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_)))
|
||||
}
|
||||
do ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc|
|
||||
do ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| {
|
||||
vec::push(deps, {cnum: crate_num,
|
||||
name: @docstr(depdoc, tag_crate_dep_name),
|
||||
vers: @docstr(depdoc, tag_crate_dep_vers),
|
||||
|
|
@ -665,7 +666,7 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] {
|
|||
fn list_crate_deps(data: @~[u8], out: io::writer) {
|
||||
out.write_str("=External Dependencies=\n");
|
||||
|
||||
for get_crate_deps(data).each {|dep|
|
||||
for get_crate_deps(data).each |dep| {
|
||||
out.write_str(#fmt["%d %s-%s-%s\n",
|
||||
dep.cnum, *dep.name, *dep.hash, *dep.vers]);
|
||||
}
|
||||
|
|
@ -691,7 +692,7 @@ fn get_crate_vers(data: @~[u8]) -> @str {
|
|||
fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) {
|
||||
out.write_str("=Items=\n");
|
||||
let items = ebml::get_doc(md, tag_items);
|
||||
do iter_crate_items(bytes) {|path, did|
|
||||
do iter_crate_items(bytes) |path, did| {
|
||||
out.write_str(#fmt["%s (%s)\n", path, describe_def(items, did)]);
|
||||
}
|
||||
out.write_str("\n");
|
||||
|
|
@ -702,9 +703,9 @@ fn iter_crate_items(bytes: @~[u8], proc: fn(str, ast::def_id)) {
|
|||
let paths = ebml::get_doc(md, tag_paths);
|
||||
let index = ebml::get_doc(paths, tag_index);
|
||||
let bs = ebml::get_doc(index, tag_index_buckets);
|
||||
do ebml::tagged_docs(bs, tag_index_buckets_bucket) {|bucket|
|
||||
do ebml::tagged_docs(bs, tag_index_buckets_bucket) |bucket| {
|
||||
let et = tag_index_buckets_bucket_elt;
|
||||
do ebml::tagged_docs(bucket, et) {|elt|
|
||||
do ebml::tagged_docs(bucket, et) |elt| {
|
||||
let data = read_path(elt);
|
||||
let {tag:_, doc:def} = ebml::doc_at(bytes, data.pos);
|
||||
let did_doc = ebml::get_doc(def, tag_def_id);
|
||||
|
|
@ -723,7 +724,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] {
|
|||
// fowarded path due to renamed import or reexport
|
||||
let mut res = ~[];
|
||||
let mods = map::str_hash();
|
||||
do iter_crate_items(bytes) {|path, did|
|
||||
do iter_crate_items(bytes) |path, did| {
|
||||
let m = mod_of_path(path);
|
||||
if str::is_not_empty(m) {
|
||||
// if m has a sub-item, it must be a module
|
||||
|
|
@ -734,7 +735,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] {
|
|||
// unified later by using the mods map
|
||||
vec::push(res, (did, path));
|
||||
}
|
||||
ret do vec::filter(res) {|x|
|
||||
ret do vec::filter(res) |x| {
|
||||
let (_, xp) = x;
|
||||
mods.contains_key(xp)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,20 +87,20 @@ fn encode_name_and_def_id(ebml_w: ebml::writer, nm: ident,
|
|||
}
|
||||
|
||||
fn encode_region_param(ebml_w: ebml::writer, rp: region_param) {
|
||||
do ebml_w.wr_tag(tag_region_param) {||
|
||||
do ebml_w.wr_tag(tag_region_param) || {
|
||||
serialize_region_param(ebml_w, rp)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) {
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name(ebml_w, name);
|
||||
encode_def_id(ebml_w, id);
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
|
||||
do ebml_w.wr_tag(tag_class_mut) {||
|
||||
do ebml_w.wr_tag(tag_class_mut) || {
|
||||
ebml_w.writer.write(&[alt mt { class_immutable { 'i' }
|
||||
class_mutable { 'm' } } as u8]);
|
||||
}
|
||||
|
|
@ -110,9 +110,9 @@ type entry<T> = {val: T, pos: uint};
|
|||
|
||||
fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: ~[variant],
|
||||
path: ~[ident], &index: ~[entry<str>]) {
|
||||
for variants.each {|variant|
|
||||
for variants.each |variant| {
|
||||
add_to_index(ebml_w, path, index, variant.node.name);
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name(ebml_w, variant.node.name);
|
||||
encode_def_id(ebml_w, local_def(variant.node.id));
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry<str>],
|
|||
|
||||
fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod,
|
||||
path: ~[ident], &index: ~[entry<str>]) {
|
||||
for nmod.items.each {|nitem|
|
||||
for nmod.items.each |nitem| {
|
||||
add_to_index(ebml_w, path, index, nitem.ident);
|
||||
encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id));
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod,
|
|||
|
||||
fn encode_class_item_paths(ebml_w: ebml::writer,
|
||||
items: ~[@class_member], path: ~[ident], &index: ~[entry<str>]) {
|
||||
for items.each {|it|
|
||||
for items.each |it| {
|
||||
alt ast_util::class_member_visibility(it) {
|
||||
private { cont; }
|
||||
public {
|
||||
|
|
@ -156,7 +156,7 @@ fn encode_class_item_paths(ebml_w: ebml::writer,
|
|||
fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
module: _mod, path: ~[ident],
|
||||
&index: ~[entry<str>]) {
|
||||
for module.items.each {|it|
|
||||
for module.items.each |it| {
|
||||
if !reachable(ecx, it.id) ||
|
||||
!ast_util::is_exported(it.ident, module) { cont; }
|
||||
if !ast_util::is_item_impl(it) {
|
||||
|
|
@ -170,7 +170,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
encode_named_def_id(ebml_w, it.ident, local_def(it.id));
|
||||
}
|
||||
item_mod(_mod) {
|
||||
do ebml_w.wr_tag(tag_paths_data_mod) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_mod) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
encode_module_item_paths(ebml_w, ecx, _mod,
|
||||
vec::append_one(path, it.ident),
|
||||
|
|
@ -178,7 +178,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
}
|
||||
}
|
||||
item_foreign_mod(nmod) {
|
||||
do ebml_w.wr_tag(tag_paths_data_mod) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_mod) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
encode_foreign_module_item_paths(
|
||||
ebml_w, nmod,
|
||||
|
|
@ -186,15 +186,15 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
}
|
||||
}
|
||||
item_ty(_, tps, _) {
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
}
|
||||
}
|
||||
item_class(_, _, items, ctor, m_dtor, _) {
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
}
|
||||
do ebml_w.wr_tag(tag_paths) {||
|
||||
do ebml_w.wr_tag(tag_paths) || {
|
||||
// We add the same ident twice: for the
|
||||
// class and for its ctor
|
||||
add_to_index(ebml_w, path, index, it.ident);
|
||||
|
|
@ -206,13 +206,13 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
}
|
||||
}
|
||||
item_enum(variants, _, _) {
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
}
|
||||
encode_enum_variant_paths(ebml_w, variants, path, index);
|
||||
}
|
||||
item_iface(*) {
|
||||
do ebml_w.wr_tag(tag_paths_data_item) {||
|
||||
do ebml_w.wr_tag(tag_paths_data_item) || {
|
||||
encode_name_and_def_id(ebml_w, it.ident, it.id);
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
|
|||
|
||||
fn encode_reexport_paths(ebml_w: ebml::writer,
|
||||
ecx: @encode_ctxt, &index: ~[entry<str>]) {
|
||||
for ecx.reexports.each {|reexport|
|
||||
for ecx.reexports.each |reexport| {
|
||||
let (path, def_id) = reexport;
|
||||
vec::push(index, {val: path, pos: ebml_w.writer.tell()});
|
||||
ebml_w.start_tag(tag_paths_data_item);
|
||||
|
|
@ -265,9 +265,9 @@ fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
let ty_str_ctxt = @{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: ecx.tcx,
|
||||
reachable: {|a|reachable(ecx, a)},
|
||||
reachable: |a| reachable(ecx, a),
|
||||
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
|
||||
for params.each {|param|
|
||||
for params.each |param| {
|
||||
ebml_w.start_tag(tag_items_data_item_ty_param_bounds);
|
||||
let bs = ecx.tcx.ty_param_bounds.get(param.id);
|
||||
tyencode::enc_bounds(ebml_w.writer, ty_str_ctxt, bs);
|
||||
|
|
@ -286,7 +286,7 @@ fn write_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) {
|
|||
@{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: ecx.tcx,
|
||||
reachable: {|a|reachable(ecx, a)},
|
||||
reachable: |a| reachable(ecx, a),
|
||||
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
|
||||
tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ);
|
||||
}
|
||||
|
|
@ -335,7 +335,7 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
let mut disr_val = 0;
|
||||
let mut i = 0;
|
||||
let vi = ty::enum_variants(ecx.tcx, {crate: local_crate, node: id});
|
||||
for variants.each {|variant|
|
||||
for variants.each |variant| {
|
||||
vec::push(*index, {val: variant.node.id, pos: ebml_w.writer.tell()});
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(variant.node.id));
|
||||
|
|
@ -372,9 +372,9 @@ fn encode_path(ebml_w: ebml::writer,
|
|||
ebml_w.wr_tagged_str(tag, *name);
|
||||
}
|
||||
|
||||
do ebml_w.wr_tag(tag_path) {||
|
||||
do ebml_w.wr_tag(tag_path) || {
|
||||
ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32);
|
||||
do vec::iter(path) {|pe| encode_path_elt(ebml_w, pe); }
|
||||
do vec::iter(path) |pe| { encode_path_elt(ebml_w, pe); }
|
||||
encode_path_elt(ebml_w, name);
|
||||
}
|
||||
}
|
||||
|
|
@ -386,7 +386,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
|
|||
encode_family(ebml_w, 'm');
|
||||
encode_name(ebml_w, name);
|
||||
let impls = ecx.impl_map(id);
|
||||
for impls.each {|i|
|
||||
for impls.each |i| {
|
||||
let (ident, did) = i;
|
||||
if ast_util::is_exported(ident, md) {
|
||||
ebml_w.start_tag(tag_mod_impl);
|
||||
|
|
@ -432,7 +432,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
may have fields with the same name */
|
||||
let index = @mut ~[];
|
||||
let tcx = ecx.tcx;
|
||||
for items.each {|ci|
|
||||
for items.each |ci| {
|
||||
/* We encode both private and public fields -- need to include
|
||||
private fields to get the offsets right */
|
||||
alt ci.node {
|
||||
|
|
@ -547,7 +547,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
index: @mut ~[entry<int>]) {
|
||||
vec::push(*index, {val: item.id, pos: ebml_w.writer.tell()});
|
||||
}
|
||||
let add_to_index = {|copy ebml_w|add_to_index_(item, ebml_w, index)};
|
||||
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
|
||||
|
||||
alt item.node {
|
||||
item_const(_, _) {
|
||||
|
|
@ -602,13 +602,13 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
}
|
||||
item_enum(variants, tps, rp) {
|
||||
add_to_index();
|
||||
do ebml_w.wr_tag(tag_items_data_item) {||
|
||||
do ebml_w.wr_tag(tag_items_data_item) || {
|
||||
encode_def_id(ebml_w, local_def(item.id));
|
||||
encode_family(ebml_w, 't');
|
||||
encode_type_param_bounds(ebml_w, ecx, tps);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
|
||||
encode_name(ebml_w, item.ident);
|
||||
for variants.each {|v|
|
||||
for variants.each |v| {
|
||||
encode_variant_id(ebml_w, local_def(v.node.id));
|
||||
}
|
||||
ecx.encode_inlined_item(ecx, ebml_w, path, ii_item(item));
|
||||
|
|
@ -626,7 +626,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
let idx = encode_info_for_class(ecx, ebml_w, item.id, path, tps,
|
||||
items, index);
|
||||
/* Encode the dtor */
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()});
|
||||
encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
|
||||
+ "_dtor"), path, if tps.len() > 0u {
|
||||
|
|
@ -646,13 +646,13 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
encode_name(ebml_w, item.ident);
|
||||
encode_path(ebml_w, path, ast_map::path_name(item.ident));
|
||||
encode_region_param(ebml_w, rp);
|
||||
for ifaces.each {|t|
|
||||
for ifaces.each |t| {
|
||||
encode_iface_ref(ebml_w, ecx, t);
|
||||
}
|
||||
/* Encode the dtor */
|
||||
/* Encode id for dtor */
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do ebml_w.wr_tag(tag_item_dtor) {||
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
do ebml_w.wr_tag(tag_item_dtor) || {
|
||||
encode_def_id(ebml_w, local_def(dtor.node.id));
|
||||
}
|
||||
};
|
||||
|
|
@ -661,14 +661,14 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
for methods, write all the stuff get_iface_method
|
||||
needs to know*/
|
||||
let (fs,ms) = ast_util::split_class_items(items);
|
||||
for fs.each {|f|
|
||||
for fs.each |f| {
|
||||
ebml_w.start_tag(tag_item_field);
|
||||
encode_visibility(ebml_w, f.vis);
|
||||
encode_name(ebml_w, f.ident);
|
||||
encode_def_id(ebml_w, local_def(f.id));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
for ms.each {|m|
|
||||
for ms.each |m| {
|
||||
alt m.vis {
|
||||
private { /* do nothing */ }
|
||||
public {
|
||||
|
|
@ -703,12 +703,12 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
encode_type_param_bounds(ebml_w, ecx, tps);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
|
||||
encode_name(ebml_w, item.ident);
|
||||
for methods.each {|m|
|
||||
for methods.each |m| {
|
||||
ebml_w.start_tag(tag_item_impl_method);
|
||||
ebml_w.writer.write(str::bytes(def_to_str(local_def(m.id))));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
do option::iter(ifce) {|t|
|
||||
do option::iter(ifce) |t| {
|
||||
encode_iface_ref(ebml_w, ecx, t)
|
||||
};
|
||||
encode_path(ebml_w, path, ast_map::path_name(item.ident));
|
||||
|
|
@ -716,7 +716,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
|
||||
let impl_path = vec::append_one(path,
|
||||
ast_map::path_name(item.ident));
|
||||
for methods.each {|m|
|
||||
for methods.each |m| {
|
||||
vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()});
|
||||
encode_info_for_method(ecx, ebml_w, impl_path,
|
||||
should_inline(m.attrs), item.id, m,
|
||||
|
|
@ -733,7 +733,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
|
||||
encode_name(ebml_w, item.ident);
|
||||
let mut i = 0u;
|
||||
for vec::each(*ty::iface_methods(tcx, local_def(item.id))) {|mty|
|
||||
for vec::each(*ty::iface_methods(tcx, local_def(item.id))) |mty| {
|
||||
ebml_w.start_tag(tag_item_iface_method);
|
||||
encode_name(ebml_w, mty.ident);
|
||||
encode_type_param_bounds(ebml_w, ecx, ms[i].tps);
|
||||
|
|
@ -782,8 +782,8 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
encode_info_for_mod(ecx, ebml_w, crate.node.module,
|
||||
crate_node_id, ~[], @"");
|
||||
visit::visit_crate(*crate, (), visit::mk_vt(@{
|
||||
visit_expr: {|_e, _cx, _v|},
|
||||
visit_item: {|i, cx, v, copy ebml_w|
|
||||
visit_expr: |_e, _cx, _v| { },
|
||||
visit_item: |i, cx, v, copy ebml_w| {
|
||||
visit::visit_item(i, cx, v);
|
||||
alt check ecx.tcx.items.get(i.id) {
|
||||
ast_map::node_item(_, pt) {
|
||||
|
|
@ -806,7 +806,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
}
|
||||
}
|
||||
},
|
||||
visit_foreign_item: {|ni, cx, v, copy ebml_w|
|
||||
visit_foreign_item: |ni, cx, v, copy ebml_w| {
|
||||
visit::visit_foreign_item(ni, cx, v);
|
||||
alt check ecx.tcx.items.get(ni.id) {
|
||||
ast_map::node_foreign_item(_, abi, pt) {
|
||||
|
|
@ -827,14 +827,14 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
fn create_index<T: copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
|
||||
~[@~[entry<T>]] {
|
||||
let mut buckets: ~[@mut ~[entry<T>]] = ~[];
|
||||
for uint::range(0u, 256u) {|_i| vec::push(buckets, @mut ~[]); };
|
||||
for index.each {|elt|
|
||||
for uint::range(0u, 256u) |_i| { vec::push(buckets, @mut ~[]); };
|
||||
for index.each |elt| {
|
||||
let h = hash_fn(elt.val);
|
||||
vec::push(*buckets[h % 256u], elt);
|
||||
}
|
||||
|
||||
let mut buckets_frozen = ~[];
|
||||
for buckets.each {|bucket|
|
||||
for buckets.each |bucket| {
|
||||
vec::push(buckets_frozen, @*bucket);
|
||||
}
|
||||
ret buckets_frozen;
|
||||
|
|
@ -846,10 +846,10 @@ fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]],
|
|||
ebml_w.start_tag(tag_index);
|
||||
let mut bucket_locs: ~[uint] = ~[];
|
||||
ebml_w.start_tag(tag_index_buckets);
|
||||
for buckets.each {|bucket|
|
||||
for buckets.each |bucket| {
|
||||
vec::push(bucket_locs, ebml_w.writer.tell());
|
||||
ebml_w.start_tag(tag_index_buckets_bucket);
|
||||
for vec::each(*bucket) {|elt|
|
||||
for vec::each(*bucket) |elt| {
|
||||
ebml_w.start_tag(tag_index_buckets_bucket_elt);
|
||||
writer.write_be_uint(elt.pos, 4u);
|
||||
write_fn(writer, elt.val);
|
||||
|
|
@ -859,7 +859,7 @@ fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]],
|
|||
}
|
||||
ebml_w.end_tag();
|
||||
ebml_w.start_tag(tag_index_table);
|
||||
for bucket_locs.each {|pos| writer.write_be_uint(pos, 4u); }
|
||||
for bucket_locs.each |pos| { writer.write_be_uint(pos, 4u); }
|
||||
ebml_w.end_tag();
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
|
@ -899,7 +899,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
|
|||
ebml_w.start_tag(tag_meta_item_name);
|
||||
ebml_w.writer.write(str::bytes(*name));
|
||||
ebml_w.end_tag();
|
||||
for items.each {|inner_item|
|
||||
for items.each |inner_item| {
|
||||
encode_meta_item(ebml_w, *inner_item);
|
||||
}
|
||||
ebml_w.end_tag();
|
||||
|
|
@ -909,7 +909,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
|
|||
|
||||
fn encode_attributes(ebml_w: ebml::writer, attrs: ~[attribute]) {
|
||||
ebml_w.start_tag(tag_attributes);
|
||||
for attrs.each {|attr|
|
||||
for attrs.each |attr| {
|
||||
ebml_w.start_tag(tag_attribute);
|
||||
encode_meta_item(ebml_w, attr.node.value);
|
||||
ebml_w.end_tag();
|
||||
|
|
@ -948,7 +948,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
|
|||
|
||||
let mut attrs: ~[attribute] = ~[];
|
||||
let mut found_link_attr = false;
|
||||
for crate.node.attrs.each {|attr|
|
||||
for crate.node.attrs.each |attr| {
|
||||
vec::push(
|
||||
attrs,
|
||||
if *attr::get_attr_name(attr) != "link" {
|
||||
|
|
@ -977,7 +977,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
|||
|
||||
// Pull the cnums and name,vers,hash out of cstore
|
||||
let mut deps: ~[mut numdep] = ~[mut];
|
||||
do cstore::iter_crate_data(cstore) {|key, val|
|
||||
do cstore::iter_crate_data(cstore) |key, val| {
|
||||
let dep = {cnum: key, name: @val.name,
|
||||
vers: decoder::get_crate_vers(val.data),
|
||||
hash: decoder::get_crate_hash(val.data)};
|
||||
|
|
@ -990,7 +990,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
|||
|
||||
// Sanity-check the crate numbers
|
||||
let mut expected_cnum = 1;
|
||||
for deps.each {|n|
|
||||
for deps.each |n| {
|
||||
assert (n.cnum == expected_cnum);
|
||||
expected_cnum += 1;
|
||||
}
|
||||
|
|
@ -1004,7 +1004,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
|||
// FIXME (#2166): This is not nearly enough to support correct versioning
|
||||
// but is enough to get transitive crate dependencies working.
|
||||
ebml_w.start_tag(tag_crate_deps);
|
||||
for get_ordered_deps(cstore).each {|dep|
|
||||
for get_ordered_deps(cstore).each |dep| {
|
||||
encode_crate_dep(ebml_w, dep);
|
||||
}
|
||||
ebml_w.end_tag();
|
||||
|
|
@ -1081,7 +1081,7 @@ fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> str {
|
|||
let cx = @{diag: tcx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: tcx,
|
||||
reachable: {|_id| false},
|
||||
reachable: |_id| false,
|
||||
abbrevs: tyencode::ac_no_abbrevs};
|
||||
let buf = io::mem_buffer();
|
||||
tyencode::enc_ty(io::mem_buffer_writer(buf), cx, t);
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ fn mk_filesearch(maybe_sysroot: option<path>,
|
|||
|
||||
fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> {
|
||||
let mut rslt = none;
|
||||
for filesearch.lib_search_paths().each {|lib_search_path|
|
||||
for filesearch.lib_search_paths().each |lib_search_path| {
|
||||
#debug("searching %s", lib_search_path);
|
||||
for os::list_dir_path(lib_search_path).each {|path|
|
||||
for os::list_dir_path(lib_search_path).each |path| {
|
||||
#debug("testing %s", path);
|
||||
let maybe_picked = pick(path);
|
||||
if option::is_some(maybe_picked) {
|
||||
|
|
@ -134,7 +134,7 @@ fn get_cargo_root() -> result<path, str> {
|
|||
}
|
||||
|
||||
fn get_cargo_root_nearest() -> result<path, str> {
|
||||
do result::chain(get_cargo_root()) { |p|
|
||||
do result::chain(get_cargo_root()) |p| {
|
||||
let cwd = os::getcwd();
|
||||
let mut dirname = path::dirname(cwd);
|
||||
let mut dirpath = path::split(dirname);
|
||||
|
|
@ -158,13 +158,13 @@ fn get_cargo_root_nearest() -> result<path, str> {
|
|||
}
|
||||
|
||||
fn get_cargo_lib_path() -> result<path, str> {
|
||||
do result::chain(get_cargo_root()) { |p|
|
||||
do result::chain(get_cargo_root()) |p| {
|
||||
result::ok(path::connect(p, libdir()))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_cargo_lib_path_nearest() -> result<path, str> {
|
||||
do result::chain(get_cargo_root_nearest()) { |p|
|
||||
do result::chain(get_cargo_root_nearest()) |p| {
|
||||
result::ok(path::connect(p, libdir()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ fn find_library_crate_aux(cx: ctxt,
|
|||
let suffix: str = nn.suffix;
|
||||
|
||||
let mut matches = ~[];
|
||||
filesearch::search(filesearch, { |path|
|
||||
filesearch::search(filesearch, |path| {
|
||||
#debug("inspecting file %s", path);
|
||||
let f: str = path::basename(path);
|
||||
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
|
||||
|
|
@ -109,7 +109,7 @@ fn find_library_crate_aux(cx: ctxt,
|
|||
cx.diag.span_err(
|
||||
cx.span, #fmt("multiple matching crates for `%s`", *crate_name));
|
||||
cx.diag.handler().note("candidates:");
|
||||
for matches.each {|match|
|
||||
for matches.each |match| {
|
||||
cx.diag.handler().note(#fmt("path: %s", match.ident));
|
||||
let attrs = decoder::get_crate_attributes(match.data);
|
||||
note_linkage_attrs(cx.diag, attrs);
|
||||
|
|
@ -135,7 +135,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @str {
|
|||
}
|
||||
|
||||
fn note_linkage_attrs(diag: span_handler, attrs: ~[ast::attribute]) {
|
||||
for attr::find_linkage_attrs(attrs).each {|attr|
|
||||
for attr::find_linkage_attrs(attrs).each |attr| {
|
||||
diag.handler().note(#fmt("meta: %s", pprust::attr_to_str(attr)));
|
||||
}
|
||||
}
|
||||
|
|
@ -158,11 +158,11 @@ fn metadata_matches(extern_metas: ~[@ast::meta_item],
|
|||
vec::len(local_metas), vec::len(extern_metas));
|
||||
|
||||
#debug("crate metadata:");
|
||||
for extern_metas.each {|have|
|
||||
for extern_metas.each |have| {
|
||||
#debug(" %s", pprust::meta_item_to_str(*have));
|
||||
}
|
||||
|
||||
for local_metas.each {|needed|
|
||||
for local_metas.each |needed| {
|
||||
#debug("looking for %s", pprust::meta_item_to_str(*needed));
|
||||
if !attr::contains(extern_metas, needed) {
|
||||
#debug("missing %s", pprust::meta_item_to_str(*needed));
|
||||
|
|
@ -174,7 +174,7 @@ fn metadata_matches(extern_metas: ~[@ast::meta_item],
|
|||
|
||||
fn get_metadata_section(os: os,
|
||||
filename: str) -> option<@~[u8]> unsafe {
|
||||
let mb = str::as_c_str(filename, {|buf|
|
||||
let mb = str::as_c_str(filename, |buf| {
|
||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||
});
|
||||
if mb as int == 0 { ret option::none::<@~[u8]>; }
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn next_byte(st: @pstate) -> u8 {
|
|||
|
||||
fn parse_ident(st: @pstate, last: char) -> ast::ident {
|
||||
fn is_last(b: char, c: char) -> bool { ret c == b; }
|
||||
ret parse_ident_(st, {|a|is_last(last, a)});
|
||||
ret parse_ident_(st, |a| is_last(last, a) );
|
||||
}
|
||||
|
||||
fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
|
||||
|
|
@ -192,9 +192,9 @@ fn parse_vstore(st: @pstate) -> ty::vstore {
|
|||
}
|
||||
|
||||
fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs {
|
||||
let self_r = parse_opt(st, {|| parse_region(st) });
|
||||
let self_r = parse_opt(st, || parse_region(st) );
|
||||
|
||||
let self_ty = parse_opt(st, {|| parse_ty(st, conv) });
|
||||
let self_ty = parse_opt(st, || parse_ty(st, conv) );
|
||||
|
||||
assert next(st) == '[';
|
||||
let mut params: [ty::t]/~ = []/~;
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ fn enc_opt<T>(w: io::writer, t: option<T>, enc_f: fn(T)) {
|
|||
}
|
||||
|
||||
fn enc_substs(w: io::writer, cx: @ctxt, substs: ty::substs) {
|
||||
do enc_opt(w, substs.self_r) { |r| enc_region(w, cx, r) }
|
||||
do enc_opt(w, substs.self_ty) { |t| enc_ty(w, cx, t) }
|
||||
do enc_opt(w, substs.self_r) |r| { enc_region(w, cx, r) }
|
||||
do enc_opt(w, substs.self_ty) |t| { enc_ty(w, cx, t) }
|
||||
w.write_char('[');
|
||||
for substs.tps.each { |t| enc_ty(w, cx, t); }
|
||||
for substs.tps.each |t| { enc_ty(w, cx, t); }
|
||||
w.write_char(']');
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
|||
}
|
||||
ty::ty_tup(ts) {
|
||||
w.write_str("T["/&);
|
||||
for ts.each {|t| enc_ty(w, cx, t); }
|
||||
for ts.each |t| { enc_ty(w, cx, t); }
|
||||
w.write_char(']');
|
||||
}
|
||||
ty::ty_box(mt) { w.write_char('@'); enc_mt(w, cx, mt); }
|
||||
|
|
@ -255,7 +255,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
|||
ty::ty_unboxed_vec(mt) { w.write_char('U'); enc_mt(w, cx, mt); }
|
||||
ty::ty_rec(fields) {
|
||||
w.write_str("R["/&);
|
||||
for fields.each {|field|
|
||||
for fields.each |field| {
|
||||
w.write_str(*field.ident);
|
||||
w.write_char('=');
|
||||
enc_mt(w, cx, field.mt);
|
||||
|
|
@ -290,7 +290,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
|||
ty::ty_constr(ty, cs) {
|
||||
w.write_str("A["/&);
|
||||
enc_ty(w, cx, ty);
|
||||
for cs.each {|tc| enc_ty_constr(w, cx, tc); }
|
||||
for cs.each |tc| { enc_ty_constr(w, cx, tc); }
|
||||
w.write_char(']');
|
||||
}
|
||||
ty::ty_opaque_box { w.write_char('B'); }
|
||||
|
|
@ -341,13 +341,13 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) {
|
|||
enc_proto(w, ft.proto);
|
||||
enc_purity(w, ft.purity);
|
||||
w.write_char('[');
|
||||
for ft.inputs.each {|arg|
|
||||
for ft.inputs.each |arg| {
|
||||
enc_mode(w, cx, arg.mode);
|
||||
enc_ty(w, cx, arg.ty);
|
||||
}
|
||||
w.write_char(']');
|
||||
let mut colon = true;
|
||||
for ft.constraints.each {|c|
|
||||
for ft.constraints.each |c| {
|
||||
if colon {
|
||||
w.write_char(':');
|
||||
colon = false;
|
||||
|
|
@ -368,7 +368,7 @@ fn enc_constr_gen<T>(w: io::writer, cx: @ctxt,
|
|||
w.write_str(cx.ds(c.node.id));
|
||||
w.write_char('|');
|
||||
let mut semi = false;
|
||||
for c.node.args.each {|a|
|
||||
for c.node.args.each |a| {
|
||||
if semi { w.write_char(';'); } else { semi = true; }
|
||||
write_arg(a);
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ fn enc_constr_gen<T>(w: io::writer, cx: @ctxt,
|
|||
}
|
||||
|
||||
fn enc_constr(w: io::writer, cx: @ctxt, c: @ty::constr) {
|
||||
enc_constr_gen(w, cx, c, {|a|
|
||||
enc_constr_gen(w, cx, c, |a| {
|
||||
alt a.node {
|
||||
carg_base { w.write_char('*'); }
|
||||
carg_ident(i) { w.write_uint(i); }
|
||||
|
|
@ -386,7 +386,7 @@ fn enc_constr(w: io::writer, cx: @ctxt, c: @ty::constr) {
|
|||
}
|
||||
|
||||
fn enc_ty_constr(w: io::writer, cx: @ctxt, c: @ty::type_constr) {
|
||||
enc_constr_gen(w, cx, c, {|a|
|
||||
enc_constr_gen(w, cx, c, |a| {
|
||||
alt a.node {
|
||||
carg_base { w.write_char('*'); }
|
||||
carg_ident(p) { w.write_str(path_to_str(p)); }
|
||||
|
|
@ -396,7 +396,7 @@ fn enc_ty_constr(w: io::writer, cx: @ctxt, c: @ty::type_constr) {
|
|||
}
|
||||
|
||||
fn enc_bounds(w: io::writer, cx: @ctxt, bs: @~[ty::param_bound]) {
|
||||
for vec::each(*bs) {|bound|
|
||||
for vec::each(*bs) |bound| {
|
||||
alt bound {
|
||||
ty::bound_send { w.write_char('S'); }
|
||||
ty::bound_copy { w.write_char('C'); }
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
|
|||
ebml_w.writer.tell()];
|
||||
|
||||
let id_range = ast_util::compute_id_range_for_inlined_item(ii);
|
||||
do ebml_w.wr_tag(c::tag_ast as uint) {||
|
||||
do ebml_w.wr_tag(c::tag_ast as uint) || {
|
||||
ast_util::serialize_id_range(ebml_w, id_range);
|
||||
encode_ast(ebml_w, simplify_ast(ii));
|
||||
encode_side_tables_for_ii(ecx, maps, ebml_w, ii);
|
||||
|
|
@ -210,7 +210,7 @@ impl deserializer_helpers<D: deserializer> for D {
|
|||
// but eventually we should add entries to the local codemap as required.
|
||||
|
||||
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {||
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) || {
|
||||
ast::serialize_inlined_item(ebml_w, item)
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
|||
// inlined items.
|
||||
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
|
||||
let stmts_sans_items = do vec::filter(blk.stmts) {|stmt|
|
||||
let stmts_sans_items = do vec::filter(blk.stmts) |stmt| {
|
||||
alt stmt.node {
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
|
||||
ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) { true }
|
||||
|
|
@ -278,8 +278,8 @@ fn decode_ast(par_doc: ebml::doc) -> ast::inlined_item {
|
|||
fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||
-> ast::inlined_item {
|
||||
let fld = fold::make_fold(@{
|
||||
new_id: {|a|xcx.tr_id(a)},
|
||||
new_span: {|a|xcx.tr_span(a)}
|
||||
new_id: |a| xcx.tr_id(a),
|
||||
new_span: |a| xcx.tr_span(a)
|
||||
with *fold::default_ast_fold()
|
||||
});
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
|
|||
// ty::t doesn't work, and there is no way (atm) to have
|
||||
// hand-written serialization routines combine with auto-generated
|
||||
// ones. perhaps we should fix this.
|
||||
do ebml_w.emit_from_vec(*dr) {|vtable_origin|
|
||||
do ebml_w.emit_from_vec(*dr) |vtable_origin| {
|
||||
encode_vtable_origin(ecx, ebml_w, vtable_origin)
|
||||
}
|
||||
}
|
||||
|
|
@ -433,37 +433,37 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
|
|||
fn encode_vtable_origin(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::writer,
|
||||
vtable_origin: typeck::vtable_origin) {
|
||||
do ebml_w.emit_enum("vtable_origin") {||
|
||||
do ebml_w.emit_enum("vtable_origin") || {
|
||||
alt vtable_origin {
|
||||
typeck::vtable_static(def_id, tys, vtable_res) {
|
||||
do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) {||
|
||||
do ebml_w.emit_enum_variant_arg(0u) {||
|
||||
do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) || {
|
||||
do ebml_w.emit_enum_variant_arg(0u) || {
|
||||
ebml_w.emit_def_id(def_id)
|
||||
}
|
||||
do ebml_w.emit_enum_variant_arg(1u) {||
|
||||
do ebml_w.emit_enum_variant_arg(1u) || {
|
||||
ebml_w.emit_tys(ecx, tys);
|
||||
}
|
||||
do ebml_w.emit_enum_variant_arg(2u) {||
|
||||
do ebml_w.emit_enum_variant_arg(2u) || {
|
||||
encode_vtable_res(ecx, ebml_w, vtable_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
typeck::vtable_param(pn, bn) {
|
||||
do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) {||
|
||||
do ebml_w.emit_enum_variant_arg(0u) {||
|
||||
do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) || {
|
||||
do ebml_w.emit_enum_variant_arg(0u) || {
|
||||
ebml_w.emit_uint(pn);
|
||||
}
|
||||
do ebml_w.emit_enum_variant_arg(1u) {||
|
||||
do ebml_w.emit_enum_variant_arg(1u) || {
|
||||
ebml_w.emit_uint(bn);
|
||||
}
|
||||
}
|
||||
}
|
||||
typeck::vtable_iface(def_id, tys) {
|
||||
do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) {||
|
||||
do ebml_w.emit_enum_variant_arg(0u) {||
|
||||
do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) || {
|
||||
do ebml_w.emit_enum_variant_arg(0u) || {
|
||||
ebml_w.emit_def_id(def_id)
|
||||
}
|
||||
do ebml_w.emit_enum_variant_arg(1u) {||
|
||||
do ebml_w.emit_enum_variant_arg(1u) || {
|
||||
ebml_w.emit_tys(ecx, tys);
|
||||
}
|
||||
}
|
||||
|
|
@ -475,43 +475,43 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt,
|
|||
|
||||
impl helpers for ebml::ebml_deserializer {
|
||||
fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
|
||||
@self.read_to_vec({|| self.read_vtable_origin(xcx) })
|
||||
@self.read_to_vec(|| self.read_vtable_origin(xcx) )
|
||||
}
|
||||
|
||||
fn read_vtable_origin(xcx: extended_decode_ctxt)
|
||||
-> typeck::vtable_origin {
|
||||
do self.read_enum("vtable_origin") {||
|
||||
do self.read_enum_variant {|i|
|
||||
do self.read_enum("vtable_origin") || {
|
||||
do self.read_enum_variant |i| {
|
||||
alt check i {
|
||||
0u {
|
||||
typeck::vtable_static(
|
||||
do self.read_enum_variant_arg(0u) {||
|
||||
do self.read_enum_variant_arg(0u) || {
|
||||
self.read_def_id(xcx)
|
||||
},
|
||||
do self.read_enum_variant_arg(1u) {||
|
||||
do self.read_enum_variant_arg(1u) || {
|
||||
self.read_tys(xcx)
|
||||
},
|
||||
do self.read_enum_variant_arg(2u) {||
|
||||
do self.read_enum_variant_arg(2u) || {
|
||||
self.read_vtable_res(xcx)
|
||||
}
|
||||
)
|
||||
}
|
||||
1u {
|
||||
typeck::vtable_param(
|
||||
do self.read_enum_variant_arg(0u) {||
|
||||
do self.read_enum_variant_arg(0u) || {
|
||||
self.read_uint()
|
||||
},
|
||||
do self.read_enum_variant_arg(1u) {||
|
||||
do self.read_enum_variant_arg(1u) || {
|
||||
self.read_uint()
|
||||
}
|
||||
)
|
||||
}
|
||||
2u {
|
||||
typeck::vtable_iface(
|
||||
do self.read_enum_variant_arg(0u) {||
|
||||
do self.read_enum_variant_arg(0u) || {
|
||||
self.read_def_id(xcx)
|
||||
},
|
||||
do self.read_enum_variant_arg(1u) {||
|
||||
do self.read_enum_variant_arg(1u) || {
|
||||
self.read_tys(xcx)
|
||||
}
|
||||
)
|
||||
|
|
@ -530,7 +530,7 @@ impl helpers for @e::encode_ctxt {
|
|||
@{diag: self.tcx.sess.diagnostic(),
|
||||
ds: e::def_to_str,
|
||||
tcx: self.tcx,
|
||||
reachable: {|a|encoder::reachable(self, a)},
|
||||
reachable: |a| encoder::reachable(self, a),
|
||||
abbrevs: tyencode::ac_use_abbrevs(self.type_abbrevs)}
|
||||
}
|
||||
}
|
||||
|
|
@ -541,7 +541,7 @@ impl helpers for ebml::writer {
|
|||
}
|
||||
|
||||
fn emit_tys(ecx: @e::encode_ctxt, tys: ~[ty::t]) {
|
||||
do self.emit_from_vec(tys) {|ty|
|
||||
do self.emit_from_vec(tys) |ty| {
|
||||
e::write_type(ecx, self, ty)
|
||||
}
|
||||
}
|
||||
|
|
@ -551,16 +551,16 @@ impl helpers for ebml::writer {
|
|||
}
|
||||
|
||||
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) {
|
||||
do self.emit_rec {||
|
||||
do self.emit_rec_field("bounds", 0u) {||
|
||||
do self.emit_from_vec(*tpbt.bounds) {|bs|
|
||||
do self.emit_rec || {
|
||||
do self.emit_rec_field("bounds", 0u) || {
|
||||
do self.emit_from_vec(*tpbt.bounds) |bs| {
|
||||
self.emit_bounds(ecx, bs)
|
||||
}
|
||||
}
|
||||
do self.emit_rec_field("rp", 1u) {||
|
||||
do self.emit_rec_field("rp", 1u) || {
|
||||
ast::serialize_region_param(self, tpbt.rp)
|
||||
}
|
||||
do self.emit_rec_field("ty", 2u) {||
|
||||
do self.emit_rec_field("ty", 2u) || {
|
||||
self.emit_ty(ecx, tpbt.ty);
|
||||
}
|
||||
}
|
||||
|
|
@ -569,7 +569,7 @@ impl helpers for ebml::writer {
|
|||
|
||||
impl writer for ebml::writer {
|
||||
fn tag(tag_id: c::astencode_tag, f: fn()) {
|
||||
do self.wr_tag(tag_id as uint) {|| f() }
|
||||
do self.wr_tag(tag_id as uint) || { f() }
|
||||
}
|
||||
|
||||
fn id(id: ast::node_id) {
|
||||
|
|
@ -581,7 +581,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
|
|||
maps: maps,
|
||||
ebml_w: ebml::writer,
|
||||
ii: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_table as uint) {||
|
||||
do ebml_w.wr_tag(c::tag_table as uint) || {
|
||||
ast_util::visit_ids_for_inlined_item(
|
||||
ii,
|
||||
fn@(id: ast::node_id, copy ebml_w) {
|
||||
|
|
@ -601,37 +601,37 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||
|
||||
#debug["Encoding side tables for id %d", id];
|
||||
|
||||
do option::iter(tcx.def_map.find(id)) {|def|
|
||||
do ebml_w.tag(c::tag_table_def) {||
|
||||
do option::iter(tcx.def_map.find(id)) |def| {
|
||||
do ebml_w.tag(c::tag_table_def) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
ast::serialize_def(ebml_w, def)
|
||||
}
|
||||
}
|
||||
}
|
||||
do option::iter((*tcx.node_types).find(id as uint)) {|ty|
|
||||
do ebml_w.tag(c::tag_table_node_type) {||
|
||||
do option::iter((*tcx.node_types).find(id as uint)) |ty| {
|
||||
do ebml_w.tag(c::tag_table_node_type) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
e::write_type(ecx, ebml_w, ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.node_type_substs.find(id)) {|tys|
|
||||
do ebml_w.tag(c::tag_table_node_type_subst) {||
|
||||
do option::iter(tcx.node_type_substs.find(id)) |tys| {
|
||||
do ebml_w.tag(c::tag_table_node_type_subst) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
ebml_w.emit_tys(ecx, tys)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.freevars.find(id)) {|fv|
|
||||
do ebml_w.tag(c::tag_table_freevars) {||
|
||||
do option::iter(tcx.freevars.find(id)) |fv| {
|
||||
do ebml_w.tag(c::tag_table_freevars) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.emit_from_vec(*fv) {|fv_entry|
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
do ebml_w.emit_from_vec(*fv) |fv_entry| {
|
||||
encode_freevar_entry(ebml_w, *fv_entry)
|
||||
}
|
||||
}
|
||||
|
|
@ -639,19 +639,19 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||
}
|
||||
|
||||
let lid = {crate: ast::local_crate, node: id};
|
||||
do option::iter(tcx.tcache.find(lid)) {|tpbt|
|
||||
do ebml_w.tag(c::tag_table_tcache) {||
|
||||
do option::iter(tcx.tcache.find(lid)) |tpbt| {
|
||||
do ebml_w.tag(c::tag_table_tcache) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
ebml_w.emit_tpbt(ecx, tpbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.ty_param_bounds.find(id)) {|pbs|
|
||||
do ebml_w.tag(c::tag_table_param_bounds) {||
|
||||
do option::iter(tcx.ty_param_bounds.find(id)) |pbs| {
|
||||
do ebml_w.tag(c::tag_table_param_bounds) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
ebml_w.emit_bounds(ecx, pbs)
|
||||
}
|
||||
}
|
||||
|
|
@ -671,17 +671,17 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||
// }
|
||||
//}
|
||||
|
||||
do option::iter(maps.mutbl_map.find(id)) {|_m|
|
||||
do ebml_w.tag(c::tag_table_mutbl) {||
|
||||
do option::iter(maps.mutbl_map.find(id)) |_m| {
|
||||
do ebml_w.tag(c::tag_table_mutbl) || {
|
||||
ebml_w.id(id);
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(maps.last_use_map.find(id)) {|m|
|
||||
do ebml_w.tag(c::tag_table_last_use) {||
|
||||
do option::iter(maps.last_use_map.find(id)) |m| {
|
||||
do ebml_w.tag(c::tag_table_last_use) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.emit_from_vec((*m).get()) {|id|
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
do ebml_w.emit_from_vec((*m).get()) |id| {
|
||||
ebml_w.emit_int(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -691,28 +691,28 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||
// impl_map is not used except when emitting metadata,
|
||||
// don't need to keep it.
|
||||
|
||||
do option::iter(maps.method_map.find(id)) {|mme|
|
||||
do ebml_w.tag(c::tag_table_method_map) {||
|
||||
do option::iter(maps.method_map.find(id)) |mme| {
|
||||
do ebml_w.tag(c::tag_table_method_map) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
serialize_method_map_entry(ebml_w, mme)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(maps.vtable_map.find(id)) {|dr|
|
||||
do ebml_w.tag(c::tag_table_vtable_map) {||
|
||||
do option::iter(maps.vtable_map.find(id)) |dr| {
|
||||
do ebml_w.tag(c::tag_table_vtable_map) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
encode_vtable_res(ecx, ebml_w, dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.borrowings.find(id)) {|borrow|
|
||||
do ebml_w.tag(c::tag_table_borrowings) {||
|
||||
do option::iter(tcx.borrowings.find(id)) |borrow| {
|
||||
do ebml_w.tag(c::tag_table_borrowings) || {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {||
|
||||
do ebml_w.tag(c::tag_table_val) || {
|
||||
ty::serialize_borrow(ebml_w, borrow)
|
||||
}
|
||||
}
|
||||
|
|
@ -738,30 +738,30 @@ impl decoder for ebml::ebml_deserializer {
|
|||
|
||||
tydecode::parse_ty_data(
|
||||
self.parent.data, xcx.dcx.cdata.cnum, self.pos, xcx.dcx.tcx,
|
||||
{|a|xcx.tr_def_id(a)})
|
||||
|a| xcx.tr_def_id(a) )
|
||||
}
|
||||
|
||||
fn read_tys(xcx: extended_decode_ctxt) -> ~[ty::t] {
|
||||
self.read_to_vec({|| self.read_ty(xcx) })
|
||||
self.read_to_vec(|| self.read_ty(xcx) )
|
||||
}
|
||||
|
||||
fn read_bounds(xcx: extended_decode_ctxt) -> @~[ty::param_bound] {
|
||||
tydecode::parse_bounds_data(
|
||||
self.parent.data, self.pos, xcx.dcx.cdata.cnum, xcx.dcx.tcx,
|
||||
{|a|xcx.tr_def_id(a)})
|
||||
|a| xcx.tr_def_id(a) )
|
||||
}
|
||||
|
||||
fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
do self.read_rec {||
|
||||
do self.read_rec || {
|
||||
{
|
||||
bounds: self.read_rec_field("bounds", 0u, {||
|
||||
@self.read_to_vec({|| self.read_bounds(xcx) })
|
||||
bounds: self.read_rec_field("bounds", 0u, || {
|
||||
@self.read_to_vec(|| self.read_bounds(xcx) )
|
||||
}),
|
||||
rp: self.read_rec_field("rp", 1u, {||
|
||||
rp: self.read_rec_field("rp", 1u, || {
|
||||
ast::deserialize_region_param(self)
|
||||
}),
|
||||
ty: self.read_rec_field("ty", 2u, {||
|
||||
ty: self.read_rec_field("ty", 2u, || {
|
||||
self.read_ty(xcx)
|
||||
})
|
||||
}
|
||||
|
|
@ -773,7 +773,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
|||
ast_doc: ebml::doc) {
|
||||
let dcx = xcx.dcx;
|
||||
let tbl_doc = ast_doc[c::tag_table];
|
||||
do ebml::docs(tbl_doc) {|tag, entry_doc|
|
||||
do ebml::docs(tbl_doc) |tag, entry_doc| {
|
||||
let id0 = entry_doc[c::tag_table_id].as_int();
|
||||
let id = xcx.tr_id(id0);
|
||||
|
||||
|
|
@ -796,7 +796,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
|||
let tys = val_dsr.read_tys(xcx);
|
||||
dcx.tcx.node_type_substs.insert(id, tys);
|
||||
} else if tag == (c::tag_table_freevars as uint) {
|
||||
let fv_info = @val_dsr.read_to_vec({||
|
||||
let fv_info = @val_dsr.read_to_vec(|| {
|
||||
@val_dsr.read_freevar_entry(xcx)
|
||||
});
|
||||
dcx.tcx.freevars.insert(id, fv_info);
|
||||
|
|
@ -808,7 +808,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
|||
let bounds = val_dsr.read_bounds(xcx);
|
||||
dcx.tcx.ty_param_bounds.insert(id, bounds);
|
||||
} else if tag == (c::tag_table_last_use as uint) {
|
||||
let ids = val_dsr.read_to_vec({||
|
||||
let ids = val_dsr.read_to_vec(|| {
|
||||
xcx.tr_id(val_dsr.read_int())
|
||||
});
|
||||
let dvec = @dvec::from_vec(vec::to_mut(ids));
|
||||
|
|
@ -838,7 +838,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
|||
|
||||
#[cfg(test)]
|
||||
fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {||
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) || {
|
||||
ast::serialize_item(ebml_w, *item);
|
||||
}
|
||||
}
|
||||
|
|
@ -881,9 +881,9 @@ fn roundtrip(in_item: @ast::item) {
|
|||
#debug["out_item = %s", pprust::item_to_str(out_item)];
|
||||
|
||||
let exp_str =
|
||||
io::with_str_writer({|w| ast::serialize_item(w, *in_item) });
|
||||
io::with_str_writer(|w| ast::serialize_item(w, *in_item) );
|
||||
let out_str =
|
||||
io::with_str_writer({|w| ast::serialize_item(w, *out_item) });
|
||||
io::with_str_writer(|w| ast::serialize_item(w, *out_item) );
|
||||
|
||||
#debug["expected string: %s", exp_str];
|
||||
#debug["actual string : %s", out_str];
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
cx.allow_block = true;
|
||||
v.visit_expr(f, cx, v);
|
||||
let mut i = 0u;
|
||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each {|arg_t|
|
||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| {
|
||||
cx.allow_block = (ty::arg_mode(cx.tcx, arg_t) == by_ref);
|
||||
v.visit_expr(args[i], cx, v);
|
||||
i += 1u;
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
self.cat_to_repr(cmt.cat),
|
||||
cmt.id,
|
||||
self.mut_to_str(cmt.mutbl),
|
||||
cmt.lp.map_default("none", { |p| self.lp_to_str(p) }),
|
||||
cmt.lp.map_default("none", |p| self.lp_to_str(p) ),
|
||||
ty_to_str(self.tcx, cmt.ty)]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ impl public_methods for borrowck_ctxt {
|
|||
cmt: cmt) -> cmt {
|
||||
@{id: arg.id(), span: arg.span(),
|
||||
cat: cat_comp(cmt, comp_variant(enum_did)),
|
||||
lp: cmt.lp.map({ |l| @lp_comp(l, comp_variant(enum_did)) }),
|
||||
lp: cmt.lp.map(|l| @lp_comp(l, comp_variant(enum_did)) ),
|
||||
mutbl: cmt.mutbl, // imm iff in an immutable context
|
||||
ty: self.tcx.ty(arg)}
|
||||
}
|
||||
|
|
@ -311,9 +311,7 @@ impl public_methods for borrowck_ctxt {
|
|||
m_mutbl | m_const { f_mutbl }
|
||||
};
|
||||
let f_comp = comp_field(f_name, f_mutbl);
|
||||
let lp = base_cmt.lp.map({ |lp|
|
||||
@lp_comp(lp, f_comp)
|
||||
});
|
||||
let lp = base_cmt.lp.map(|lp| @lp_comp(lp, f_comp) );
|
||||
@{id: node.id(), span: node.span(),
|
||||
cat: cat_comp(base_cmt, f_comp), lp:lp,
|
||||
mutbl: m, ty: self.tcx.ty(node)}
|
||||
|
|
@ -321,10 +319,10 @@ impl public_methods for borrowck_ctxt {
|
|||
|
||||
fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint,
|
||||
expl: bool) -> option<cmt> {
|
||||
do ty::deref(self.tcx, base_cmt.ty, expl).map { |mt|
|
||||
do ty::deref(self.tcx, base_cmt.ty, expl).map |mt| {
|
||||
alt deref_kind(self.tcx, base_cmt.ty) {
|
||||
deref_ptr(ptr) {
|
||||
let lp = do base_cmt.lp.chain { |l|
|
||||
let lp = do base_cmt.lp.chain |l| {
|
||||
// Given that the ptr itself is loanable, we can
|
||||
// loan out deref'd uniq ptrs as the data they are
|
||||
// the only way to reach the data they point at.
|
||||
|
|
@ -341,7 +339,7 @@ impl public_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
deref_comp(comp) {
|
||||
let lp = base_cmt.lp.map({ |l| @lp_comp(l, comp) });
|
||||
let lp = base_cmt.lp.map(|l| @lp_comp(l, comp) );
|
||||
@{id:node.id(), span:node.span(),
|
||||
cat:cat_comp(base_cmt, comp), lp:lp,
|
||||
mutbl:mt.mutbl, ty:mt.ty}
|
||||
|
|
@ -367,7 +365,7 @@ impl public_methods for borrowck_ctxt {
|
|||
deref_ptr(ptr) {
|
||||
// make deref of vectors explicit, as explained in the comment at
|
||||
// the head of this section
|
||||
let deref_lp = base_cmt.lp.map({ |lp| @lp_deref(lp, ptr) });
|
||||
let deref_lp = base_cmt.lp.map(|lp| @lp_deref(lp, ptr) );
|
||||
let deref_cmt = @{id:expr.id, span:expr.span,
|
||||
cat:cat_deref(base_cmt, 0u, ptr), lp:deref_lp,
|
||||
mutbl:m_imm, ty:mt.ty};
|
||||
|
|
@ -383,7 +381,7 @@ impl public_methods for borrowck_ctxt {
|
|||
fn comp(expr: @ast::expr, of_cmt: cmt,
|
||||
vect: ty::t, mt: ty::mt) -> cmt {
|
||||
let comp = comp_index(vect, mt.mutbl);
|
||||
let index_lp = of_cmt.lp.map({ |lp| @lp_comp(lp, comp) });
|
||||
let index_lp = of_cmt.lp.map(|lp| @lp_comp(lp, comp) );
|
||||
@{id:expr.id, span:expr.span,
|
||||
cat:cat_comp(of_cmt, comp), lp:index_lp,
|
||||
mutbl:mt.mutbl, ty:mt.ty}
|
||||
|
|
@ -393,7 +391,7 @@ impl public_methods for borrowck_ctxt {
|
|||
fn cat_tuple_elt<N: ast_node>(elt: N, cmt: cmt) -> cmt {
|
||||
@{id: elt.id(), span: elt.span(),
|
||||
cat: cat_comp(cmt, comp_tuple),
|
||||
lp: cmt.lp.map({ |l| @lp_comp(l, comp_tuple) }),
|
||||
lp: cmt.lp.map(|l| @lp_comp(l, comp_tuple) ),
|
||||
mutbl: cmt.mutbl, // imm iff in an immutable context
|
||||
ty: self.tcx.ty(elt)}
|
||||
}
|
||||
|
|
@ -432,14 +430,14 @@ fn field_mutbl(tcx: ty::ctxt,
|
|||
// Need to refactor so that records/class fields can be treated uniformly.
|
||||
alt ty::get(base_ty).struct {
|
||||
ty::ty_rec(fields) {
|
||||
for fields.each { |f|
|
||||
for fields.each |f| {
|
||||
if f.ident == f_name {
|
||||
ret some(f.mt.mutbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::ty_class(did, substs) {
|
||||
for ty::lookup_class_fields(tcx, did).each { |fld|
|
||||
for ty::lookup_class_fields(tcx, did).each |fld| {
|
||||
if fld.ident == f_name {
|
||||
let m = alt fld.mutability {
|
||||
ast::class_mutable { ast::m_mutbl }
|
||||
|
|
|
|||
|
|
@ -120,9 +120,9 @@ impl methods for check_loan_ctxt {
|
|||
let req_loan_map = self.req_maps.req_loan_map;
|
||||
|
||||
loop {
|
||||
for req_loan_map.find(scope_id).each { |loanss|
|
||||
for (*loanss).each { |loans|
|
||||
for (*loans).each { |loan|
|
||||
for req_loan_map.find(scope_id).each |loanss| {
|
||||
for (*loanss).each |loans| {
|
||||
for (*loans).each |loan| {
|
||||
if !f(loan) { ret; }
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ impl methods for check_loan_ctxt {
|
|||
fn walk_loans_of(scope_id: ast::node_id,
|
||||
lp: @loan_path,
|
||||
f: fn(loan) -> bool) {
|
||||
for self.walk_loans(scope_id) { |loan|
|
||||
for self.walk_loans(scope_id) |loan| {
|
||||
if loan.lp == lp {
|
||||
if !f(loan) { ret; }
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ impl methods for check_loan_ctxt {
|
|||
#debug["check_pure_callee_or_arg(pc=%?, expr=%?, \
|
||||
callee_id=%d, ty=%s)",
|
||||
pc,
|
||||
opt_expr.map({|e| pprust::expr_to_str(e)}),
|
||||
opt_expr.map(|e| pprust::expr_to_str(e) ),
|
||||
callee_id,
|
||||
ty_to_str(self.tcx(), ty::node_id_to_type(tcx, callee_id))];
|
||||
|
||||
|
|
@ -244,9 +244,9 @@ impl methods for check_loan_ctxt {
|
|||
};
|
||||
|
||||
let par_scope_id = self.tcx().region_map.get(scope_id);
|
||||
for self.walk_loans(par_scope_id) { |old_loan|
|
||||
for (*new_loanss).each { |new_loans|
|
||||
for (*new_loans).each { |new_loan|
|
||||
for self.walk_loans(par_scope_id) |old_loan| {
|
||||
for (*new_loanss).each |new_loans| {
|
||||
for (*new_loans).each |new_loan| {
|
||||
if old_loan.lp != new_loan.lp { cont; }
|
||||
alt (old_loan.mutbl, new_loan.mutbl) {
|
||||
(m_const, _) | (_, m_const) |
|
||||
|
|
@ -333,7 +333,7 @@ impl methods for check_loan_ctxt {
|
|||
// which will be checked for compat separately in
|
||||
// check_for_conflicting_loans()
|
||||
if at != at_mutbl_ref {
|
||||
for cmt.lp.each { |lp|
|
||||
for cmt.lp.each |lp| {
|
||||
self.check_for_loan_conflicting_with_assignment(
|
||||
at, ex, cmt, lp);
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ impl methods for check_loan_ctxt {
|
|||
cmt: cmt,
|
||||
lp: @loan_path) {
|
||||
|
||||
for self.walk_loans_of(ex.id, lp) { |loan|
|
||||
for self.walk_loans_of(ex.id, lp) |loan| {
|
||||
alt loan.mutbl {
|
||||
m_mutbl | m_const { /*ok*/ }
|
||||
m_imm {
|
||||
|
|
@ -439,7 +439,7 @@ impl methods for check_loan_ctxt {
|
|||
none { ret; }
|
||||
some(lp) { lp }
|
||||
};
|
||||
for self.walk_loans_of(cmt.id, lp) { |loan|
|
||||
for self.walk_loans_of(cmt.id, lp) |loan| {
|
||||
self.bccx.span_err(
|
||||
cmt.span,
|
||||
#fmt["moving out of %s prohibited due to outstanding loan",
|
||||
|
|
@ -461,7 +461,7 @@ impl methods for check_loan_ctxt {
|
|||
none { ret; }
|
||||
some(lp) { lp }
|
||||
};
|
||||
for self.walk_loans_of(cmt.id, lp) { |_loan|
|
||||
for self.walk_loans_of(cmt.id, lp) |_loan| {
|
||||
#debug["Removing last use entry %? due to outstanding loan",
|
||||
expr.id];
|
||||
self.bccx.last_use_map.remove(expr.id);
|
||||
|
|
@ -479,7 +479,7 @@ impl methods for check_loan_ctxt {
|
|||
some(pc) {
|
||||
self.check_pure_callee_or_arg(
|
||||
pc, callee, callee_id, callee_span);
|
||||
for args.each { |arg|
|
||||
for args.each |arg| {
|
||||
self.check_pure_callee_or_arg(
|
||||
pc, some(arg), arg.id, arg.span);
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ impl methods for check_loan_ctxt {
|
|||
let arg_tys =
|
||||
ty::ty_fn_args(
|
||||
ty::node_id_to_type(self.tcx(), callee_id));
|
||||
do vec::iter2(args, arg_tys) { |arg, arg_ty|
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_move {
|
||||
self.check_move_out(arg);
|
||||
|
|
@ -508,9 +508,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
visitor: visit::vt<check_loan_ctxt>) {
|
||||
|
||||
#debug["purity on entry=%?", copy self.declared_purity];
|
||||
do save_and_restore(self.in_ctor) {||
|
||||
do save_and_restore(self.declared_purity) {||
|
||||
do save_and_restore(self.fn_args) {||
|
||||
do save_and_restore(self.in_ctor) || {
|
||||
do save_and_restore(self.declared_purity) || {
|
||||
do save_and_restore(self.fn_args) || {
|
||||
let is_stack_closure = self.is_stack_closure(id);
|
||||
|
||||
// In principle, we could consider fk_anon(*) or
|
||||
|
|
@ -523,7 +523,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
visit::fk_ctor(*) {
|
||||
self.in_ctor = true;
|
||||
self.declared_purity = decl.purity;
|
||||
self.fn_args = @decl.inputs.map({|i| i.id});
|
||||
self.fn_args = @decl.inputs.map(|i| i.id );
|
||||
}
|
||||
visit::fk_anon(*) |
|
||||
visit::fk_fn_block(*) if is_stack_closure {
|
||||
|
|
@ -535,7 +535,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
visit::fk_dtor(*) {
|
||||
self.in_ctor = false;
|
||||
self.declared_purity = decl.purity;
|
||||
self.fn_args = @decl.inputs.map({|i| i.id});
|
||||
self.fn_args = @decl.inputs.map(|i| i.id );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +582,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
|||
}
|
||||
ast::expr_fn(_, _, _, cap_clause) |
|
||||
ast::expr_fn_block(_, _, cap_clause) {
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
if cap_item.is_move {
|
||||
let def = self.tcx().def_map.get(cap_item.id);
|
||||
|
||||
|
|
@ -637,7 +637,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
|||
fn check_loans_in_block(blk: ast::blk,
|
||||
&&self: check_loan_ctxt,
|
||||
vt: visit::vt<check_loan_ctxt>) {
|
||||
do save_and_restore(self.declared_purity) {||
|
||||
do save_and_restore(self.declared_purity) || {
|
||||
self.check_for_conflicting_loans(blk.node.id);
|
||||
|
||||
alt blk.node.rules {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
#debug["req_loans_in_expr(ex=%s)", pprust::expr_to_str(ex)];
|
||||
|
||||
// If this expression is borrowed, have to ensure it remains valid:
|
||||
for tcx.borrowings.find(ex.id).each { |borrow|
|
||||
for tcx.borrowings.find(ex.id).each |borrow| {
|
||||
let cmt = self.bccx.cat_borrow_of_expr(ex);
|
||||
let scope_r = ty::re_scope(borrow.scope_id);
|
||||
self.guarantee_valid(cmt, borrow.mutbl, scope_r);
|
||||
|
|
@ -56,7 +56,7 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
ast::expr_call(f, args, _) {
|
||||
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
|
||||
let scope_r = ty::re_scope(ex.id);
|
||||
do vec::iter2(args, arg_tys) { |arg, arg_ty|
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_mutbl_ref {
|
||||
let arg_cmt = self.bccx.cat_expr(arg);
|
||||
|
|
@ -114,8 +114,8 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
|
||||
ast::expr_alt(ex_v, arms, _) {
|
||||
let cmt = self.bccx.cat_expr(ex_v);
|
||||
for arms.each { |arm|
|
||||
for arm.pats.each { |pat|
|
||||
for arms.each |arm| {
|
||||
for arm.pats.each |pat| {
|
||||
self.gather_pat(cmt, pat, arm.body.node.id, ex.id);
|
||||
}
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ impl methods for gather_loan_ctxt {
|
|||
};
|
||||
|
||||
let result = {
|
||||
do self.check_mutbl(req_mutbl, cmt).chain { |_ok|
|
||||
do self.check_mutbl(req_mutbl, cmt).chain |_ok| {
|
||||
self.bccx.preserve(cmt, opt_scope_id)
|
||||
}
|
||||
};
|
||||
|
|
@ -345,7 +345,7 @@ impl methods for gather_loan_ctxt {
|
|||
not variant", e])}
|
||||
};
|
||||
|
||||
for subpats.each { |subpat|
|
||||
for subpats.each |subpat| {
|
||||
let subcmt = self.bccx.cat_variant(subpat, enum_did, cmt);
|
||||
self.gather_pat(subcmt, subpat, arm_id, alt_id);
|
||||
}
|
||||
|
|
@ -375,14 +375,14 @@ impl methods for gather_loan_ctxt {
|
|||
|
||||
self.guarantee_valid(cmt1, m_const, arm_scope);
|
||||
|
||||
for o_pat.each { |p|
|
||||
for o_pat.each |p| {
|
||||
self.gather_pat(cmt, p, arm_id, alt_id);
|
||||
}
|
||||
}
|
||||
|
||||
ast::pat_rec(field_pats, _) {
|
||||
// {f1: p1, ..., fN: pN}
|
||||
for field_pats.each { |fp|
|
||||
for field_pats.each |fp| {
|
||||
let cmt_field = self.bccx.cat_field(fp.pat, cmt, fp.ident);
|
||||
self.gather_pat(cmt_field, fp.pat, arm_id, alt_id);
|
||||
}
|
||||
|
|
@ -390,7 +390,7 @@ impl methods for gather_loan_ctxt {
|
|||
|
||||
ast::pat_tup(subpats) {
|
||||
// (p1, ..., pN)
|
||||
for subpats.each { |subpat|
|
||||
for subpats.each |subpat| {
|
||||
let subcmt = self.bccx.cat_tuple_elt(subpat, cmt);
|
||||
self.gather_pat(subcmt, subpat, arm_id, alt_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ fn check_capture_clause(tcx: ty::ctxt,
|
|||
let freevars = freevars::get_freevars(tcx, fn_expr_id);
|
||||
let seen_defs = map::int_hash();
|
||||
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
let cap_def = tcx.def_map.get(cap_item.id);
|
||||
if !vec::any(*freevars, {|fv| fv.def == cap_def}) {
|
||||
if !vec::any(*freevars, |fv| fv.def == cap_def ) {
|
||||
tcx.sess.span_warn(
|
||||
cap_item.span,
|
||||
#fmt("captured variable '%s' not used in closure",
|
||||
|
|
@ -66,7 +66,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
|
||||
// first add entries for anything explicitly named in the cap clause
|
||||
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
#debug("Doing capture var: %s (%?)",
|
||||
*cap_item.name, cap_item.id);
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
if cap_item.is_move {
|
||||
// if we are moving the value in, but it's not actually used,
|
||||
// must drop it.
|
||||
if vec::any(*freevars, {|fv| fv.def == cap_def}) {
|
||||
if vec::any(*freevars, |fv| fv.def == cap_def ) {
|
||||
cap_map.insert(cap_def_id, {def:cap_def,
|
||||
span: cap_item.span,
|
||||
cap_item: some(cap_item),
|
||||
|
|
@ -89,7 +89,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
} else {
|
||||
// if we are copying the value in, but it's not actually used,
|
||||
// just ignore it.
|
||||
if vec::any(*freevars, {|fv| fv.def == cap_def}) {
|
||||
if vec::any(*freevars, |fv| fv.def == cap_def ) {
|
||||
cap_map.insert(cap_def_id, {def:cap_def,
|
||||
span: cap_item.span,
|
||||
cap_item: some(cap_item),
|
||||
|
|
@ -106,7 +106,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy }
|
||||
};
|
||||
|
||||
do vec::iter(*freevars) { |fvar|
|
||||
do vec::iter(*freevars) |fvar| {
|
||||
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;
|
||||
alt cap_map.find(fvar_def_id) {
|
||||
option::some(_) { /* was explicitly named, do nothing */ }
|
||||
|
|
@ -120,6 +120,6 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
let mut result = ~[];
|
||||
for cap_map.each_value { |cap_var| vec::push(result, cap_var); }
|
||||
for cap_map.each_value |cap_var| { vec::push(result, cap_var); }
|
||||
ret result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import std::map::hashmap;
|
|||
|
||||
fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
||||
visit::visit_crate(*crate, (), visit::mk_vt(@{
|
||||
visit_expr: {|a,b,c|check_expr(tcx, a, b, c)},
|
||||
visit_local: {|a,b,c|check_local(tcx, a, b, c)}
|
||||
visit_expr: |a,b,c| check_expr(tcx, a, b, c),
|
||||
visit_local: |a,b,c| check_local(tcx, a, b, c)
|
||||
with *visit::default_visitor::<()>()
|
||||
}));
|
||||
tcx.sess.abort_if_errors();
|
||||
|
|
@ -38,8 +38,8 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
|||
// Check for unreachable patterns
|
||||
fn check_arms(tcx: ty::ctxt, arms: ~[arm]) {
|
||||
let mut seen = ~[];
|
||||
for arms.each {|arm|
|
||||
for arm.pats.each {|pat|
|
||||
for arms.each |arm| {
|
||||
for arm.pats.each |pat| {
|
||||
let v = ~[pat];
|
||||
alt is_useful(tcx, seen, v) {
|
||||
not_useful {
|
||||
|
|
@ -60,7 +60,7 @@ fn raw_pat(p: @pat) -> @pat {
|
|||
}
|
||||
|
||||
fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
|
||||
let ext = alt is_useful(tcx, vec::map(pats, {|p| ~[p]}), ~[wild()]) {
|
||||
let ext = alt is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) {
|
||||
not_useful { ret; } // This is good, wildcard pattern isn't reachable
|
||||
useful_ { none }
|
||||
useful(ty, ctor) {
|
||||
|
|
@ -74,7 +74,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
|
|||
ty::ty_enum(id, _) {
|
||||
let vid = alt check ctor { variant(id) { id } };
|
||||
alt check vec::find(*ty::enum_variants(tcx, id),
|
||||
{|v| v.id == vid}) {
|
||||
|v| v.id == vid) {
|
||||
some(v) { some(v.name) }
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ enum ctor {
|
|||
fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
||||
if m.len() == 0u { ret useful_; }
|
||||
if m[0].len() == 0u { ret not_useful; }
|
||||
let real_pat = alt vec::find(m, {|r| r[0].id != 0}) {
|
||||
let real_pat = alt vec::find(m, |r| r[0].id != 0) {
|
||||
some(r) { r[0] } none { v[0] }
|
||||
};
|
||||
let left_ty = if real_pat.id == 0 { ty::mk_nil(tcx) }
|
||||
|
|
@ -136,7 +136,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
}
|
||||
}
|
||||
ty::ty_enum(eid, _) {
|
||||
for (*ty::enum_variants(tcx, eid)).each {|va|
|
||||
for (*ty::enum_variants(tcx, eid)).each |va| {
|
||||
alt is_useful_specialized(tcx, m, v, variant(va.id),
|
||||
va.args.len(), left_ty) {
|
||||
not_useful {}
|
||||
|
|
@ -152,7 +152,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
}
|
||||
}
|
||||
some(ctor) {
|
||||
alt is_useful(tcx, vec::filter_map(m, {|r| default(tcx, r)}),
|
||||
alt is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ),
|
||||
vec::tail(v)) {
|
||||
useful_ { useful(left_ty, ctor) }
|
||||
u { u }
|
||||
|
|
@ -169,7 +169,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
|
||||
fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
|
||||
arity: uint, lty: ty::t) -> useful {
|
||||
let ms = vec::filter_map(m, {|r| specialize(tcx, r, ctor, arity, lty)});
|
||||
let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) );
|
||||
alt is_useful(tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))){
|
||||
useful_ { useful(lty, ctor) }
|
||||
u { u }
|
||||
|
|
@ -211,21 +211,21 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
|
|||
fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
|
||||
alt ty::get(left_ty).struct {
|
||||
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) {
|
||||
for m.each {|r|
|
||||
for m.each |r| {
|
||||
if !is_wild(tcx, r[0]) { ret none; }
|
||||
}
|
||||
ret some(single);
|
||||
}
|
||||
ty::ty_enum(eid, _) {
|
||||
let mut found = ~[];
|
||||
for m.each {|r|
|
||||
do option::iter(pat_ctor_id(tcx, r[0])) {|id|
|
||||
for m.each |r| {
|
||||
do option::iter(pat_ctor_id(tcx, r[0])) |id| {
|
||||
if !vec::contains(found, id) { vec::push(found, id); }
|
||||
}
|
||||
}
|
||||
let variants = ty::enum_variants(tcx, eid);
|
||||
if found.len() != (*variants).len() {
|
||||
for vec::each(*variants) {|v|
|
||||
for vec::each(*variants) |v| {
|
||||
if !found.contains(variant(v.id)) {
|
||||
ret some(variant(v.id));
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
|
|||
ty::ty_nil { none }
|
||||
ty::ty_bool {
|
||||
let mut true_found = false, false_found = false;
|
||||
for m.each {|r|
|
||||
for m.each |r| {
|
||||
alt check pat_ctor_id(tcx, r[0]) {
|
||||
none {}
|
||||
some(val(const_int(1i64))) { true_found = true; }
|
||||
|
|
@ -258,7 +258,7 @@ fn ctor_arity(tcx: ty::ctxt, ctor: ctor, ty: ty::t) -> uint {
|
|||
ty::ty_box(_) | ty::ty_uniq(_) { 1u }
|
||||
ty::ty_enum(eid, _) {
|
||||
let id = alt check ctor { variant(id) { id } };
|
||||
alt check vec::find(*ty::enum_variants(tcx, eid), {|v| v.id == id}) {
|
||||
alt check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) {
|
||||
some(v) { v.args.len() }
|
||||
}
|
||||
}
|
||||
|
|
@ -301,8 +301,8 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
|||
let ty_flds = alt check ty::get(left_ty).struct {
|
||||
ty::ty_rec(flds) { flds }
|
||||
};
|
||||
let args = vec::map(ty_flds, {|ty_f|
|
||||
alt vec::find(flds, {|f| f.ident == ty_f.ident}) {
|
||||
let args = vec::map(ty_flds, |ty_f| {
|
||||
alt vec::find(flds, |f| f.ident == ty_f.ident ) {
|
||||
some(f) { f.pat } _ { wild() }
|
||||
}
|
||||
});
|
||||
|
|
@ -363,17 +363,17 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
|
|||
pat_wild | pat_ident(_, none) { false }
|
||||
pat_lit(_) | pat_range(_, _) { true }
|
||||
pat_rec(fields, _) {
|
||||
for fields.each {|it|
|
||||
for fields.each |it| {
|
||||
if is_refutable(tcx, it.pat) { ret true; }
|
||||
}
|
||||
false
|
||||
}
|
||||
pat_tup(elts) {
|
||||
for elts.each {|elt| if is_refutable(tcx, elt) { ret true; } }
|
||||
for elts.each |elt| { if is_refutable(tcx, elt) { ret true; } }
|
||||
false
|
||||
}
|
||||
pat_enum(_, some(args)) {
|
||||
for args.each {|p| if is_refutable(tcx, p) { ret true; } };
|
||||
for args.each |p| { if is_refutable(tcx, p) { ret true; } };
|
||||
false
|
||||
}
|
||||
pat_enum(_,_) { false }
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
|
|||
def_map: resolve::def_map,
|
||||
method_map: typeck::method_map, tcx: ty::ctxt) {
|
||||
visit::visit_crate(*crate, false, visit::mk_vt(@{
|
||||
visit_item: {|a,b,c|check_item(sess, ast_map, def_map, a, b, c)},
|
||||
visit_item: |a,b,c| check_item(sess, ast_map, def_map, a, b, c),
|
||||
visit_pat: check_pat,
|
||||
visit_expr: {|a,b,c|
|
||||
visit_expr: |a,b,c|
|
||||
check_expr(sess, def_map, method_map, tcx, a, b, c)
|
||||
}
|
||||
with *visit::default_visitor()
|
||||
}));
|
||||
sess.abort_if_errors();
|
||||
|
|
@ -26,8 +25,8 @@ fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve::def_map,
|
|||
check_item_recursion(sess, ast_map, def_map, it);
|
||||
}
|
||||
item_enum(vs, _, _) {
|
||||
for vs.each {|var|
|
||||
do option::iter(var.node.disr_expr) {|ex|
|
||||
for vs.each |var| {
|
||||
do option::iter(var.node.disr_expr) |ex| {
|
||||
v.visit_expr(ex, true, v);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ type ctx = {in_loop: bool, can_ret: bool};
|
|||
|
||||
fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
||||
visit::visit_crate(*crate, {in_loop: false,can_ret: true}, visit::mk_vt(@{
|
||||
visit_item: {|i, _cx, v|
|
||||
visit_item: |i, _cx, v| {
|
||||
visit::visit_item(i, {in_loop: false, can_ret: true}, v);
|
||||
},
|
||||
visit_expr: {|e: @expr, cx: ctx, v: visit::vt<ctx>|
|
||||
visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| {
|
||||
alt e.node {
|
||||
expr_while(e, b) {
|
||||
v.visit_expr(e, cx, v);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
|
|||
if !is_move { check_copy(cx, id, var_t, sp, is_implicit); }
|
||||
|
||||
// check that only immutable variables are implicitly copied in
|
||||
for fv.each { |fv|
|
||||
for fv.each |fv| {
|
||||
check_imm_free_var(cx, fv.def, fv.span);
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
|
|||
if !is_move { check_copy(cx, id, var_t, sp, is_implicit); }
|
||||
|
||||
// check that only immutable variables are implicitly copied in
|
||||
for fv.each { |fv|
|
||||
for fv.each |fv| {
|
||||
check_imm_free_var(cx, fv.def, fv.span);
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
|
||||
// Find the check function that enforces the appropriate bounds for this
|
||||
// kind of function:
|
||||
do with_appropriate_checker(cx, fn_id) { |chk|
|
||||
do with_appropriate_checker(cx, fn_id) |chk| {
|
||||
|
||||
// Begin by checking the variables in the capture clause, if any.
|
||||
// Here we slightly abuse the map function to both check and report
|
||||
|
|
@ -162,7 +162,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
visit::fk_item_fn(*) | visit::fk_method(*) |
|
||||
visit::fk_ctor(*) | visit::fk_dtor(*) { @~[] }
|
||||
};
|
||||
let captured_vars = do (*cap_clause).map { |cap_item|
|
||||
let captured_vars = do (*cap_clause).map |cap_item| {
|
||||
let cap_def = cx.tcx.def_map.get(cap_item.id);
|
||||
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
|
||||
let ty = ty::node_id_to_type(cx.tcx, cap_def_id);
|
||||
|
|
@ -172,7 +172,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
|
||||
// Iterate over any free variables that may not have appeared in the
|
||||
// capture list. Ensure that they too are of the appropriate kind.
|
||||
for vec::each(*freevars::get_freevars(cx.tcx, fn_id)) {|fv|
|
||||
for vec::each(*freevars::get_freevars(cx.tcx, fn_id)) |fv| {
|
||||
let id = ast_util::def_id_of_def(fv.def).node;
|
||||
|
||||
// skip over free variables that appear in the cap clause
|
||||
|
|
@ -217,7 +217,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
check_copy_ex(cx, rs, false);
|
||||
}
|
||||
expr_rec(fields, def) {
|
||||
for fields.each {|field| maybe_copy(cx, field.node.expr); }
|
||||
for fields.each |field| { maybe_copy(cx, field.node.expr); }
|
||||
alt def {
|
||||
some(ex) {
|
||||
// All noncopyable fields must be overridden
|
||||
|
|
@ -226,8 +226,8 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
ty::ty_rec(f) { f }
|
||||
_ { cx.tcx.sess.span_bug(ex.span, "bad expr type in record"); }
|
||||
};
|
||||
for ty_fields.each {|tf|
|
||||
if !vec::any(fields, {|f| f.node.ident == tf.ident}) &&
|
||||
for ty_fields.each |tf| {
|
||||
if !vec::any(fields, |f| f.node.ident == tf.ident ) &&
|
||||
!ty::kind_can_be_copied(ty::type_kind(cx.tcx, tf.mt.ty)) {
|
||||
cx.tcx.sess.span_err(ex.span,
|
||||
"copying a noncopyable value");
|
||||
|
|
@ -238,11 +238,11 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
}
|
||||
expr_tup(exprs) | expr_vec(exprs, _) {
|
||||
for exprs.each {|expr| maybe_copy(cx, expr); }
|
||||
for exprs.each |expr| { maybe_copy(cx, expr); }
|
||||
}
|
||||
expr_call(f, args, _) {
|
||||
let mut i = 0u;
|
||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each {|arg_t|
|
||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| {
|
||||
alt ty::arg_mode(cx.tcx, arg_t) {
|
||||
by_copy { maybe_copy(cx, args[i]); }
|
||||
by_ref | by_val | by_mutbl_ref | by_move { }
|
||||
|
|
@ -251,7 +251,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
}
|
||||
expr_path(_) | expr_field(_, _, _) {
|
||||
do option::iter(cx.tcx.node_type_substs.find(e.id)) {|ts|
|
||||
do option::iter(cx.tcx.node_type_substs.find(e.id)) |ts| {
|
||||
let bounds = alt check e.node {
|
||||
expr_path(_) {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
|
||||
|
|
@ -286,7 +286,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
%s (%u tys), declared = %? (%u tys)",
|
||||
tys_to_str(cx.tcx, ts), ts.len(), *bounds, (*bounds).len());
|
||||
}
|
||||
do vec::iter2(ts, *bounds) {|ty, bound|
|
||||
do vec::iter2(ts, *bounds) |ty, bound| {
|
||||
check_bounds(cx, e.id, e.span, ty, bound)
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +299,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt stmt.node {
|
||||
stmt_decl(@{node: decl_local(locals), _}, _) {
|
||||
for locals.each {|local|
|
||||
for locals.each |local| {
|
||||
alt local.node.init {
|
||||
some({op: init_assign, expr}) { maybe_copy(cx, expr); }
|
||||
_ {}
|
||||
|
|
@ -314,10 +314,10 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
|||
fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt aty.node {
|
||||
ty_path(_, id) {
|
||||
do option::iter(cx.tcx.node_type_substs.find(id)) {|ts|
|
||||
do option::iter(cx.tcx.node_type_substs.find(id)) |ts| {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
|
||||
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
|
||||
do vec::iter2(ts, *bounds) {|ty, bound|
|
||||
do vec::iter2(ts, *bounds) |ty, bound| {
|
||||
check_bounds(cx, aty.id, aty.span, ty, bound)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,10 +211,10 @@ impl methods for ctxt {
|
|||
let mut new_ctxt = self;
|
||||
|
||||
let metas = attr::attr_metas(attr::find_attrs_by_name(attrs, "warn"));
|
||||
for metas.each {|meta|
|
||||
for metas.each |meta| {
|
||||
alt meta.node {
|
||||
ast::meta_list(_, metas) {
|
||||
for metas.each {|meta|
|
||||
for metas.each |meta| {
|
||||
alt meta.node {
|
||||
ast::meta_word(lintname) {
|
||||
alt lookup_lint(self.dict, *lintname) {
|
||||
|
|
@ -273,7 +273,7 @@ fn lookup_lint(dict: lint_dict, s: str)
|
|||
}
|
||||
|
||||
fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) {
|
||||
do cx.with_warn_attrs(i.attrs) {|cx|
|
||||
do cx.with_warn_attrs(i.attrs) |cx| {
|
||||
if !cx.is_default {
|
||||
cx.sess.warning_settings.settings_map.insert(i.id, cx.curr);
|
||||
}
|
||||
|
|
@ -289,17 +289,17 @@ fn build_settings_crate(sess: session::session, crate: @ast::crate) {
|
|||
sess: sess};
|
||||
|
||||
// Install defaults.
|
||||
for cx.dict.each {|_k, spec| cx.set_level(spec.lint, spec.default); }
|
||||
for cx.dict.each |_k, spec| { cx.set_level(spec.lint, spec.default); }
|
||||
|
||||
// Install command-line options, overriding defaults.
|
||||
for sess.opts.lint_opts.each {|pair|
|
||||
for sess.opts.lint_opts.each |pair| {
|
||||
let (lint,level) = pair;
|
||||
cx.set_level(lint, level);
|
||||
}
|
||||
|
||||
do cx.with_warn_attrs(crate.node.attrs) {|cx|
|
||||
do cx.with_warn_attrs(crate.node.attrs) |cx| {
|
||||
// Copy out the default settings
|
||||
for cx.curr.each {|k, v|
|
||||
for cx.curr.each |k, v| {
|
||||
sess.warning_settings.default_settings.insert(k, v);
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
|
|||
// not traverse into subitems, since that is handled by the outer
|
||||
// lint visitor.
|
||||
fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
|
||||
visit::mk_vt(@{visit_item: {|_i, _e, _v| } with **v})
|
||||
visit::mk_vt(@{visit_item: |_i, _e, _v| { } with **v})
|
||||
}
|
||||
|
||||
fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
|
||||
|
|
@ -357,8 +357,8 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
|
||||
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
|
||||
decl: ast::fn_decl) {
|
||||
let tys = vec::map(decl.inputs, {|a| a.ty });
|
||||
for vec::each(vec::append_one(tys, decl.output)) {|ty|
|
||||
let tys = vec::map(decl.inputs, |a| a.ty );
|
||||
for vec::each(vec::append_one(tys, decl.output)) |ty| {
|
||||
alt ty.node {
|
||||
ast::ty_path(_, id) {
|
||||
alt cx.def_map.get(id) {
|
||||
|
|
@ -387,7 +387,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
alt it.node {
|
||||
ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) !=
|
||||
either::right(ast::foreign_abi_rust_intrinsic) {
|
||||
for nmod.items.each {|ni|
|
||||
for nmod.items.each |ni| {
|
||||
alt ni.node {
|
||||
ast::foreign_item_fn(decl, tps) {
|
||||
check_foreign_fn(cx, it.id, decl);
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
|||
|
||||
#debug["creating fn_maps: %x", ptr::addr_of(*fn_maps) as uint];
|
||||
|
||||
for decl.inputs.each { |arg|
|
||||
for decl.inputs.each |arg| {
|
||||
#debug["adding argument %d", arg.id];
|
||||
let mode = ty::resolved_mode(self.tcx, arg.mode);
|
||||
(*fn_maps).add_variable(vk_arg(arg.id, arg.ident, mode));
|
||||
|
|
@ -397,7 +397,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
|||
}
|
||||
|
||||
fn add_class_fields(self: @ir_maps, did: def_id) {
|
||||
for ty::lookup_class_fields(self.tcx, did).each { |field_ty|
|
||||
for ty::lookup_class_fields(self.tcx, did).each |field_ty| {
|
||||
assert field_ty.id.crate == local_crate;
|
||||
let var = (*self).add_variable(vk_field(field_ty.ident));
|
||||
self.field_map.insert(field_ty.ident, var);
|
||||
|
|
@ -406,7 +406,7 @@ fn add_class_fields(self: @ir_maps, did: def_id) {
|
|||
|
||||
fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) {
|
||||
let def_map = self.tcx.def_map;
|
||||
do pat_util::pat_bindings(def_map, local.node.pat) { |p_id, sp, path|
|
||||
do pat_util::pat_bindings(def_map, local.node.pat) |p_id, sp, path| {
|
||||
#debug["adding local variable %d", p_id];
|
||||
let name = ast_util::path_to_ident(path);
|
||||
(*self).add_live_node_for_node(p_id, lnk_vdef(sp));
|
||||
|
|
@ -436,7 +436,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) {
|
|||
let cvs = capture::compute_capture_vars(self.tcx, expr.id,
|
||||
proto, cap_clause);
|
||||
let mut call_caps = ~[];
|
||||
for cvs.each { |cv|
|
||||
for cvs.each |cv| {
|
||||
alt relevant_def(cv.def) {
|
||||
some(rv) {
|
||||
let cv_ln = (*self).add_live_node(lnk_freevar(cv.span));
|
||||
|
|
@ -560,9 +560,9 @@ class liveness {
|
|||
alt expr.node {
|
||||
expr_path(_) {
|
||||
let def = self.tcx.def_map.get(expr.id);
|
||||
relevant_def(def).map({ |rdef|
|
||||
self.variable_from_rdef(rdef, expr.span)
|
||||
})
|
||||
relevant_def(def).map(
|
||||
|rdef| self.variable_from_rdef(rdef, expr.span)
|
||||
)
|
||||
}
|
||||
_ {none}
|
||||
}
|
||||
|
|
@ -576,9 +576,9 @@ class liveness {
|
|||
span: span) -> option<variable> {
|
||||
alt self.tcx.def_map.find(node_id) {
|
||||
some(def) {
|
||||
relevant_def(def).map({ |rdef|
|
||||
self.variable_from_rdef(rdef, span)
|
||||
})
|
||||
relevant_def(def).map(
|
||||
|rdef| self.variable_from_rdef(rdef, span)
|
||||
)
|
||||
}
|
||||
none {
|
||||
self.tcx.sess.span_bug(
|
||||
|
|
@ -589,7 +589,7 @@ class liveness {
|
|||
|
||||
fn pat_bindings(pat: @pat, f: fn(live_node, variable, span)) {
|
||||
let def_map = self.tcx.def_map;
|
||||
do pat_util::pat_bindings(def_map, pat) {|p_id, sp, _n|
|
||||
do pat_util::pat_bindings(def_map, pat) |p_id, sp, _n| {
|
||||
let ln = self.live_node(p_id, sp);
|
||||
let var = self.variable(p_id, sp);
|
||||
f(ln, var, sp);
|
||||
|
|
@ -635,7 +635,7 @@ class liveness {
|
|||
|
||||
fn indices(ln: live_node, op: fn(uint)) {
|
||||
let node_base_idx = self.idx(ln, variable(0u));
|
||||
for uint::range(0u, self.ir.num_vars) { |var_idx|
|
||||
for uint::range(0u, self.ir.num_vars) |var_idx| {
|
||||
op(node_base_idx + var_idx)
|
||||
}
|
||||
}
|
||||
|
|
@ -644,7 +644,7 @@ class liveness {
|
|||
op: fn(uint, uint)) {
|
||||
let node_base_idx = self.idx(ln, variable(0u));
|
||||
let succ_base_idx = self.idx(succ_ln, variable(0u));
|
||||
for uint::range(0u, self.ir.num_vars) { |var_idx|
|
||||
for uint::range(0u, self.ir.num_vars) |var_idx| {
|
||||
op(node_base_idx + var_idx, succ_base_idx + var_idx);
|
||||
}
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ class liveness {
|
|||
ln: live_node,
|
||||
test: fn(uint) -> live_node) {
|
||||
let node_base_idx = self.idx(ln, variable(0u));
|
||||
for uint::range(0u, self.ir.num_vars) { |var_idx|
|
||||
for uint::range(0u, self.ir.num_vars) |var_idx| {
|
||||
let idx = node_base_idx + var_idx;
|
||||
if test(idx).is_valid() {
|
||||
wr.write_str(" ");
|
||||
|
|
@ -663,15 +663,15 @@ class liveness {
|
|||
}
|
||||
|
||||
fn ln_str(ln: live_node) -> str {
|
||||
do io::with_str_writer { |wr|
|
||||
do io::with_str_writer |wr| {
|
||||
wr.write_str("[ln(");
|
||||
wr.write_uint(*ln);
|
||||
wr.write_str(") of kind ");
|
||||
wr.write_str(#fmt["%?", copy self.ir.lnks[*ln]]);
|
||||
wr.write_str(" reads");
|
||||
self.write_vars(wr, ln, {|idx| self.users[idx].reader});
|
||||
self.write_vars(wr, ln, |idx| self.users[idx].reader );
|
||||
wr.write_str(" writes");
|
||||
self.write_vars(wr, ln, {|idx| self.users[idx].writer});
|
||||
self.write_vars(wr, ln, |idx| self.users[idx].writer );
|
||||
wr.write_str(" ");
|
||||
wr.write_str(" precedes ");
|
||||
wr.write_str((copy self.successors[*ln]).to_str());
|
||||
|
|
@ -695,8 +695,8 @@ class liveness {
|
|||
fn init_from_succ(ln: live_node, succ_ln: live_node) {
|
||||
// more efficient version of init_empty() / merge_from_succ()
|
||||
self.successors[*ln] = succ_ln;
|
||||
self.indices2(ln, succ_ln, { |idx, succ_idx|
|
||||
self.users[idx] = self.users[succ_idx];
|
||||
self.indices2(ln, succ_ln, |idx, succ_idx| {
|
||||
self.users[idx] = self.users[succ_idx]
|
||||
});
|
||||
#debug["init_from_succ(ln=%s, succ=%s)",
|
||||
self.ln_str(ln), self.ln_str(succ_ln)];
|
||||
|
|
@ -707,7 +707,7 @@ class liveness {
|
|||
if ln == succ_ln { ret false; }
|
||||
|
||||
let mut changed = false;
|
||||
do self.indices2(ln, succ_ln) { |idx, succ_idx|
|
||||
do self.indices2(ln, succ_ln) |idx, succ_idx| {
|
||||
changed |= copy_if_invalid(copy self.users[succ_idx].reader,
|
||||
self.users[idx].reader);
|
||||
changed |= copy_if_invalid(copy self.users[succ_idx].writer,
|
||||
|
|
@ -776,14 +776,14 @@ class liveness {
|
|||
// effectively a return---this only occurs in `for` loops,
|
||||
// where the body is really a closure.
|
||||
let entry_ln: live_node =
|
||||
self.with_loop_nodes(self.s.exit_ln, self.s.exit_ln, {||
|
||||
self.with_loop_nodes(self.s.exit_ln, self.s.exit_ln, || {
|
||||
self.propagate_through_fn_block(decl, body)
|
||||
});
|
||||
|
||||
// hack to skip the loop unless #debug is enabled:
|
||||
#debug["^^ liveness computation results for body %d (entry=%s)",
|
||||
{
|
||||
for uint::range(0u, self.ir.num_live_nodes) { |ln_idx|
|
||||
for uint::range(0u, self.ir.num_live_nodes) |ln_idx| {
|
||||
#debug["%s", self.ln_str(live_node(ln_idx))];
|
||||
}
|
||||
body.node.id
|
||||
|
|
@ -795,7 +795,7 @@ class liveness {
|
|||
|
||||
fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> live_node {
|
||||
// inputs passed by & mode should be considered live on exit:
|
||||
for decl.inputs.each { |arg|
|
||||
for decl.inputs.each |arg| {
|
||||
alt ty::resolved_mode(self.tcx, arg.mode) {
|
||||
by_mutbl_ref | by_ref | by_val {
|
||||
// These are "non-owned" modes, so register a read at
|
||||
|
|
@ -816,7 +816,7 @@ class liveness {
|
|||
self.acc(self.s.exit_ln, self.s.self_var, ACC_READ);
|
||||
|
||||
// in a ctor, there is an implicit use of self.f for all fields f:
|
||||
for self.ir.field_map.each_value { |var|
|
||||
for self.ir.field_map.each_value |var| {
|
||||
self.acc(self.s.exit_ln, var, ACC_READ|ACC_USE);
|
||||
}
|
||||
|
||||
|
|
@ -832,7 +832,7 @@ class liveness {
|
|||
|
||||
fn propagate_through_block(blk: blk, succ: live_node) -> live_node {
|
||||
let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
|
||||
do blk.node.stmts.foldr(succ) { |stmt, succ|
|
||||
do blk.node.stmts.foldr(succ) |stmt, succ| {
|
||||
self.propagate_through_stmt(stmt, succ)
|
||||
}
|
||||
}
|
||||
|
|
@ -852,7 +852,7 @@ class liveness {
|
|||
fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node {
|
||||
alt decl.node {
|
||||
decl_local(locals) {
|
||||
do locals.foldr(succ) { |local, succ|
|
||||
do locals.foldr(succ) |local, succ| {
|
||||
self.propagate_through_local(local, succ)
|
||||
}
|
||||
}
|
||||
|
|
@ -877,9 +877,9 @@ class liveness {
|
|||
// initialization, which is mildly more complex than checking
|
||||
// once at the func header but otherwise equivalent.
|
||||
|
||||
let opt_init = local.node.init.map({ |i| i.expr });
|
||||
let opt_init = local.node.init.map(|i| i.expr );
|
||||
let mut succ = self.propagate_through_opt_expr(opt_init, succ);
|
||||
do self.pat_bindings(local.node.pat) { |ln, var, _sp|
|
||||
do self.pat_bindings(local.node.pat) |ln, var, _sp| {
|
||||
self.init_from_succ(ln, succ);
|
||||
self.define(ln, var);
|
||||
succ = ln;
|
||||
|
|
@ -889,14 +889,14 @@ class liveness {
|
|||
|
||||
fn propagate_through_exprs(exprs: ~[@expr],
|
||||
succ: live_node) -> live_node {
|
||||
do exprs.foldr(succ) { |expr, succ|
|
||||
do exprs.foldr(succ) |expr, succ| {
|
||||
self.propagate_through_expr(expr, succ)
|
||||
}
|
||||
}
|
||||
|
||||
fn propagate_through_opt_expr(opt_expr: option<@expr>,
|
||||
succ: live_node) -> live_node {
|
||||
do opt_expr.foldl(succ) { |succ, expr|
|
||||
do opt_expr.foldl(succ) |succ, expr| {
|
||||
self.propagate_through_expr(expr, succ)
|
||||
}
|
||||
}
|
||||
|
|
@ -930,7 +930,7 @@ class liveness {
|
|||
// the construction of a closure itself is not important,
|
||||
// but we have to consider the closed over variables.
|
||||
let caps = (*self.ir).captures(expr);
|
||||
do (*caps).foldr(succ) { |cap, succ|
|
||||
do (*caps).foldr(succ) |cap, succ| {
|
||||
self.init_from_succ(cap.ln, succ);
|
||||
let var = self.variable_from_rdef(cap.rv, expr.span);
|
||||
self.acc(cap.ln, var, ACC_READ | ACC_USE);
|
||||
|
|
@ -987,7 +987,7 @@ class liveness {
|
|||
let ln = self.live_node(expr.id, expr.span);
|
||||
self.init_empty(ln, succ);
|
||||
let mut first_merge = true;
|
||||
for arms.each { |arm|
|
||||
for arms.each |arm| {
|
||||
let arm_succ =
|
||||
self.propagate_through_opt_expr(
|
||||
arm.guard,
|
||||
|
|
@ -1063,7 +1063,7 @@ class liveness {
|
|||
|
||||
expr_rec(fields, with_expr) {
|
||||
let succ = self.propagate_through_opt_expr(with_expr, succ);
|
||||
do fields.foldr(succ) { |field, succ|
|
||||
do fields.foldr(succ) |field, succ| {
|
||||
self.propagate_through_expr(field.node.expr, succ)
|
||||
}
|
||||
}
|
||||
|
|
@ -1241,7 +1241,7 @@ class liveness {
|
|||
let ln = self.live_node(expr.id, expr.span);
|
||||
if acc != 0u {
|
||||
self.init_from_succ(ln, succ);
|
||||
for self.ir.field_map.each_value { |var|
|
||||
for self.ir.field_map.each_value |var| {
|
||||
self.acc(ln, var, acc);
|
||||
}
|
||||
}
|
||||
|
|
@ -1273,7 +1273,7 @@ class liveness {
|
|||
alt def {
|
||||
def_self(_) {
|
||||
// Note: the field_map is empty unless we are in a ctor
|
||||
ret self.ir.field_map.find(fld).map({ |var|
|
||||
ret self.ir.field_map.find(fld).map(|var| {
|
||||
let ln = self.live_node(expr.id, expr.span);
|
||||
(ln, var)
|
||||
});
|
||||
|
|
@ -1320,7 +1320,7 @@ class liveness {
|
|||
first_merge = false;
|
||||
}
|
||||
let cond_ln = self.propagate_through_opt_expr(cond, ln);
|
||||
let body_ln = self.with_loop_nodes(succ, ln, {||
|
||||
let body_ln = self.with_loop_nodes(succ, ln, || {
|
||||
self.propagate_through_block(body, cond_ln)
|
||||
});
|
||||
|
||||
|
|
@ -1328,7 +1328,7 @@ class liveness {
|
|||
while self.merge_from_succ(ln, body_ln, first_merge) {
|
||||
first_merge = false;
|
||||
assert cond_ln == self.propagate_through_opt_expr(cond, ln);
|
||||
assert body_ln == self.with_loop_nodes(succ, ln, {||
|
||||
assert body_ln == self.with_loop_nodes(succ, ln, || {
|
||||
self.propagate_through_block(body, cond_ln)
|
||||
});
|
||||
}
|
||||
|
|
@ -1373,7 +1373,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
|
|||
// should not be live at this point.
|
||||
|
||||
#debug["check_local() with no initializer"];
|
||||
do (*self).pat_bindings(local.node.pat) { |ln, var, sp|
|
||||
do (*self).pat_bindings(local.node.pat) |ln, var, sp| {
|
||||
if !self.warn_about_unused(sp, ln, var) {
|
||||
alt (*self).live_on_exit(ln, var) {
|
||||
none { /* not live: good */ }
|
||||
|
|
@ -1394,7 +1394,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
|
|||
fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
|
||||
alt expr.node {
|
||||
expr_path(_) {
|
||||
for (*self).variable_from_def_map(expr.id, expr.span).each { |var|
|
||||
for (*self).variable_from_def_map(expr.id, expr.span).each |var| {
|
||||
let ln = (*self).live_node(expr.id, expr.span);
|
||||
self.consider_last_use(expr, ln, var);
|
||||
}
|
||||
|
|
@ -1404,7 +1404,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
|
|||
|
||||
expr_fn(_, _, _, cap_clause) | expr_fn_block(_, _, cap_clause) {
|
||||
let caps = (*self.ir).captures(expr);
|
||||
for (*caps).each { |cap|
|
||||
for (*caps).each |cap| {
|
||||
let var = (*self).variable_from_rdef(cap.rv, expr.span);
|
||||
self.consider_last_use(expr, cap.ln, var);
|
||||
if cap.is_move {
|
||||
|
|
@ -1438,7 +1438,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
|
|||
expr_call(f, args, _) {
|
||||
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
|
||||
vt.visit_expr(f, self, vt);
|
||||
do vec::iter2(args, targs) { |arg_expr, arg_ty|
|
||||
do vec::iter2(args, targs) |arg_expr, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx, arg_ty.mode) {
|
||||
by_val | by_copy | by_ref | by_mutbl_ref{
|
||||
vt.visit_expr(arg_expr, self, vt);
|
||||
|
|
@ -1480,7 +1480,7 @@ enum read_kind {
|
|||
|
||||
impl check_methods for @liveness {
|
||||
fn check_fields(sp: span, entry_ln: live_node) {
|
||||
for self.ir.field_map.each { |nm, var|
|
||||
for self.ir.field_map.each |nm, var| {
|
||||
alt (*self).live_on_entry(entry_ln, var) {
|
||||
none { /* ok */ }
|
||||
some(lnk_exit) {
|
||||
|
|
@ -1621,7 +1621,7 @@ impl check_methods for @liveness {
|
|||
}
|
||||
|
||||
fn check_for_reassignments_in_pat(pat: @pat) {
|
||||
do (*self).pat_bindings(pat) { |ln, var, sp|
|
||||
do (*self).pat_bindings(pat) |ln, var, sp| {
|
||||
self.check_for_reassignment(ln, var, sp);
|
||||
}
|
||||
}
|
||||
|
|
@ -1728,7 +1728,7 @@ impl check_methods for @liveness {
|
|||
}
|
||||
|
||||
fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) {
|
||||
for decl.inputs.each { |arg|
|
||||
for decl.inputs.each |arg| {
|
||||
let var = (*self).variable(arg.id, arg.ty.span);
|
||||
alt ty::resolved_mode(self.tcx, arg.mode) {
|
||||
by_mutbl_ref {
|
||||
|
|
@ -1752,7 +1752,7 @@ impl check_methods for @liveness {
|
|||
}
|
||||
|
||||
fn warn_about_unused_or_dead_vars_in_pat(pat: @pat) {
|
||||
do (*self).pat_bindings(pat) { |ln, var, sp|
|
||||
do (*self).pat_bindings(pat) |ln, var, sp| {
|
||||
if !self.warn_about_unused(sp, ln, var) {
|
||||
self.warn_about_dead_assign(sp, ln, var);
|
||||
}
|
||||
|
|
@ -1761,7 +1761,7 @@ impl check_methods for @liveness {
|
|||
|
||||
fn warn_about_unused(sp: span, ln: live_node, var: variable) -> bool {
|
||||
if !(*self).used_on_entry(ln, var) {
|
||||
for self.should_warn(var).each { |name|
|
||||
for self.should_warn(var).each |name| {
|
||||
|
||||
// annoying: for parameters in funcs like `fn(x: int)
|
||||
// {ret}`, there is only one node, so asking about
|
||||
|
|
@ -1788,7 +1788,7 @@ impl check_methods for @liveness {
|
|||
|
||||
fn warn_about_dead_assign(sp: span, ln: live_node, var: variable) {
|
||||
if (*self).live_on_exit(ln, var).is_none() {
|
||||
for self.should_warn(var).each { |name|
|
||||
for self.should_warn(var).each |name| {
|
||||
self.tcx.sess.span_warn(
|
||||
sp,
|
||||
#fmt["value assigned to `%s` is never read", *name]);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type pat_id_map = std::map::hashmap<ident, node_id>;
|
|||
// use the node_id of their namesake in the first pattern.
|
||||
fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map {
|
||||
let map = std::map::box_str_hash();
|
||||
do pat_bindings(dm, pat) {|p_id, _s, n|
|
||||
do pat_bindings(dm, pat) |p_id, _s, n| {
|
||||
map.insert(path_to_ident(n), p_id);
|
||||
};
|
||||
ret map;
|
||||
|
|
@ -39,7 +39,7 @@ fn pat_is_variant(dm: resolve::def_map, pat: @pat) -> bool {
|
|||
// Could return a constrained type in order to express that (future work)
|
||||
fn pat_bindings(dm: resolve::def_map, pat: @pat,
|
||||
it: fn(node_id, span, @path)) {
|
||||
do walk_pat(pat) {|p|
|
||||
do walk_pat(pat) |p| {
|
||||
alt p.node {
|
||||
pat_ident(pth, _) if !pat_is_variant(dm, p) {
|
||||
it(p.id, p.span, pth);
|
||||
|
|
@ -51,6 +51,6 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
|
|||
|
||||
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> ~[node_id] {
|
||||
let mut found = ~[];
|
||||
pat_bindings(dm, pat, {|b_id, _sp, _pt| vec::push(found, b_id); });
|
||||
pat_bindings(dm, pat, |b_id, _sp, _pt| vec::push(found, b_id) );
|
||||
ret found;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
|
|||
// although the capture items are not expressions per se, they
|
||||
// do get "evaluated" in some sense as copies or moves of the
|
||||
// relevant variables so we parent them like an expression
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
record_parent(cx, cap_item.id);
|
||||
}
|
||||
visit::visit_expr(expr, cx, visitor);
|
||||
|
|
@ -375,7 +375,7 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
fn_cx.parent: %?",
|
||||
body.node.id, cx.parent, fn_cx.parent];
|
||||
|
||||
for decl.inputs.each { |input|
|
||||
for decl.inputs.each |input| {
|
||||
cx.region_map.insert(input.id, body.node.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ fn new_ext_hash() -> ext_hash {
|
|||
ret ast_util::def_eq(v1.did, v2.did) &&
|
||||
str::eq(*v1.ident, *v2.ident) && v1.ns == v2.ns;
|
||||
}
|
||||
std::map::hashmap(hash, {|a, b| a == b})
|
||||
std::map::hashmap(hash, |a, b| a == b)
|
||||
}
|
||||
|
||||
enum mod_index_entry {
|
||||
|
|
@ -158,7 +158,7 @@ fn resolve_crate(sess: session, amap: ast_map::map, crate: @ast::crate) ->
|
|||
check_for_collisions(e, *crate);
|
||||
|
||||
// FIXME: move this to the lint pass when rewriting resolve. (#1634)
|
||||
for sess.opts.lint_opts.each {|pair|
|
||||
for sess.opts.lint_opts.each |pair| {
|
||||
let (lint,level) = pair;
|
||||
if lint == lint::unused_imports && level != lint::ignore {
|
||||
check_unused_imports(e, level);
|
||||
|
|
@ -192,7 +192,7 @@ fn create_env(sess: session, amap: ast_map::map) -> @env {
|
|||
fn iter_export_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
|
||||
alt vi.node {
|
||||
ast::view_item_export(vps) {
|
||||
for vps.each {|vp|
|
||||
for vps.each |vp| {
|
||||
f(vp);
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ fn iter_export_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
|
|||
fn iter_import_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
|
||||
alt vi.node {
|
||||
ast::view_item_import(vps) {
|
||||
for vps.each {|vp| f(vp);}
|
||||
for vps.each |vp| { f(vp);}
|
||||
}
|
||||
_ {}
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ fn iter_import_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
|
|||
fn iter_effective_import_paths(vi: ast::view_item,
|
||||
f: fn(vp: @ast::view_path)) {
|
||||
iter_import_paths(vi, f);
|
||||
do iter_export_paths(vi) {|vp|
|
||||
do iter_export_paths(vi) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(_, _, _) { }
|
||||
// FIXME (but also see #1893): support uniform ident-list exports
|
||||
|
|
@ -231,7 +231,7 @@ fn iter_effective_import_paths(vi: ast::view_item,
|
|||
fn map_crate(e: @env, c: @ast::crate) {
|
||||
|
||||
fn index_vi(e: @env, i: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
|
||||
do iter_effective_import_paths(*i) { |vp|
|
||||
do iter_effective_import_paths(*i) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(name, path, id) {
|
||||
e.imports.insert(id, todo(name, @path.idents, vp.span,
|
||||
|
|
@ -241,7 +241,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
e.imports.insert(id, is_glob(@path.idents, sc, vp.span));
|
||||
}
|
||||
ast::view_path_list(mod_path, idents, _) {
|
||||
for idents.each {|ident|
|
||||
for idents.each |ident| {
|
||||
let t = todo(ident.node.name,
|
||||
@(vec::append_one(mod_path.idents,
|
||||
ident.node.name)),
|
||||
|
|
@ -255,7 +255,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
|
||||
fn path_from_scope(sc: scopes, n: str) -> str {
|
||||
let mut path = n + "::";
|
||||
do list::iter(sc) {|s|
|
||||
do list::iter(sc) |s| {
|
||||
alt s {
|
||||
scope_item(i) { path = *i.ident + "::" + path; }
|
||||
_ {}
|
||||
|
|
@ -294,7 +294,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
// So we wind up reusing the glob-import machinery when looking at
|
||||
// glob exports. They just do re-exporting in a later step.
|
||||
fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
|
||||
do iter_effective_import_paths(*vi) { |vp|
|
||||
do iter_effective_import_paths(*vi) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_glob(path, _) {
|
||||
alt follow_import(*e, sc, path.idents, vp.span) {
|
||||
|
|
@ -329,8 +329,8 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
|
||||
// First, find all the modules, and index the names that they contain
|
||||
let v_map_mod =
|
||||
@{visit_view_item: {|a,b,c|index_vi(e, a, b, c)},
|
||||
visit_item: {|a,b,c|index_i(e, a, b, c)},
|
||||
@{visit_view_item: |a,b,c| index_vi(e, a, b, c),
|
||||
visit_item: |a,b,c| index_i(e, a, b, c),
|
||||
visit_block: visit_block_with_scope
|
||||
with *visit::default_visitor::<scopes>()};
|
||||
visit::visit_crate(*c, top_scope(), visit::mk_vt(v_map_mod));
|
||||
|
|
@ -346,9 +346,9 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
|
||||
// Next, assemble the links for globbed imports and exports.
|
||||
let v_link_glob =
|
||||
@{visit_view_item: {|a,b,c|link_glob(e, a, b, c)},
|
||||
@{visit_view_item: |a,b,c| link_glob(e, a, b, c),
|
||||
visit_block: visit_block_with_scope,
|
||||
visit_item: {|a,b,c|visit_item_with_scope(e, a, b, c)}
|
||||
visit_item: |a,b,c| visit_item_with_scope(e, a, b, c)
|
||||
with *visit::default_visitor::<scopes>()};
|
||||
visit::visit_crate(*c, top_scope(), visit::mk_vt(v_link_glob));
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
|
||||
fn resolve_imports(e: env) {
|
||||
e.used_imports.track = true;
|
||||
for e.imports.each {|id, v|
|
||||
for e.imports.each |id, v| {
|
||||
alt check v {
|
||||
todo(name, path, span, scopes) {
|
||||
resolve_import(e, id, name, *path, span, scopes);
|
||||
|
|
@ -372,7 +372,7 @@ fn resolve_imports(e: env) {
|
|||
// using lint-specific control flags presently but resolve-specific data
|
||||
// structures. Should use the general lint framework (with scopes, attrs).
|
||||
fn check_unused_imports(e: @env, level: lint::level) {
|
||||
for e.imports.each {|k, v|
|
||||
for e.imports.each |k, v| {
|
||||
alt v {
|
||||
resolved(_, _, _, _, name, sp) {
|
||||
if !vec::contains(e.used_imports.data, k) {
|
||||
|
|
@ -415,17 +415,17 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
|||
e.used_imports.track = true;
|
||||
let v =
|
||||
@{visit_foreign_item: visit_foreign_item_with_scope,
|
||||
visit_item: {|a,b,c|walk_item(e, a, b, c)},
|
||||
visit_item: |a,b,c| walk_item(e, a, b, c),
|
||||
visit_block: visit_block_with_scope,
|
||||
visit_decl: visit_decl_with_scope,
|
||||
visit_arm: visit_arm_with_scope,
|
||||
visit_local: {|a,b,c|visit_local_with_scope(e, a, b, c)},
|
||||
visit_pat: {|a,b,c|walk_pat(e, a, b, c)},
|
||||
visit_expr: {|a,b,c|walk_expr(e, a, b ,c)},
|
||||
visit_ty: {|a,b,c|walk_ty(e, a, b, c)},
|
||||
visit_ty_params: {|a,b,c|walk_tps(e, a, b, c)},
|
||||
visit_constr: {|a,b,c,d,f|walk_constr(e, a, b, c, d, f)},
|
||||
visit_fn: {|a,b,c,d,f,g,h|
|
||||
visit_local: |a,b,c| visit_local_with_scope(e, a, b, c),
|
||||
visit_pat: |a,b,c| walk_pat(e, a, b, c),
|
||||
visit_expr: |a,b,c| walk_expr(e, a, b ,c),
|
||||
visit_ty: |a,b,c| walk_ty(e, a, b, c),
|
||||
visit_ty_params: |a,b,c| walk_tps(e, a, b, c),
|
||||
visit_constr: |a,b,c,d,f| walk_constr(e, a, b, c, d, f),
|
||||
visit_fn: |a,b,c,d,f,g,h| {
|
||||
visit_fn_with_scope(e, a, b, c, d, f, g, h)
|
||||
}
|
||||
with *visit::default_visitor()};
|
||||
|
|
@ -440,10 +440,10 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
|||
refer to, so it's possible to resolve them.
|
||||
*/
|
||||
ast::item_impl(_, _, ifce, _, _) {
|
||||
ifce.iter({|p| resolve_iface_ref(p, sc, e);})
|
||||
ifce.iter(|p| resolve_iface_ref(p, sc, e))
|
||||
}
|
||||
ast::item_class(_, ifaces, _, _, _, _) {
|
||||
for ifaces.each {|p|
|
||||
for ifaces.each |p| {
|
||||
resolve_iface_ref(p, sc, e);
|
||||
}
|
||||
}
|
||||
|
|
@ -460,7 +460,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
|||
}
|
||||
ast::expr_fn(_, _, _, cap_clause) |
|
||||
ast::expr_fn_block(_, _, cap_clause) {
|
||||
for (*cap_clause).each { |ci|
|
||||
for (*cap_clause).each |ci| {
|
||||
resolve_capture_item(e, sc, ci);
|
||||
}
|
||||
}
|
||||
|
|
@ -481,9 +481,9 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
|||
&&sc: scopes, v: vt<scopes>) {
|
||||
let outer_current_tp = e.current_tp;
|
||||
let mut current = 0u;
|
||||
for tps.each {|tp|
|
||||
for tps.each |tp| {
|
||||
e.current_tp = some(current);
|
||||
for vec::each(*tp.bounds) {|bound|
|
||||
for vec::each(*tp.bounds) |bound| {
|
||||
alt bound {
|
||||
bound_iface(t) { v.visit_ty(t, sc, v); }
|
||||
_ {}
|
||||
|
|
@ -554,9 +554,9 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
|
|||
alt i.node {
|
||||
ast::item_impl(tps, _, ifce, sty, methods) {
|
||||
v.visit_ty_params(tps, sc, v);
|
||||
option::iter(ifce, {|p| visit::visit_path(p.path, sc, v)});
|
||||
option::iter(ifce, |p| visit::visit_path(p.path, sc, v));
|
||||
v.visit_ty(sty, sc, v);
|
||||
for methods.each {|m|
|
||||
for methods.each |m| {
|
||||
v.visit_ty_params(m.tps, sc, v);
|
||||
let msc = @cons(scope_method(m.self_id, vec::append(tps, m.tps)),
|
||||
sc);
|
||||
|
|
@ -567,10 +567,10 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
|
|||
ast::item_iface(tps, _, methods) {
|
||||
v.visit_ty_params(tps, sc, v);
|
||||
let isc = @cons(scope_method(i.id, tps), sc);
|
||||
for methods.each {|m|
|
||||
for methods.each |m| {
|
||||
v.visit_ty_params(m.tps, isc, v);
|
||||
let msc = @cons(scope_method(i.id, vec::append(tps, m.tps)), sc);
|
||||
for m.decl.inputs.each {|a| v.visit_ty(a.ty, msc, v); }
|
||||
for m.decl.inputs.each |a| { v.visit_ty(a.ty, msc, v); }
|
||||
v.visit_ty(m.decl.output, msc, v);
|
||||
}
|
||||
}
|
||||
|
|
@ -581,14 +581,14 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
|
|||
let ctor_scope = @cons(scope_method(ctor.node.self_id, tps),
|
||||
class_scope);
|
||||
/* visit the iface refs in the class scope */
|
||||
for ifaces.each {|p|
|
||||
for ifaces.each |p| {
|
||||
visit::visit_path(p.path, class_scope, v);
|
||||
}
|
||||
visit_fn_with_scope(e, visit::fk_ctor(i.ident, tps, ctor.node.self_id,
|
||||
local_def(i.id)), ctor.node.dec,
|
||||
ctor.node.body, ctor.span, ctor.node.id,
|
||||
ctor_scope, v);
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
let dtor_scope = @cons(scope_method(dtor.node.self_id, tps),
|
||||
class_scope);
|
||||
|
||||
|
|
@ -599,7 +599,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
|
|||
dtor_scope, v);
|
||||
};
|
||||
/* visit the items */
|
||||
for members.each {|cm|
|
||||
for members.each |cm| {
|
||||
alt cm.node {
|
||||
class_method(m) {
|
||||
let msc = @cons(scope_method(m.self_id,
|
||||
|
|
@ -641,7 +641,7 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
|
|||
|
||||
// here's where we need to set up the mapping
|
||||
// for f's constrs in the table.
|
||||
for decl.constraints.each {|c| resolve_constr(e, c, sc, v); }
|
||||
for decl.constraints.each |c| { resolve_constr(e, c, sc, v); }
|
||||
let scope = alt fk {
|
||||
visit::fk_item_fn(_, tps) | visit::fk_method(_, tps, _)
|
||||
| visit::fk_ctor(_, tps, _, _) | visit::fk_dtor(tps, _, _) {
|
||||
|
|
@ -658,8 +658,8 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
|
|||
fn visit_block_with_scope(b: ast::blk, &&sc: scopes, v: vt<scopes>) {
|
||||
let pos = @mut 0u, loc = @mut 0u;
|
||||
let block_sc = @cons(scope_block(b, pos, loc), sc);
|
||||
for b.node.view_items.each {|vi| v.visit_view_item(vi, block_sc, v); }
|
||||
for b.node.stmts.each {|stmt|
|
||||
for b.node.view_items.each |vi| { v.visit_view_item(vi, block_sc, v); }
|
||||
for b.node.stmts.each |stmt| {
|
||||
v.visit_stmt(stmt, block_sc, v);;
|
||||
*pos += 1u;;
|
||||
*loc = 0u;
|
||||
|
|
@ -674,14 +674,14 @@ fn visit_decl_with_scope(d: @decl, &&sc: scopes, v: vt<scopes>) {
|
|||
};
|
||||
alt d.node {
|
||||
decl_local(locs) {
|
||||
for locs.each {|loc| v.visit_local(loc, sc, v);; *loc_pos += 1u; }
|
||||
for locs.each |loc| { v.visit_local(loc, sc, v);; *loc_pos += 1u; }
|
||||
}
|
||||
decl_item(it) { v.visit_item(it, sc, v); }
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_arm_with_scope(a: ast::arm, &&sc: scopes, v: vt<scopes>) {
|
||||
for a.pats.each {|p| v.visit_pat(p, sc, v); }
|
||||
for a.pats.each |p| { v.visit_pat(p, sc, v); }
|
||||
let sc_inner = @cons(scope_arm(a), sc);
|
||||
visit::visit_expr_opt(a.guard, sc_inner, v);
|
||||
v.visit_block(a.body, sc_inner, v);
|
||||
|
|
@ -694,7 +694,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
|
|||
// scope. We disallow this, in order to make alt patterns consisting of a
|
||||
// single identifier unambiguous (does the pattern "foo" refer to enum
|
||||
// foo, or is it binding a new name foo?)
|
||||
do ast_util::walk_pat(loc.node.pat) { |p|
|
||||
do ast_util::walk_pat(loc.node.pat) |p| {
|
||||
alt p.node {
|
||||
pat_ident(path, _) {
|
||||
alt lookup_in_scope(*e, sc, loc.span, path_to_ident(path),
|
||||
|
|
@ -738,7 +738,7 @@ fn follow_import(e: env, &&sc: scopes, path: ~[ident], sp: span) ->
|
|||
alt dcur {
|
||||
some(ast::def_mod(_)) | some(ast::def_foreign_mod(_)) { ret dcur; }
|
||||
_ {
|
||||
e.sess.span_err(sp, str::connect(path.map({|x|*x}), "::") +
|
||||
e.sess.span_err(sp, str::connect(path.map(|x|*x), "::") +
|
||||
" does not name a module.");
|
||||
ret none;
|
||||
}
|
||||
|
|
@ -779,8 +779,8 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
|
|||
fn find_imports_after(e: env, id: node_id, &&sc: scopes) -> ~[node_id] {
|
||||
fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] {
|
||||
let mut imports = ~[], found = false;
|
||||
for vis.each {|vi|
|
||||
do iter_effective_import_paths(*vi) {|vp|
|
||||
for vis.each |vi| {
|
||||
do iter_effective_import_paths(*vi) |vp| {
|
||||
alt vp.node {
|
||||
view_path_simple(_, _, id)
|
||||
| view_path_glob(_, id) {
|
||||
|
|
@ -788,7 +788,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
|
|||
if found { vec::push(imports, id); }
|
||||
}
|
||||
view_path_list(_, ids, _) {
|
||||
for ids.each {|id|
|
||||
for ids.each |id| {
|
||||
if id.node.id == my_id { found = true; }
|
||||
if found { vec::push(imports, id.node.id); }
|
||||
}
|
||||
|
|
@ -826,7 +826,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
|
|||
let end_id = ids[n_idents - 1u];
|
||||
if n_idents == 1u {
|
||||
register(e, n_id, in_scope(sc), sp, name,
|
||||
{|ns| lookup_in_scope(e, sc, sp, end_id, ns, true) }, ~[]);
|
||||
|ns| lookup_in_scope(e, sc, sp, end_id, ns, true), ~[]);
|
||||
} else {
|
||||
alt lookup_in_scope(e, sc, sp, ids[0], ns_module, true) {
|
||||
none {
|
||||
|
|
@ -838,7 +838,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
|
|||
if i == n_idents - 1u {
|
||||
let mut impls = ~[];
|
||||
find_impls_in_mod(e, dcur, impls, some(end_id));
|
||||
register(e, n_id, in_mod(dcur), sp, name, {|ns|
|
||||
register(e, n_id, in_mod(dcur), sp, name, |ns| {
|
||||
lookup_in_mod(e, dcur, sp, end_id, ns, outside)
|
||||
}, impls);
|
||||
break;
|
||||
|
|
@ -884,7 +884,7 @@ enum ctxt { in_mod(def), in_scope(scopes), }
|
|||
|
||||
fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
|
||||
fn find_fn_or_mod_scope(sc: scopes) -> option<scope> {
|
||||
for list::each(sc) {|cur|
|
||||
for list::each(sc) |cur| {
|
||||
alt cur {
|
||||
scope_crate | scope_bare_fn(_, _, _) | scope_fn_expr(_, _, _) |
|
||||
scope_item(@{node: ast::item_mod(_), _}) {
|
||||
|
|
@ -900,7 +900,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
|
|||
in_scope(sc) {
|
||||
alt find_fn_or_mod_scope(sc) {
|
||||
some(err_scope) {
|
||||
for e.reported.each {|rs|
|
||||
for e.reported.each |rs| {
|
||||
if str::eq(*rs.ident, *name) && err_scope == rs.sc { ret; }
|
||||
}
|
||||
e.reported.push({ident: name, sc: err_scope});
|
||||
|
|
@ -914,7 +914,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
|
|||
path = @(e.mod_map.get(did.node).path + *path);
|
||||
} else if did.node != ast::crate_node_id {
|
||||
let paths = e.ext_map.get(did);
|
||||
path = @str::connect(vec::append_one(paths, path).map({|x|*x}),
|
||||
path = @str::connect(vec::append_one(paths, path).map(|x|*x),
|
||||
"::");
|
||||
}
|
||||
}
|
||||
|
|
@ -1168,7 +1168,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
|
|||
fn lookup_in_ty_params(e: env, name: ident, ty_params: ~[ast::ty_param])
|
||||
-> option<def> {
|
||||
let mut n = 0u;
|
||||
for ty_params.each {|tp|
|
||||
for ty_params.each |tp| {
|
||||
if str::eq(*tp.ident, *name) && alt e.current_tp {
|
||||
some(cur) { n < cur } none { true }
|
||||
} { ret some(ast::def_ty_param(local_def(tp.id), n)); }
|
||||
|
|
@ -1180,7 +1180,7 @@ fn lookup_in_ty_params(e: env, name: ident, ty_params: ~[ast::ty_param])
|
|||
fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> {
|
||||
let mut found = none;
|
||||
|
||||
do pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n|
|
||||
do pat_util::pat_bindings(e.def_map, pat) |p_id, _sp, n| {
|
||||
if str::eq(*path_to_ident(n), *name)
|
||||
{ found = some(p_id); }
|
||||
};
|
||||
|
|
@ -1192,7 +1192,7 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
|
|||
ns: namespace) -> option<def> {
|
||||
alt ns {
|
||||
ns_val {
|
||||
for decl.inputs.each {|a|
|
||||
for decl.inputs.each |a| {
|
||||
if str::eq(*a.ident, *name) {
|
||||
ret some(ast::def_arg(a.id, a.mode));
|
||||
}
|
||||
|
|
@ -1242,7 +1242,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
|
|||
} else {
|
||||
alt ns {
|
||||
ns_val {
|
||||
for variants.each {|v|
|
||||
for variants.each |v| {
|
||||
if str::eq(*v.node.name, *name) {
|
||||
let i = v.node.id;
|
||||
ret some(ast::def_variant
|
||||
|
|
@ -1269,7 +1269,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
|
|||
_ { }
|
||||
}
|
||||
}
|
||||
for b.view_items.each {|vi|
|
||||
for b.view_items.each |vi| {
|
||||
let mut is_import = false;
|
||||
alt vi.node {
|
||||
ast::view_item_import(_) { is_import = true; }
|
||||
|
|
@ -1279,7 +1279,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
|
|||
alt vi.node {
|
||||
|
||||
ast::view_item_import(vps) | ast::view_item_export(vps) {
|
||||
for vps.each {|vp|
|
||||
for vps.each |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(ident, _, id) {
|
||||
if is_import && name == ident {
|
||||
|
|
@ -1288,7 +1288,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
|
|||
}
|
||||
|
||||
ast::view_path_list(path, idents, _) {
|
||||
for idents.each {|ident|
|
||||
for idents.each |ident| {
|
||||
if name == ident.node.name {
|
||||
ret lookup_import(e, ident.node.id, ns);
|
||||
}
|
||||
|
|
@ -1487,7 +1487,7 @@ fn lookup_in_local_mod(e: env, node_id: node_id, sp: span, id: ident,
|
|||
alt inf.index.find(id) {
|
||||
none { }
|
||||
some(lst) {
|
||||
let found = list_search(lst, {|x| lookup_in_mie(e, x, ns)});
|
||||
let found = list_search(lst, |x| lookup_in_mie(e, x, ns));
|
||||
if !is_none(found) {
|
||||
ret found;
|
||||
}
|
||||
|
|
@ -1518,14 +1518,14 @@ fn lookup_in_globs(e: env, globs: ~[glob_imp_def], sp: span, id: ident,
|
|||
}
|
||||
let g = copy globs; // FIXME #2405
|
||||
let matches = vec::filter_map(g,
|
||||
{|x| lookup_in_mod_(e, x, sp, id, ns, dr)});
|
||||
|x| lookup_in_mod_(e, x, sp, id, ns, dr));
|
||||
if vec::len(matches) == 0u {
|
||||
ret none;
|
||||
}
|
||||
else if vec::len(matches) == 1u {
|
||||
ret some(matches[0].def);
|
||||
} else {
|
||||
for matches.each {|match|
|
||||
for matches.each |match| {
|
||||
let sp = match.path.span;
|
||||
e.sess.span_note(sp, #fmt["'%s' is imported here", *id]);
|
||||
}
|
||||
|
|
@ -1604,7 +1604,7 @@ fn add_to_index(index: hashmap<ident, @list<mod_index_entry>>, id: ident,
|
|||
|
||||
fn index_view_items(view_items: ~[@ast::view_item],
|
||||
index: hashmap<ident, @list<mod_index_entry>>) {
|
||||
for view_items.each {|vi|
|
||||
for view_items.each |vi| {
|
||||
alt vi.node {
|
||||
ast::view_item_use(ident, _, id) {
|
||||
add_to_index(index, ident, mie_view_item(ident, id, vi.span));
|
||||
|
|
@ -1612,13 +1612,13 @@ fn index_view_items(view_items: ~[@ast::view_item],
|
|||
_ {}
|
||||
}
|
||||
|
||||
do iter_effective_import_paths(*vi) {|vp|
|
||||
do iter_effective_import_paths(*vi) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(ident, _, id) {
|
||||
add_to_index(index, ident, mie_import_ident(id, vp.span));
|
||||
}
|
||||
ast::view_path_list(_, idents, _) {
|
||||
for idents.each {|ident|
|
||||
for idents.each |ident| {
|
||||
add_to_index(index, ident.node.name,
|
||||
mie_import_ident(ident.node.id,
|
||||
ident.span));
|
||||
|
|
@ -1637,7 +1637,7 @@ fn index_mod(md: ast::_mod) -> mod_index {
|
|||
|
||||
index_view_items(md.view_items, index);
|
||||
|
||||
for md.items.each {|it|
|
||||
for md.items.each |it| {
|
||||
alt it.node {
|
||||
ast::item_const(_, _) | ast::item_fn(_, _, _) | ast::item_mod(_) |
|
||||
ast::item_foreign_mod(_) | ast::item_ty(_, _, _) |
|
||||
|
|
@ -1647,7 +1647,7 @@ fn index_mod(md: ast::_mod) -> mod_index {
|
|||
ast::item_enum(variants, _, _) {
|
||||
add_to_index(index, it.ident, mie_item(it));
|
||||
let mut variant_idx: uint = 0u;
|
||||
for variants.each {|v|
|
||||
for variants.each |v| {
|
||||
add_to_index(index, v.node.name,
|
||||
mie_enum_variant(variant_idx, variants,
|
||||
it.id, it.span));
|
||||
|
|
@ -1669,7 +1669,7 @@ fn index_nmod(md: ast::foreign_mod) -> mod_index {
|
|||
|
||||
index_view_items(md.view_items, index);
|
||||
|
||||
for md.items.each {|it|
|
||||
for md.items.each |it| {
|
||||
add_to_index(index, it.ident, mie_foreign_item(it));
|
||||
}
|
||||
ret index;
|
||||
|
|
@ -1694,7 +1694,7 @@ fn ns_for_def(d: def) -> namespace {
|
|||
fn lookup_external(e: env, cnum: int, ids: ~[ident], ns: namespace) ->
|
||||
option<def> {
|
||||
let mut result = none;
|
||||
for csearch::lookup_defs(e.sess.cstore, cnum, ids).each {|d|
|
||||
for csearch::lookup_defs(e.sess.cstore, cnum, ids).each |d| {
|
||||
e.ext_map.insert(def_id_of_def(d), ids);
|
||||
if ns == ns_for_def(d) { result = some(d); }
|
||||
}
|
||||
|
|
@ -1706,16 +1706,16 @@ fn lookup_external(e: env, cnum: int, ids: ~[ident], ns: namespace) ->
|
|||
fn check_for_collisions(e: @env, c: ast::crate) {
|
||||
// Module indices make checking those relatively simple -- just check each
|
||||
// name for multiple entities in the same namespace.
|
||||
for e.mod_map.each_value {|val|
|
||||
for val.index.each {|k, v| check_mod_name(*e, k, v); };
|
||||
for e.mod_map.each_value |val| {
|
||||
for val.index.each |k, v| { check_mod_name(*e, k, v); };
|
||||
};
|
||||
// Other scopes have to be checked the hard way.
|
||||
let v =
|
||||
@{visit_item: {|a,b,c|check_item(e, a, b, c)},
|
||||
visit_block: {|a,b,c|check_block(e, a, b, c)},
|
||||
visit_arm: {|a,b,c|check_arm(e, a, b, c)},
|
||||
visit_expr: {|a,b,c|check_expr(e, a, b, c)},
|
||||
visit_ty: {|a,b,c|check_ty(e, a, b, c)}
|
||||
@{visit_item: |a,b,c| check_item(e, a, b, c),
|
||||
visit_block: |a,b,c| check_block(e, a, b, c),
|
||||
visit_arm: |a,b,c| check_arm(e, a, b, c),
|
||||
visit_expr: |a,b,c| check_expr(e, a, b, c),
|
||||
visit_ty: |a,b,c| check_ty(e, a, b, c)
|
||||
with *visit::default_visitor()};
|
||||
visit::visit_crate(c, (), visit::mk_vt(v));
|
||||
}
|
||||
|
|
@ -1766,26 +1766,26 @@ fn mie_span(mie: mod_index_entry) -> span {
|
|||
fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) {
|
||||
fn typaram_names(tps: ~[ast::ty_param]) -> ~[ident] {
|
||||
let mut x: ~[ast::ident] = ~[];
|
||||
for tps.each {|tp| vec::push(x, tp.ident); }
|
||||
for tps.each |tp| { vec::push(x, tp.ident); }
|
||||
ret x;
|
||||
}
|
||||
visit::visit_item(i, x, v);
|
||||
alt i.node {
|
||||
ast::item_fn(decl, ty_params, _) {
|
||||
check_fn(*e, i.span, decl);
|
||||
ensure_unique(*e, i.span, ty_params, {|tp| tp.ident},
|
||||
ensure_unique(*e, i.span, ty_params, |tp| tp.ident,
|
||||
"type parameter");
|
||||
}
|
||||
ast::item_enum(_, ty_params, _) {
|
||||
ensure_unique(*e, i.span, ty_params, {|tp| tp.ident},
|
||||
ensure_unique(*e, i.span, ty_params, |tp| tp.ident,
|
||||
"type parameter");
|
||||
}
|
||||
ast::item_iface(_, _, methods) {
|
||||
ensure_unique(*e, i.span, methods, {|m| m.ident},
|
||||
ensure_unique(*e, i.span, methods, |m| m.ident,
|
||||
"method");
|
||||
}
|
||||
ast::item_impl(_, _, _, _, methods) {
|
||||
ensure_unique(*e, i.span, methods, {|m| m.ident},
|
||||
ensure_unique(*e, i.span, methods, |m| m.ident,
|
||||
"method");
|
||||
}
|
||||
_ { }
|
||||
|
|
@ -1793,7 +1793,7 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) {
|
|||
}
|
||||
|
||||
fn check_pat(e: @env, ch: checker, p: @ast::pat) {
|
||||
do pat_util::pat_bindings(e.def_map, p) {|_i, p_sp, n|
|
||||
do pat_util::pat_bindings(e.def_map, p) |_i, p_sp, n| {
|
||||
add_name(ch, p_sp, path_to_ident(n));
|
||||
};
|
||||
}
|
||||
|
|
@ -1815,8 +1815,8 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) {
|
|||
e.sess.span_err(a.pats[i].span,
|
||||
"inconsistent number of bindings");
|
||||
} else {
|
||||
for ch.seen.each {|name|
|
||||
if is_none(vec::find(seen0, {|x|str::eq(*name, *x)})) {
|
||||
for ch.seen.each |name| {
|
||||
if is_none(vec::find(seen0, |x| str::eq(*name, *x))) {
|
||||
// Fight the alias checker
|
||||
let name_ = name;
|
||||
e.sess.span_err(a.pats[i].span,
|
||||
|
|
@ -1833,15 +1833,15 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) {
|
|||
let values = checker(*e, "value");
|
||||
let types = checker(*e, "type");
|
||||
let mods = checker(*e, "module");
|
||||
for b.node.stmts.each {|st|
|
||||
for b.node.stmts.each |st| {
|
||||
alt st.node {
|
||||
ast::stmt_decl(d, _) {
|
||||
alt d.node {
|
||||
ast::decl_local(locs) {
|
||||
let local_values = checker(*e, "value");
|
||||
for locs.each {|loc|
|
||||
for locs.each |loc| {
|
||||
do pat_util::pat_bindings(e.def_map, loc.node.pat)
|
||||
{|_i, p_sp, n|
|
||||
|_i, p_sp, n| {
|
||||
let ident = path_to_ident(n);
|
||||
add_name(local_values, p_sp, ident);
|
||||
check_name(values, p_sp, ident);
|
||||
|
|
@ -1852,7 +1852,7 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) {
|
|||
alt it.node {
|
||||
ast::item_enum(variants, _, _) {
|
||||
add_name(types, it.span, it.ident);
|
||||
for variants.each {|v|
|
||||
for variants.each |v| {
|
||||
add_name(values, v.span, v.node.name);
|
||||
}
|
||||
}
|
||||
|
|
@ -1909,7 +1909,7 @@ fn checker(e: env, kind: str) -> checker {
|
|||
}
|
||||
|
||||
fn check_name(ch: checker, sp: span, name: ident) {
|
||||
for ch.seen.each {|s|
|
||||
for ch.seen.each |s| {
|
||||
if str::eq(*s, *name) {
|
||||
ch.sess.span_fatal(
|
||||
sp, "duplicate " + ch.kind + " name: " + *name);
|
||||
|
|
@ -1924,7 +1924,7 @@ fn add_name(ch: checker, sp: span, name: ident) {
|
|||
fn ensure_unique<T>(e: env, sp: span, elts: ~[T], id: fn(T) -> ident,
|
||||
kind: str) {
|
||||
let ch = checker(e, kind);
|
||||
for elts.each {|elt| add_name(ch, sp, id(elt)); }
|
||||
for elts.each |elt| { add_name(ch, sp, id(elt)); }
|
||||
}
|
||||
|
||||
fn check_exports(e: @env) {
|
||||
|
|
@ -1942,15 +1942,15 @@ fn check_exports(e: @env) {
|
|||
assert mid.crate == ast::local_crate;
|
||||
let ixm = e.mod_map.get(mid.node);
|
||||
|
||||
for ixm.index.each {|ident, mies|
|
||||
do list::iter(mies) {|mie|
|
||||
for ixm.index.each |ident, mies| {
|
||||
do list::iter(mies) |mie| {
|
||||
alt mie {
|
||||
mie_item(item) {
|
||||
let defs =
|
||||
~[ found_def_item(item, ns_val),
|
||||
found_def_item(item, ns_type),
|
||||
found_def_item(item, ns_module) ];
|
||||
for defs.each {|d|
|
||||
for defs.each |d| {
|
||||
alt d {
|
||||
some(def) {
|
||||
f(ident, def);
|
||||
|
|
@ -1984,7 +1984,7 @@ fn check_exports(e: @env) {
|
|||
|
||||
|
||||
fn maybe_add_reexport(e: @env, export_id: node_id, def: option<def>) {
|
||||
do option::iter(def) {|def|
|
||||
do option::iter(def) |def| {
|
||||
add_export(e, export_id, def_id_of_def(def), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -2004,7 +2004,7 @@ fn check_exports(e: @env) {
|
|||
if _mod.index.contains_key(ident) {
|
||||
found_something = true;
|
||||
let xs = _mod.index.get(ident);
|
||||
do list::iter(xs) {|x|
|
||||
do list::iter(xs) |x| {
|
||||
alt x {
|
||||
mie_import_ident(id, _) {
|
||||
alt check e.imports.get(id) {
|
||||
|
|
@ -2045,7 +2045,7 @@ fn check_exports(e: @env) {
|
|||
e.sess.span_fatal(sp, #fmt("undefined id %s in an export", *id));
|
||||
}
|
||||
some(ms) {
|
||||
let maybe_id = do list_search(ms) {|m|
|
||||
let maybe_id = do list_search(ms) |m| {
|
||||
alt m {
|
||||
mie_item(@{node: item_enum(_, _, _), id, _}) { some(id) }
|
||||
_ { none }
|
||||
|
|
@ -2065,11 +2065,11 @@ fn check_exports(e: @env) {
|
|||
ids: ~[ast::path_list_ident]) {
|
||||
let parent_id = check_enum_ok(e, span, id, _mod);
|
||||
add_export(e, export_id, local_def(parent_id), false);
|
||||
for ids.each {|variant_id|
|
||||
for ids.each |variant_id| {
|
||||
let mut found = false;
|
||||
alt _mod.index.find(variant_id.node.name) {
|
||||
some(ms) {
|
||||
do list::iter(ms) {|m|
|
||||
do list::iter(ms) |m| {
|
||||
alt m {
|
||||
mie_enum_variant(_, _, actual_parent_id, _) {
|
||||
found = true;
|
||||
|
|
@ -2093,13 +2093,13 @@ fn check_exports(e: @env) {
|
|||
}
|
||||
}
|
||||
|
||||
for e.mod_map.each_value {|_mod|
|
||||
for e.mod_map.each_value |_mod| {
|
||||
alt _mod.m {
|
||||
some(m) {
|
||||
let glob_is_re_exported = int_hash();
|
||||
|
||||
for m.view_items.each {|vi|
|
||||
do iter_export_paths(*vi) { |vp|
|
||||
for m.view_items.each |vi| {
|
||||
do iter_export_paths(*vi) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(ident, _, id) {
|
||||
check_export(e, ident, _mod, id, vi);
|
||||
|
|
@ -2121,13 +2121,13 @@ fn check_exports(e: @env) {
|
|||
}
|
||||
// Now follow the export-glob links and fill in the
|
||||
// globbed_exports and exp_map lists.
|
||||
for _mod.glob_imports.each {|glob|
|
||||
for _mod.glob_imports.each |glob| {
|
||||
let id = alt check glob.path.node {
|
||||
ast::view_path_glob(_, node_id) { node_id }
|
||||
};
|
||||
if ! glob_is_re_exported.contains_key(id) { cont; }
|
||||
do iter_mod(*e, glob.def,
|
||||
glob.path.span, outside) {|ident, def|
|
||||
glob.path.span, outside) |ident, def| {
|
||||
vec::push(_mod.globbed_exports, ident);
|
||||
maybe_add_reexport(e, id, some(def));
|
||||
}
|
||||
|
|
@ -2154,9 +2154,9 @@ type iscopes = @list<@~[@_impl]>;
|
|||
|
||||
fn resolve_impls(e: @env, c: @ast::crate) {
|
||||
visit::visit_crate(*c, @nil, visit::mk_vt(@{
|
||||
visit_block: {|a,b,c|visit_block_with_impl_scope(e, a, b, c)},
|
||||
visit_mod: {|a,b,c,d,f|visit_mod_with_impl_scope(e, a, b, c, d, f)},
|
||||
visit_expr: {|a,b,c|resolve_impl_in_expr(e, a, b, c)}
|
||||
visit_block: |a,b,c| visit_block_with_impl_scope(e, a, b, c),
|
||||
visit_mod: |a,b,c,d,f| visit_mod_with_impl_scope(e, a, b, c, d, f),
|
||||
visit_expr: |a,b,c| resolve_impl_in_expr(e, a, b, c)
|
||||
with *visit::default_visitor()
|
||||
}));
|
||||
}
|
||||
|
|
@ -2177,15 +2177,15 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
|
|||
}
|
||||
}
|
||||
|
||||
do iter_effective_import_paths(*vi) { |vp|
|
||||
do iter_effective_import_paths(*vi) |vp| {
|
||||
alt vp.node {
|
||||
ast::view_path_simple(name, pt, id) {
|
||||
let mut found = ~[];
|
||||
if vec::len(pt.idents) == 1u {
|
||||
do option::iter(sc) {|sc|
|
||||
do list::iter(sc) {|level|
|
||||
do option::iter(sc) |sc| {
|
||||
do list::iter(sc) |level| {
|
||||
if vec::len(found) == 0u {
|
||||
for vec::each(*level) {|imp|
|
||||
for vec::each(*level) |imp| {
|
||||
if imp.ident == pt.idents[0] {
|
||||
vec::push(found,
|
||||
@{ident: name with *imp});
|
||||
|
|
@ -2198,8 +2198,8 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
do lookup_imported_impls(e, id) {|is|
|
||||
for vec::each(*is) {|i|
|
||||
do lookup_imported_impls(e, id) |is| {
|
||||
for vec::each(*is) |i| {
|
||||
vec::push(impls, @{ident: name with *i});
|
||||
}
|
||||
}
|
||||
|
|
@ -2207,8 +2207,8 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
|
|||
}
|
||||
|
||||
ast::view_path_list(base, names, _) {
|
||||
for names.each {|nm|
|
||||
lookup_imported_impls(e, nm.node.id, {|is|
|
||||
for names.each |nm| {
|
||||
lookup_imported_impls(e, nm.node.id, |is| {
|
||||
vec::push_all(impls, *is);
|
||||
})
|
||||
}
|
||||
|
|
@ -2246,7 +2246,7 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: ~[@_impl],
|
|||
} {
|
||||
vec::push(impls, @{did: local_def(i.id),
|
||||
ident: i.ident,
|
||||
methods: vec::map(mthds, {|m|
|
||||
methods: vec::map(mthds, |m| {
|
||||
@{did: local_def(m.id),
|
||||
n_tps: vec::len(m.tps),
|
||||
ident: m.ident}
|
||||
|
|
@ -2256,15 +2256,15 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: ~[@_impl],
|
|||
ast::item_class(tps, ifces, items, _, _, _) {
|
||||
let (_, mthds) = ast_util::split_class_items(items);
|
||||
let n_tps = tps.len();
|
||||
do vec::iter(ifces) {|p|
|
||||
// The def_id, in this case, identifies the combination of
|
||||
// class and iface
|
||||
vec::push(impls, @{did: local_def(p.id),
|
||||
ident: i.ident,
|
||||
methods: vec::map(mthds, {|m|
|
||||
@{did: local_def(m.id),
|
||||
n_tps: n_tps + m.tps.len(),
|
||||
ident: m.ident}})});
|
||||
do vec::iter(ifces) |p| {
|
||||
// The def_id, in this case, identifies the combination of
|
||||
// class and iface
|
||||
vec::push(impls, @{did: local_def(p.id),
|
||||
ident: i.ident,
|
||||
methods: vec::map(mthds, |m| {
|
||||
@{did: local_def(m.id),
|
||||
n_tps: n_tps + m.tps.len(),
|
||||
ident: m.ident}})});
|
||||
}
|
||||
}
|
||||
_ {}
|
||||
|
|
@ -2283,13 +2283,13 @@ fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: ~[@_impl],
|
|||
let mut tmp = ~[];
|
||||
let mi = e.mod_map.get(defid.node);
|
||||
let md = option::get(mi.m);
|
||||
for md.view_items.each {|vi|
|
||||
for md.view_items.each |vi| {
|
||||
find_impls_in_view_item(e, vi, tmp, none);
|
||||
}
|
||||
for md.items.each {|i|
|
||||
for md.items.each |i| {
|
||||
find_impls_in_item(e, i, tmp, none, none);
|
||||
}
|
||||
@vec::filter(tmp, {|i| is_exported(e, i.ident, mi)})
|
||||
@vec::filter(tmp, |i| is_exported(e, i.ident, mi))
|
||||
} else {
|
||||
csearch::get_impls_for_mod(e.sess.cstore, defid, none)
|
||||
};
|
||||
|
|
@ -2298,7 +2298,7 @@ fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: ~[@_impl],
|
|||
}
|
||||
alt name {
|
||||
some(n) {
|
||||
for vec::each(*cached) {|im|
|
||||
for vec::each(*cached) |im| {
|
||||
if n == im.ident { vec::push(impls, im); }
|
||||
}
|
||||
}
|
||||
|
|
@ -2319,10 +2319,10 @@ fn find_impls_in_mod(e: env, m: def, &impls: ~[@_impl],
|
|||
fn visit_block_with_impl_scope(e: @env, b: ast::blk, &&sc: iscopes,
|
||||
v: vt<iscopes>) {
|
||||
let mut impls = ~[];
|
||||
for b.node.view_items.each {|vi|
|
||||
for b.node.view_items.each |vi| {
|
||||
find_impls_in_view_item(*e, vi, impls, some(sc));
|
||||
}
|
||||
for b.node.stmts.each {|st|
|
||||
for b.node.stmts.each |st| {
|
||||
alt st.node {
|
||||
ast::stmt_decl(@{node: ast::decl_item(i), _}, _) {
|
||||
find_impls_in_item(*e, i, impls, none, none);
|
||||
|
|
@ -2337,10 +2337,10 @@ fn visit_block_with_impl_scope(e: @env, b: ast::blk, &&sc: iscopes,
|
|||
fn visit_mod_with_impl_scope(e: @env, m: ast::_mod, s: span, id: node_id,
|
||||
&&sc: iscopes, v: vt<iscopes>) {
|
||||
let mut impls = ~[];
|
||||
for m.view_items.each {|vi|
|
||||
for m.view_items.each |vi| {
|
||||
find_impls_in_view_item(*e, vi, impls, some(sc));
|
||||
}
|
||||
for m.items.each {|i| find_impls_in_item(*e, i, impls, none, none); }
|
||||
for m.items.each |i| { find_impls_in_item(*e, i, impls, none, none); }
|
||||
let impls = @impls;
|
||||
visit::visit_mod(m, s, id, if vec::len(*impls) > 0u {
|
||||
@cons(impls, sc)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
|
|||
fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
|
||||
let vdef = ast_util::variant_def_ids(tcx.def_map.get(pat_id));
|
||||
let variants = ty::enum_variants(tcx, vdef.enm);
|
||||
for vec::each(*variants) {|v|
|
||||
for vec::each(*variants) |v| {
|
||||
if vdef.var == v.id { ret var(v.disr_val, vdef); }
|
||||
}
|
||||
core::unreachable();
|
||||
|
|
@ -79,7 +79,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
|
|||
|
||||
type bind_map = ~[{ident: ast::ident, val: ValueRef}];
|
||||
fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> {
|
||||
for vec::each(list) {|elt|
|
||||
for vec::each(list) |elt| {
|
||||
if str::eq(*elt.ident, *key) { ret some(elt.val); }
|
||||
}
|
||||
ret none;
|
||||
|
|
@ -94,7 +94,7 @@ type match_branch =
|
|||
type match = ~[match_branch];
|
||||
|
||||
fn has_nested_bindings(m: match, col: uint) -> bool {
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
ast::pat_ident(_, some(_)) { ret true; }
|
||||
_ {}
|
||||
|
|
@ -105,7 +105,7 @@ fn has_nested_bindings(m: match, col: uint) -> bool {
|
|||
|
||||
fn expand_nested_bindings(m: match, col: uint, val: ValueRef) -> match {
|
||||
let mut result = ~[];
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
ast::pat_ident(name, some(inner)) {
|
||||
let pats = vec::append(
|
||||
|
|
@ -130,7 +130,7 @@ type enter_pat = fn(@ast::pat) -> option<~[@ast::pat]>;
|
|||
fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef,
|
||||
e: enter_pat) -> match {
|
||||
let mut result = ~[];
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt e(br.pats[col]) {
|
||||
some(sub) {
|
||||
let pats = vec::append(
|
||||
|
|
@ -153,7 +153,7 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef,
|
|||
}
|
||||
|
||||
fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
||||
do enter_match(dm, m, col, val) {|p|
|
||||
do enter_match(dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some(~[]) }
|
||||
ast::pat_ident(_, none) if !pat_is_variant(dm, p) {
|
||||
|
|
@ -167,7 +167,7 @@ fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
|||
fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
|
||||
variant_size: uint, val: ValueRef) -> match {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(tcx.def_map, m, col, val) {|p|
|
||||
do enter_match(tcx.def_map, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_enum(_, subpats) {
|
||||
if opt_eq(tcx, variant_opt(tcx, p.id), opt) {
|
||||
|
|
@ -193,13 +193,13 @@ fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
|
|||
fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident],
|
||||
val: ValueRef) -> match {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(dm, m, col, val) {|p|
|
||||
do enter_match(dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_rec(fpats, _) {
|
||||
let mut pats = ~[];
|
||||
for vec::each(fields) {|fname|
|
||||
for vec::each(fields) |fname| {
|
||||
let mut pat = dummy;
|
||||
for vec::each(fpats) {|fpat|
|
||||
for vec::each(fpats) |fpat| {
|
||||
if str::eq(*fpat.ident, *fname) { pat = fpat.pat; break; }
|
||||
}
|
||||
vec::push(pats, pat);
|
||||
|
|
@ -214,7 +214,7 @@ fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident],
|
|||
fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef,
|
||||
n_elts: uint) -> match {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(dm, m, col, val) {|p|
|
||||
do enter_match(dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_tup(elts) { some(elts) }
|
||||
_ { some(vec::from_elem(n_elts, dummy)) }
|
||||
|
|
@ -224,7 +224,7 @@ fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef,
|
|||
|
||||
fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(dm, m, col, val) {|p|
|
||||
do enter_match(dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_box(sub) { some(~[sub]) }
|
||||
_ { some(~[dummy]) }
|
||||
|
|
@ -234,7 +234,7 @@ fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
|||
|
||||
fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(dm, m, col, val) {|p|
|
||||
do enter_match(dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
ast::pat_uniq(sub) { some(~[sub]) }
|
||||
_ { some(~[dummy]) }
|
||||
|
|
@ -244,12 +244,12 @@ fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
|
|||
|
||||
fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> ~[opt] {
|
||||
fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) {
|
||||
if set.any({|l| opt_eq(tcx, l, val)}) {ret;}
|
||||
if set.any(|l| opt_eq(tcx, l, val)) {ret;}
|
||||
set.push(val);
|
||||
}
|
||||
|
||||
let found = dvec();
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
let cur = br.pats[col];
|
||||
if pat_is_variant(ccx.tcx.def_map, cur) {
|
||||
add_to_set(ccx.tcx, found, variant_opt(ccx.tcx, br.pats[col].id));
|
||||
|
|
@ -285,7 +285,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
|
|||
}
|
||||
let vdefs_tg = vdefs.enm;
|
||||
let vdefs_var = vdefs.var;
|
||||
let args = do vec::from_fn(size) { |i|
|
||||
let args = do vec::from_fn(size) |i| {
|
||||
GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var,
|
||||
enum_ty_substs, i)
|
||||
};
|
||||
|
|
@ -294,11 +294,11 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
|
|||
|
||||
fn collect_record_fields(m: match, col: uint) -> ~[ast::ident] {
|
||||
let mut fields: ~[ast::ident] = ~[];
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
ast::pat_rec(fs, _) {
|
||||
for vec::each(fs) {|f|
|
||||
if !vec::any(fields, {|x| str::eq(*f.ident, *x)}) {
|
||||
for vec::each(fs) |f| {
|
||||
if !vec::any(fields, |x| str::eq(*f.ident, *x)) {
|
||||
vec::push(fields, f.ident);
|
||||
}
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ fn collect_record_fields(m: match, col: uint) -> ~[ast::ident] {
|
|||
}
|
||||
|
||||
fn root_pats_as_necessary(bcx: block, m: match, col: uint, val: ValueRef) {
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
let pat_id = br.pats[col].id;
|
||||
|
||||
alt bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
||||
|
|
@ -330,21 +330,21 @@ fn root_pats_as_necessary(bcx: block, m: match, col: uint, val: ValueRef) {
|
|||
}
|
||||
|
||||
fn any_box_pat(m: match, col: uint) -> bool {
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node { ast::pat_box(_) { ret true; } _ { } }
|
||||
}
|
||||
ret false;
|
||||
}
|
||||
|
||||
fn any_uniq_pat(m: match, col: uint) -> bool {
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node { ast::pat_uniq(_) { ret true; } _ { } }
|
||||
}
|
||||
ret false;
|
||||
}
|
||||
|
||||
fn any_tup_pat(m: match, col: uint) -> bool {
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node { ast::pat_tup(_) { ret true; } _ { } }
|
||||
}
|
||||
ret false;
|
||||
|
|
@ -362,14 +362,14 @@ fn pick_col(m: match) -> uint {
|
|||
}
|
||||
}
|
||||
let scores = vec::to_mut(vec::from_elem(m[0].pats.len(), 0u));
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
let mut i = 0u;
|
||||
for vec::each(br.pats) {|p| scores[i] += score(p); i += 1u; }
|
||||
for vec::each(br.pats) |p| { scores[i] += score(p); i += 1u; }
|
||||
}
|
||||
let mut max_score = 0u;
|
||||
let mut best_col = 0u;
|
||||
let mut i = 0u;
|
||||
for vec::each(scores) {|score|
|
||||
for vec::each(scores) |score| {
|
||||
// Irrefutable columns always go first, they'd only be duplicated in
|
||||
// the branches.
|
||||
if score == 0u { ret i; }
|
||||
|
|
@ -393,16 +393,16 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
some(e) {
|
||||
// Temporarily set bindings. They'll be rewritten to PHI nodes
|
||||
// for the actual arm block.
|
||||
for data.id_map.each {|key, val|
|
||||
for data.id_map.each |key, val| {
|
||||
let loc = local_mem(option::get(assoc(key, m[0].bound)));
|
||||
bcx.fcx.lllocals.insert(val, loc);
|
||||
};
|
||||
let {bcx: guard_cx, val} = {
|
||||
do with_scope_result(bcx, e.info(), "guard") {|bcx|
|
||||
do with_scope_result(bcx, e.info(), "guard") |bcx| {
|
||||
trans_temp_expr(bcx, e)
|
||||
}
|
||||
};
|
||||
bcx = do with_cond(guard_cx, Not(guard_cx, val)) {|bcx|
|
||||
bcx = do with_cond(guard_cx, Not(guard_cx, val)) |bcx| {
|
||||
compile_submatch(bcx, vec::tail(m), vals, chk, exits);
|
||||
bcx
|
||||
};
|
||||
|
|
@ -427,7 +427,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
vec::view(vals, col + 1u, vals.len()));
|
||||
let ccx = bcx.fcx.ccx;
|
||||
let mut pat_id = 0;
|
||||
for vec::each(m) {|br|
|
||||
for vec::each(m) |br| {
|
||||
// Find a real id (we're adding placeholder wildcard patterns, but
|
||||
// each column is guaranteed to have at least one real pattern)
|
||||
if pat_id == 0 { pat_id = br.pats[col].id; }
|
||||
|
|
@ -440,7 +440,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
if rec_fields.len() > 0u {
|
||||
let fields = ty::get_fields(node_id_type(bcx, pat_id));
|
||||
let mut rec_vals = ~[];
|
||||
for vec::each(rec_fields) {|field_name|
|
||||
for vec::each(rec_fields) |field_name| {
|
||||
let ix = option::get(ty::field_idx(field_name, fields));
|
||||
vec::push(rec_vals, GEPi(bcx, val, ~[0u, ix]));
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
}
|
||||
}
|
||||
}
|
||||
for vec::each(opts) {|o|
|
||||
for vec::each(opts) |o| {
|
||||
alt o {
|
||||
range(_, _) { kind = compare; break; }
|
||||
_ { }
|
||||
|
|
@ -535,7 +535,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
let len = opts.len();
|
||||
let mut i = 0u;
|
||||
// Compile subtrees for each option
|
||||
for vec::each(opts) {|opt|
|
||||
for vec::each(opts) |opt| {
|
||||
i += 1u;
|
||||
let mut opt_cx = else_cx;
|
||||
if !exhaustive || i < len {
|
||||
|
|
@ -553,7 +553,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
|
|||
compare {
|
||||
let t = node_id_type(bcx, pat_id);
|
||||
let {bcx: after_cx, val: matches} = {
|
||||
do with_scope_result(bcx, none, "compare_scope") {|bcx|
|
||||
do with_scope_result(bcx, none, "compare_scope") |bcx| {
|
||||
alt trans_opt(bcx, opt) {
|
||||
single_result({bcx, val}) {
|
||||
trans_compare(bcx, ast::eq, test_val, t, val, t)
|
||||
|
|
@ -604,10 +604,10 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node],
|
|||
let _icx = bcx.insn_ctxt("alt::make_phi_bindings");
|
||||
let our_block = bcx.llbb as uint;
|
||||
let mut success = true, bcx = bcx;
|
||||
for ids.each {|name, node_id|
|
||||
for ids.each |name, node_id| {
|
||||
let mut llbbs = ~[];
|
||||
let mut vals = ~[];
|
||||
for vec::each(map) {|ex|
|
||||
for vec::each(map) |ex| {
|
||||
if ex.to as uint == our_block {
|
||||
alt assoc(name, ex.bound) {
|
||||
some(val) {
|
||||
|
|
@ -636,7 +636,7 @@ fn trans_alt(bcx: block,
|
|||
mode: ast::alt_mode,
|
||||
dest: dest) -> block {
|
||||
let _icx = bcx.insn_ctxt("alt::trans_alt");
|
||||
do with_scope(bcx, alt_expr.info(), "alt") {|bcx|
|
||||
do with_scope(bcx, alt_expr.info(), "alt") |bcx| {
|
||||
trans_alt_inner(bcx, expr, arms, mode, dest)
|
||||
}
|
||||
}
|
||||
|
|
@ -650,11 +650,11 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
|
|||
let {bcx, val, _} = trans_temp_expr(bcx, expr);
|
||||
if bcx.unreachable { ret bcx; }
|
||||
|
||||
for vec::each(arms) {|a|
|
||||
for vec::each(arms) |a| {
|
||||
let body = scope_block(bcx, a.body.info(), "case_body");
|
||||
let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]);
|
||||
vec::push(bodies, body);
|
||||
for vec::each(a.pats) {|p|
|
||||
for vec::each(a.pats) |p| {
|
||||
vec::push(match, @{pats: ~[p],
|
||||
bound: ~[],
|
||||
data: @{bodycx: body, guard: a.guard,
|
||||
|
|
@ -674,7 +674,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
|
|||
*done = some(fail_cx.llbb);
|
||||
ret fail_cx.llbb;
|
||||
}
|
||||
some({||mk_fail(scope_cx, expr.span, fail_cx)})
|
||||
some(|| mk_fail(scope_cx, expr.span, fail_cx))
|
||||
}
|
||||
ast::alt_exhaustive { none }
|
||||
};
|
||||
|
|
@ -684,7 +684,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
|
|||
compile_submatch(bcx, match, ~[spilled], mk_fail, exit_map);
|
||||
|
||||
let mut arm_cxs = ~[], arm_dests = ~[], i = 0u;
|
||||
for vec::each(arms) {|a|
|
||||
for vec::each(arms) |a| {
|
||||
let body_cx = bodies[i];
|
||||
let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]);
|
||||
if make_phi_bindings(body_cx, exit_map, id_map) {
|
||||
|
|
@ -728,14 +728,14 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
|||
let vdefs = ast_util::variant_def_ids(ccx.tcx.def_map.get(pat.id));
|
||||
let args = extract_variant_args(bcx, pat.id, vdefs, val);
|
||||
let mut i = 0;
|
||||
do option::iter(sub) {|sub| for vec::each(args.vals) {|argval|
|
||||
do option::iter(sub) |sub| { for vec::each(args.vals) |argval| {
|
||||
bcx = bind_irrefutable_pat(bcx, sub[i], argval, make_copy);
|
||||
i += 1;
|
||||
}}
|
||||
}
|
||||
ast::pat_rec(fields, _) {
|
||||
let rec_fields = ty::get_fields(node_id_type(bcx, pat.id));
|
||||
for vec::each(fields) {|f|
|
||||
for vec::each(fields) |f| {
|
||||
let ix = option::get(ty::field_idx(f.ident, rec_fields));
|
||||
let fldptr = GEPi(bcx, val, ~[0u, ix]);
|
||||
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy);
|
||||
|
|
@ -743,7 +743,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
|||
}
|
||||
ast::pat_tup(elems) {
|
||||
let mut i = 0u;
|
||||
for vec::each(elems) {|elem|
|
||||
for vec::each(elems) |elem| {
|
||||
let fldptr = GEPi(bcx, val, ~[0u, i]);
|
||||
bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy);
|
||||
i += 1u;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block],
|
|||
in_ds: ~[dest], out_dest: dest) -> block {
|
||||
let out = sub_block(parent_cx, "join");
|
||||
let mut reachable = false, i = 0u, phi = none;
|
||||
for vec::each(in_cxs) {|cx|
|
||||
for vec::each(in_cxs) |cx| {
|
||||
if !cx.unreachable {
|
||||
Br(cx, out.llbb);
|
||||
reachable = true;
|
||||
|
|
@ -172,7 +172,7 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec,
|
|||
|
||||
fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv,
|
||||
llty: TypeRef) -> ValueRef {
|
||||
let llfn: ValueRef = str::as_c_str(name, {|buf|
|
||||
let llfn: ValueRef = str::as_c_str(name, |buf| {
|
||||
llvm::LLVMGetOrInsertFunction(llmod, buf, llty)
|
||||
});
|
||||
lib::llvm::SetFunctionCallConv(llfn, cc);
|
||||
|
|
@ -204,7 +204,7 @@ fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str,
|
|||
fn get_extern_const(externs: hashmap<str, ValueRef>, llmod: ModuleRef,
|
||||
name: str, ty: TypeRef) -> ValueRef {
|
||||
if externs.contains_key(name) { ret externs.get(name); }
|
||||
let c = str::as_c_str(name, {|buf| llvm::LLVMAddGlobal(llmod, ty, buf) });
|
||||
let c = str::as_c_str(name, |buf| llvm::LLVMAddGlobal(llmod, ty, buf));
|
||||
externs.insert(name, c);
|
||||
ret c;
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ fn trans_foreign_call(cx: block, externs: hashmap<str, ValueRef>,
|
|||
let llforeign: ValueRef =
|
||||
get_simple_extern_fn(cx, externs, llmod, name, n);
|
||||
let mut call_args: ~[ValueRef] = ~[];
|
||||
for vec::each(args) {|a|
|
||||
for vec::each(args) |a| {
|
||||
vec::push(call_args, a);
|
||||
}
|
||||
ret Call(cx, llforeign, call_args);
|
||||
|
|
@ -323,7 +323,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id,
|
|||
let variant = ty::enum_variant_with_id(ccx.tcx, enum_id, variant_id);
|
||||
assert ix < variant.args.len();
|
||||
|
||||
let arg_lltys = vec::map(variant.args, {|aty|
|
||||
let arg_lltys = vec::map(variant.args, |aty| {
|
||||
type_of(ccx, ty::subst_tps(ccx.tcx, ty_substs, aty))
|
||||
});
|
||||
let typed_blobptr = PointerCast(bcx, llblobptr,
|
||||
|
|
@ -499,7 +499,7 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
|
|||
} else { mangle_internal_name_by_seq(ccx, @"tydesc") };
|
||||
note_unique_llvm_symbol(ccx, name);
|
||||
log(debug, #fmt("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name));
|
||||
let gvar = str::as_c_str(name, {|buf|
|
||||
let gvar = str::as_c_str(name, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
|
||||
});
|
||||
let inf =
|
||||
|
|
@ -574,7 +574,7 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
|
|||
|
||||
fn emit_tydescs(ccx: @crate_ctxt) {
|
||||
let _icx = ccx.insn_ctxt("emit_tydescs");
|
||||
for ccx.tydescs.each {|key, val|
|
||||
for ccx.tydescs.each |key, val| {
|
||||
let glue_fn_ty = T_ptr(T_glue_fn(ccx));
|
||||
let ti = val;
|
||||
let take_glue =
|
||||
|
|
@ -733,7 +733,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
|||
}
|
||||
ty::ty_class(did,substs) {
|
||||
// Call the dtor if there is one
|
||||
do option::map_default(ty::ty_dtor(bcx.tcx(), did), bcx) {|dt_id|
|
||||
do option::map_default(ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| {
|
||||
trans_class_drop(bcx, v, dt_id, did, substs)
|
||||
}
|
||||
}
|
||||
|
|
@ -746,7 +746,7 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id,
|
|||
class_did: ast::def_id,
|
||||
substs: ty::substs) -> block {
|
||||
let drop_flag = GEPi(bcx, v0, ~[0u, 0u]);
|
||||
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) {|cx|
|
||||
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
|
||||
let mut bcx = cx;
|
||||
// We have to cast v0
|
||||
let classptr = GEPi(bcx, v0, ~[0u, 1u]);
|
||||
|
|
@ -765,7 +765,7 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id,
|
|||
// Drop the fields
|
||||
for vec::eachi(ty::class_items_as_mutable_fields(bcx.tcx(), class_did,
|
||||
substs))
|
||||
{|i, fld|
|
||||
|i, fld| {
|
||||
let llfld_a = GEPi(bcx, classptr, ~[0u, i]);
|
||||
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
|
||||
}
|
||||
|
|
@ -864,19 +864,19 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
|
|||
|
||||
let llbox_ty = T_opaque_box_ptr(ccx);
|
||||
let box_ptr = PointerCast(bcx, box_ptr, llbox_ty);
|
||||
do with_cond(bcx, IsNotNull(bcx, box_ptr)) {|bcx|
|
||||
do with_cond(bcx, IsNotNull(bcx, box_ptr)) |bcx| {
|
||||
let rc_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_refcnt]);
|
||||
let rc = Sub(bcx, Load(bcx, rc_ptr), C_int(ccx, 1));
|
||||
Store(bcx, rc, rc_ptr);
|
||||
let zero_test = ICmp(bcx, lib::llvm::IntEQ, C_int(ccx, 0), rc);
|
||||
with_cond(bcx, zero_test, {|bcx| free_ty(bcx, box_ptr, t)})
|
||||
with_cond(bcx, zero_test, |bcx| free_ty(bcx, box_ptr, t))
|
||||
}
|
||||
}
|
||||
|
||||
// Structural comparison: a rather involved form of glue.
|
||||
fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: str) {
|
||||
if cx.sess.opts.save_temps {
|
||||
let _: () = str::as_c_str(s, {|buf| llvm::LLVMSetValueName(v, buf) });
|
||||
let _: () = str::as_c_str(s, |buf| llvm::LLVMSetValueName(v, buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +887,7 @@ enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
|
|||
|
||||
fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
|
||||
t: ty::t, op: ast::binop) -> result {
|
||||
let f = {|a|compare_scalar_values(cx, lhs, rhs, a, op)};
|
||||
let f = |a| compare_scalar_values(cx, lhs, rhs, a, op);
|
||||
|
||||
alt ty::get(t).struct {
|
||||
ty::ty_nil { ret rslt(cx, f(nil_type)); }
|
||||
|
|
@ -998,7 +998,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
|||
ty::ty_fn({inputs: args, _}) {
|
||||
let mut j = 0u;
|
||||
let v_id = variant.id;
|
||||
for vec::each(args) {|a|
|
||||
for vec::each(args) |a| {
|
||||
let llfldp_a = GEP_enum(cx, a_tup, tid, v_id, tps, j);
|
||||
let ty_subst = ty::subst_tps(ccx.tcx, tps, a.ty);
|
||||
cx = f(cx, llfldp_a, ty_subst);
|
||||
|
|
@ -1016,7 +1016,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
|||
let mut cx = cx;
|
||||
alt ty::get(t).struct {
|
||||
ty::ty_rec(fields) {
|
||||
for vec::eachi(fields) {|i, fld|
|
||||
for vec::eachi(fields) |i, fld| {
|
||||
let llfld_a = GEPi(cx, av, ~[0u, i]);
|
||||
cx = f(cx, llfld_a, fld.mt.ty);
|
||||
}
|
||||
|
|
@ -1027,7 +1027,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
|||
cx = tvec::iter_vec_raw(cx, base, t, len, f);
|
||||
}
|
||||
ty::ty_tup(args) {
|
||||
for vec::eachi(args) {|i, arg|
|
||||
for vec::eachi(args) |i, arg| {
|
||||
let llfld_a = GEPi(cx, av, ~[0u, i]);
|
||||
cx = f(cx, llfld_a, arg);
|
||||
}
|
||||
|
|
@ -1056,7 +1056,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
|||
Unreachable(unr_cx);
|
||||
let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants);
|
||||
let next_cx = sub_block(cx, "enum-iter-next");
|
||||
for vec::each(*variants) {|variant|
|
||||
for vec::each(*variants) |variant| {
|
||||
let variant_cx =
|
||||
sub_block(cx,
|
||||
"enum-iter-variant-" +
|
||||
|
|
@ -1077,7 +1077,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
|||
else { av };
|
||||
for vec::eachi(ty::class_items_as_mutable_fields(cx.tcx(), did,
|
||||
substs))
|
||||
{|i, fld|
|
||||
|i, fld| {
|
||||
let llfld_a = GEPi(cx, classptr, ~[0u, i]);
|
||||
cx = f(cx, llfld_a, fld.mt.ty);
|
||||
}
|
||||
|
|
@ -1354,7 +1354,7 @@ fn copy_val(cx: block, action: copy_action, dst: ValueRef,
|
|||
let dstcmp = load_if_immediate(cx, dst, t);
|
||||
let cast = PointerCast(cx, dstcmp, val_ty(src));
|
||||
// Self-copy check
|
||||
do with_cond(cx, ICmp(cx, lib::llvm::IntNE, cast, src)) {|bcx|
|
||||
do with_cond(cx, ICmp(cx, lib::llvm::IntNE, cast, src)) |bcx| {
|
||||
copy_val_no_check(bcx, action, dst, src, t)
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1505,7 +1505,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
|
|||
ret trans_call_inner(
|
||||
bcx, un_expr.info(), fty,
|
||||
expr_ty(bcx, un_expr),
|
||||
{|bcx| impl::trans_method_callee(bcx, callee_id, e, mentry) },
|
||||
|bcx| impl::trans_method_callee(bcx, callee_id, e, mentry),
|
||||
arg_exprs(~[]), dest);
|
||||
}
|
||||
_ {}
|
||||
|
|
@ -1581,8 +1581,8 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
|
|||
fn cast_shift_expr_rhs(cx: block, op: ast::binop,
|
||||
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||
cast_shift_rhs(op, lhs, rhs,
|
||||
{|a,b|Trunc(cx, a, b)},
|
||||
{|a,b|ZExt(cx, a, b)})
|
||||
|a,b| Trunc(cx, a, b),
|
||||
|a,b| ZExt(cx, a, b))
|
||||
}
|
||||
|
||||
fn cast_shift_const_rhs(op: ast::binop,
|
||||
|
|
@ -1637,7 +1637,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
|
|||
ty_to_str(cx.ccx().tcx, rhs_t));
|
||||
}
|
||||
};
|
||||
do with_cond(cx, is_zero) {|bcx|
|
||||
do with_cond(cx, is_zero) |bcx| {
|
||||
trans_fail(bcx, some(span), text)
|
||||
}
|
||||
}
|
||||
|
|
@ -1742,7 +1742,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
|
|||
let bcx = trans_call_inner(
|
||||
bcx, ex.info(), fty,
|
||||
expr_ty(bcx, ex),
|
||||
{|bcx|
|
||||
|bcx| {
|
||||
// FIXME (#2528): provide the already-computed address, not
|
||||
// the expr.
|
||||
impl::trans_method_callee(bcx, callee_id, dst, origin)
|
||||
|
|
@ -1870,7 +1870,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr,
|
|||
b: @ast::expr, dest: dest) -> block {
|
||||
let _icx = bcx.insn_ctxt("trans_lazy_binop");
|
||||
let {bcx: past_lhs, val: lhs} = {
|
||||
do with_scope_result(bcx, a.info(), "lhs") { |bcx|
|
||||
do with_scope_result(bcx, a.info(), "lhs") |bcx| {
|
||||
trans_temp_expr(bcx, a)
|
||||
}
|
||||
};
|
||||
|
|
@ -1882,7 +1882,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr,
|
|||
lazy_or { CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb); }
|
||||
}
|
||||
let {bcx: past_rhs, val: rhs} = {
|
||||
do with_scope_result(before_rhs, b.info(), "rhs") { |bcx|
|
||||
do with_scope_result(before_rhs, b.info(), "rhs") |bcx| {
|
||||
trans_temp_expr(bcx, b)
|
||||
}
|
||||
};
|
||||
|
|
@ -1905,7 +1905,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr,
|
|||
ret trans_call_inner(
|
||||
bcx, ex.info(), fty,
|
||||
expr_ty(bcx, ex),
|
||||
{|bcx|
|
||||
|bcx| {
|
||||
impl::trans_method_callee(bcx, callee_id, lhs, origin)
|
||||
},
|
||||
arg_exprs(~[rhs]), dest);
|
||||
|
|
@ -2079,9 +2079,9 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
|||
some(vts) {
|
||||
let bounds = ty::lookup_item_type(ccx.tcx, item).bounds;
|
||||
let mut i = 0u;
|
||||
vec::map2(*bounds, substs, {|bounds, subst|
|
||||
vec::map2(*bounds, substs, |bounds, subst| {
|
||||
let mut v = ~[];
|
||||
for vec::each(*bounds) {|bound|
|
||||
for vec::each(*bounds) |bound| {
|
||||
alt bound {
|
||||
ty::bound_iface(_) {
|
||||
vec::push(v, impl::vtable_id(ccx, vts[i]));
|
||||
|
|
@ -2094,12 +2094,12 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
|||
})
|
||||
}
|
||||
none {
|
||||
vec::map(substs, {|subst| mono_precise(subst, none)})
|
||||
vec::map(substs, |subst| mono_precise(subst, none))
|
||||
}
|
||||
};
|
||||
let param_ids = alt param_uses {
|
||||
some(uses) {
|
||||
vec::map2(precise_param_ids, uses, {|id, uses|
|
||||
vec::map2(precise_param_ids, uses, |id, uses| {
|
||||
alt check id {
|
||||
mono_precise(_, some(_)) { id }
|
||||
mono_precise(subst, none) {
|
||||
|
|
@ -2131,28 +2131,28 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
|||
-> {val: ValueRef, must_cast: bool} {
|
||||
let _icx = ccx.insn_ctxt("monomorphic_fn");
|
||||
let mut must_cast = false;
|
||||
let substs = vec::map(real_substs, {|t|
|
||||
let substs = vec::map(real_substs, |t| {
|
||||
alt normalize_for_monomorphization(ccx.tcx, t) {
|
||||
some(t) { must_cast = true; t }
|
||||
none { t }
|
||||
}
|
||||
});
|
||||
|
||||
for real_substs.each() {|s| assert !ty::type_has_params(s); };
|
||||
for substs.each() {|s| assert !ty::type_has_params(s); };
|
||||
for real_substs.each() |s| { assert !ty::type_has_params(s); }
|
||||
for substs.each() |s| { assert !ty::type_has_params(s); }
|
||||
|
||||
let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len());
|
||||
let hash_id = make_mono_id(ccx, fn_id, substs, vtables, some(param_uses));
|
||||
if vec::any(hash_id.params,
|
||||
{|p| alt p { mono_precise(_, _) { false } _ { true } } }) {
|
||||
|p| alt p { mono_precise(_, _) { false } _ { true } }) {
|
||||
must_cast = true;
|
||||
}
|
||||
|
||||
#debug["monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \
|
||||
hash_id = %?",
|
||||
fn_id, ty::item_path_str(ccx.tcx, fn_id),
|
||||
real_substs.map({|s| ty_to_str(ccx.tcx, s)}),
|
||||
substs.map({|s| ty_to_str(ccx.tcx, s)}), hash_id];
|
||||
real_substs.map(|s| ty_to_str(ccx.tcx, s)),
|
||||
substs.map(|s| ty_to_str(ccx.tcx, s)), hash_id];
|
||||
|
||||
alt ccx.monomorphized.find(hash_id) {
|
||||
some(val) {
|
||||
|
|
@ -2165,9 +2165,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
|||
let mut llitem_ty = tpt.ty;
|
||||
|
||||
let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node),
|
||||
{|| #fmt("While monomorphizing %?, couldn't find it in the item map \
|
||||
|| #fmt("While monomorphizing %?, couldn't find it in the item map \
|
||||
(may have attempted to monomorphize an item defined in a different \
|
||||
crate?)", fn_id)});
|
||||
crate?)", fn_id));
|
||||
// Get the path so that we can create a symbol
|
||||
let (pt, name, span) = alt map_node {
|
||||
ast_map::node_item(i, pt) { (pt, i.ident, i.span) }
|
||||
|
|
@ -2210,7 +2210,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
|||
let pt = vec::append(*pt, ~[path_name(@ccx.names(*name))]);
|
||||
let s = mangle_exported_name(ccx, pt, mono_ty);
|
||||
|
||||
let mk_lldecl = {||
|
||||
let mk_lldecl = || {
|
||||
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, llfty);
|
||||
ccx.monomorphized.insert(hash_id, lldecl);
|
||||
lldecl
|
||||
|
|
@ -2235,7 +2235,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
|
|||
}
|
||||
ast_map::node_variant(v, enum_item, _) {
|
||||
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
|
||||
let this_tv = option::get(vec::find(*tvs, {|tv|
|
||||
let this_tv = option::get(vec::find(*tvs, |tv| {
|
||||
tv.id.node == fn_id.node}));
|
||||
let d = mk_lldecl();
|
||||
set_inline_hint(d);
|
||||
|
|
@ -2303,7 +2303,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
|
|||
none { // Not seen yet
|
||||
alt csearch::maybe_get_item_ast(
|
||||
ccx.tcx, fn_id,
|
||||
{|a,b,c,d|
|
||||
|a,b,c,d| {
|
||||
astencode::decode_inlined_item(a, b, ccx.maps, c, d)
|
||||
}) {
|
||||
|
||||
|
|
@ -2331,7 +2331,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
|
|||
ast::item_enum(_, _, _) {
|
||||
let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id));
|
||||
let vs_there = ty::enum_variants(ccx.tcx, parent_id);
|
||||
do vec::iter2(*vs_here, *vs_there) {|here, there|
|
||||
do vec::iter2(*vs_here, *vs_there) |here, there| {
|
||||
if there.id == fn_id { my_id = here.id.node; }
|
||||
ccx.external.insert(there.id, some(here.id.node));
|
||||
}
|
||||
|
|
@ -2370,7 +2370,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
|
|||
fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id)
|
||||
-> lval_maybe_callee {
|
||||
let _icx = bcx.insn_ctxt("lval_static_fn");
|
||||
let vts = option::map(bcx.ccx().maps.vtable_map.find(id), {|vts|
|
||||
let vts = option::map(bcx.ccx().maps.vtable_map.find(id), |vts| {
|
||||
impl::resolve_vtables_in_fn_ctxt(bcx.fcx, vts)
|
||||
});
|
||||
lval_static_fn_inner(bcx, fn_id, id, node_id_type_params(bcx, id), vts)
|
||||
|
|
@ -2433,7 +2433,7 @@ fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef {
|
|||
// It's an external discriminant that we haven't seen yet.
|
||||
assert (vid.crate != ast::local_crate);
|
||||
let sym = csearch::get_symbol(ccx.sess.cstore, vid);
|
||||
let gvar = str::as_c_str(sym, {|buf|
|
||||
let gvar = str::as_c_str(sym, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(gvar, lib::llvm::ExternalLinkage);
|
||||
|
|
@ -2622,7 +2622,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
|
|||
#debug("trans_index: len %s", val_str(bcx.ccx().tn, len));
|
||||
|
||||
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len);
|
||||
let bcx = do with_cond(bcx, bounds_check) {|bcx|
|
||||
let bcx = do with_cond(bcx, bounds_check) |bcx| {
|
||||
// fail: bad bounds check.
|
||||
trans_fail(bcx, some(ex.span), "bounds check")
|
||||
};
|
||||
|
|
@ -3109,7 +3109,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t,
|
|||
arg_exprs(es) {
|
||||
let llarg_tys = type_of_explicit_args(ccx, arg_tys);
|
||||
let last = es.len() - 1u;
|
||||
do vec::iteri(es) {|i, e|
|
||||
do vec::iteri(es) |i, e| {
|
||||
let r = trans_arg_expr(bcx, arg_tys[i], llarg_tys[i],
|
||||
e, temp_cleanups, if i == last { ret_flag }
|
||||
else { none }, 0u);
|
||||
|
|
@ -3125,7 +3125,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t,
|
|||
// now that all arguments have been successfully built, we can revoke any
|
||||
// temporary cleanups, as they are only needed if argument construction
|
||||
// should fail (for example, cleanup of copy mode args).
|
||||
do vec::iter(temp_cleanups) {|c|
|
||||
do vec::iter(temp_cleanups) |c| {
|
||||
revoke_clean(bcx, c)
|
||||
}
|
||||
|
||||
|
|
@ -3140,14 +3140,14 @@ fn trans_call(in_cx: block, call_ex: @ast::expr, f: @ast::expr,
|
|||
let _icx = in_cx.insn_ctxt("trans_call");
|
||||
trans_call_inner(
|
||||
in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id),
|
||||
{|cx| trans_callee(cx, f)}, args, dest)
|
||||
|cx| trans_callee(cx, f), args, dest)
|
||||
}
|
||||
|
||||
fn body_contains_ret(body: ast::blk) -> bool {
|
||||
let cx = {mut found: false};
|
||||
visit::visit_block(body, cx, visit::mk_vt(@{
|
||||
visit_item: {|_i, _cx, _v|},
|
||||
visit_expr: {|e: @ast::expr, cx: {mut found: bool}, v|
|
||||
visit_item: |_i, _cx, _v| { },
|
||||
visit_expr: |e: @ast::expr, cx: {mut found: bool}, v| {
|
||||
if !cx.found {
|
||||
alt e.node {
|
||||
ast::expr_ret(_) { cx.found = true; }
|
||||
|
|
@ -3169,7 +3169,7 @@ fn trans_call_inner(
|
|||
args: call_args,
|
||||
dest: dest) -> block {
|
||||
|
||||
do with_scope(in_cx, call_info, "call") {|cx|
|
||||
do with_scope(in_cx, call_info, "call") |cx| {
|
||||
let ret_in_loop = alt args {
|
||||
arg_exprs(args) { args.len() > 0u && alt vec::last(args).node {
|
||||
ast::expr_loop_body(@{node: ast::expr_fn_block(_, body, _), _}) {
|
||||
|
|
@ -3237,8 +3237,8 @@ fn trans_call_inner(
|
|||
if ty::type_is_bot(ret_ty) {
|
||||
Unreachable(bcx);
|
||||
} else if ret_in_loop {
|
||||
bcx = do with_cond(bcx, Load(bcx, option::get(ret_flag))) {|bcx|
|
||||
do option::iter(copy bcx.fcx.loop_ret) {|lret|
|
||||
bcx = do with_cond(bcx, Load(bcx, option::get(ret_flag))) |bcx| {
|
||||
do option::iter(copy bcx.fcx.loop_ret) |lret| {
|
||||
Store(bcx, C_bool(true), lret.flagptr);
|
||||
Store(bcx, C_bool(false), bcx.fcx.llretptr);
|
||||
}
|
||||
|
|
@ -3276,7 +3276,7 @@ fn need_invoke(bcx: block) -> bool {
|
|||
loop {
|
||||
alt cur.kind {
|
||||
block_scope(inf) {
|
||||
for vec::each(inf.cleanups) {|cleanup|
|
||||
for vec::each(inf.cleanups) |cleanup| {
|
||||
alt cleanup {
|
||||
clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) {
|
||||
if cleanup_type == normal_exit_and_unwind {
|
||||
|
|
@ -3297,7 +3297,7 @@ fn need_invoke(bcx: block) -> bool {
|
|||
|
||||
fn have_cached_lpad(bcx: block) -> bool {
|
||||
let mut res = false;
|
||||
do in_lpad_scope_cx(bcx) {|inf|
|
||||
do in_lpad_scope_cx(bcx) |inf| {
|
||||
alt inf.landing_pad {
|
||||
some(_) { res = true; }
|
||||
none { res = false; }
|
||||
|
|
@ -3325,7 +3325,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef {
|
|||
let _icx = bcx.insn_ctxt("get_landing_pad");
|
||||
|
||||
let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below
|
||||
do in_lpad_scope_cx(bcx) {|inf|
|
||||
do in_lpad_scope_cx(bcx) |inf| {
|
||||
// If there is a valid landing pad still around, use it
|
||||
alt copy inf.landing_pad {
|
||||
some(target) { cached = some(target); }
|
||||
|
|
@ -3375,21 +3375,21 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block {
|
|||
let mut bcx = bcx;
|
||||
let addr = alt dest {
|
||||
ignore {
|
||||
for vec::each(elts) {|ex| bcx = trans_expr(bcx, ex, ignore); }
|
||||
for vec::each(elts) |ex| { bcx = trans_expr(bcx, ex, ignore); }
|
||||
ret bcx;
|
||||
}
|
||||
save_in(pos) { pos }
|
||||
_ { bcx.tcx().sess.bug("trans_tup: weird dest"); }
|
||||
};
|
||||
let mut temp_cleanups = ~[];
|
||||
for vec::eachi(elts) {|i, e|
|
||||
for vec::eachi(elts) |i, e| {
|
||||
let dst = GEPi(bcx, addr, ~[0u, i]);
|
||||
let e_ty = expr_ty(bcx, e);
|
||||
bcx = trans_expr_save_in(bcx, e, dst);
|
||||
add_clean_temp_mem(bcx, dst, e_ty);
|
||||
vec::push(temp_cleanups, dst);
|
||||
}
|
||||
for vec::each(temp_cleanups) {|cleanup| revoke_clean(bcx, cleanup); }
|
||||
for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); }
|
||||
ret bcx;
|
||||
}
|
||||
|
||||
|
|
@ -3401,7 +3401,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field],
|
|||
let mut bcx = bcx;
|
||||
let addr = alt check dest {
|
||||
ignore {
|
||||
for vec::each(fields) {|fld|
|
||||
for vec::each(fields) |fld| {
|
||||
bcx = trans_expr(bcx, fld.node.expr, ignore);
|
||||
}
|
||||
ret bcx;
|
||||
|
|
@ -3412,8 +3412,8 @@ fn trans_rec(bcx: block, fields: ~[ast::field],
|
|||
let ty_fields = alt check ty::get(t).struct { ty::ty_rec(f) { f } };
|
||||
|
||||
let mut temp_cleanups = ~[];
|
||||
for fields.each {|fld|
|
||||
let ix = option::get(vec::position(ty_fields, {|ft|
|
||||
for fields.each |fld| {
|
||||
let ix = option::get(vec::position(ty_fields, |ft| {
|
||||
str::eq(*fld.node.ident, *ft.ident)
|
||||
}));
|
||||
let dst = GEPi(bcx, addr, ~[0u, ix]);
|
||||
|
|
@ -3426,8 +3426,8 @@ fn trans_rec(bcx: block, fields: ~[ast::field],
|
|||
let {bcx: cx, val: base_val} = trans_temp_expr(bcx, bexp);
|
||||
bcx = cx;
|
||||
// Copy over inherited fields
|
||||
for ty_fields.eachi {|i, tf|
|
||||
if !vec::any(fields, {|f| str::eq(*f.node.ident, *tf.ident)}) {
|
||||
for ty_fields.eachi |i, tf| {
|
||||
if !vec::any(fields, |f| str::eq(*f.node.ident, *tf.ident)) {
|
||||
let dst = GEPi(bcx, addr, ~[0u, i]);
|
||||
let base = GEPi(bcx, base_val, ~[0u, i]);
|
||||
let val = load_if_immediate(bcx, base, tf.mt.ty);
|
||||
|
|
@ -3440,7 +3440,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field],
|
|||
|
||||
// Now revoke the cleanups as we pass responsibility for the data
|
||||
// structure on to the caller
|
||||
for temp_cleanups.each {|cleanup| revoke_clean(bcx, cleanup); }
|
||||
for temp_cleanups.each |cleanup| { revoke_clean(bcx, cleanup); }
|
||||
ret bcx;
|
||||
}
|
||||
|
||||
|
|
@ -3585,7 +3585,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
|||
ret alt::trans_alt(bcx, e, expr, arms, mode, dest);
|
||||
}
|
||||
ast::expr_block(blk) {
|
||||
ret do with_scope(bcx, blk.info(), "block-expr body") {|bcx|
|
||||
ret do with_scope(bcx, blk.info(), "block-expr body") |bcx| {
|
||||
trans_block(bcx, blk, dest)
|
||||
};
|
||||
}
|
||||
|
|
@ -3653,9 +3653,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
|||
ret trans_call_inner(
|
||||
bcx, e.info(), fty,
|
||||
expr_ty(bcx, e),
|
||||
{ |bcx|
|
||||
impl::trans_method_callee(bcx, callee_id, base, origin)
|
||||
},
|
||||
|bcx| impl::trans_method_callee(bcx, callee_id, base, origin),
|
||||
arg_exprs(~[idx]), dest);
|
||||
}
|
||||
|
||||
|
|
@ -3697,7 +3695,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
|||
otherwise. */
|
||||
let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod,
|
||||
"check_claims", T_bool());
|
||||
ret do with_cond(bcx, Load(bcx, c)) {|bcx|
|
||||
ret do with_cond(bcx, Load(bcx, c)) |bcx| {
|
||||
trans_check_expr(bcx, e, a, "Claim")
|
||||
};
|
||||
}
|
||||
|
|
@ -3774,8 +3772,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
|
|||
let origin = bcx.ccx().maps.method_map.get(alloc_id);
|
||||
let bcx = trans_call_inner(
|
||||
bcx, e.info(), node_id_type(bcx, alloc_id), void_ty,
|
||||
{|bcx| impl::trans_method_callee(bcx, alloc_id,
|
||||
pool, origin) },
|
||||
|bcx| impl::trans_method_callee(bcx, alloc_id,
|
||||
pool, origin),
|
||||
arg_vals(args),
|
||||
save_in(voidval));
|
||||
|
||||
|
|
@ -3874,9 +3872,9 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
|
|||
|
||||
let modpath = vec::append(
|
||||
~[path_mod(ccx.link_meta.name)],
|
||||
vec::filter(bcx.fcx.path, {|e|
|
||||
vec::filter(bcx.fcx.path, |e|
|
||||
alt e { path_mod(_) { true } _ { false } }
|
||||
}));
|
||||
));
|
||||
let modname = path_str(modpath);
|
||||
|
||||
let global = if ccx.module_data.contains_key(modname) {
|
||||
|
|
@ -3884,7 +3882,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
|
|||
} else {
|
||||
let s = link::mangle_internal_name_by_path_and_seq(
|
||||
ccx, modpath, @"loglevel");
|
||||
let global = str::as_c_str(s, {|buf|
|
||||
let global = str::as_c_str(s, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf)
|
||||
});
|
||||
llvm::LLVMSetGlobalConstant(global, False);
|
||||
|
|
@ -3895,14 +3893,14 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
|
|||
};
|
||||
let current_level = Load(bcx, global);
|
||||
let {bcx, val: level} = {
|
||||
do with_scope_result(bcx, lvl.info(), "level") {|bcx|
|
||||
do with_scope_result(bcx, lvl.info(), "level") |bcx| {
|
||||
trans_temp_expr(bcx, lvl)
|
||||
}
|
||||
};
|
||||
|
||||
do with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level)) {
|
||||
|bcx|
|
||||
do with_scope(bcx, log_ex.info(), "log") {|bcx|
|
||||
do with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level))
|
||||
|bcx| {
|
||||
do with_scope(bcx, log_ex.info(), "log") |bcx| {
|
||||
let {bcx, val, _} = trans_temp_expr(bcx, e);
|
||||
let e_ty = expr_ty(bcx, e);
|
||||
let tydesc = get_tydesc_simple(ccx, e_ty);
|
||||
|
|
@ -3920,11 +3918,11 @@ fn trans_check_expr(bcx: block, chk_expr: @ast::expr,
|
|||
let _icx = bcx.insn_ctxt("trans_check_expr");
|
||||
let expr_str = s + " " + expr_to_str(pred_expr) + " failed";
|
||||
let {bcx, val} = {
|
||||
do with_scope_result(bcx, chk_expr.info(), "check") {|bcx|
|
||||
do with_scope_result(bcx, chk_expr.info(), "check") |bcx| {
|
||||
trans_temp_expr(bcx, pred_expr)
|
||||
}
|
||||
};
|
||||
do with_cond(bcx, Not(bcx, val)) {|bcx|
|
||||
do with_cond(bcx, Not(bcx, val)) |bcx| {
|
||||
trans_fail(bcx, some(pred_expr.span), expr_str)
|
||||
}
|
||||
}
|
||||
|
|
@ -4133,7 +4131,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
|
|||
ast::stmt_decl(d, _) {
|
||||
alt d.node {
|
||||
ast::decl_local(locals) {
|
||||
for vec::each(locals) {|local|
|
||||
for vec::each(locals) |local| {
|
||||
bcx = init_local(bcx, local);
|
||||
if cx.sess().opts.extra_debuginfo {
|
||||
debuginfo::create_local_var(bcx, local);
|
||||
|
|
@ -4156,11 +4154,11 @@ fn new_block(cx: fn_ctxt, parent: option<block>, +kind: block_kind,
|
|||
let s = if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo {
|
||||
cx.ccx.names(name)
|
||||
} else { "" };
|
||||
let llbb: BasicBlockRef = str::as_c_str(s, {|buf|
|
||||
let llbb: BasicBlockRef = str::as_c_str(s, |buf| {
|
||||
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
||||
});
|
||||
let bcx = mk_block(llbb, parent, kind, opt_node_info, cx);
|
||||
do option::iter(parent) {|cx|
|
||||
do option::iter(parent) |cx| {
|
||||
if cx.unreachable { Unreachable(bcx); }
|
||||
};
|
||||
ret bcx;
|
||||
|
|
@ -4224,7 +4222,7 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) ->
|
|||
alt check cleanup_cx.kind {
|
||||
block_scope({cleanups, _}) {
|
||||
let cleanups = copy cleanups;
|
||||
do vec::riter(cleanups) {|cu|
|
||||
do vec::riter(cleanups) |cu| {
|
||||
alt cu {
|
||||
clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) {
|
||||
// Some types don't need to be cleaned up during
|
||||
|
|
@ -4260,7 +4258,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>,
|
|||
alt cur.kind {
|
||||
block_scope(inf) if inf.cleanups.len() > 0u {
|
||||
for vec::find(inf.cleanup_paths,
|
||||
{|cp| cp.target == leave}).each {|cp|
|
||||
|cp| cp.target == leave).each |cp| {
|
||||
Br(bcx, cp.dest);
|
||||
ret;
|
||||
}
|
||||
|
|
@ -4328,12 +4326,12 @@ fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block {
|
|||
}
|
||||
|
||||
fn block_locals(b: ast::blk, it: fn(@ast::local)) {
|
||||
for vec::each(b.node.stmts) {|s|
|
||||
for vec::each(b.node.stmts) |s| {
|
||||
alt s.node {
|
||||
ast::stmt_decl(d, _) {
|
||||
alt d.node {
|
||||
ast::decl_local(locals) {
|
||||
for vec::each(locals) {|local| it(local); }
|
||||
for vec::each(locals) |local| { it(local); }
|
||||
}
|
||||
_ {/* fall through */ }
|
||||
}
|
||||
|
|
@ -4362,8 +4360,8 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
|
|||
};
|
||||
let val = alloc_ty(cx, t);
|
||||
if cx.sess().opts.debuginfo {
|
||||
do option::iter(simple_name) {|name|
|
||||
str::as_c_str(*name, {|buf|
|
||||
do option::iter(simple_name) |name| {
|
||||
str::as_c_str(*name, |buf| {
|
||||
llvm::LLVMSetValueName(val, buf)
|
||||
});
|
||||
}
|
||||
|
|
@ -4376,8 +4374,8 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest)
|
|||
-> block {
|
||||
let _icx = bcx.insn_ctxt("trans_block");
|
||||
let mut bcx = bcx;
|
||||
do block_locals(b) {|local| bcx = alloc_local(bcx, local); };
|
||||
for vec::each(b.node.stmts) {|s|
|
||||
do block_locals(b) |local| { bcx = alloc_local(bcx, local); };
|
||||
for vec::each(b.node.stmts) |s| {
|
||||
debuginfo::update_source_pos(bcx, b.span);
|
||||
bcx = trans_stmt(bcx, *s);
|
||||
}
|
||||
|
|
@ -4395,12 +4393,12 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest)
|
|||
// Creates the standard set of basic blocks for a function
|
||||
fn mk_standard_basic_blocks(llfn: ValueRef) ->
|
||||
{sa: BasicBlockRef, ca: BasicBlockRef, rt: BasicBlockRef} {
|
||||
{sa: str::as_c_str("static_allocas", {|buf|
|
||||
llvm::LLVMAppendBasicBlock(llfn, buf) }),
|
||||
ca: str::as_c_str("load_env", {|buf|
|
||||
llvm::LLVMAppendBasicBlock(llfn, buf) }),
|
||||
rt: str::as_c_str("return", {|buf|
|
||||
llvm::LLVMAppendBasicBlock(llfn, buf) })}
|
||||
{sa: str::as_c_str("static_allocas",
|
||||
|buf| llvm::LLVMAppendBasicBlock(llfn, buf)),
|
||||
ca: str::as_c_str("load_env",
|
||||
|buf| llvm::LLVMAppendBasicBlock(llfn, buf)),
|
||||
rt: str::as_c_str("return",
|
||||
|buf| llvm::LLVMAppendBasicBlock(llfn, buf))}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4468,7 +4466,7 @@ fn create_llargs_for_fn_args(cx: fn_ctxt,
|
|||
|
||||
// Populate the llargs field of the function context with the ValueRefs
|
||||
// that we get from llvm::LLVMGetParam for each argument.
|
||||
for vec::each(args) {|arg|
|
||||
for vec::each(args) |arg| {
|
||||
let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
||||
assert (llarg as int != 0);
|
||||
// Note that this uses local_mem even for things passed by value.
|
||||
|
|
@ -4488,7 +4486,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg],
|
|||
tcx.sess.bug("someone forgot\
|
||||
to document an invariant in copy_args_to_allocas!");
|
||||
};
|
||||
for vec::each(arg_tys) {|arg|
|
||||
for vec::each(arg_tys) |arg| {
|
||||
let id = args[arg_n].id;
|
||||
let argval = alt fcx.llargs.get(id) { local_mem(v) { v }
|
||||
_ { epic_fail() } };
|
||||
|
|
@ -4599,11 +4597,13 @@ fn trans_fn(ccx: @crate_ctxt,
|
|||
else { {sec: 0i64, nsec: 0i32} };
|
||||
let _icx = ccx.insn_ctxt("trans_fn");
|
||||
trans_closure(ccx, path, decl, body, llfndecl, ty_self,
|
||||
param_substs, id, {|fcx|
|
||||
if ccx.sess.opts.extra_debuginfo {
|
||||
debuginfo::create_function(fcx);
|
||||
}
|
||||
}, {|_bcx|});
|
||||
param_substs, id,
|
||||
|fcx| {
|
||||
if ccx.sess.opts.extra_debuginfo {
|
||||
debuginfo::create_function(fcx);
|
||||
}
|
||||
},
|
||||
|_bcx| { });
|
||||
if do_time {
|
||||
let end = time::get_time();
|
||||
log_fn_time(ccx, path_str(path), start, end);
|
||||
|
|
@ -4616,12 +4616,11 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
|
|||
llfndecl: ValueRef) {
|
||||
let _icx = ccx.insn_ctxt("trans_enum_variant");
|
||||
// Translate variant arguments to function arguments.
|
||||
let fn_args = vec::map(variant.node.args, {|varg|
|
||||
let fn_args = vec::map(variant.node.args, |varg|
|
||||
{mode: ast::expl(ast::by_copy),
|
||||
ty: varg.ty,
|
||||
ident: @"arg",
|
||||
id: varg.id}
|
||||
});
|
||||
id: varg.id});
|
||||
let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id,
|
||||
param_substs, none);
|
||||
create_llargs_for_fn_args(fcx, no_self, fn_args);
|
||||
|
|
@ -4645,7 +4644,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
|
|||
};
|
||||
let t_id = local_def(enum_id);
|
||||
let v_id = local_def(variant.node.id);
|
||||
for vec::eachi(variant.node.args) {|i, va|
|
||||
for vec::eachi(variant.node.args) |i, va| {
|
||||
let lldestptr = GEP_enum(bcx, llblobptr, t_id, v_id,
|
||||
ty_param_substs, i);
|
||||
// If this argument to this function is a enum, it'll have come in to
|
||||
|
|
@ -4844,7 +4843,7 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
|
|||
let mut bcx = bcx_top;
|
||||
// Initialize fields to zero so init assignments can validly
|
||||
// drop their LHS
|
||||
for fields.each {|field|
|
||||
for fields.each |field| {
|
||||
let ix = field_idx_strict(bcx.tcx(), sp, field.ident, fields);
|
||||
bcx = zero_mem(bcx, GEPi(bcx, valptr, ~[0u, ix]), field.mt.ty);
|
||||
}
|
||||
|
|
@ -4872,7 +4871,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
|
|||
/* Look up the parent class's def_id */
|
||||
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
|
||||
/* Substitute in the class type if necessary */
|
||||
do option::iter(psubsts) {|ss|
|
||||
do option::iter(psubsts) |ss| {
|
||||
class_ty = ty::subst_tps(tcx, ss.tys, class_ty);
|
||||
}
|
||||
|
||||
|
|
@ -4890,7 +4889,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
|
|||
|
||||
/* If we're monomorphizing, register the monomorphized decl
|
||||
for the dtor */
|
||||
do option::iter(hash_id) {|h_id|
|
||||
do option::iter(hash_id) |h_id| {
|
||||
ccx.monomorphized.insert(h_id, lldecl);
|
||||
}
|
||||
/* Translate the dtor body */
|
||||
|
|
@ -4919,7 +4918,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
|||
vec::append(*path, ~[path_name(item.ident)]),
|
||||
decl, body, llfndecl, no_self, none, item.id);
|
||||
} else {
|
||||
for vec::each(body.node.stmts) {|stmt|
|
||||
for vec::each(body.node.stmts) |stmt| {
|
||||
alt stmt.node {
|
||||
ast::stmt_decl(@{node: ast::decl_item(i), _}, _) {
|
||||
trans_item(ccx, *i);
|
||||
|
|
@ -4940,7 +4939,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
|||
let degen = variants.len() == 1u;
|
||||
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
|
||||
let mut i = 0;
|
||||
for vec::each(variants) {|variant|
|
||||
for vec::each(variants) |variant| {
|
||||
if variant.node.args.len() > 0u {
|
||||
let llfn = get_item_val(ccx, variant.node.id);
|
||||
trans_enum_variant(ccx, item.id, variant,
|
||||
|
|
@ -4967,7 +4966,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
|||
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,
|
||||
get_item_val(ccx, ctor.node.id), psubsts,
|
||||
ctor.node.id, local_def(item.id), ctor.span);
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
trans_class_dtor(ccx, *path, dtor.node.body,
|
||||
dtor.node.id, none, none, local_def(item.id));
|
||||
};
|
||||
|
|
@ -4989,7 +4988,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
|||
// and control visibility.
|
||||
fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) {
|
||||
let _icx = ccx.insn_ctxt("trans_mod");
|
||||
for vec::each(m.items) {|item| trans_item(ccx, *item); }
|
||||
for vec::each(m.items) |item| { trans_item(ccx, *item); }
|
||||
}
|
||||
|
||||
fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef {
|
||||
|
|
@ -5082,7 +5081,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
|||
fn main_name() -> str { ret "main"; }
|
||||
let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type);
|
||||
let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty);
|
||||
let llbb = str::as_c_str("top", {|buf|
|
||||
let llbb = str::as_c_str("top", |buf| {
|
||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||
});
|
||||
let bld = ccx.builder.B;
|
||||
|
|
@ -5179,7 +5178,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
|
|||
ast::item_const(_, _) {
|
||||
let typ = ty::node_id_to_type(ccx.tcx, i.id);
|
||||
let s = mangle_exported_name(ccx, my_path, typ);
|
||||
let g = str::as_c_str(s, {|buf|
|
||||
let g = str::as_c_str(s, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, typ), buf)
|
||||
});
|
||||
ccx.item_symbols.insert(i.id, s);
|
||||
|
|
@ -5268,13 +5267,13 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
|
|||
node: it.id});
|
||||
let mut i = 0;
|
||||
let path = item_path(ccx, it);
|
||||
for vec::each(variants) {|variant|
|
||||
for vec::each(variants) |variant| {
|
||||
let p = vec::append(path, ~[path_name(variant.node.name),
|
||||
path_name(@"discrim")]);
|
||||
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
|
||||
let disr_val = vi[i].disr_val;
|
||||
note_unique_llvm_symbol(ccx, s);
|
||||
let discrim_gvar = str::as_c_str(s, {|buf|
|
||||
let discrim_gvar = str::as_c_str(s, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
|
||||
});
|
||||
llvm::LLVMSetInitializer(discrim_gvar, C_int(ccx, disr_val));
|
||||
|
|
@ -5291,7 +5290,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
|
|||
|
||||
fn trans_constants(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
|
||||
visit_item: {|a|trans_constant(ccx, a)}
|
||||
visit_item: |a| trans_constant(ccx, a)
|
||||
with *visit::default_simple_visitor()
|
||||
}));
|
||||
}
|
||||
|
|
@ -5377,16 +5376,16 @@ fn trap(bcx: block) {
|
|||
fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
||||
let elttype = T_struct(~[ccx.int_type, ccx.int_type]);
|
||||
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||
let map = str::as_c_str("_rust_mod_map", {|buf|
|
||||
let map = str::as_c_str("_rust_mod_map", |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
|
||||
let mut elts: ~[ValueRef] = ~[];
|
||||
for ccx.module_data.each {|key, val|
|
||||
for ccx.module_data.each |key, val| {
|
||||
let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)),
|
||||
p2i(ccx, val)]);
|
||||
vec::push(elts, elt);
|
||||
};
|
||||
}
|
||||
let term = C_struct(~[C_int(ccx, 0), C_int(ccx, 0)]);
|
||||
vec::push(elts, term);
|
||||
llvm::LLVMSetInitializer(map, C_array(elttype, elts));
|
||||
|
|
@ -5407,7 +5406,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta,
|
|||
let sym_name = "_rust_crate_map_" + mapname;
|
||||
let arrtype = T_array(int_type, n_subcrates as uint);
|
||||
let maptype = T_struct(~[int_type, arrtype]);
|
||||
let map = str::as_c_str(sym_name, {|buf|
|
||||
let map = str::as_c_str(sym_name, |buf| {
|
||||
llvm::LLVMAddGlobal(llmod, maptype, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage);
|
||||
|
|
@ -5423,7 +5422,7 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
|
|||
let nm = "_rust_crate_map_" + cdata.name +
|
||||
"_" + *cstore::get_crate_vers(cstore, i) +
|
||||
"_" + *cstore::get_crate_hash(cstore, i);
|
||||
let cr = str::as_c_str(nm, {|buf|
|
||||
let cr = str::as_c_str(nm, |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
|
||||
});
|
||||
vec::push(subcrates, p2i(ccx, cr));
|
||||
|
|
@ -5439,14 +5438,14 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
|
|||
-> encoder::encode_parms {
|
||||
|
||||
let encode_inlined_item =
|
||||
{|a,b,c,d|astencode::encode_inlined_item(a, b, c, d, cx.maps)};
|
||||
|a,b,c,d| astencode::encode_inlined_item(a, b, c, d, cx.maps);
|
||||
|
||||
ret {
|
||||
diag: cx.sess.diagnostic(),
|
||||
tcx: cx.tcx,
|
||||
reachable: cx.reachable,
|
||||
reexports: reexports(cx),
|
||||
impl_map: {|a|impl_map(cx, a)},
|
||||
impl_map: |a| impl_map(cx, a),
|
||||
item_symbols: cx.item_symbols,
|
||||
discrim_symbols: cx.discrim_symbols,
|
||||
link_meta: cx.link_meta,
|
||||
|
|
@ -5456,8 +5455,8 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
|
|||
|
||||
fn reexports(cx: @crate_ctxt) -> ~[(str, ast::def_id)] {
|
||||
let mut reexports = ~[];
|
||||
for cx.exp_map.each {|exp_id, defs|
|
||||
for defs.each {|def|
|
||||
for cx.exp_map.each |exp_id, defs| {
|
||||
for defs.each |def| {
|
||||
if !def.reexp { cont; }
|
||||
let path = alt check cx.tcx.items.get(exp_id) {
|
||||
ast_map::node_export(_, path) {
|
||||
|
|
@ -5473,9 +5472,8 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
|
|||
fn impl_map(cx: @crate_ctxt,
|
||||
id: ast::node_id) -> ~[(ast::ident, ast::def_id)] {
|
||||
let mut result = ~[];
|
||||
for list::each(cx.maps.impl_map.get(id)) {
|
||||
|impls|
|
||||
vec::push_all(result, (*impls).map({|i| (i.ident, i.did) }));
|
||||
for list::each(cx.maps.impl_map.get(id)) |impls| {
|
||||
vec::push_all(result, (*impls).map(|i| (i.ident, i.did)));
|
||||
}
|
||||
ret result;
|
||||
}
|
||||
|
|
@ -5486,18 +5484,18 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
|
|||
let encode_parms = crate_ctxt_to_encode_parms(cx);
|
||||
let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate));
|
||||
let llconst = C_struct(~[llmeta]);
|
||||
let mut llglobal = str::as_c_str("rust_metadata", {|buf|
|
||||
let mut llglobal = str::as_c_str("rust_metadata", |buf| {
|
||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
||||
});
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
str::as_c_str(cx.sess.targ_cfg.target_strs.meta_sect_name, {|buf|
|
||||
str::as_c_str(cx.sess.targ_cfg.target_strs.meta_sect_name, |buf| {
|
||||
llvm::LLVMSetSection(llglobal, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
|
||||
|
||||
let t_ptr_i8 = T_ptr(T_i8());
|
||||
llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8);
|
||||
let llvm_used = str::as_c_str("llvm.used", {|buf|
|
||||
let llvm_used = str::as_c_str("llvm.used", |buf| {
|
||||
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(llvm_used, lib::llvm::AppendingLinkage);
|
||||
|
|
@ -5529,7 +5527,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
|||
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
||||
let llmod_id = *link_meta.name + ".rc";
|
||||
|
||||
let llmod = str::as_c_str(llmod_id, {|buf|
|
||||
let llmod = str::as_c_str(llmod_id, |buf| {
|
||||
llvm::LLVMModuleCreateWithNameInContext
|
||||
(buf, llvm::LLVMGetGlobalContext())
|
||||
});
|
||||
|
|
@ -5537,10 +5535,10 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
|||
let targ_triple = sess.targ_cfg.target_strs.target_triple;
|
||||
let _: () =
|
||||
str::as_c_str(data_layout,
|
||||
{|buf| llvm::LLVMSetDataLayout(llmod, buf) });
|
||||
|buf| llvm::LLVMSetDataLayout(llmod, buf));
|
||||
let _: () =
|
||||
str::as_c_str(targ_triple,
|
||||
{|buf| llvm::LLVMSetTarget(llmod, buf) });
|
||||
|buf| llvm::LLVMSetTarget(llmod, buf));
|
||||
let targ_cfg = sess.targ_cfg;
|
||||
let td = mk_target_data(sess.targ_cfg.target_strs.data_layout);
|
||||
let tn = mk_type_names();
|
||||
|
|
@ -5580,10 +5578,10 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
|||
discrim_symbols: int_hash::<str>(),
|
||||
tydescs: ty::new_ty_hash(),
|
||||
external: ast_util::new_def_hash(),
|
||||
monomorphized: map::hashmap(hash_mono_id, {|a, b| a == b}),
|
||||
monomorphized: map::hashmap(hash_mono_id, |a, b| a == b),
|
||||
monomorphizing: ast_util::new_def_hash(),
|
||||
type_use_cache: ast_util::new_def_hash(),
|
||||
vtables: map::hashmap(hash_mono_id, {|a, b| a == b}),
|
||||
vtables: map::hashmap(hash_mono_id, |a, b| a == b),
|
||||
const_cstr_cache: map::str_hash(),
|
||||
module_data: str_hash::<ValueRef>(),
|
||||
lltypes: ty::new_ty_hash(),
|
||||
|
|
@ -5647,14 +5645,14 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
|||
// FIXME (#2280): this temporary shouldn't be
|
||||
// necessary, but seems to be, for borrowing.
|
||||
let times = copy *ccx.stats.fn_times;
|
||||
for vec::each(times) {|timing|
|
||||
for vec::each(times) |timing| {
|
||||
io::println(#fmt("time: %s took %d ms", timing.ident,
|
||||
timing.time));
|
||||
}
|
||||
}
|
||||
|
||||
if ccx.sess.count_llvm_insns() {
|
||||
for ccx.stats.llvm_insns.each { |k, v|
|
||||
for ccx.stats.llvm_insns.each |k, v| {
|
||||
io::println(#fmt("%-7u %s", v, k));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
|||
cx.terminated = true;
|
||||
#debug["Invoke(%s with arguments (%s))",
|
||||
val_str(cx.ccx().tn, Fn),
|
||||
str::connect(vec::map(Args, {|a|val_str(cx.ccx().tn, a)}),
|
||||
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)),
|
||||
", ")];
|
||||
unsafe {
|
||||
count_insn(cx, "invoke");
|
||||
|
|
@ -430,7 +430,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
|
|||
// in C_i32()
|
||||
fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef {
|
||||
let mut v: ~[ValueRef] = ~[];
|
||||
for vec::each(ixs) {|i| vec::push(v, C_i32(i as i32)); }
|
||||
for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); }
|
||||
count_insn(cx, "gepi");
|
||||
ret InBoundsGEP(cx, base, v);
|
||||
}
|
||||
|
|
@ -654,8 +654,8 @@ fn add_comment(bcx: block, text: str) {
|
|||
if !ccx.sess.no_asm_comments() {
|
||||
let sanitized = str::replace(text, "$", "");
|
||||
let comment_text = "# " + sanitized;
|
||||
let asm = str::as_c_str(comment_text, {|c|
|
||||
str::as_c_str("", {|e|
|
||||
let asm = str::as_c_str(comment_text, |c| {
|
||||
str::as_c_str("", |e| {
|
||||
count_insn(bcx, "inlineasm");
|
||||
llvm::LLVMConstInlineAsm(T_fn(~[], T_void()), c, e,
|
||||
False, False)
|
||||
|
|
@ -672,7 +672,7 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
|
|||
|
||||
#debug["Call(Fn=%s, Args=%?)",
|
||||
val_str(cx.ccx().tn, Fn),
|
||||
Args.map({ |arg| val_str(cx.ccx().tn, arg) })];
|
||||
Args.map(|arg| val_str(cx.ccx().tn, arg))];
|
||||
|
||||
ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
|
|
@ -775,7 +775,7 @@ fn Trap(cx: block) {
|
|||
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b);
|
||||
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
|
||||
let M: ModuleRef = llvm::LLVMGetGlobalParent(FN);
|
||||
let T: ValueRef = str::as_c_str("llvm.trap", {|buf|
|
||||
let T: ValueRef = str::as_c_str("llvm.trap", |buf| {
|
||||
llvm::LLVMGetNamedFunction(M, buf)
|
||||
});
|
||||
assert (T as int != 0);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ fn mk_closure_tys(tcx: ty::ctxt,
|
|||
let mut bound_tys = ~[];
|
||||
|
||||
// Compute the closed over data
|
||||
for vec::each(bound_values) {|bv|
|
||||
for vec::each(bound_values) |bv| {
|
||||
vec::push(bound_tys, alt bv {
|
||||
env_copy(_, t, _) { t }
|
||||
env_move(_, t, _) { t }
|
||||
|
|
@ -233,7 +233,7 @@ fn store_environment(bcx: block,
|
|||
|
||||
// Copy expr values into boxed bindings.
|
||||
let mut bcx = bcx;
|
||||
do vec::iteri(bound_values) { |i, bv|
|
||||
do vec::iteri(bound_values) |i, bv| {
|
||||
#debug["Copy %s into closure", ev_to_str(ccx, bv)];
|
||||
|
||||
if !ccx.sess.no_asm_comments() {
|
||||
|
|
@ -275,7 +275,7 @@ fn store_environment(bcx: block,
|
|||
}
|
||||
}
|
||||
}
|
||||
for vec::each(temp_cleanups) {|cleanup| revoke_clean(bcx, cleanup); }
|
||||
for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); }
|
||||
|
||||
ret {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx};
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ fn build_closure(bcx0: block,
|
|||
let ccx = bcx.ccx(), tcx = ccx.tcx;
|
||||
|
||||
// Package up the captured upvars
|
||||
do vec::iter(cap_vars) { |cap_var|
|
||||
do vec::iter(cap_vars) |cap_var| {
|
||||
#debug["Building closure: captured variable %?", cap_var];
|
||||
let lv = trans_local_var(bcx, cap_var.def);
|
||||
let nid = ast_util::def_id_of_def(cap_var.def).node;
|
||||
|
|
@ -323,7 +323,7 @@ fn build_closure(bcx0: block,
|
|||
}
|
||||
}
|
||||
}
|
||||
do option::iter(include_ret_handle) {|flagptr|
|
||||
do option::iter(include_ret_handle) |flagptr| {
|
||||
let our_ret = alt bcx.fcx.loop_ret {
|
||||
some({retptr, _}) { retptr }
|
||||
none { bcx.fcx.llretptr }
|
||||
|
|
@ -354,7 +354,7 @@ fn load_environment(fcx: fn_ctxt,
|
|||
|
||||
// Populate the upvars from the environment.
|
||||
let mut i = 0u;
|
||||
do vec::iter(cap_vars) { |cap_var|
|
||||
do vec::iter(cap_vars) |cap_var| {
|
||||
alt cap_var.mode {
|
||||
capture::cap_drop { /* ignore */ }
|
||||
_ {
|
||||
|
|
@ -404,10 +404,10 @@ fn trans_expr_fn(bcx: block,
|
|||
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id,
|
||||
ret_handle);
|
||||
trans_closure(ccx, sub_path, decl, body, llfn, no_self,
|
||||
bcx.fcx.param_substs, id, {|fcx|
|
||||
bcx.fcx.param_substs, id, |fcx| {
|
||||
load_environment(fcx, cdata_ty, cap_vars,
|
||||
option::is_some(ret_handle), ck);
|
||||
}, {|bcx|
|
||||
}, |bcx| {
|
||||
if option::is_some(is_loop_body) {
|
||||
Store(bcx, C_bool(true), bcx.fcx.llretptr);
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ fn trans_expr_fn(bcx: block,
|
|||
ast::proto_uniq { trans_closure_env(ty::ck_uniq) }
|
||||
ast::proto_bare {
|
||||
trans_closure(ccx, sub_path, decl, body, llfn, no_self, none,
|
||||
id, {|_fcx|}, {|_bcx|});
|
||||
id, |_fcx| { }, |_bcx| { });
|
||||
C_null(T_opaque_box_ptr(ccx))
|
||||
}
|
||||
};
|
||||
|
|
@ -436,12 +436,12 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t,
|
|||
let _icx = cx.insn_ctxt("closure::trans_bind1");
|
||||
let ccx = cx.ccx();
|
||||
let mut bound: ~[@ast::expr] = ~[];
|
||||
for vec::each(args) {|argopt|
|
||||
for vec::each(args) |argopt| {
|
||||
alt argopt { none { } some(e) { vec::push(bound, e); } }
|
||||
}
|
||||
let mut bcx = f_res.bcx;
|
||||
if dest == ignore {
|
||||
for vec::each(bound) {|ex| bcx = trans_expr(bcx, ex, ignore); }
|
||||
for vec::each(bound) |ex| { bcx = trans_expr(bcx, ex, ignore); }
|
||||
ret bcx;
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +478,9 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t,
|
|||
// Actually construct the closure
|
||||
let {llbox, cdata_ty, bcx} = store_environment(
|
||||
bcx, vec::append(env_vals,
|
||||
vec::map(bound, {|x| env_expr(x, expr_ty(bcx, x))})),
|
||||
vec::map(bound, |x| {
|
||||
env_expr(x, expr_ty(bcx, x))
|
||||
})),
|
||||
ty::ck_box);
|
||||
|
||||
// Make thunk
|
||||
|
|
@ -504,7 +506,7 @@ fn make_fn_glue(
|
|||
let fn_env = fn@(ck: ty::closure_kind) -> block {
|
||||
let box_cell_v = GEPi(cx, v, ~[0u, abi::fn_field_box]);
|
||||
let box_ptr_v = Load(cx, box_cell_v);
|
||||
do with_cond(cx, IsNotNull(cx, box_ptr_v)) {|bcx|
|
||||
do with_cond(cx, IsNotNull(cx, box_ptr_v)) |bcx| {
|
||||
let closure_ty = ty::mk_opaque_closure_ptr(tcx, ck);
|
||||
glue_fn(bcx, box_cell_v, closure_ty)
|
||||
}
|
||||
|
|
@ -537,7 +539,7 @@ fn make_opaque_cbox_take_glue(
|
|||
let ccx = bcx.ccx(), tcx = ccx.tcx;
|
||||
let llopaquecboxty = T_opaque_box_ptr(ccx);
|
||||
let cbox_in = Load(bcx, cboxptr);
|
||||
do with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx|
|
||||
do with_cond(bcx, IsNotNull(bcx, cbox_in)) |bcx| {
|
||||
// Load the size from the type descr found in the cbox
|
||||
let cbox_in = PointerCast(bcx, cbox_in, llopaquecboxty);
|
||||
let tydescptr = GEPi(bcx, cbox_in, ~[0u, abi::box_field_tydesc]);
|
||||
|
|
@ -599,7 +601,7 @@ fn make_opaque_cbox_free_glue(
|
|||
}
|
||||
|
||||
let ccx = bcx.ccx();
|
||||
do with_cond(bcx, IsNotNull(bcx, cbox)) {|bcx|
|
||||
do with_cond(bcx, IsNotNull(bcx, cbox)) |bcx| {
|
||||
// Load the type descr found in the cbox
|
||||
let lltydescty = T_ptr(ccx.tydesc_type);
|
||||
let cbox = PointerCast(bcx, cbox, T_opaque_cbox_ptr(ccx));
|
||||
|
|
@ -740,7 +742,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt,
|
|||
let mut a: uint = first_real_arg; // retptr, env come first
|
||||
let mut b: uint = starting_idx;
|
||||
let mut outgoing_arg_index: uint = 0u;
|
||||
for vec::each(args) {|arg|
|
||||
for vec::each(args) |arg| {
|
||||
let out_arg = outgoing_args[outgoing_arg_index];
|
||||
alt arg {
|
||||
// Arg provided at binding time; thunk copies it from
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
|
|||
cx.to_str(), val_str(cx.ccx().tn, val),
|
||||
ty_to_str(cx.ccx().tcx, ty)];
|
||||
let cleanup_type = cleanup_type(cx.tcx(), ty);
|
||||
do in_scope_cx(cx) {|info|
|
||||
vec::push(info.cleanups, clean({|a|base::drop_ty(a, val, ty)},
|
||||
do in_scope_cx(cx) |info| {
|
||||
vec::push(info.cleanups, clean(|a| base::drop_ty(a, val, ty),
|
||||
cleanup_type));
|
||||
scope_clean_changed(info);
|
||||
}
|
||||
|
|
@ -271,8 +271,8 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
|
|||
ret base::drop_ty(bcx, val, ty);
|
||||
}
|
||||
}
|
||||
do in_scope_cx(cx) {|info|
|
||||
vec::push(info.cleanups, clean_temp(val, {|a|do_drop(a, val, ty)},
|
||||
do in_scope_cx(cx) |info| {
|
||||
vec::push(info.cleanups, clean_temp(val, |a| do_drop(a, val, ty),
|
||||
cleanup_type));
|
||||
scope_clean_changed(info);
|
||||
}
|
||||
|
|
@ -283,19 +283,19 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
|
|||
cx.to_str(), val_str(cx.ccx().tn, val),
|
||||
ty_to_str(cx.ccx().tcx, ty)];
|
||||
let cleanup_type = cleanup_type(cx.tcx(), ty);
|
||||
do in_scope_cx(cx) {|info|
|
||||
do in_scope_cx(cx) |info| {
|
||||
vec::push(info.cleanups,
|
||||
clean_temp(val, {|a|base::drop_ty(a, val, ty)},
|
||||
clean_temp(val, |a| base::drop_ty(a, val, ty),
|
||||
cleanup_type));
|
||||
scope_clean_changed(info);
|
||||
}
|
||||
}
|
||||
fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
|
||||
let free_fn = alt heap {
|
||||
heap_shared { {|a|base::trans_free(a, ptr)} }
|
||||
heap_exchange { {|a|base::trans_unique_free(a, ptr)} }
|
||||
heap_shared { |a| base::trans_free(a, ptr) }
|
||||
heap_exchange { |a| base::trans_unique_free(a, ptr) }
|
||||
};
|
||||
do in_scope_cx(cx) {|info|
|
||||
do in_scope_cx(cx) |info| {
|
||||
vec::push(info.cleanups, clean_temp(ptr, free_fn,
|
||||
normal_exit_and_unwind));
|
||||
scope_clean_changed(info);
|
||||
|
|
@ -307,10 +307,10 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
|
|||
// this will be more involved. For now, we simply zero out the local, and the
|
||||
// drop glue checks whether it is zero.
|
||||
fn revoke_clean(cx: block, val: ValueRef) {
|
||||
do in_scope_cx(cx) {|info|
|
||||
do option::iter(vec::position(info.cleanups, {|cu|
|
||||
do in_scope_cx(cx) |info| {
|
||||
do option::iter(vec::position(info.cleanups, |cu| {
|
||||
alt cu { clean_temp(v, _, _) if v == val { true } _ { false } }
|
||||
})) {|i|
|
||||
})) |i| {
|
||||
info.cleanups =
|
||||
vec::append(vec::slice(info.cleanups, 0u, i),
|
||||
vec::view(info.cleanups,
|
||||
|
|
@ -361,7 +361,7 @@ impl node_info for ast::blk {
|
|||
|
||||
impl node_info for option<@ast::expr> {
|
||||
fn info() -> option<node_info> {
|
||||
self.chain({ |s| s.info() })
|
||||
self.chain(|s| s.info())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -592,7 +592,7 @@ fn T_struct(elts: ~[TypeRef]) -> TypeRef unsafe {
|
|||
|
||||
fn T_named_struct(name: str) -> TypeRef {
|
||||
let c = llvm::LLVMGetGlobalContext();
|
||||
ret str::as_c_str(name, {|buf| llvm::LLVMStructCreateNamed(c, buf) });
|
||||
ret str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf));
|
||||
}
|
||||
|
||||
fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe {
|
||||
|
|
@ -800,7 +800,7 @@ fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef {
|
|||
}
|
||||
|
||||
fn C_floating(s: str, t: TypeRef) -> ValueRef {
|
||||
ret str::as_c_str(s, {|buf| llvm::LLVMConstRealOfString(t, buf) });
|
||||
ret str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf));
|
||||
}
|
||||
|
||||
fn C_nil() -> ValueRef {
|
||||
|
|
@ -840,12 +840,12 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
|
|||
none { }
|
||||
}
|
||||
|
||||
let sc = do str::as_c_str(s) {|buf|
|
||||
let sc = do str::as_c_str(s) |buf| {
|
||||
llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
|
||||
};
|
||||
let g =
|
||||
str::as_c_str(cx.names("str"),
|
||||
{|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf) });
|
||||
|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf));
|
||||
llvm::LLVMSetInitializer(g, sc);
|
||||
llvm::LLVMSetGlobalConstant(g, True);
|
||||
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
|
||||
|
|
@ -862,7 +862,7 @@ fn C_estr_slice(cx: @crate_ctxt, s: str) -> ValueRef {
|
|||
|
||||
// Returns a Plain Old LLVM String:
|
||||
fn C_postr(s: str) -> ValueRef {
|
||||
ret do str::as_c_str(s) {|buf|
|
||||
ret do str::as_c_str(s) |buf| {
|
||||
llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
|
||||
};
|
||||
}
|
||||
|
|
@ -898,7 +898,7 @@ fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe {
|
|||
|
||||
fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef {
|
||||
let llshape = C_bytes(bytes);
|
||||
let llglobal = str::as_c_str(ccx.names("shape"), {|buf|
|
||||
let llglobal = str::as_c_str(ccx.names("shape"), |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf)
|
||||
});
|
||||
llvm::LLVMSetInitializer(llglobal, llshape);
|
||||
|
|
@ -920,12 +920,12 @@ enum mono_param_id {
|
|||
type mono_id = @{def: ast::def_id, params: ~[mono_param_id]};
|
||||
fn hash_mono_id(&&mi: mono_id) -> uint {
|
||||
let mut h = syntax::ast_util::hash_def(mi.def);
|
||||
for vec::each(mi.params) {|param|
|
||||
for vec::each(mi.params) |param| {
|
||||
h = h * alt param {
|
||||
mono_precise(ty, vts) {
|
||||
let mut h = ty::type_id(ty);
|
||||
do option::iter(vts) {|vts|
|
||||
for vec::each(vts) {|vt| h += hash_mono_id(vt); }
|
||||
do option::iter(vts) |vts| {
|
||||
for vec::each(vts) |vt| { h += hash_mono_id(vt); }
|
||||
}
|
||||
h
|
||||
}
|
||||
|
|
@ -954,7 +954,7 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
|
|||
|
||||
fn path_str(p: path) -> str {
|
||||
let mut r = "", first = true;
|
||||
for vec::each(p) {|e|
|
||||
for vec::each(p) |e| {
|
||||
alt e { ast_map::path_name(s) | ast_map::path_mod(s) {
|
||||
if first { first = false; }
|
||||
else { r += "::"; }
|
||||
|
|
@ -980,7 +980,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
|
|||
let params = ty::node_id_to_type_params(tcx, id);
|
||||
alt bcx.fcx.param_substs {
|
||||
some(substs) {
|
||||
vec::map(params, {|t| ty::subst_tps(tcx, substs.tys, t) })
|
||||
vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t))
|
||||
}
|
||||
_ { params }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const DW_ATE_unsigned: int = 0x07;
|
|||
const DW_ATE_unsigned_char: int = 0x08;
|
||||
|
||||
fn llstr(s: str) -> ValueRef {
|
||||
str::as_c_str(s, {|sbuf|
|
||||
str::as_c_str(s, |sbuf| {
|
||||
llvm::LLVMMDString(sbuf, str::len(s) as libc::c_uint)
|
||||
})
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ fn llnull() -> ValueRef unsafe {
|
|||
}
|
||||
|
||||
fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) {
|
||||
str::as_c_str(name, {|sbuf|
|
||||
str::as_c_str(name, |sbuf| {
|
||||
llvm::LLVMAddNamedMetadataOperand(cx.llmod, sbuf, val)
|
||||
})
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
|
|||
eq: fn(md: T) -> bool) -> option<T> unsafe {
|
||||
if cache.contains_key(mdtag) {
|
||||
let items = cache.get(mdtag);
|
||||
for items.each {|item|
|
||||
for items.each |item| {
|
||||
let md: T = md_from_metadata::<T>(item);
|
||||
if eq(md) {
|
||||
ret option::some(md);
|
||||
|
|
@ -166,7 +166,7 @@ fn create_compile_unit(cx: @crate_ctxt)
|
|||
let crate_name = option::get(cx.dbg_cx).crate_file;
|
||||
let tg = CompileUnitTag;
|
||||
alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|
||||
{|md| md.data.name == crate_name}) {
|
||||
|md| md.data.name == crate_name) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata<file_md> {
|
|||
let cache = get_cache(cx);;
|
||||
let tg = FileDescriptorTag;
|
||||
alt cached_metadata::<@metadata<file_md>>(
|
||||
cache, tg, {|md| md.data.path == full_path}) {
|
||||
cache, tg, |md| md.data.path == full_path) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
|||
let cache = get_cache(cx);
|
||||
let tg = BasicTypeDescriptorTag;
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| ty::type_id(t) == md.data.hash}) {
|
||||
cache, tg, |md| ty::type_id(t) == md.data.hash) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field],
|
|||
option::get(cx.dbg_cx).names("rec"),
|
||||
line_from_span(cx.sess.codemap,
|
||||
span) as int);
|
||||
for fields.each {|field|
|
||||
for fields.each |field| {
|
||||
let field_t = ty::get_field(t, field.node.ident).mt.ty;
|
||||
let ty_md = create_ty(cx, field_t, field.node.mt.ty);
|
||||
let (size, align) = size_and_align_of(cx, field_t);
|
||||
|
|
@ -640,7 +640,7 @@ fn create_local_var(bcx: block, local: @ast::local)
|
|||
let cache = get_cache(cx);
|
||||
let tg = AutoVariableTag;
|
||||
alt cached_metadata::<@metadata<local_var_md>>(
|
||||
cache, tg, {|md| md.data.id == local.node.id}) {
|
||||
cache, tg, |md| md.data.id == local.node.id) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
@ -690,7 +690,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
|||
let cache = get_cache(cx);
|
||||
let tg = ArgVariableTag;
|
||||
alt cached_metadata::<@metadata<argument_md>>(
|
||||
cache, ArgVariableTag, {|md| md.data.id == arg.id}) {
|
||||
cache, ArgVariableTag, |md| md.data.id == arg.id) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
@ -778,7 +778,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
|||
|
||||
let cache = get_cache(cx);
|
||||
alt cached_metadata::<@metadata<subprogram_md>>(
|
||||
cache, SubprogramTag, {|md| md.data.id == id}) {
|
||||
cache, SubprogramTag, |md| md.data.id == id) {
|
||||
option::some(md) { ret md; }
|
||||
option::none {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
|
||||
let n = llvm::LLVMCountStructElementTypes(ty);
|
||||
let elts = vec::from_elem(n as uint, ptr::null());
|
||||
do vec::as_buf(elts) {|buf|
|
||||
do vec::as_buf(elts) |buf| {
|
||||
llvm::LLVMGetStructElementTypes(ty, buf);
|
||||
}
|
||||
ret elts;
|
||||
|
|
@ -82,7 +82,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
2 /* float */ { 4u }
|
||||
3 /* double */ { 8u }
|
||||
10 /* struct */ {
|
||||
do vec::foldl(0u, struct_tys(ty)) {|a, t|
|
||||
do vec::foldl(0u, struct_tys(ty)) |a, t| {
|
||||
uint::max(a, ty_align(t))
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
2 /* float */ { 4u }
|
||||
3 /* double */ { 8u }
|
||||
10 /* struct */ {
|
||||
do vec::foldl(0u, struct_tys(ty)) {|s, t|
|
||||
do vec::foldl(0u, struct_tys(ty)) |s, t| {
|
||||
s + ty_size(t)
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
}
|
||||
|
||||
fn all_mem(cls: ~[mut x86_64_reg_class]) {
|
||||
for uint::range(0u, cls.len()) { |i|
|
||||
for uint::range(0u, cls.len()) |i| {
|
||||
cls[i] = memory_class;
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
classify(T_i64(), cls, i, off);
|
||||
} else {
|
||||
let mut field_off = off;
|
||||
for vec::each(tys) {|ty|
|
||||
for vec::each(tys) |ty| {
|
||||
field_off = align(field_off, ty);
|
||||
classify(ty, cls, i, field_off);
|
||||
field_off += ty_size(ty);
|
||||
|
|
@ -279,7 +279,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
|
||||
fn llvec_len(cls: ~[x86_64_reg_class]) -> uint {
|
||||
let mut len = 1u;
|
||||
for vec::each(cls) {|c|
|
||||
for vec::each(cls) |c| {
|
||||
if c != sseup_class {
|
||||
break;
|
||||
}
|
||||
|
|
@ -375,7 +375,7 @@ fn x86_64_tys(atys: ~[TypeRef],
|
|||
|
||||
let mut arg_tys = ~[];
|
||||
let mut attrs = ~[];
|
||||
for vec::each(atys) {|t|
|
||||
for vec::each(atys) |t| {
|
||||
let (ty, attr) = x86_64_ty(t, is_pass_byval, ByValAttribute);
|
||||
vec::push(arg_tys, ty);
|
||||
vec::push(attrs, attr);
|
||||
|
|
@ -404,12 +404,12 @@ fn x86_64_tys(atys: ~[TypeRef],
|
|||
|
||||
fn decl_x86_64_fn(tys: x86_64_tys,
|
||||
decl: fn(fnty: TypeRef) -> ValueRef) -> ValueRef {
|
||||
let atys = vec::map(tys.arg_tys, {|t| t.ty });
|
||||
let atys = vec::map(tys.arg_tys, |t| t.ty);
|
||||
let rty = tys.ret_ty.ty;
|
||||
let fnty = T_fn(atys, rty);
|
||||
let llfn = decl(fnty);
|
||||
|
||||
do vec::iteri(tys.attrs) {|i, a|
|
||||
do vec::iteri(tys.attrs) |i, a| {
|
||||
alt a {
|
||||
option::some(attr) {
|
||||
let llarg = get_param(llfn, i);
|
||||
|
|
@ -640,7 +640,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
let _icx = bcx.insn_ctxt("foreign::shim::build_ret");
|
||||
alt tys.x86_64_tys {
|
||||
some(x86_64) {
|
||||
do vec::iteri(x86_64.attrs) {|i, a|
|
||||
do vec::iteri(x86_64.attrs) |i, a| {
|
||||
alt a {
|
||||
some(attr) {
|
||||
llvm::LLVMAddInstrAttribute(
|
||||
|
|
@ -691,7 +691,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
// Declare the "prototype" for the base function F:
|
||||
alt tys.x86_64_tys {
|
||||
some(x86_64) {
|
||||
do decl_x86_64_fn(x86_64) {|fnty|
|
||||
do decl_x86_64_fn(x86_64) |fnty| {
|
||||
decl_fn(ccx.llmod, lname, cc, fnty)
|
||||
}
|
||||
}
|
||||
|
|
@ -712,7 +712,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
let llbasefn = base_fn(ccx, link_name(item), tys, cc);
|
||||
let ty = ty::lookup_item_type(ccx.tcx,
|
||||
ast_util::local_def(item.id)).ty;
|
||||
let args = vec::from_fn(ty::ty_fn_args(ty).len(), {|i|
|
||||
let args = vec::from_fn(ty::ty_fn_args(ty).len(), |i| {
|
||||
get_param(decl, i + first_real_arg)
|
||||
});
|
||||
let retval = Call(bcx, llbasefn, args);
|
||||
|
|
@ -762,7 +762,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
ast::foreign_abi_stdcall { lib::llvm::X86StdcallCallConv }
|
||||
};
|
||||
|
||||
for vec::each(foreign_mod.items) {|foreign_item|
|
||||
for vec::each(foreign_mod.items) |foreign_item| {
|
||||
alt foreign_item.node {
|
||||
ast::foreign_item_fn(fn_decl, typarams) {
|
||||
let id = foreign_item.id;
|
||||
|
|
@ -974,12 +974,10 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
|||
constraints: ~[]
|
||||
});
|
||||
bcx = trans_call_inner(bcx, none, fty, ty::mk_nil(bcx.tcx()),
|
||||
{ |bcx|
|
||||
lval_no_env(
|
||||
bcx,
|
||||
get_param(decl, first_real_arg),
|
||||
temporary)
|
||||
},
|
||||
|bcx| lval_no_env(
|
||||
bcx,
|
||||
get_param(decl, first_real_arg),
|
||||
temporary),
|
||||
arg_vals(~[frameaddress_val]), ignore);
|
||||
}
|
||||
}
|
||||
|
|
@ -1091,7 +1089,7 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
|||
_ {
|
||||
let llretptr = alloca(bcx, tys.ret_ty);
|
||||
let n = vec::len(tys.arg_tys);
|
||||
for uint::range(0u, n) {|i|
|
||||
for uint::range(0u, n) |i| {
|
||||
let llargval = get_param(llwrapfn, i);
|
||||
store_inbounds(bcx, llargval, llargbundle,
|
||||
~[0u, i]);
|
||||
|
|
@ -1153,7 +1151,7 @@ fn register_extern_fn(ccx: @crate_ctxt, sp: span,
|
|||
ret if ccx.sess.targ_cfg.arch == arch_x86_64 {
|
||||
let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty);
|
||||
let x86_64 = x86_64_tys(llargtys, llretty, ret_def);
|
||||
do decl_x86_64_fn(x86_64) {|fnty|
|
||||
do decl_x86_64_fn(x86_64) |fnty| {
|
||||
register_fn_fuller(ccx, sp, path, node_id,
|
||||
t, lib::llvm::CCallConv, fnty)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
|
|||
let _icx = ccx.insn_ctxt("impl::trans_impl");
|
||||
if tps.len() > 0u { ret; }
|
||||
let sub_path = vec::append_one(path, path_name(name));
|
||||
for vec::each(methods) {|m|
|
||||
for vec::each(methods) |m| {
|
||||
if m.tps.len() == 0u {
|
||||
let llfn = get_item_val(ccx, m.id);
|
||||
trans_fn(ccx,
|
||||
|
|
@ -77,7 +77,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
|
|||
|
||||
fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
|
||||
-> ast::def_id {
|
||||
local_def(option::get(vec::find(ms, {|m| m.ident == name})).id)
|
||||
local_def(option::get(vec::find(ms, |m| m.ident == name)).id)
|
||||
}
|
||||
|
||||
fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
|
||||
|
|
@ -170,9 +170,9 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint)
|
|||
let mut vtable_off = n_bound, i = 0u;
|
||||
// Vtables are stored in a flat array, finding the right one is
|
||||
// somewhat awkward
|
||||
for vec::each(*ps.bounds) {|bounds|
|
||||
for vec::each(*ps.bounds) |bounds| {
|
||||
if i >= n_param { break; }
|
||||
for vec::each(*bounds) {|bound|
|
||||
for vec::each(*bounds) |bound| {
|
||||
alt bound { ty::bound_iface(_) { vtable_off += 1u; } _ {} }
|
||||
}
|
||||
i += 1u;
|
||||
|
|
@ -182,7 +182,7 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint)
|
|||
|
||||
fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res)
|
||||
-> typeck::vtable_res {
|
||||
@vec::map(*vts, {|d| resolve_vtable_in_fn_ctxt(fcx, d)})
|
||||
@vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, d))
|
||||
}
|
||||
|
||||
fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
||||
|
|
@ -191,9 +191,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
|||
typeck::vtable_static(iid, tys, sub) {
|
||||
let tys = alt fcx.param_substs {
|
||||
some(substs) {
|
||||
vec::map(tys, {|t|
|
||||
ty::subst_tps(fcx.ccx.tcx, substs.tys, t)
|
||||
})
|
||||
vec::map(tys, |t| ty::subst_tps(fcx.ccx.tcx, substs.tys, t))
|
||||
}
|
||||
_ { tys }
|
||||
};
|
||||
|
|
@ -219,7 +217,7 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id {
|
|||
}
|
||||
typeck::vtable_iface(iface_id, substs) {
|
||||
@{def: iface_id,
|
||||
params: vec::map(substs, {|t| mono_precise(t, none)})}
|
||||
params: vec::map(substs, |t| mono_precise(t, none))}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +240,7 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin)
|
|||
fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
|
||||
let _icx = ccx.insn_ctxt("impl::make_vtable");
|
||||
let tbl = C_struct(ptrs);
|
||||
let vt_gvar = str::as_c_str(ccx.names("vtable"), {|buf|
|
||||
let vt_gvar = str::as_c_str(ccx.names("vtable"), |buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf)
|
||||
});
|
||||
llvm::LLVMSetInitializer(vt_gvar, tbl);
|
||||
|
|
@ -258,9 +256,9 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
|
|||
let ifce_id = expect(ccx.sess,
|
||||
ty::ty_to_def_id(option::get(ty::impl_iface(tcx,
|
||||
impl_id))),
|
||||
{|| "make_impl_vtable: non-iface-type implemented"});
|
||||
|| "make_impl_vtable: non-iface-type implemented");
|
||||
let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u;
|
||||
make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id), {|im|
|
||||
make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id), |im| {
|
||||
let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty));
|
||||
if (*im.tps).len() > 0u || ty::type_has_self(fty) {
|
||||
C_null(T_ptr(T_nil()))
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map,
|
|||
|
||||
fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
|
||||
let mut found_export = false;
|
||||
for vec::each(vis) {|vi|
|
||||
for vec::each(vis) |vi| {
|
||||
alt vi.node {
|
||||
view_item_export(vps) {
|
||||
found_export = true;
|
||||
for vec::each(vps) {|vp|
|
||||
for vec::each(vps) |vp| {
|
||||
alt vp.node {
|
||||
view_path_simple(_, _, id) | view_path_glob(_, id) |
|
||||
view_path_list(_, _, id) {
|
||||
|
|
@ -53,8 +53,8 @@ fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
|
|||
}
|
||||
|
||||
fn traverse_export(cx: ctx, exp_id: node_id) {
|
||||
do option::iter(cx.exp_map.find(exp_id)) {|defs|
|
||||
for vec::each(defs) {|def| traverse_def_id(cx, def.id); }
|
||||
do option::iter(cx.exp_map.find(exp_id)) |defs| {
|
||||
for vec::each(defs) |def| { traverse_def_id(cx, def.id); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ fn traverse_def_id(cx: ctx, did: def_id) {
|
|||
fn traverse_public_mod(cx: ctx, m: _mod) {
|
||||
if !traverse_exports(cx, m.view_items) {
|
||||
// No exports, so every local item is exported
|
||||
for vec::each(m.items) {|item| traverse_public_item(cx, item); }
|
||||
for vec::each(m.items) |item| { traverse_public_item(cx, item); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
item_mod(m) { traverse_public_mod(cx, m); }
|
||||
item_foreign_mod(nm) {
|
||||
if !traverse_exports(cx, nm.view_items) {
|
||||
for vec::each(nm.items) {|item| cx.rmap.insert(item.id, ()); }
|
||||
for vec::each(nm.items) |item| { cx.rmap.insert(item.id, ()); }
|
||||
}
|
||||
}
|
||||
item_fn(_, tps, blk) {
|
||||
|
|
@ -101,7 +101,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
}
|
||||
}
|
||||
item_impl(tps, _, _, _, ms) {
|
||||
for vec::each(ms) {|m|
|
||||
for vec::each(ms) |m| {
|
||||
if tps.len() > 0u || m.tps.len() > 0u ||
|
||||
attr::find_inline_attr(m.attrs) != attr::ia_none {
|
||||
cx.rmap.insert(m.id, ());
|
||||
|
|
@ -111,14 +111,14 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
}
|
||||
item_class(tps, _ifaces, items, ctor, m_dtor, _) {
|
||||
cx.rmap.insert(ctor.node.id, ());
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
cx.rmap.insert(dtor.node.id, ());
|
||||
// dtors don't have attrs
|
||||
if tps.len() > 0u {
|
||||
traverse_inline_body(cx, dtor.node.body);
|
||||
}
|
||||
}
|
||||
for vec::each(items) {|item|
|
||||
for vec::each(items) |item| {
|
||||
alt item.node {
|
||||
class_method(m) {
|
||||
cx.rmap.insert(m.id, ());
|
||||
|
|
@ -156,7 +156,7 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
|||
some(d) { traverse_def_id(cx, def_id_of_def(d)); }
|
||||
none { /* do nothing -- but should we fail here? */ }
|
||||
}
|
||||
for p.types.each {|t| v.visit_ty(t, cx, v); };
|
||||
for p.types.each |t| { v.visit_ty(t, cx, v); };
|
||||
}
|
||||
_ { visit::visit_ty(ty, cx, v); }
|
||||
}
|
||||
|
|
@ -201,8 +201,8 @@ fn traverse_inline_body(cx: ctx, body: blk) {
|
|||
|
||||
fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
|
||||
visit::visit_mod(crate_mod, ast_util::dummy_sp(), 0, cx, visit::mk_vt(@{
|
||||
visit_expr: {|_e, _cx, _v|},
|
||||
visit_item: {|i, cx, v|
|
||||
visit_expr: |_e, _cx, _v| { },
|
||||
visit_item: |i, cx, v| {
|
||||
visit::visit_item(i, cx, v);
|
||||
alt i.node {
|
||||
item_class(_, _, _, _, some(_), _) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl methods for reflector {
|
|||
*self.visitor_methods));
|
||||
let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty);
|
||||
let v = self.visitor_val;
|
||||
let get_lval = {|bcx|
|
||||
let get_lval = |bcx| {
|
||||
let callee =
|
||||
impl::trans_iface_callee(bcx, v, mth_ty, mth_idx);
|
||||
#debug("calling mth ty %s, lltype %s",
|
||||
|
|
@ -55,7 +55,7 @@ impl methods for reflector {
|
|||
};
|
||||
#debug("passing %u args:", vec::len(args));
|
||||
let bcx = self.bcx;
|
||||
for args.eachi {|i, a|
|
||||
for args.eachi |i, a| {
|
||||
#debug("arg %u: %s", i, val_str(bcx.ccx().tn, a));
|
||||
}
|
||||
self.bcx =
|
||||
|
|
@ -129,12 +129,12 @@ impl methods for reflector {
|
|||
|
||||
ty::ty_vec(mt) { self.bracketed_mt("vec", mt, ~[]) }
|
||||
ty::ty_estr(vst) {
|
||||
do self.vstore_name_and_extra(t, vst) {|name, extra|
|
||||
do self.vstore_name_and_extra(t, vst) |name, extra| {
|
||||
self.visit("estr_" + name, extra)
|
||||
}
|
||||
}
|
||||
ty::ty_evec(mt, vst) {
|
||||
do self.vstore_name_and_extra(t, vst) {|name, extra|
|
||||
do self.vstore_name_and_extra(t, vst) |name, extra| {
|
||||
self.bracketed_mt("evec_" + name, mt, extra)
|
||||
}
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ impl methods for reflector {
|
|||
let extra = (vec::append(~[self.c_uint(vec::len(fields))],
|
||||
self.c_size_and_align(t)));
|
||||
self.visit("enter_rec", extra);
|
||||
for fields.eachi {|i, field|
|
||||
for fields.eachi |i, field| {
|
||||
self.bracketed_mt("rec_field", field.mt,
|
||||
~[self.c_uint(i),
|
||||
self.c_slice(*field.ident)]);
|
||||
|
|
@ -159,7 +159,7 @@ impl methods for reflector {
|
|||
let extra = (vec::append(~[self.c_uint(vec::len(tys))],
|
||||
self.c_size_and_align(t)));
|
||||
self.visit("enter_tup", extra);
|
||||
for tys.eachi {|i, t|
|
||||
for tys.eachi |i, t| {
|
||||
self.bracketed_t("tup_field", t, ~[self.c_uint(i)]);
|
||||
}
|
||||
self.visit("leave_tup", extra);
|
||||
|
|
@ -190,7 +190,7 @@ impl methods for reflector {
|
|||
self.c_uint(vec::len(fty.inputs)),
|
||||
self.c_uint(retval)];
|
||||
self.visit("enter_fn", extra);
|
||||
for fty.inputs.eachi {|i, arg|
|
||||
for fty.inputs.eachi |i, arg| {
|
||||
let modeval = alt arg.mode {
|
||||
ast::infer(_) { 0u }
|
||||
ast::expl(e) {
|
||||
|
|
@ -220,7 +220,7 @@ impl methods for reflector {
|
|||
self.c_size_and_align(t));
|
||||
|
||||
self.visit("enter_class", extra);
|
||||
for fields.eachi {|i, field|
|
||||
for fields.eachi |i, field| {
|
||||
self.bracketed_mt("class_field", field.mt,
|
||||
~[self.c_uint(i),
|
||||
self.c_slice(*field.ident)]);
|
||||
|
|
@ -240,13 +240,13 @@ impl methods for reflector {
|
|||
self.c_size_and_align(t));
|
||||
|
||||
self.visit("enter_enum", extra);
|
||||
for variants.eachi {|i, v|
|
||||
for variants.eachi |i, v| {
|
||||
let extra = ~[self.c_uint(i),
|
||||
self.c_int(v.disr_val),
|
||||
self.c_uint(vec::len(v.args)),
|
||||
self.c_slice(*v.name)];
|
||||
self.visit("enter_enum_variant", extra);
|
||||
for v.args.eachi {|j, a|
|
||||
for v.args.eachi |j, a| {
|
||||
self.bracketed_t("enum_variant_field", a,
|
||||
~[self.c_uint(j)]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ type nominal_id = @{did: ast::def_id, parent_id: option<ast::def_id>,
|
|||
fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id,
|
||||
parent_id: option<ast::def_id>,
|
||||
tps: ~[ty::t]) -> nominal_id {
|
||||
let tps_norm = tps.map({ |t| ty::normalize_ty(tcx, t) });
|
||||
let tps_norm = tps.map(|t| ty::normalize_ty(tcx, t));
|
||||
@{did: did, parent_id: parent_id, tps: tps_norm}
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ fn hash_nominal_id(&&ri: nominal_id) -> uint {
|
|||
h += ri.did.crate as uint;
|
||||
h *= 33u;
|
||||
h += ri.did.node as uint;
|
||||
for vec::each(ri.tps) {|t|
|
||||
for vec::each(ri.tps) |t| {
|
||||
h *= 33u;
|
||||
h += ty::type_id(t);
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool {
|
|||
if mi.did != ni.did {
|
||||
false
|
||||
} else {
|
||||
do vec::all2(mi.tps, ni.tps) { |m_tp, n_tp|
|
||||
do vec::all2(mi.tps, ni.tps) |m_tp, n_tp| {
|
||||
ty::type_id(m_tp) == ty::type_id(n_tp)
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
|
|||
ValueRef {
|
||||
let llglobal =
|
||||
str::as_c_str(name,
|
||||
{|buf|
|
||||
|buf| {
|
||||
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod,
|
||||
val_ty(llval), buf)
|
||||
});
|
||||
|
|
@ -137,7 +137,7 @@ enum enum_kind {
|
|||
|
||||
fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind {
|
||||
let variants = ty::enum_variants(ccx.tcx, did);
|
||||
if vec::any(*variants, {|v| vec::len(v.args) > 0u}) {
|
||||
if vec::any(*variants, |v| vec::len(v.args) > 0u) {
|
||||
if vec::len(*variants) == 1u { tk_newtype }
|
||||
else { tk_complex }
|
||||
} else {
|
||||
|
|
@ -185,7 +185,7 @@ fn s_send_tydesc(_tcx: ty_ctxt) -> u8 {
|
|||
|
||||
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||
let llshapetablesty = trans::common::T_named_struct("shapes");
|
||||
let llshapetables = str::as_c_str("shapes", {|buf|
|
||||
let llshapetables = str::as_c_str("shapes", |buf| {
|
||||
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
||||
});
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
|
||||
ty::ty_rec(fields) {
|
||||
let mut s = ~[shape_struct], sub = ~[];
|
||||
for vec::each(fields) {|f|
|
||||
for vec::each(fields) |f| {
|
||||
sub += shape_of(ccx, f.mt.ty);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
|
|
@ -323,7 +323,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
}
|
||||
ty::ty_tup(elts) {
|
||||
let mut s = ~[shape_struct], sub = ~[];
|
||||
for vec::each(elts) {|elt|
|
||||
for vec::each(elts) |elt| {
|
||||
sub += shape_of(ccx, elt);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
|
|
@ -338,7 +338,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
~[shape_res]
|
||||
}
|
||||
else { ~[shape_struct] }, sub = ~[];
|
||||
do option::iter(m_dtor_did) {|dtor_did|
|
||||
do option::iter(m_dtor_did) |dtor_did| {
|
||||
let ri = @{did: dtor_did, parent_id: some(did), tps: tps};
|
||||
let id = interner::intern(ccx.shape_cx.resources, ri);
|
||||
add_u16(s, id as u16);
|
||||
|
|
@ -347,7 +347,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
// hasn't changed since we started monomorphizing.
|
||||
add_u16(s, 0_u16);
|
||||
};
|
||||
for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each {|f|
|
||||
for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each |f| {
|
||||
sub += shape_of(ccx, f.mt.ty);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
|
|
@ -376,7 +376,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
|
||||
fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> ~[u8] {
|
||||
let mut s = ~[];
|
||||
for vec::each(v.args) {|t| s += shape_of(ccx, t); }
|
||||
for vec::each(v.args) |t| { s += shape_of(ccx, t); }
|
||||
ret s;
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
while i < ccx.shape_cx.tag_order.len() {
|
||||
let {did, substs} = ccx.shape_cx.tag_order[i];
|
||||
let variants = @ty::substd_enum_variants(ccx.tcx, did, substs);
|
||||
do vec::iter(*variants) {|v|
|
||||
do vec::iter(*variants) |v| {
|
||||
offsets += ~[vec::len(data) as u16];
|
||||
|
||||
let variant_shape = shape_of_variant(ccx, v);
|
||||
|
|
@ -414,7 +414,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
let data_sz = vec::len(data) as u16;
|
||||
|
||||
let mut inf_sz = 0u16;
|
||||
for enum_variants.each { |variants|
|
||||
for enum_variants.each |variants| {
|
||||
let num_variants = vec::len(*variants) as u16;
|
||||
add_u16(header, header_sz + inf_sz);
|
||||
inf_sz += 2u16 * (num_variants + 2u16) + 3u16;
|
||||
|
|
@ -426,7 +426,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
|
||||
let mut lv_table = ~[];
|
||||
let mut i = 0u;
|
||||
for enum_variants.each { |variants|
|
||||
for enum_variants.each |variants| {
|
||||
add_u16(inf, vec::len(*variants) as u16);
|
||||
|
||||
// Construct the largest-variants table.
|
||||
|
|
@ -435,11 +435,11 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
|
||||
let lv = largest_variants(ccx, variants);
|
||||
add_u16(lv_table, vec::len(lv) as u16);
|
||||
for vec::each(lv) {|v| add_u16(lv_table, v as u16); }
|
||||
for vec::each(lv) |v| { add_u16(lv_table, v as u16); }
|
||||
|
||||
// Determine whether the enum has dynamic size.
|
||||
assert !vec::any(*variants, {|v|
|
||||
vec::any(v.args, {|t| ty::type_has_params(t)})
|
||||
assert !vec::any(*variants, |v| {
|
||||
vec::any(v.args, |t| ty::type_has_params(t))
|
||||
});
|
||||
|
||||
// If we can, write in the static size and alignment of the enum.
|
||||
|
|
@ -451,7 +451,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
inf += ~[size_align.align];
|
||||
|
||||
// Now write in the offset of each variant.
|
||||
for vec::each(*variants) {|_v|
|
||||
for vec::each(*variants) |_v| {
|
||||
add_u16(inf, header_sz + inf_sz + offsets[i]);
|
||||
i += 1u;
|
||||
}
|
||||
|
|
@ -478,10 +478,10 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
// variant that contains (T,T) must be as least as large as
|
||||
// any variant that contains just T.
|
||||
let mut ranges = ~[];
|
||||
for vec::each(*variants) {|variant|
|
||||
for vec::each(*variants) |variant| {
|
||||
let mut bounded = true;
|
||||
let mut min_size = 0u, min_align = 0u;
|
||||
for vec::each(variant.args) {|elem_t|
|
||||
for vec::each(variant.args) |elem_t| {
|
||||
if ty::type_has_params(elem_t) {
|
||||
// NB: We could do better here; this causes us to
|
||||
// conservatively assume that (int, T) has minimum size 0,
|
||||
|
|
@ -501,7 +501,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
|
||||
// Initialize the candidate set to contain all variants.
|
||||
let mut candidates = ~[mut];
|
||||
for vec::each(*variants) {|_v| candidates += ~[mut true]; }
|
||||
for vec::each(*variants) |_v| { candidates += ~[mut true]; }
|
||||
|
||||
// Do a pairwise comparison among all variants still in the
|
||||
// candidate set. Throw out any variant that we know has size
|
||||
|
|
@ -548,10 +548,10 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
-> size_align {
|
||||
let mut max_size = 0u16;
|
||||
let mut max_align = 1u8;
|
||||
for vec::each(largest_variants) {|vid|
|
||||
for vec::each(largest_variants) |vid| {
|
||||
// We increment a "virtual data pointer" to compute the size.
|
||||
let mut lltys = ~[];
|
||||
for vec::each(variants[vid].args) {|typ|
|
||||
for vec::each(variants[vid].args) |typ| {
|
||||
lltys += ~[type_of::type_of(ccx, typ)];
|
||||
}
|
||||
|
||||
|
|
@ -580,10 +580,10 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
let mut dtors = ~[];
|
||||
let len = interner::len(ccx.shape_cx.resources);
|
||||
for uint::range(0u, len) {|i|
|
||||
for uint::range(0u, len) |i| {
|
||||
let ri = interner::get(ccx.shape_cx.resources, i);
|
||||
for ri.tps.each() {|s| assert !ty::type_has_params(s); }
|
||||
do option::iter(ri.parent_id) {|id|
|
||||
for ri.tps.each() |s| { assert !ty::type_has_params(s); }
|
||||
do option::iter(ri.parent_id) |id| {
|
||||
dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)];
|
||||
}
|
||||
}
|
||||
|
|
@ -694,7 +694,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
|
|||
// Compute max(variant sizes).
|
||||
let mut max_size = 0u;
|
||||
let variants = ty::enum_variants(cx.tcx, tid);
|
||||
for vec::each(*variants) {|variant|
|
||||
for vec::each(*variants) |variant| {
|
||||
let tup_ty = simplify_type(cx.tcx,
|
||||
ty::mk_tup(cx.tcx, variant.args));
|
||||
// Perform any type parameter substitutions.
|
||||
|
|
@ -742,7 +742,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
|||
ty::mk_u8(tcx),
|
||||
mutbl: ast::m_mutbl}}] }
|
||||
else { ~[] }) +
|
||||
do ty::lookup_class_fields(tcx, did).map {|f|
|
||||
do ty::lookup_class_fields(tcx, did).map |f| {
|
||||
let t = ty::lookup_field_type(tcx, did, f.id, substs);
|
||||
{ident: f.ident,
|
||||
mt: {ty: simplify_type(tcx, t), mutbl: ast::m_const}}
|
||||
|
|
@ -752,5 +752,5 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
|||
_ { typ }
|
||||
}
|
||||
}
|
||||
ty::fold_ty(tcx, typ, {|t| simplifier(tcx, t) })
|
||||
ty::fold_ty(tcx, typ, |t| simplifier(tcx, t))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr],
|
|||
let ccx = bcx.ccx();
|
||||
let mut bcx = bcx;
|
||||
if dest == base::ignore {
|
||||
for vec::each(args) {|arg|
|
||||
for vec::each(args) |arg| {
|
||||
bcx = base::trans_expr(bcx, arg, base::ignore);
|
||||
}
|
||||
ret bcx;
|
||||
|
|
@ -192,7 +192,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr],
|
|||
#debug("trans_evec: v: %s, dataptr: %s",
|
||||
val_str(ccx.tn, val),
|
||||
val_str(ccx.tn, dataptr));
|
||||
for vec::each(args) {|e|
|
||||
for vec::each(args) |e| {
|
||||
let lleltptr = InBoundsGEP(bcx, dataptr, ~[C_uint(ccx, i)]);
|
||||
bcx = base::trans_expr_save_in(bcx, e, lleltptr);
|
||||
add_clean_temp_mem(bcx, lleltptr, unit_ty);
|
||||
|
|
@ -200,7 +200,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr],
|
|||
i += 1u;
|
||||
}
|
||||
|
||||
for vec::each(temp_cleanups) {|cln| revoke_clean(bcx, cln); }
|
||||
for vec::each(temp_cleanups) |cln| { revoke_clean(bcx, cln); }
|
||||
|
||||
alt vst {
|
||||
ast::vstore_fixed(_) {
|
||||
|
|
@ -335,7 +335,7 @@ fn trans_append(bcx: block, vec_ty: ty::t, lhsptr: ValueRef,
|
|||
if strings { lhs_off = Sub(bcx, lhs_off, C_int(ccx, 1)); }
|
||||
let write_ptr = pointer_add(bcx, lhs_data, lhs_off);
|
||||
let write_ptr_ptr = do_spill_noroot(bcx, write_ptr);
|
||||
iter_vec_uniq(bcx, rhs, vec_ty, rfill, {|bcx, addr, _ty|
|
||||
iter_vec_uniq(bcx, rhs, vec_ty, rfill, |bcx, addr, _ty| {
|
||||
let write_ptr = Load(bcx, write_ptr_ptr);
|
||||
let bcx = copy_val(bcx, INIT, write_ptr,
|
||||
load_if_immediate(bcx, addr, unit_ty), unit_ty);
|
||||
|
|
@ -353,14 +353,14 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
|
|||
let elt_llty = type_of::type_of(ccx, elt_ty);
|
||||
let elt_sz = shape::llsize_of(ccx, elt_llty);
|
||||
let scratch = base::alloca(bcx, elt_llty);
|
||||
for vec::each(vals) {|val|
|
||||
for vec::each(vals) |val| {
|
||||
bcx = base::trans_expr_save_in(bcx, val, scratch);
|
||||
let vptr = get_bodyptr(bcx, Load(bcx, vptrptr));
|
||||
let old_fill = get_fill(bcx, vptr);
|
||||
let new_fill = Add(bcx, old_fill, elt_sz);
|
||||
let do_grow = ICmp(bcx, lib::llvm::IntUGT, new_fill,
|
||||
get_alloc(bcx, vptr));
|
||||
bcx = do base::with_cond(bcx, do_grow) {|bcx|
|
||||
bcx = do base::with_cond(bcx, do_grow) |bcx| {
|
||||
let pt = PointerCast(bcx, vptrptr,
|
||||
T_ptr(T_ptr(T_i8())));
|
||||
Call(bcx, ccx.upcalls.vec_grow, ~[pt, new_fill]);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export type_of_non_gc_box;
|
|||
|
||||
fn type_of_explicit_args(cx: @crate_ctxt,
|
||||
inputs: ~[ty::arg]) -> ~[TypeRef] {
|
||||
do vec::map(inputs) {|arg|
|
||||
do vec::map(inputs) |arg| {
|
||||
let arg_ty = arg.ty;
|
||||
let llty = type_of(cx, arg_ty);
|
||||
alt ty::resolved_mode(cx.tcx, arg.mode) {
|
||||
|
|
@ -135,7 +135,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
|
||||
ty::ty_rec(fields) {
|
||||
let mut tys: ~[TypeRef] = ~[];
|
||||
for vec::each(fields) {|f|
|
||||
for vec::each(fields) |f| {
|
||||
let mt_ty = f.mt.ty;
|
||||
vec::push(tys, type_of(cx, mt_ty));
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
ty::ty_type { T_ptr(cx.tydesc_type) }
|
||||
ty::ty_tup(elts) {
|
||||
let mut tys = ~[];
|
||||
for vec::each(elts) {|elt|
|
||||
for vec::each(elts) |elt| {
|
||||
vec::push(tys, type_of(cx, elt));
|
||||
}
|
||||
T_struct(tys)
|
||||
|
|
@ -175,7 +175,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
ty::ty_class(did, ts) {
|
||||
// Only instance vars are record fields at runtime.
|
||||
let fields = lookup_class_fields(cx.tcx, did);
|
||||
let mut tys = do vec::map(fields) {|f|
|
||||
let mut tys = do vec::map(fields) |f| {
|
||||
let t = ty::lookup_field_type(cx.tcx, did, f.id, ts);
|
||||
type_of(cx, t)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))};
|
||||
alt ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct {
|
||||
ty::ty_fn({inputs, _}) {
|
||||
for vec::each(inputs) {|arg|
|
||||
for vec::each(inputs) |arg| {
|
||||
if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); }
|
||||
}
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
handle_body(cx, body);
|
||||
}
|
||||
ast_map::node_variant(_, _, _) {
|
||||
for uint::range(0u, n_tps) {|n| cx.uses[n] |= use_repr;}
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_repr;}
|
||||
}
|
||||
ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _},
|
||||
abi, _) {
|
||||
|
|
@ -89,7 +89,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
}
|
||||
"forget" | "addr_of" { 0u }
|
||||
};
|
||||
for uint::range(0u, n_tps) {|n| cx.uses[n] |= flags;}
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;}
|
||||
}
|
||||
}
|
||||
ast_map::node_ctor(_, _, ctor, _, _){
|
||||
|
|
@ -108,13 +108,13 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
fn type_needs(cx: ctx, use: uint, ty: ty::t) {
|
||||
let mut done = true;
|
||||
// Optimization -- don't descend type if all params already have this use
|
||||
for vec::each(cx.uses) {|u| if u & use != use { done = false } }
|
||||
for vec::each(cx.uses) |u| { if u & use != use { done = false } }
|
||||
if !done { type_needs_inner(cx, use, ty, @nil); }
|
||||
}
|
||||
|
||||
fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,
|
||||
enums_seen: @list<def_id>) {
|
||||
do ty::maybe_walk_ty(ty) {|ty|
|
||||
do ty::maybe_walk_ty(ty) |ty| {
|
||||
if ty::type_has_params(ty) {
|
||||
alt ty::get(ty).struct {
|
||||
/*
|
||||
|
|
@ -126,10 +126,10 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,
|
|||
ty::ty_fn(_) | ty::ty_ptr(_) | ty::ty_rptr(_, _)
|
||||
| ty::ty_iface(_, _) { false }
|
||||
ty::ty_enum(did, substs) {
|
||||
if option::is_none(list::find(enums_seen, {|id| id == did})) {
|
||||
if option::is_none(list::find(enums_seen, |id| id == did)) {
|
||||
let seen = @cons(did, enums_seen);
|
||||
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) {|v|
|
||||
for vec::each(v.args) {|aty|
|
||||
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
|
||||
for vec::each(v.args) |aty| {
|
||||
let t = ty::subst(cx.ccx.tcx, substs, aty);
|
||||
type_needs_inner(cx, use, t, seen);
|
||||
}
|
||||
|
|
@ -181,18 +181,19 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
}
|
||||
expr_path(_) {
|
||||
do cx.ccx.tcx.node_type_substs.find(e.id).iter {|ts|
|
||||
do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
|
||||
let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id));
|
||||
vec::iter2(type_uses_for(cx.ccx, id, ts.len()), ts, {|uses, subst|
|
||||
type_needs(cx, uses, subst)
|
||||
})
|
||||
vec::iter2(type_uses_for(cx.ccx, id, ts.len()), ts,
|
||||
|uses, subst| {
|
||||
type_needs(cx, uses, subst)
|
||||
})
|
||||
}
|
||||
}
|
||||
expr_fn(*) | expr_fn_block(*) {
|
||||
alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
|
||||
proto_bare | proto_any | proto_uniq {}
|
||||
proto_box | proto_block {
|
||||
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) {|fv|
|
||||
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
|
||||
let node_id = ast_util::def_id_of_def(fv.def).node;
|
||||
node_type_needs(cx, use_repr, node_id);
|
||||
}
|
||||
|
|
@ -209,12 +210,12 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id);
|
||||
type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty));
|
||||
|
||||
do option::iter(cx.ccx.maps.method_map.find(e.id)) {|mth|
|
||||
do option::iter(cx.ccx.maps.method_map.find(e.id)) |mth| {
|
||||
alt mth.origin {
|
||||
typeck::method_static(did) {
|
||||
do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) {|ts|
|
||||
do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) |ts| {
|
||||
do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts)
|
||||
{|uses, subst| type_needs(cx, uses, subst)}
|
||||
|uses, subst| { type_needs(cx, uses, subst)}
|
||||
}
|
||||
}
|
||||
typeck::method_param({param_num: param, _}) {
|
||||
|
|
@ -231,7 +232,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
node_type_needs(cx, use_repr, v.id);
|
||||
}
|
||||
expr_call(f, _, _) {
|
||||
vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), {|a|
|
||||
vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| {
|
||||
alt a.mode {
|
||||
expl(by_move) | expl(by_copy) | expl(by_val) {
|
||||
type_needs(cx, use_repr, a.ty);
|
||||
|
|
@ -251,25 +252,25 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
|
||||
fn handle_body(cx: ctx, body: blk) {
|
||||
let v = visit::mk_vt(@{
|
||||
visit_expr: {|e, cx, v|
|
||||
visit_expr: |e, cx, v| {
|
||||
visit::visit_expr(e, cx, v);
|
||||
mark_for_expr(cx, e);
|
||||
},
|
||||
visit_local: {|l, cx, v|
|
||||
visit_local: |l, cx, v| {
|
||||
visit::visit_local(l, cx, v);
|
||||
node_type_needs(cx, use_repr, l.node.id);
|
||||
},
|
||||
visit_pat: {|p, cx, v|
|
||||
visit_pat: |p, cx, v| {
|
||||
visit::visit_pat(p, cx, v);
|
||||
node_type_needs(cx, use_repr, p.id);
|
||||
},
|
||||
visit_block: {|b, cx, v|
|
||||
visit_block: |b, cx, v| {
|
||||
visit::visit_block(b, cx, v);
|
||||
do option::iter(b.node.expr) {|e|
|
||||
do option::iter(b.node.expr) |e| {
|
||||
node_type_needs(cx, use_repr, e.id);
|
||||
}
|
||||
},
|
||||
visit_item: {|_i, _cx, _v|}
|
||||
visit_item: |_i, _cx, _v| { }
|
||||
with *visit::default_visitor()
|
||||
});
|
||||
v.visit_block(body, cx, v);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export make_free_glue, autoderef, duplicate;
|
|||
fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t)
|
||||
-> block {
|
||||
let _icx = bcx.insn_ctxt("uniq::make_free_glue");
|
||||
do with_cond(bcx, IsNotNull(bcx, vptr)) {|bcx|
|
||||
do with_cond(bcx, IsNotNull(bcx, vptr)) |bcx| {
|
||||
let content_ty = content_ty(t);
|
||||
let body_ptr = opaque_box_body(bcx, content_ty, vptr);
|
||||
let bcx = drop_ty(bcx, body_ptr, content_ty);
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut ~[node_id]) {
|
|||
|
||||
fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut ~[node_id]) {
|
||||
let collect_ids =
|
||||
visit::mk_simple_visitor(@{visit_expr: {|a|collect_ids_expr(a, rs)},
|
||||
visit_block: {|a|collect_ids_block(a, rs)},
|
||||
visit_stmt: {|a|collect_ids_stmt(a, rs)},
|
||||
visit_local: {|a|
|
||||
collect_ids_local(tcx, a, rs)}
|
||||
visit::mk_simple_visitor(@{visit_expr: |a| collect_ids_expr(a, rs),
|
||||
visit_block: |a| collect_ids_block(a, rs),
|
||||
visit_stmt: |a| collect_ids_stmt(a, rs),
|
||||
visit_local: |a|
|
||||
collect_ids_local(tcx, a, rs)
|
||||
with *visit::default_simple_visitor()});
|
||||
collect_ids.visit_block(body, (), collect_ids);
|
||||
}
|
||||
|
||||
fn init_vecs(ccx: crate_ctxt, node_ids: ~[node_id], len: uint) {
|
||||
for node_ids.each {|i|
|
||||
for node_ids.each |i| {
|
||||
log(debug, int::str(i) + " |-> " + uint::str(len));
|
||||
add_node(ccx, i, empty_ann(len));
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ fn annotate_in_fn(ccx: crate_ctxt, _fk: visit::fn_kind, _decl: fn_decl,
|
|||
fn annotate_crate(ccx: crate_ctxt, crate: crate) {
|
||||
let do_ann =
|
||||
visit::mk_simple_visitor(
|
||||
@{visit_fn: {|a,b,c,d,e|annotate_in_fn(ccx, a, b, c, d, e)}
|
||||
@{visit_fn: |a,b,c,d,e| annotate_in_fn(ccx, a, b, c, d, e)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(crate, (), do_ann);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn def_id_to_str(d: def_id) -> str {
|
|||
fn comma_str(args: ~[@constr_arg_use]) -> str {
|
||||
let mut rslt = "";
|
||||
let mut comma = false;
|
||||
for args.each {|a|
|
||||
for args.each |a| {
|
||||
if comma { rslt += ", "; } else { comma = true; }
|
||||
alt a.node {
|
||||
carg_base { rslt += "*"; }
|
||||
|
|
@ -58,7 +58,7 @@ fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> str {
|
|||
fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> str {
|
||||
let mut s = "";
|
||||
let mut comma = false;
|
||||
for constraints(fcx).each {|p|
|
||||
for constraints(fcx).each |p| {
|
||||
alt tritv_get(v, p.bit_num) {
|
||||
dont_care { }
|
||||
tt {
|
||||
|
|
@ -79,7 +79,7 @@ fn log_tritv(fcx: fn_ctxt, v: tritv::t) {
|
|||
fn first_difference_string(fcx: fn_ctxt, expected: tritv::t, actual: tritv::t)
|
||||
-> str {
|
||||
let mut s = "";
|
||||
for constraints(fcx).each {|c|
|
||||
for constraints(fcx).each |c| {
|
||||
if tritv_get(expected, c.bit_num) == ttrue &&
|
||||
tritv_get(actual, c.bit_num) != ttrue {
|
||||
s = constraint_to_str(fcx.ccx.tcx, c.c);
|
||||
|
|
@ -95,7 +95,7 @@ fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) {
|
|||
|
||||
fn tos(v: ~[uint]) -> str {
|
||||
let mut rslt = "";
|
||||
for v.each {|i|
|
||||
for v.each |i| {
|
||||
if i == 0u {
|
||||
rslt += "0";
|
||||
} else if i == 1u { rslt += "1"; } else { rslt += "?"; }
|
||||
|
|
@ -473,7 +473,7 @@ fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> {
|
|||
|
||||
fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] {
|
||||
let mut rslt: ~[norm_constraint] = ~[];
|
||||
for (*c.descs).each {|pd|
|
||||
for (*c.descs).each |pd| {
|
||||
vec::push(rslt,
|
||||
{bit_num: pd.node.bit_num,
|
||||
c: respan(pd.span, {path: c.path,
|
||||
|
|
@ -488,7 +488,7 @@ fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] {
|
|||
// non-exhaustive match in trans.
|
||||
fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] {
|
||||
let mut rslt: ~[norm_constraint] = ~[];
|
||||
for fcx.enclosing.constrs.each {|key, val|
|
||||
for fcx.enclosing.constrs.each |key, val| {
|
||||
vec::push_all(rslt, norm_a_constraint(key, val));
|
||||
};
|
||||
ret rslt;
|
||||
|
|
@ -500,7 +500,7 @@ fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>,
|
|||
occ: ~[@constr_arg_use]) -> uint {
|
||||
#debug("match_args: looking at %s",
|
||||
constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ));
|
||||
for (*occs).each {|pd|
|
||||
for (*occs).each |pd| {
|
||||
log(debug,
|
||||
"match_args: candidate " + pred_args_to_str(pd));
|
||||
fn eq(p: inst, q: inst) -> bool { ret p.node == q.node; }
|
||||
|
|
@ -551,9 +551,9 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use {
|
|||
|
||||
fn exprs_to_constr_args(tcx: ty::ctxt,
|
||||
args: ~[@expr]) -> ~[@constr_arg_use] {
|
||||
let f = {|a|expr_to_constr_arg(tcx, a)};
|
||||
let f = |a| expr_to_constr_arg(tcx, a);
|
||||
let mut rslt: ~[@constr_arg_use] = ~[];
|
||||
for args.each {|e| vec::push(rslt, f(e)); }
|
||||
for args.each |e| { vec::push(rslt, f(e)); }
|
||||
rslt
|
||||
}
|
||||
|
||||
|
|
@ -588,7 +588,7 @@ fn pred_args_to_str(p: pred_args) -> str {
|
|||
fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) ->
|
||||
tsconstr {
|
||||
let mut rslt: ~[@constr_arg_use] = ~[];
|
||||
for c.node.args.each {|a|
|
||||
for c.node.args.each |a| {
|
||||
vec::push(rslt, substitute_arg(cx, actuals, a));
|
||||
}
|
||||
ret {path: c.node.path,
|
||||
|
|
@ -616,7 +616,7 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>],
|
|||
desc: pred_args) ->
|
||||
bool {
|
||||
let mut i = 0u;
|
||||
for desc.node.args.each {|c|
|
||||
for desc.node.args.each |c| {
|
||||
let n = pattern[i];
|
||||
alt c.node {
|
||||
carg_ident(p) {
|
||||
|
|
@ -641,7 +641,7 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>],
|
|||
fn find_instance_(pattern: ~[constr_arg_general_<inst>],
|
||||
descs: ~[pred_args]) ->
|
||||
option<uint> {
|
||||
for descs.each {|d|
|
||||
for descs.each |d| {
|
||||
if pred_args_matches(pattern, d) { ret some(d.node.bit_num); }
|
||||
}
|
||||
ret none;
|
||||
|
|
@ -661,9 +661,9 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
|
|||
|
||||
if vec::len(subst) == 0u { ret ~[]; }
|
||||
let mut res = ~[];
|
||||
do (*c.descs).swap { |v|
|
||||
do (*c.descs).swap |v| {
|
||||
let v <- vec::from_mut(v);
|
||||
for v.each { |d|
|
||||
for v.each |d| {
|
||||
if args_mention(d.node.args, find_in_subst_bool, subst) {
|
||||
let old_bit_num = d.node.bit_num;
|
||||
let newv = replace(subst, d);
|
||||
|
|
@ -679,7 +679,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
|
|||
}
|
||||
|
||||
fn find_in_subst(id: node_id, s: subst) -> option<inst> {
|
||||
for s.each {|p|
|
||||
for s.each |p| {
|
||||
if id == p.from.node { ret some(p.to); }
|
||||
}
|
||||
ret none;
|
||||
|
|
@ -691,7 +691,7 @@ fn find_in_subst_bool(s: subst, id: node_id) -> bool {
|
|||
|
||||
fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> str {
|
||||
let mut rslt = "<";
|
||||
for stuff.each {|i|
|
||||
for stuff.each |i| {
|
||||
rslt +=
|
||||
" " +
|
||||
alt i {
|
||||
|
|
@ -706,7 +706,7 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> str {
|
|||
|
||||
fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] {
|
||||
let mut rslt: ~[constr_arg_general_<inst>] = ~[];
|
||||
for d.node.args.each {|c|
|
||||
for d.node.args.each |c| {
|
||||
alt c.node {
|
||||
carg_ident(p) {
|
||||
alt find_in_subst(p.node, subst) {
|
||||
|
|
@ -727,7 +727,7 @@ enum if_ty { if_check, plain_if, }
|
|||
|
||||
fn for_constraints_mentioning(fcx: fn_ctxt, id: node_id,
|
||||
f: fn(norm_constraint)) {
|
||||
for constraints(fcx).each {|c|
|
||||
for constraints(fcx).each |c| {
|
||||
if constraint_mentions(fcx, c, id) { f(c); }
|
||||
};
|
||||
}
|
||||
|
|
@ -805,11 +805,11 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
|
|||
}
|
||||
|
||||
|
||||
for fcx.enclosing.constrs.each_value {|val|
|
||||
for fcx.enclosing.constrs.each_value |val| {
|
||||
// replace any occurrences of the src def_id with the
|
||||
// dest def_id
|
||||
let insts = find_instances(fcx, subst, val);
|
||||
for insts.each {|p|
|
||||
for insts.each |p| {
|
||||
if bitvectors::promises_(p.from, src_post) {
|
||||
set_in_poststate_(p.to, target_post);
|
||||
}
|
||||
|
|
@ -821,8 +821,8 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
|
|||
// In the postcondition given by parent_exp, clear the bits
|
||||
// for any constraints mentioning dead_v
|
||||
let d = local_node_id_to_local_def_id(fcx, dead_v);
|
||||
do option::iter(d) {|d_id|
|
||||
do for_constraints_mentioning(fcx, d_id) {|c|
|
||||
do option::iter(d) |d_id| {
|
||||
do for_constraints_mentioning(fcx, d_id) |c| {
|
||||
#debug("clearing constraint %u %s",
|
||||
c.bit_num,
|
||||
constraint_to_str(fcx.ccx.tcx, c.c));
|
||||
|
|
@ -838,8 +838,8 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool {
|
|||
// for any constraints mentioning dead_v
|
||||
let d = local_node_id_to_local_def_id(fcx, dead_v);
|
||||
let mut changed = false;
|
||||
do option::iter(d) {|d_id|
|
||||
do for_constraints_mentioning(fcx, d_id) {|c|
|
||||
do option::iter(d) |d_id| {
|
||||
do for_constraints_mentioning(fcx, d_id) |c| {
|
||||
changed |= clear_in_poststate_(c.bit_num, p);
|
||||
}
|
||||
}
|
||||
|
|
@ -847,7 +847,7 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool {
|
|||
}
|
||||
|
||||
fn any_eq(v: ~[node_id], d: node_id) -> bool {
|
||||
for v.each {|i| if i == d { ret true; } }
|
||||
for v.each |i| { if i == d { ret true; } }
|
||||
false
|
||||
}
|
||||
|
||||
|
|
@ -860,7 +860,7 @@ fn args_mention<T>(args: ~[@constr_arg_use],
|
|||
q: fn(~[T], node_id) -> bool,
|
||||
s: ~[T]) -> bool {
|
||||
|
||||
for args.each {|a|
|
||||
for args.each |a| {
|
||||
alt a.node { carg_ident(p1) { if q(s, p1.node) { ret true; } } _ { } }
|
||||
}
|
||||
ret false;
|
||||
|
|
@ -886,7 +886,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg],
|
|||
-> ~[@constr_arg_use] {
|
||||
let mut actuals: ~[@constr_arg_use] = ~[];
|
||||
let num_args = vec::len(args);
|
||||
for indices.each {|a|
|
||||
for indices.each |a| {
|
||||
vec::push(
|
||||
actuals,
|
||||
@respan(a.span,
|
||||
|
|
@ -926,7 +926,7 @@ type binding = {lhs: ~[dest], rhs: option<initializer>};
|
|||
|
||||
fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding {
|
||||
let mut lhs = ~[];
|
||||
do pat_bindings(tcx.def_map, loc.node.pat) {|p_id, _s, name|
|
||||
do pat_bindings(tcx.def_map, loc.node.pat) |p_id, _s, name| {
|
||||
vec::push(lhs, local_dest({ident: path_to_ident(name), node: p_id}));
|
||||
};
|
||||
{lhs: lhs, rhs: loc.node.init}
|
||||
|
|
@ -934,7 +934,7 @@ fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding {
|
|||
|
||||
fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] {
|
||||
let mut rslt = ~[];
|
||||
for locals.each {|loc| vec::push(rslt, local_to_bindings(tcx, loc)); }
|
||||
for locals.each |loc| { vec::push(rslt, local_to_bindings(tcx, loc)); }
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
|
|
@ -944,7 +944,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
|
|||
alt ty::get(ty).struct {
|
||||
ty::ty_fn({inputs: args, _}) {
|
||||
let mut modes = ~[];
|
||||
for args.each {|arg| vec::push(modes, arg.mode); }
|
||||
for args.each |arg| { vec::push(modes, arg.mode); }
|
||||
ret modes;
|
||||
}
|
||||
_ {
|
||||
|
|
@ -956,7 +956,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
|
|||
}
|
||||
|
||||
fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] {
|
||||
do vec::map(callee_modes(fcx, callee)) {|m|
|
||||
do vec::map(callee_modes(fcx, callee)) |m| {
|
||||
alt ty::resolved_mode(fcx.ccx.tcx, m) {
|
||||
by_move { init_move }
|
||||
by_copy | by_ref | by_val | by_mutbl_ref { init_assign }
|
||||
|
|
@ -967,7 +967,7 @@ fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] {
|
|||
fn arg_bindings(ops: ~[init_op], es: ~[@expr]) -> ~[binding] {
|
||||
let mut bindings: ~[binding] = ~[];
|
||||
let mut i = 0u;
|
||||
for ops.each {|op|
|
||||
for ops.each |op| {
|
||||
vec::push(bindings,
|
||||
{lhs: ~[call], rhs: some({op: op, expr: es[i]})});
|
||||
i += 1u;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn seq_postconds(fcx: fn_ctxt, ps: ~[postcond]) -> postcond {
|
|||
let sz = vec::len(ps);
|
||||
if sz >= 1u {
|
||||
let prev = tritv_clone(ps[0]);
|
||||
vec::iter_between(ps, 1u, sz, {|p| seq_tritv(prev, p); });
|
||||
vec::iter_between(ps, 1u, sz, |p| seq_tritv(prev, p) );
|
||||
ret prev;
|
||||
} else { ret ann::empty_poststate(num_constraints(fcx.enclosing)); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ fn check_states_against_conditions(fcx: fn_ctxt,
|
|||
let visitor = visit::mk_vt(
|
||||
@{visit_stmt: check_states_stmt,
|
||||
visit_expr: check_states_expr,
|
||||
visit_fn: {|a,b,c,d,e,f,g|
|
||||
visit_fn: |a,b,c,d,e,f,g| {
|
||||
do_nothing::<fn_ctxt>(a, b, c, d, e, f, g)
|
||||
}
|
||||
with *visit::default_visitor::<fn_ctxt>()});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) {
|
|||
// If it's a call, generate appropriate instances of the
|
||||
// call's constraints.
|
||||
expr_call(operator, operands, _) {
|
||||
for constraints_expr(cx.tcx, operator).each {|c|
|
||||
for constraints_expr(cx.tcx, operator).each |c| {
|
||||
let ct: sp_constr =
|
||||
respan(c.span,
|
||||
aux::substitute_constr_args(cx.tcx, operands, c));
|
||||
|
|
@ -126,7 +126,7 @@ fn mk_fn_info(ccx: crate_ctxt,
|
|||
}
|
||||
/* if this function has any constraints, instantiate them to the
|
||||
argument names and add them */
|
||||
for f_decl.constraints.each {|c|
|
||||
for f_decl.constraints.each |c| {
|
||||
let sc = ast_constr_to_sp_constr(cx.tcx, f_decl.inputs, c);
|
||||
next = add_constraint(cx.tcx, sc, next, res_map);
|
||||
}
|
||||
|
|
@ -150,9 +150,7 @@ fn mk_fn_info(ccx: crate_ctxt,
|
|||
fn mk_f_to_fn_info(ccx: crate_ctxt, c: @crate) {
|
||||
let visitor =
|
||||
visit::mk_simple_visitor(@{
|
||||
visit_fn: {|a,b,c,d,e|
|
||||
mk_fn_info(ccx, a, b, c, d, e)
|
||||
}
|
||||
visit_fn: |a,b,c,d,e| mk_fn_info(ccx, a, b, c, d, e)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(*c, (), visitor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) {
|
|||
fail "find_pre_post_item: shouldn't be called on item_class";
|
||||
}
|
||||
item_impl(_, _, _, _, ms) {
|
||||
for ms.each {|m| find_pre_post_method(ccx, m); }
|
||||
for ms.each |m| { find_pre_post_method(ccx, m); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,12 +68,12 @@ fn find_pre_post_exprs(fcx: fn_ctxt, args: ~[@expr], id: node_id) {
|
|||
#debug["find_pre_post_exprs: oper = %s", expr_to_str(args[0])];
|
||||
}
|
||||
fn do_one(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); }
|
||||
for args.each {|e| do_one(fcx, e); }
|
||||
for args.each |e| { do_one(fcx, e); }
|
||||
|
||||
fn get_pp(ccx: crate_ctxt, &&e: @expr) -> pre_and_post {
|
||||
ret expr_pp(ccx, e);
|
||||
}
|
||||
let pps = vec::map(args, {|a|get_pp(fcx.ccx, a)});
|
||||
let pps = vec::map(args, |a| get_pp(fcx.ccx, a) );
|
||||
|
||||
set_pre_and_post(fcx.ccx, id, seq_preconds(fcx, pps),
|
||||
seq_postconds(fcx, vec::map(pps, get_post)));
|
||||
|
|
@ -230,7 +230,7 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
|
|||
|
||||
fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: ~[mode],
|
||||
operands: ~[@expr]) {
|
||||
do vec::iteri(modes) {|i,mode|
|
||||
do vec::iteri(modes) |i,mode| {
|
||||
alt ty::resolved_mode(fcx.ccx.tcx, mode) {
|
||||
by_move { forget_in_postcond(fcx, parent.id, operands[i].id); }
|
||||
by_ref | by_val | by_mutbl_ref | by_copy { }
|
||||
|
|
@ -259,7 +259,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
|
||||
find_pre_post_exprs(fcx, args, e.id);
|
||||
/* see if the call has any constraints on its type */
|
||||
for constraints_expr(fcx.ccx.tcx, operator).each {|c|
|
||||
for constraints_expr(fcx.ccx.tcx, operator).each |c| {
|
||||
let i =
|
||||
bit_num(fcx, substitute_constr_args(fcx.ccx.tcx, args, c));
|
||||
require(i, expr_pp(fcx.ccx, e));
|
||||
|
|
@ -295,12 +295,12 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
expr_fn(_, _, _, cap_clause) | expr_fn_block(_, _, cap_clause) {
|
||||
find_pre_post_expr_fn_upvars(fcx, e);
|
||||
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
let d = local_node_id_to_local_def_id(fcx, cap_item.id);
|
||||
option::iter(d, { |id| use_var(fcx, id) });
|
||||
option::iter(d, |id| use_var(fcx, id) );
|
||||
}
|
||||
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
if cap_item.is_move {
|
||||
log(debug, ("forget_in_postcond: ", cap_item));
|
||||
forget_in_postcond(fcx, e.id, cap_item.id);
|
||||
|
|
@ -398,7 +398,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
ret block_pp(fcx.ccx, an_alt.body);
|
||||
}
|
||||
let mut alt_pps = ~[];
|
||||
for alts.each {|a| vec::push(alt_pps, do_an_alt(fcx, a)); }
|
||||
for alts.each |a| { vec::push(alt_pps, do_an_alt(fcx, a)); }
|
||||
fn combine_pp(antec: pre_and_post, fcx: fn_ctxt, &&pp: pre_and_post,
|
||||
&&next: pre_and_post) -> pre_and_post {
|
||||
union(pp.precondition, seq_preconds(fcx, ~[antec, next]));
|
||||
|
|
@ -409,7 +409,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
let e_pp =
|
||||
{precondition: empty_prestate(num_local_vars),
|
||||
postcondition: false_postcond(num_local_vars)};
|
||||
let g = {|a,b|combine_pp(antec_pp, fcx, a, b)};
|
||||
let g = |a,b| combine_pp(antec_pp, fcx, a, b);
|
||||
let alts_overall_pp =
|
||||
vec::foldl(e_pp, alt_pps, g);
|
||||
set_pre_and_post(fcx.ccx, e.id, alts_overall_pp.precondition,
|
||||
|
|
@ -457,14 +457,14 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
|||
alt adecl.node {
|
||||
decl_local(alocals) {
|
||||
let prev_pp = empty_pre_post(num_constraints(fcx.enclosing));
|
||||
for alocals.each {|alocal|
|
||||
for alocals.each |alocal| {
|
||||
alt alocal.node.init {
|
||||
some(an_init) {
|
||||
/* LHS always becomes initialized,
|
||||
whether or not this is a move */
|
||||
find_pre_post_expr(fcx, an_init.expr);
|
||||
do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat)
|
||||
{|p_id, _s, _n|
|
||||
|p_id, _s, _n| {
|
||||
copy_pre_post(fcx.ccx, p_id, an_init.expr);
|
||||
};
|
||||
/* Inherit ann from initializer, and add var being
|
||||
|
|
@ -478,7 +478,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
|||
}
|
||||
|
||||
do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat)
|
||||
{|p_id, _s, n|
|
||||
|p_id, _s, n| {
|
||||
let ident = path_to_ident(n);
|
||||
alt p {
|
||||
some(p) {
|
||||
|
|
@ -506,7 +506,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
|||
}
|
||||
none {
|
||||
do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat)
|
||||
{|p_id, _s, _n|
|
||||
|p_id, _s, _n| {
|
||||
clear_pp(node_id_to_ts_ann(fcx.ccx, p_id).conditions);
|
||||
};
|
||||
clear_pp(node_id_to_ts_ann(fcx.ccx, id).conditions);
|
||||
|
|
@ -549,13 +549,13 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) {
|
|||
fn do_one_(fcx: fn_ctxt, s: @stmt) {
|
||||
find_pre_post_stmt(fcx, *s);
|
||||
}
|
||||
for b.node.stmts.each {|s| do_one_(fcx, s); }
|
||||
for b.node.stmts.each |s| { do_one_(fcx, s); }
|
||||
fn do_inner_(fcx: fn_ctxt, &&e: @expr) { find_pre_post_expr(fcx, e); }
|
||||
let do_inner = {|a|do_inner_(fcx, a)};
|
||||
let do_inner = |a| do_inner_(fcx, a);
|
||||
option::map::<@expr, ()>(b.node.expr, do_inner);
|
||||
|
||||
let mut pps: ~[pre_and_post] = ~[];
|
||||
for b.node.stmts.each {|s| vec::push(pps, stmt_pp(fcx.ccx, *s)); }
|
||||
for b.node.stmts.each |s| { vec::push(pps, stmt_pp(fcx.ccx, *s)); }
|
||||
alt b.node.expr {
|
||||
none {/* no-op */ }
|
||||
some(e) { vec::push(pps, expr_pp(fcx.ccx, e)); }
|
||||
|
|
@ -564,7 +564,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) {
|
|||
let block_precond = seq_preconds(fcx, pps);
|
||||
|
||||
let mut postconds = ~[];
|
||||
for pps.each {|pp| vec::push(postconds, get_post(pp)); }
|
||||
for pps.each |pp| { vec::push(postconds, get_post(pp)); }
|
||||
|
||||
/* A block may be empty, so this next line ensures that the postconds
|
||||
vector is non-empty. */
|
||||
|
|
|
|||
|
|
@ -58,14 +58,14 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) ->
|
|||
{changed: bool, post: poststate} {
|
||||
let mut changed = false;
|
||||
let mut post = tritv_clone(pres);
|
||||
for bindings.each {|b|
|
||||
for bindings.each |b| {
|
||||
alt b.rhs {
|
||||
some(an_init) {
|
||||
// an expression, with or without a destination
|
||||
changed |=
|
||||
find_pre_post_state_expr(fcx, post, an_init.expr) || changed;
|
||||
post = tritv_clone(expr_poststate(fcx.ccx, an_init.expr));
|
||||
for b.lhs.each {|d|
|
||||
for b.lhs.each |d| {
|
||||
alt an_init.expr.node {
|
||||
expr_path(p) {
|
||||
handle_move_or_copy(fcx, post, p, an_init.expr.id, d,
|
||||
|
|
@ -271,7 +271,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
|
|||
let ccx = fcx.ccx;
|
||||
let pres_changed = set_prestate_ann(ccx, e_id, pres);
|
||||
let post = tritv_clone(pres);
|
||||
for (*cap_clause).each { |cap_item|
|
||||
for (*cap_clause).each |cap_item| {
|
||||
if cap_item.is_move {
|
||||
forget_in_poststate(fcx, post, cap_item.id);
|
||||
}
|
||||
|
|
@ -332,10 +332,11 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
|
||||
let base_pres = alt vec::last_opt(exs) { none { pres }
|
||||
some(f) { expr_poststate(fcx.ccx, f) }};
|
||||
option::iter(maybe_base, {|base|
|
||||
option::iter(maybe_base, |base| {
|
||||
changed |= find_pre_post_state_expr(fcx, base_pres, base) |
|
||||
set_poststate_ann(fcx.ccx, e.id,
|
||||
expr_poststate(fcx.ccx, base))});
|
||||
set_poststate_ann(fcx.ccx, e.id,
|
||||
expr_poststate(fcx.ccx, base))
|
||||
});
|
||||
ret changed;
|
||||
}
|
||||
expr_tup(elts) {
|
||||
|
|
@ -449,7 +450,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
let mut a_post;
|
||||
if vec::len(alts) > 0u {
|
||||
a_post = false_postcond(num_constrs);
|
||||
for alts.each {|an_alt|
|
||||
for alts.each |an_alt| {
|
||||
alt an_alt.guard {
|
||||
some(e) {
|
||||
changed |= find_pre_post_state_expr(fcx, e_post, e);
|
||||
|
|
@ -483,8 +484,10 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
let post = false_postcond(num_constrs);
|
||||
ret set_prestate_ann(fcx.ccx, e.id, pres) |
|
||||
set_poststate_ann(fcx.ccx, e.id, post) |
|
||||
option::map_default(maybe_fail_val, false, {|fail_val|
|
||||
find_pre_post_state_expr(fcx, pres, fail_val)});
|
||||
option::map_default(
|
||||
maybe_fail_val, false,
|
||||
|fail_val|
|
||||
find_pre_post_state_expr(fcx, pres, fail_val) );
|
||||
}
|
||||
expr_check(_, p) {
|
||||
/* predicate p holds after this expression executes */
|
||||
|
|
@ -563,7 +566,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool {
|
|||
initializes. Then <pres> becomes the new poststate. */
|
||||
|
||||
let mut changed = false;
|
||||
for b.node.stmts.each {|s|
|
||||
for b.node.stmts.each |s| {
|
||||
changed |= find_pre_post_state_stmt(fcx, pres, s);
|
||||
pres = stmt_poststate(fcx.ccx, *s);
|
||||
}
|
||||
|
|
@ -591,7 +594,7 @@ fn find_pre_post_state_fn(fcx: fn_ctxt,
|
|||
|
||||
// Instantiate any constraints on the arguments so we can use them
|
||||
let block_pre = block_prestate(fcx.ccx, f_body);
|
||||
for f_decl.constraints.each {|c|
|
||||
for f_decl.constraints.each |c| {
|
||||
let tsc = ast_constr_to_ts_constr(fcx.ccx.tcx, f_decl.inputs, c);
|
||||
set_in_prestate_constr(fcx, tsc, block_pre);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ impl of to_str::to_str for purity {
|
|||
|
||||
fn param_bounds_to_kind(bounds: param_bounds) -> kind {
|
||||
let mut kind = kind_noncopyable();
|
||||
for vec::each(*bounds) {|bound|
|
||||
for vec::each(*bounds) |bound| {
|
||||
alt bound {
|
||||
bound_copy {
|
||||
kind = raise_kind(kind, kind_implicitly_copyable());
|
||||
|
|
@ -491,17 +491,17 @@ fn mk_rcache() -> creader_cache {
|
|||
}
|
||||
|
||||
fn new_ty_hash<V: copy>() -> map::hashmap<t, V> {
|
||||
map::hashmap({|&&t: t| type_id(t)},
|
||||
{|&&a: t, &&b: t| type_id(a) == type_id(b)})
|
||||
map::hashmap(|&&t: t| type_id(t),
|
||||
|&&a: t, &&b: t| type_id(a) == type_id(b))
|
||||
}
|
||||
|
||||
fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
|
||||
freevars: freevars::freevar_map,
|
||||
region_map: middle::region::region_map) -> ctxt {
|
||||
let interner = map::hashmap({|&&k: intern_key|
|
||||
let interner = map::hashmap(|&&k: intern_key| {
|
||||
hash_type_structure(k.struct) +
|
||||
option::map_default(k.o_def_id, 0u, ast_util::hash_def)
|
||||
}, {|&&a, &&b| a == b});
|
||||
}, |&&a, &&b| a == b);
|
||||
let vecs_implicitly_copyable =
|
||||
get_warning_level(s.warning_settings.default_settings,
|
||||
vecs_not_implicitly_copyable) == ignore;
|
||||
|
|
@ -557,8 +557,8 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
|||
}
|
||||
fn sflags(substs: substs) -> uint {
|
||||
let mut f = 0u;
|
||||
for substs.tps.each {|tt| f |= get(tt).flags; }
|
||||
substs.self_r.iter({ |r| f |= rflags(r) });
|
||||
for substs.tps.each |tt| { f |= get(tt).flags; }
|
||||
substs.self_r.iter(|r| f |= rflags(r));
|
||||
ret f;
|
||||
}
|
||||
alt st {
|
||||
|
|
@ -587,13 +587,13 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
|||
flags |= get(m.ty).flags;
|
||||
}
|
||||
ty_rec(flds) {
|
||||
for flds.each {|f| flags |= get(f.mt.ty).flags; }
|
||||
for flds.each |f| { flags |= get(f.mt.ty).flags; }
|
||||
}
|
||||
ty_tup(ts) {
|
||||
for ts.each {|tt| flags |= get(tt).flags; }
|
||||
for ts.each |tt| { flags |= get(tt).flags; }
|
||||
}
|
||||
ty_fn(f) {
|
||||
for f.inputs.each {|a| flags |= get(a.ty).flags; }
|
||||
for f.inputs.each |a| { flags |= get(a.ty).flags; }
|
||||
flags |= get(f.output).flags;
|
||||
}
|
||||
ty_constr(tt, _) {
|
||||
|
|
@ -756,7 +756,7 @@ fn encl_region(cx: ctxt, id: ast::node_id) -> ty::region {
|
|||
}
|
||||
|
||||
fn walk_ty(ty: t, f: fn(t)) {
|
||||
maybe_walk_ty(ty, {|t| f(t); true});
|
||||
maybe_walk_ty(ty, |t| { f(t); true });
|
||||
}
|
||||
|
||||
fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
|
||||
|
|
@ -773,14 +773,14 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
|
|||
}
|
||||
ty_enum(_, substs) | ty_class(_, substs) |
|
||||
ty_iface(_, substs) {
|
||||
for substs.tps.each {|subty| maybe_walk_ty(subty, f); }
|
||||
for substs.tps.each |subty| { maybe_walk_ty(subty, f); }
|
||||
}
|
||||
ty_rec(fields) {
|
||||
for fields.each {|fl| maybe_walk_ty(fl.mt.ty, f); }
|
||||
for fields.each |fl| { maybe_walk_ty(fl.mt.ty, f); }
|
||||
}
|
||||
ty_tup(ts) { for ts.each {|tt| maybe_walk_ty(tt, f); } }
|
||||
ty_tup(ts) { for ts.each |tt| { maybe_walk_ty(tt, f); } }
|
||||
ty_fn(ft) {
|
||||
for ft.inputs.each {|a| maybe_walk_ty(a.ty, f); }
|
||||
for ft.inputs.each |a| { maybe_walk_ty(a.ty, f); }
|
||||
maybe_walk_ty(ft.output, f);
|
||||
}
|
||||
ty_constr(sub, _) { maybe_walk_ty(sub, f); }
|
||||
|
|
@ -795,8 +795,8 @@ fn fold_sty_to_ty(tcx: ty::ctxt, sty: sty, foldop: fn(t) -> t) -> t {
|
|||
fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty {
|
||||
fn fold_substs(substs: substs, fldop: fn(t) -> t) -> substs {
|
||||
{self_r: substs.self_r,
|
||||
self_ty: substs.self_ty.map({ |t| fldop(t) }),
|
||||
tps: substs.tps.map({ |t| fldop(t) })}
|
||||
self_ty: substs.self_ty.map(|t| fldop(t)),
|
||||
tps: substs.tps.map(|t| fldop(t))}
|
||||
}
|
||||
|
||||
alt sty {
|
||||
|
|
@ -825,7 +825,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty {
|
|||
ty_iface(did, fold_substs(substs, fldop))
|
||||
}
|
||||
ty_rec(fields) {
|
||||
let new_fields = do vec::map(fields) {|fl|
|
||||
let new_fields = do vec::map(fields) |fl| {
|
||||
let new_ty = fldop(fl.mt.ty);
|
||||
let new_mt = {ty: new_ty, mutbl: fl.mt.mutbl};
|
||||
{ident: fl.ident, mt: new_mt}
|
||||
|
|
@ -833,11 +833,11 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty {
|
|||
ty_rec(new_fields)
|
||||
}
|
||||
ty_tup(ts) {
|
||||
let new_ts = vec::map(ts, {|tt| fldop(tt) });
|
||||
let new_ts = vec::map(ts, |tt| fldop(tt));
|
||||
ty_tup(new_ts)
|
||||
}
|
||||
ty_fn(f) {
|
||||
let new_args = vec::map(f.inputs, {|a|
|
||||
let new_args = vec::map(f.inputs, |a| {
|
||||
let new_ty = fldop(a.ty);
|
||||
{mode: a.mode, ty: new_ty}
|
||||
});
|
||||
|
|
@ -863,7 +863,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty {
|
|||
|
||||
// Folds types from the bottom up.
|
||||
fn fold_ty(cx: ctxt, t0: t, fldop: fn(t) -> t) -> t {
|
||||
let sty = fold_sty(get(t0).struct, {|t| fold_ty(cx, fldop(t), fldop) });
|
||||
let sty = fold_sty(get(t0).struct, |t| fold_ty(cx, fldop(t), fldop));
|
||||
fldop(mk_t(cx, sty))
|
||||
}
|
||||
|
||||
|
|
@ -876,9 +876,9 @@ fn walk_regions_and_ty(
|
|||
if (walkt(ty)) {
|
||||
fold_regions_and_ty(
|
||||
cx, ty,
|
||||
{ |r| walkr(r); r },
|
||||
{ |t| walkt(t); walk_regions_and_ty(cx, t, walkr, walkt); t },
|
||||
{ |t| walkt(t); walk_regions_and_ty(cx, t, walkr, walkt); t });
|
||||
|r| { walkr(r); r },
|
||||
|t| { walkt(t); walk_regions_and_ty(cx, t, walkr, walkt); t },
|
||||
|t| { walkt(t); walk_regions_and_ty(cx, t, walkr, walkt); t });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -894,9 +894,9 @@ fn fold_regions_and_ty(
|
|||
fldr: fn(r: region) -> region,
|
||||
fldt: fn(t: t) -> t) -> substs {
|
||||
|
||||
{self_r: substs.self_r.map({ |r| fldr(r) }),
|
||||
self_ty: substs.self_ty.map({ |t| fldt(t) }),
|
||||
tps: substs.tps.map({ |t| fldt(t) })}
|
||||
{self_r: substs.self_r.map(|r| fldr(r)),
|
||||
self_ty: substs.self_ty.map(|t| fldt(t)),
|
||||
tps: substs.tps.map(|t| fldt(t))}
|
||||
}
|
||||
|
||||
let tb = ty::get(ty);
|
||||
|
|
@ -925,10 +925,10 @@ fn fold_regions_and_ty(
|
|||
ty::mk_iface(cx, def_id, fold_substs(substs, fldr, fldt))
|
||||
}
|
||||
sty @ ty_fn(_) {
|
||||
fold_sty_to_ty(cx, sty, {|t| fldfnt(t) })
|
||||
fold_sty_to_ty(cx, sty, |t| fldfnt(t))
|
||||
}
|
||||
sty {
|
||||
fold_sty_to_ty(cx, sty, {|t| fldt(t) })
|
||||
fold_sty_to_ty(cx, sty, |t| fldt(t))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -945,9 +945,9 @@ fn fold_regions(
|
|||
if !type_has_regions(ty) { ret ty; }
|
||||
fold_regions_and_ty(
|
||||
cx, ty,
|
||||
{ |r| fldr(r, in_fn) },
|
||||
{ |t| do_fold(cx, t, true, fldr) },
|
||||
{ |t| do_fold(cx, t, in_fn, fldr) })
|
||||
|r| fldr(r, in_fn),
|
||||
|t| do_fold(cx, t, true, fldr),
|
||||
|t| do_fold(cx, t, in_fn, fldr))
|
||||
}
|
||||
do_fold(cx, ty, false, fldr)
|
||||
}
|
||||
|
|
@ -977,7 +977,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t {
|
|||
t0
|
||||
}
|
||||
sty {
|
||||
do fold_sty_to_ty(cx, sty) {|t|
|
||||
do fold_sty_to_ty(cx, sty) |t| {
|
||||
do_fold(cx, t, under_r, fldop)
|
||||
}
|
||||
}
|
||||
|
|
@ -994,7 +994,7 @@ fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t {
|
|||
if !tbox_has_flag(tb, has_params) { ret typ; }
|
||||
alt tb.struct {
|
||||
ty_param(idx, _) { tps[idx] }
|
||||
sty { fold_sty_to_ty(cx, sty, {|t| subst_tps(cx, tps, t) }) }
|
||||
sty { fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1006,9 +1006,9 @@ fn substs_is_noop(substs: substs) -> bool {
|
|||
|
||||
fn substs_to_str(cx: ctxt, substs: substs) -> str {
|
||||
#fmt["substs(self_r=%s, self_ty=%s, tps=%?)",
|
||||
substs.self_r.map_default("none", { |r| region_to_str(cx, r) }),
|
||||
substs.self_ty.map_default("none", { |t| ty_to_str(cx, t) }),
|
||||
substs.tps.map({ |t| ty_to_str(cx, t) })]
|
||||
substs.self_r.map_default("none", |r| region_to_str(cx, r)),
|
||||
substs.self_ty.map_default("none", |t| ty_to_str(cx, t)),
|
||||
substs.tps.map(|t| ty_to_str(cx, t))]
|
||||
}
|
||||
|
||||
fn subst(cx: ctxt,
|
||||
|
|
@ -1035,14 +1035,12 @@ fn subst(cx: ctxt,
|
|||
_ {
|
||||
fold_regions_and_ty(
|
||||
cx, typ,
|
||||
{ |r|
|
||||
alt r {
|
||||
re_bound(br_self) {substs.self_r.get()}
|
||||
_ {r}
|
||||
}
|
||||
|r| alt r {
|
||||
re_bound(br_self) {substs.self_r.get()}
|
||||
_ {r}
|
||||
},
|
||||
{ |t| do_subst(cx, substs, t) },
|
||||
{ |t| do_subst(cx, substs, t) })
|
||||
|t| do_subst(cx, substs, t),
|
||||
|t| do_subst(cx, substs, t))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1202,26 +1200,28 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
|||
ty_evec(mt, vstore_fixed(_)) { type_needs_drop(cx, mt.ty) }
|
||||
ty_unboxed_vec(mt) { type_needs_drop(cx, mt.ty) }
|
||||
ty_rec(flds) {
|
||||
for flds.each {|f| if type_needs_drop(cx, f.mt.ty) { accum = true; } }
|
||||
for flds.each |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
accum
|
||||
}
|
||||
ty_class(did, substs) {
|
||||
// Any class with a dtor needs a drop
|
||||
option::is_some(ty_dtor(cx, did)) || {
|
||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) {|f|
|
||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
accum
|
||||
}
|
||||
}
|
||||
ty_tup(elts) {
|
||||
for elts.each {|m| if type_needs_drop(cx, m) { accum = true; } }
|
||||
for elts.each |m| { if type_needs_drop(cx, m) { accum = true; } }
|
||||
accum
|
||||
}
|
||||
ty_enum(did, substs) {
|
||||
let variants = enum_variants(cx, did);
|
||||
for vec::each(*variants) {|variant|
|
||||
for variant.args.each {|aty|
|
||||
for vec::each(*variants) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
// Perform any type parameter substitutions.
|
||||
let arg_ty = subst(cx, substs, aty);
|
||||
if type_needs_drop(cx, arg_ty) { accum = true; }
|
||||
|
|
@ -1272,7 +1272,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
|||
|
||||
let mut encountered_box = encountered_box;
|
||||
let mut needs_unwind_cleanup = false;
|
||||
do maybe_walk_ty(ty) {|ty|
|
||||
do maybe_walk_ty(ty) |ty| {
|
||||
let old_encountered_box = encountered_box;
|
||||
let result = alt get(ty).struct {
|
||||
ty_box(_) | ty_opaque_box {
|
||||
|
|
@ -1285,8 +1285,8 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
|||
true
|
||||
}
|
||||
ty_enum(did, substs) {
|
||||
for vec::each(*enum_variants(cx, did)) {|v|
|
||||
for v.args.each {|aty|
|
||||
for vec::each(*enum_variants(cx, did)) |v| {
|
||||
for v.args.each |aty| {
|
||||
let t = subst(cx, substs, aty);
|
||||
needs_unwind_cleanup |=
|
||||
type_needs_unwind_cleanup_(cx, t, tycache,
|
||||
|
|
@ -1533,7 +1533,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
// Records lower to the lowest of their members.
|
||||
ty_rec(flds) {
|
||||
let mut lowest = kind_top();
|
||||
for flds.each {|f|
|
||||
for flds.each |f| {
|
||||
lowest = lower_kind(lowest, mutable_type_kind(cx, f.mt));
|
||||
}
|
||||
lowest
|
||||
|
|
@ -1544,7 +1544,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
// also factor out this code, copied from the records case
|
||||
let mut lowest = kind_top();
|
||||
let flds = class_items_as_fields(cx, did, substs);
|
||||
for flds.each {|f|
|
||||
for flds.each |f| {
|
||||
lowest = lower_kind(lowest, mutable_type_kind(cx, f.mt));
|
||||
}
|
||||
// ...but classes with dtors are never copyable (they can be
|
||||
|
|
@ -1557,7 +1557,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
// Tuples lower to the lowest of their members.
|
||||
ty_tup(tys) {
|
||||
let mut lowest = kind_top();
|
||||
for tys.each {|ty| lowest = lower_kind(lowest, type_kind(cx, ty)); }
|
||||
for tys.each |ty| { lowest = lower_kind(lowest, type_kind(cx, ty)); }
|
||||
lowest
|
||||
}
|
||||
// Enums lower to the lowest of their variants.
|
||||
|
|
@ -1567,8 +1567,8 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
if vec::len(*variants) == 0u {
|
||||
lowest = kind_send_only();
|
||||
} else {
|
||||
for vec::each(*variants) {|variant|
|
||||
for variant.args.each {|aty|
|
||||
for vec::each(*variants) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
// Perform any type parameter substitutions.
|
||||
let arg_ty = subst(cx, substs, aty);
|
||||
lowest = lower_kind(lowest, type_kind(cx, arg_ty));
|
||||
|
|
@ -1661,7 +1661,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
}
|
||||
|
||||
ty_rec(fields) {
|
||||
do vec::any(fields) {|field|
|
||||
do vec::any(fields) |field| {
|
||||
type_requires(cx, seen, r_ty, field.mt.ty)
|
||||
}
|
||||
}
|
||||
|
|
@ -1676,16 +1676,14 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
|
||||
ty_class(did, substs) {
|
||||
vec::push(*seen, did);
|
||||
let r = vec::any(class_items_as_fields(cx, did, substs),{|f|
|
||||
type_requires(cx, seen, r_ty, f.mt.ty)});
|
||||
let r = vec::any(class_items_as_fields(cx, did, substs),
|
||||
|f| type_requires(cx, seen, r_ty, f.mt.ty));
|
||||
vec::pop(*seen);
|
||||
r
|
||||
}
|
||||
|
||||
ty_tup(ts) {
|
||||
vec::any(ts, {|t|
|
||||
type_requires(cx, seen, r_ty, t)
|
||||
})
|
||||
vec::any(ts, |t| type_requires(cx, seen, r_ty, t))
|
||||
}
|
||||
|
||||
ty_enum(did, _) if vec::contains(*seen, did) {
|
||||
|
|
@ -1695,8 +1693,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
ty_enum(did, substs) {
|
||||
vec::push(*seen, did);
|
||||
let vs = enum_variants(cx, did);
|
||||
let r = vec::len(*vs) > 0u && vec::all(*vs, {|variant|
|
||||
vec::any(variant.args, {|aty|
|
||||
let r = vec::len(*vs) > 0u && vec::all(*vs, |variant| {
|
||||
vec::any(variant.args, |aty| {
|
||||
let sty = subst(cx, substs, aty);
|
||||
type_requires(cx, seen, r_ty, sty)
|
||||
})
|
||||
|
|
@ -1725,8 +1723,8 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
if test(sty) { ret true; }
|
||||
alt sty {
|
||||
ty_enum(did, substs) {
|
||||
for vec::each(*enum_variants(cx, did)) {|variant|
|
||||
for variant.args.each {|aty|
|
||||
for vec::each(*enum_variants(cx, did)) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
let sty = subst(cx, substs, aty);
|
||||
if type_structurally_contains(cx, sty, test) { ret true; }
|
||||
}
|
||||
|
|
@ -1734,13 +1732,13 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
ret false;
|
||||
}
|
||||
ty_rec(fields) {
|
||||
for fields.each {|field|
|
||||
for fields.each |field| {
|
||||
if type_structurally_contains(cx, field.mt.ty, test) { ret true; }
|
||||
}
|
||||
ret false;
|
||||
}
|
||||
ty_class(did, substs) {
|
||||
for lookup_class_fields(cx, did).each {|field|
|
||||
for lookup_class_fields(cx, did).each |field| {
|
||||
let ft = lookup_field_type(cx, did, field.id, substs);
|
||||
if type_structurally_contains(cx, ft, test) { ret true; }
|
||||
}
|
||||
|
|
@ -1748,7 +1746,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
}
|
||||
|
||||
ty_tup(ts) {
|
||||
for ts.each {|tt|
|
||||
for ts.each |tt| {
|
||||
if type_structurally_contains(cx, tt, test) { ret true; }
|
||||
}
|
||||
ret false;
|
||||
|
|
@ -1764,7 +1762,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
// distinguished from the value itself. I.e. types with mut content that's
|
||||
// not shared through a pointer.
|
||||
fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
|
||||
ret !type_structurally_contains(cx, ty, {|sty|
|
||||
ret !type_structurally_contains(cx, ty, |sty| {
|
||||
alt sty {
|
||||
ty_param(_, _) { true }
|
||||
|
||||
|
|
@ -1776,7 +1774,7 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
|
|||
mt.mutbl != ast::m_imm
|
||||
}
|
||||
ty_rec(fields) {
|
||||
vec::any(fields, {|f| f.mt.mutbl != ast::m_imm})
|
||||
vec::any(fields, |f| f.mt.mutbl != ast::m_imm)
|
||||
}
|
||||
_ { false }
|
||||
}
|
||||
|
|
@ -1784,7 +1782,7 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
|
||||
ret type_structurally_contains(cx, ty, {|sty|
|
||||
ret type_structurally_contains(cx, ty, |sty| {
|
||||
alt sty {
|
||||
ty_uniq(_) |
|
||||
ty_vec(_) |
|
||||
|
|
@ -1837,7 +1835,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
|||
// Structural types
|
||||
ty_enum(did, substs) {
|
||||
let variants = enum_variants(cx, did);
|
||||
for vec::each(*variants) {|variant|
|
||||
for vec::each(*variants) |variant| {
|
||||
let tup_ty = mk_tup(cx, variant.args);
|
||||
|
||||
// Perform any type parameter substitutions.
|
||||
|
|
@ -1846,12 +1844,12 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
}
|
||||
ty_rec(flds) {
|
||||
for flds.each {|f|
|
||||
for flds.each |f| {
|
||||
if !type_is_pod(cx, f.mt.ty) { result = false; }
|
||||
}
|
||||
}
|
||||
ty_tup(elts) {
|
||||
for elts.each {|elt| if !type_is_pod(cx, elt) { result = false; } }
|
||||
for elts.each |elt| { if !type_is_pod(cx, elt) { result = false; } }
|
||||
}
|
||||
ty_estr(vstore_fixed(_)) { result = true; }
|
||||
ty_evec(mt, vstore_fixed(_)) | ty_unboxed_vec(mt) {
|
||||
|
|
@ -1861,7 +1859,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
|||
ty_param(_, _) { result = false; }
|
||||
ty_opaque_closure_ptr(_) { result = true; }
|
||||
ty_class(did, substs) {
|
||||
result = vec::any(lookup_class_fields(cx, did), { |f|
|
||||
result = vec::any(lookup_class_fields(cx, did), |f| {
|
||||
let fty = ty::lookup_item_type(cx, f.id);
|
||||
let sty = subst(cx, substs, fty.ty);
|
||||
type_is_pod(cx, sty)
|
||||
|
|
@ -1893,7 +1891,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
|
|||
alt get(ty).struct {
|
||||
ty_enum(did, substs) {
|
||||
let variants = enum_variants(cx, did);
|
||||
let some_n_ary = vec::any(*variants, {|v| vec::len(v.args) > 0u});
|
||||
let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
|
||||
ret !some_n_ary;
|
||||
}
|
||||
_ { ret false;}
|
||||
|
|
@ -1972,7 +1970,7 @@ fn hash_bound_region(br: bound_region) -> uint {
|
|||
|
||||
fn br_hashmap<V:copy>() -> hashmap<bound_region, V> {
|
||||
map::hashmap(hash_bound_region,
|
||||
{|&&a: bound_region, &&b: bound_region| a == b })
|
||||
|&&a: bound_region, &&b: bound_region| a == b)
|
||||
}
|
||||
|
||||
// Type hashing.
|
||||
|
|
@ -1985,13 +1983,13 @@ fn hash_type_structure(st: sty) -> uint {
|
|||
fn hash_subty(id: uint, subty: t) -> uint { (id << 2u) + type_id(subty) }
|
||||
fn hash_subtys(id: uint, subtys: ~[t]) -> uint {
|
||||
let mut h = id;
|
||||
for subtys.each {|s| h = (h << 2u) + type_id(s) }
|
||||
for subtys.each |s| { h = (h << 2u) + type_id(s) }
|
||||
h
|
||||
}
|
||||
fn hash_type_constr(id: uint, c: @type_constr) -> uint {
|
||||
let mut h = id;
|
||||
h = (h << 2u) + hash_def(h, c.node.id);
|
||||
for c.node.args.each {|a|
|
||||
for c.node.args.each |a| {
|
||||
alt a.node {
|
||||
carg_base { h += h << 2u; }
|
||||
carg_lit(_) { fail "lit args not implemented yet"; }
|
||||
|
|
@ -2044,12 +2042,12 @@ fn hash_type_structure(st: sty) -> uint {
|
|||
ty_tup(ts) { hash_subtys(25u, ts) }
|
||||
ty_rec(fields) {
|
||||
let mut h = 26u;
|
||||
for fields.each {|f| h = hash_subty(h, f.mt.ty); }
|
||||
for fields.each |f| { h = hash_subty(h, f.mt.ty); }
|
||||
h
|
||||
}
|
||||
ty_fn(f) {
|
||||
let mut h = 27u;
|
||||
for f.inputs.each {|a| h = hash_subty(h, a.ty); }
|
||||
for f.inputs.each |a| { h = hash_subty(h, a.ty); }
|
||||
hash_subty(h, f.output)
|
||||
}
|
||||
ty_self { 28u }
|
||||
|
|
@ -2061,7 +2059,7 @@ fn hash_type_structure(st: sty) -> uint {
|
|||
ty_ptr(mt) { hash_subty(35u, mt.ty) }
|
||||
ty_constr(t, cs) {
|
||||
let mut h = hash_subty(36u, t);
|
||||
for cs.each {|c| h = (h << 2u) + hash_type_constr(h, c); }
|
||||
for cs.each |c| { h = (h << 2u) + hash_type_constr(h, c); }
|
||||
h
|
||||
}
|
||||
ty_uniq(mt) { hash_subty(37u, mt.ty) }
|
||||
|
|
@ -2107,7 +2105,7 @@ fn args_eq<T>(eq: fn(T, T) -> bool,
|
|||
a: ~[@sp_constr_arg<T>],
|
||||
b: ~[@sp_constr_arg<T>]) -> bool {
|
||||
let mut i: uint = 0u;
|
||||
for a.each {|arg|
|
||||
for a.each |arg| {
|
||||
if !arg_eq(eq, arg, b[i]) { ret false; }
|
||||
i += 1u;
|
||||
}
|
||||
|
|
@ -2123,7 +2121,7 @@ fn constr_eq(c: @constr, d: @constr) -> bool {
|
|||
fn constrs_eq(cs: ~[@constr], ds: ~[@constr]) -> bool {
|
||||
if vec::len(cs) != vec::len(ds) { ret false; }
|
||||
let mut i = 0u;
|
||||
for cs.each {|c| if !constr_eq(c, ds[i]) { ret false; } i += 1u; }
|
||||
for cs.each |c| { if !constr_eq(c, ds[i]) { ret false; } i += 1u; }
|
||||
ret true;
|
||||
}
|
||||
|
||||
|
|
@ -2184,7 +2182,7 @@ fn is_fn_ty(fty: t) -> bool {
|
|||
|
||||
// Returns a vec of all the input and output types of fty.
|
||||
fn tys_in_fn_ty(fty: fn_ty) -> ~[t] {
|
||||
vec::append_one(fty.inputs.map({|a| a.ty}), fty.output)
|
||||
vec::append_one(fty.inputs.map(|a| a.ty), fty.output)
|
||||
}
|
||||
|
||||
// Just checks whether it's a fn that returns bool,
|
||||
|
|
@ -2262,12 +2260,12 @@ fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
|
|||
|
||||
fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> {
|
||||
let mut i = 0u;
|
||||
for fields.each {|f| if f.ident == id { ret some(i); } i += 1u; }
|
||||
for fields.each |f| { if f.ident == id { ret some(i); } i += 1u; }
|
||||
ret none;
|
||||
}
|
||||
|
||||
fn get_field(rec_ty: t, id: ast::ident) -> field {
|
||||
alt check vec::find(get_fields(rec_ty), {|f| str::eq(*f.ident, *id) }) {
|
||||
alt check vec::find(get_fields(rec_ty), |f| str::eq(*f.ident, *id)) {
|
||||
some(f) { f }
|
||||
}
|
||||
}
|
||||
|
|
@ -2280,7 +2278,7 @@ fn get_fields(rec_ty:t) -> ~[field] {
|
|||
|
||||
fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> {
|
||||
let mut i = 0u;
|
||||
for meths.each {|m| if m.ident == id { ret some(i); } i += 1u; }
|
||||
for meths.each |m| { if m.ident == id { ret some(i); } i += 1u; }
|
||||
ret none;
|
||||
}
|
||||
|
||||
|
|
@ -2290,7 +2288,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) {
|
|||
// contain duplicates. (Integral type vars aren't counted.)
|
||||
fn vars_in_type(ty: t) -> ~[tv_vid] {
|
||||
let mut rslt = ~[];
|
||||
do walk_ty(ty) {|ty|
|
||||
do walk_ty(ty) |ty| {
|
||||
alt get(ty).struct { ty_var(v) { vec::push(rslt, v); } _ { } }
|
||||
}
|
||||
rslt
|
||||
|
|
@ -2570,10 +2568,9 @@ type variant_info = @{args: ~[t], ctor_ty: t, name: ast::ident,
|
|||
fn substd_enum_variants(cx: ctxt,
|
||||
id: ast::def_id,
|
||||
substs: substs) -> ~[variant_info] {
|
||||
do vec::map(*enum_variants(cx, id)) { |variant_info|
|
||||
let substd_args = vec::map(variant_info.args, {|aty|
|
||||
subst(cx, substs, aty)
|
||||
});
|
||||
do vec::map(*enum_variants(cx, id)) |variant_info| {
|
||||
let substd_args = vec::map(variant_info.args,
|
||||
|aty| subst(cx, substs, aty));
|
||||
|
||||
let substd_ctor_ty = subst(cx, substs, variant_info.ctor_ty);
|
||||
|
||||
|
|
@ -2674,11 +2671,11 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] {
|
|||
alt cx.items.get(id.node) {
|
||||
ast_map::node_item(@{node: ast::item_enum(variants, _, _), _}, _) {
|
||||
let mut disr_val = -1;
|
||||
@vec::map(variants, {|variant|
|
||||
@vec::map(variants, |variant| {
|
||||
let ctor_ty = node_id_to_type(cx, variant.node.id);
|
||||
let arg_tys = {
|
||||
if vec::len(variant.node.args) > 0u {
|
||||
ty_fn_args(ctor_ty).map({ |a| a.ty })
|
||||
ty_fn_args(ctor_ty).map(|a| a.ty)
|
||||
} else { ~[] }
|
||||
};
|
||||
alt variant.node.disr_expr {
|
||||
|
|
@ -2788,7 +2785,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
|
|||
fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id)
|
||||
-> field_ty {
|
||||
alt vec::find(lookup_class_fields(cx, parent),
|
||||
{|f| f.id.node == field_id.node}) {
|
||||
|f| f.id.node == field_id.node) {
|
||||
some(t) { t }
|
||||
none { cx.sess.bug("class ID not found in parent's fields"); }
|
||||
}
|
||||
|
|
@ -2812,8 +2809,8 @@ fn lookup_class_method_ids(cx: ctxt, did: ast::def_id)
|
|||
alt cx.items.find(did.node) {
|
||||
some(ast_map::node_item(@{node: item_class(_,_,items,_,_,_), _}, _)) {
|
||||
let (_,ms) = split_class_items(items);
|
||||
vec::map(ms, {|m| {name: m.ident, id: m.id,
|
||||
vis: m.vis}})
|
||||
vec::map(ms, |m| {name: m.ident, id: m.id,
|
||||
vis: m.vis})
|
||||
}
|
||||
_ {
|
||||
cx.sess.bug("lookup_class_method_ids: id not bound to a class");
|
||||
|
|
@ -2830,7 +2827,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
|
|||
sp: span) -> def_id {
|
||||
if check is_local(did) {
|
||||
let ms = lookup_class_method_ids(cx, did);
|
||||
for ms.each {|m|
|
||||
for ms.each |m| {
|
||||
if m.name == name {
|
||||
ret ast_util::local_def(m.id);
|
||||
}
|
||||
|
|
@ -2845,7 +2842,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
|
|||
|
||||
fn class_field_tys(items: ~[@class_member]) -> ~[field_ty] {
|
||||
let mut rslt = ~[];
|
||||
for items.each {|it|
|
||||
for items.each |it| {
|
||||
alt it.node {
|
||||
instance_var(nm, _, cm, id, vis) {
|
||||
vec::push(rslt, {ident: nm, id: ast_util::local_def(id),
|
||||
|
|
@ -2865,16 +2862,16 @@ fn class_field_tys(items: ~[@class_member]) -> ~[field_ty] {
|
|||
// be used in trans.
|
||||
fn class_items_as_mutable_fields(cx:ctxt, did: ast::def_id,
|
||||
substs: substs) -> ~[field] {
|
||||
class_item_fields(cx, did, substs, {|_mt| m_mutbl})
|
||||
class_item_fields(cx, did, substs, |_mt| m_mutbl)
|
||||
}
|
||||
|
||||
// Same as class_items_as_mutable_fields, but doesn't change
|
||||
// mutability.
|
||||
fn class_items_as_fields(cx:ctxt, did: ast::def_id,
|
||||
substs: substs) -> ~[field] {
|
||||
class_item_fields(cx, did, substs, {|mt| alt mt {
|
||||
class_item_fields(cx, did, substs, |mt| alt mt {
|
||||
class_mutable { m_mutbl }
|
||||
class_immutable { m_imm }}})
|
||||
class_immutable { m_imm }})
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2882,7 +2879,7 @@ fn class_item_fields(cx:ctxt, did: ast::def_id,
|
|||
substs: substs, frob_mutability: fn(class_mutability) -> mutability)
|
||||
-> ~[field] {
|
||||
let mut rslt = ~[];
|
||||
for lookup_class_fields(cx, did).each {|f|
|
||||
for lookup_class_fields(cx, did).each |f| {
|
||||
// consider all instance vars mut, because the
|
||||
// constructor may mutate all vars
|
||||
vec::push(rslt, {ident: f.ident, mt:
|
||||
|
|
@ -2985,7 +2982,7 @@ fn ast_constr_to_constr<T>(tcx: ctxt, c: @ast::constr_general<T>) ->
|
|||
}
|
||||
|
||||
fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] {
|
||||
vec::from_fn(tps.len(), {|i|
|
||||
vec::from_fn(tps.len(), |i| {
|
||||
ty::mk_param(tcx, i, ast_util::local_def(tps[i].id))
|
||||
})
|
||||
}
|
||||
|
|
@ -3025,7 +3022,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
|
|||
// types, which isn't necessary after #2187
|
||||
let t = mk_t(cx, mach_sty(cx.sess.targ_cfg, t));
|
||||
|
||||
let sty = fold_sty(get(t).struct, {|t| normalize_ty(cx, t) });
|
||||
let sty = fold_sty(get(t).struct, |t| { normalize_ty(cx, t) });
|
||||
let t_norm = mk_t(cx, sty);
|
||||
cx.normalized_cache.insert(t, t_norm);
|
||||
ret t_norm;
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy>(
|
|||
#fmt["wrong number of type arguments, expected %u but found %u",
|
||||
(*decl_bounds).len(), path.types.len()]);
|
||||
}
|
||||
let tps = path.types.map({ |a_t| ast_ty_to_ty(self, rscope, a_t) });
|
||||
let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, a_t));
|
||||
|
||||
let substs = {self_r:self_r, self_ty:none, tps:tps};
|
||||
{substs: substs, ty: ty::subst(tcx, substs, decl_ty)}
|
||||
|
|
@ -244,11 +244,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
|
|||
ty::mk_rptr(tcx, r, mt)
|
||||
}
|
||||
ast::ty_tup(fields) {
|
||||
let flds = vec::map(fields, { |t| ast_ty_to_ty(self, rscope, t) });
|
||||
let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, t));
|
||||
ty::mk_tup(tcx, flds)
|
||||
}
|
||||
ast::ty_rec(fields) {
|
||||
let flds = do fields.map {|f|
|
||||
let flds = do fields.map |f| {
|
||||
let tm = ast_mt_to_mt(self, rscope, f.node.mt);
|
||||
{ident: f.node.ident, mt: tm}
|
||||
};
|
||||
|
|
@ -338,7 +338,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
|
|||
}
|
||||
ast::ty_constr(t, cs) {
|
||||
let mut out_cs = ~[];
|
||||
for cs.each {|constr|
|
||||
for cs.each |constr| {
|
||||
vec::push(out_cs, ty::ast_constr_to_constr(tcx, constr));
|
||||
}
|
||||
ty::mk_constr(tcx, ast_ty_to_ty(self, rscope, t), out_cs)
|
||||
|
|
@ -412,13 +412,13 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy>(
|
|||
expected_tys: expected_tys) -> ty::fn_ty {
|
||||
|
||||
#debug["ty_of_fn_decl"];
|
||||
do indent {||
|
||||
do indent || {
|
||||
// new region names that appear inside of the fn decl are bound to
|
||||
// that function type
|
||||
let rb = in_binding_rscope(rscope);
|
||||
|
||||
let input_tys = do decl.inputs.mapi { |i, a|
|
||||
let expected_arg_ty = do expected_tys.chain { |e|
|
||||
let input_tys = do decl.inputs.mapi |i, a| {
|
||||
let expected_arg_ty = do expected_tys.chain |e| {
|
||||
// no guarantee that the correct number of expected args
|
||||
// were supplied
|
||||
if i < e.inputs.len() {some(e.inputs[i])} else {none}
|
||||
|
|
@ -426,14 +426,14 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy>(
|
|||
ty_of_arg(self, rb, a, expected_arg_ty)
|
||||
};
|
||||
|
||||
let expected_ret_ty = expected_tys.map({ |e| e.output });
|
||||
let expected_ret_ty = expected_tys.map(|e| e.output);
|
||||
let output_ty = alt decl.output.node {
|
||||
ast::ty_infer if expected_ret_ty.is_some() {expected_ret_ty.get()}
|
||||
ast::ty_infer {self.ty_infer(decl.output.span)}
|
||||
_ {ast_ty_to_ty(self, rb, decl.output)}
|
||||
};
|
||||
|
||||
let out_constrs = vec::map(decl.constraints, {|constr|
|
||||
let out_constrs = vec::map(decl.constraints, |constr| {
|
||||
ty::ast_constr_to_constr(self.tcx(), constr)
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ impl methods for isr_alist {
|
|||
}
|
||||
|
||||
fn find(br: ty::bound_region) -> option<ty::region> {
|
||||
for list::each(self) { |isr|
|
||||
for list::each(self) |isr| {
|
||||
let (isr_br, isr_r) = isr;
|
||||
if isr_br == br { ret some(isr_r); }
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ impl methods for isr_alist {
|
|||
|
||||
fn check_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
let visit = visit::mk_simple_visitor(@{
|
||||
visit_item: {|a|check_item(ccx, a)}
|
||||
visit_item: |a| check_item(ccx, a)
|
||||
with *visit::default_simple_visitor()
|
||||
});
|
||||
visit::visit_crate(*crate, (), visit);
|
||||
|
|
@ -167,18 +167,18 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
|
||||
let {isr, self_ty, fn_ty} = {
|
||||
let old_isr = option::map_default(old_fcx, @nil,
|
||||
{ |fcx| fcx.in_scope_regions });
|
||||
|fcx| fcx.in_scope_regions);
|
||||
replace_bound_regions_in_fn_ty(tcx, old_isr, self_ty, fn_ty,
|
||||
{ |br| ty::re_free(body.node.id, br) })
|
||||
|br| ty::re_free(body.node.id, br))
|
||||
};
|
||||
|
||||
let arg_tys = fn_ty.inputs.map({ |a| a.ty });
|
||||
let arg_tys = fn_ty.inputs.map(|a| a.ty);
|
||||
let ret_ty = fn_ty.output;
|
||||
|
||||
#debug["check_fn(arg_tys=%?, ret_ty=%?, self_ty=%?)",
|
||||
arg_tys.map({|a| ty_to_str(tcx, a) }),
|
||||
arg_tys.map(|a| ty_to_str(tcx, a)),
|
||||
ty_to_str(tcx, ret_ty),
|
||||
option::map(self_ty, {|st| ty_to_str(tcx, st) })];
|
||||
option::map(self_ty, |st| ty_to_str(tcx, st))];
|
||||
|
||||
// ______________________________________________________________________
|
||||
// Create the function context. This is either derived from scratch or,
|
||||
|
|
@ -239,7 +239,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
}
|
||||
|
||||
let mut i = 0u;
|
||||
do vec::iter(arg_tys) {|arg|
|
||||
do vec::iter(arg_tys) |arg| {
|
||||
fcx.write_ty(decl.inputs[i].id, arg);
|
||||
i += 1u;
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
};
|
||||
|
||||
// Add formal parameters.
|
||||
do vec::iter2(arg_tys, decl.inputs) {|arg_ty, input|
|
||||
do vec::iter2(arg_tys, decl.inputs) |arg_ty, input| {
|
||||
assign(input.id, some(arg_ty));
|
||||
#debug["Argument %s is assigned to %s",
|
||||
*input.ident, fcx.locals.get(input.id).to_str()];
|
||||
|
|
@ -356,7 +356,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
}
|
||||
ast::item_impl(tps, rp, _, ty, ms) {
|
||||
let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty);
|
||||
for ms.each {|m| check_method(ccx, m, self_ty);}
|
||||
for ms.each |m| { check_method(ccx, m, self_ty);}
|
||||
}
|
||||
ast::item_class(tps, ifaces, members, ctor, m_dtor, rp) {
|
||||
let tcx = ccx.tcx;
|
||||
|
|
@ -368,7 +368,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
// Write the ctor's self's type
|
||||
write_ty_to_tcx(tcx, ctor.node.self_id, class_t);
|
||||
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
// typecheck the dtor
|
||||
check_bare_fn(ccx, ast_util::dtor_dec(),
|
||||
dtor.node.body, dtor.node.id,
|
||||
|
|
@ -377,7 +377,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
write_ty_to_tcx(tcx, dtor.node.self_id, class_t);
|
||||
};
|
||||
// typecheck the members
|
||||
for members.each {|m| check_class_member(ccx, class_t, m); }
|
||||
for members.each |m| { check_class_member(ccx, class_t, m); }
|
||||
// Check that there's at least one field
|
||||
let (fields,_) = split_class_items(members);
|
||||
if fields.len() < 1u {
|
||||
|
|
@ -394,11 +394,11 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
ast::item_foreign_mod(m) {
|
||||
if syntax::attr::foreign_abi(it.attrs) ==
|
||||
either::right(ast::foreign_abi_rust_intrinsic) {
|
||||
for m.items.each { |item|
|
||||
for m.items.each |item| {
|
||||
check_intrinsic_type(ccx, item);
|
||||
}
|
||||
} else {
|
||||
for m.items.each { |item|
|
||||
for m.items.each |item| {
|
||||
let tpt = ty::lookup_item_type(ccx.tcx, local_def(item.id));
|
||||
if (*tpt.bounds).is_not_empty() {
|
||||
ccx.tcx.sess.span_err(
|
||||
|
|
@ -430,7 +430,7 @@ impl of region_scope for @fn_ctxt {
|
|||
result::ok(self.infcx.next_region_var())
|
||||
}
|
||||
fn named_region(id: ast::ident) -> result<ty::region, str> {
|
||||
do empty_rscope.named_region(id).chain_err { |_e|
|
||||
do empty_rscope.named_region(id).chain_err |_e| {
|
||||
alt self.in_scope_regions.find(ty::br_named(id)) {
|
||||
some(r) { result::ok(r) }
|
||||
none if *id == "blk" { self.block_region() }
|
||||
|
|
@ -632,8 +632,8 @@ fn check_expr_with(fcx: @fn_ctxt, expr: @ast::expr, expected: ty::t) -> bool {
|
|||
|
||||
fn check_expr(fcx: @fn_ctxt, expr: @ast::expr,
|
||||
expected: option<ty::t>) -> bool {
|
||||
ret do check_expr_with_unifier(fcx, expr, expected) {||
|
||||
for expected.each {|t|
|
||||
ret do check_expr_with_unifier(fcx, expr, expected) || {
|
||||
for expected.each |t| {
|
||||
demand::suptype(fcx, expr.span, t, fcx.expr_ty(expr));
|
||||
}
|
||||
};
|
||||
|
|
@ -696,8 +696,8 @@ fn lookup_field_ty(tcx: ty::ctxt, class_id: ast::def_id,
|
|||
items:~[ty::field_ty], fieldname: ast::ident,
|
||||
substs: ty::substs) -> option<ty::t> {
|
||||
|
||||
let o_field = vec::find(items, {|f| f.ident == fieldname});
|
||||
do option::map(o_field) {|f|
|
||||
let o_field = vec::find(items, |f| f.ident == fieldname);
|
||||
do option::map(o_field) |f| {
|
||||
ty::lookup_field_type(tcx, class_id, f.id, substs)
|
||||
}
|
||||
}
|
||||
|
|
@ -733,7 +733,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
sty @ ty::ty_fn(fn_ty) {
|
||||
replace_bound_regions_in_fn_ty(
|
||||
fcx.ccx.tcx, @nil, none, fn_ty,
|
||||
{ |_br| fcx.infcx.next_region_var() }).fn_ty
|
||||
|_br| fcx.infcx.next_region_var()).fn_ty
|
||||
}
|
||||
sty {
|
||||
// I would like to make this span_err, but it's
|
||||
|
|
@ -756,7 +756,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// if the wrong number of arguments were supplied
|
||||
let expected_arg_count = vec::len(fn_ty.inputs);
|
||||
let arg_tys = if expected_arg_count == supplied_arg_count {
|
||||
fn_ty.inputs.map({ |a| a.ty })
|
||||
fn_ty.inputs.map(|a| a.ty)
|
||||
} else {
|
||||
fcx.ccx.tcx.sess.span_err(
|
||||
sp, #fmt["this function takes %u parameter%s but %u \
|
||||
|
|
@ -781,8 +781,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// functions. This is so that we have more information about the types
|
||||
// of arguments when we typecheck the functions. This isn't really the
|
||||
// right way to do this.
|
||||
for [false, true]/_.each { |check_blocks|
|
||||
for args.eachi {|i, a_opt|
|
||||
for [false, true]/_.each |check_blocks| {
|
||||
for args.eachi |i, a_opt| {
|
||||
alt a_opt {
|
||||
some(a) {
|
||||
let is_block = alt a.node {
|
||||
|
|
@ -792,10 +792,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
if is_block == check_blocks {
|
||||
let arg_ty = arg_tys[i];
|
||||
bot |= check_expr_with_unifier(
|
||||
fcx, a, some(arg_ty), {||
|
||||
demand::assign(fcx, a.span, call_expr_id,
|
||||
arg_ty, a);
|
||||
});
|
||||
fcx, a, some(arg_ty),
|
||||
|| demand::assign(fcx, a.span, call_expr_id,
|
||||
arg_ty, a)
|
||||
);
|
||||
}
|
||||
}
|
||||
none { }
|
||||
|
|
@ -824,7 +824,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
|
||||
// Call the generic checker.
|
||||
let fty = {
|
||||
let args_opt = args.map({ |arg| some(arg) });
|
||||
let args_opt = args.map(|arg| some(arg));
|
||||
let r = check_call_or_bind(fcx, sp, call_expr_id,
|
||||
fn_ty, args_opt);
|
||||
bot |= r.bot;
|
||||
|
|
@ -1021,7 +1021,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
expected: option<ty::t>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
let expected_tys = do unpack_expected(fcx, expected) { |sty|
|
||||
let expected_tys = do unpack_expected(fcx, expected) |sty| {
|
||||
alt sty {
|
||||
ty::ty_fn(fn_ty) {some({inputs:fn_ty.inputs,
|
||||
output:fn_ty.output})}
|
||||
|
|
@ -1057,7 +1057,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
ast::expr_vec(args, mutbl) {
|
||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vec::len(args), vst);
|
||||
let t: ty::t = fcx.infcx.next_ty_var();
|
||||
for args.each {|e| bot |= check_expr_with(fcx, e, t); }
|
||||
for args.each |e| { bot |= check_expr_with(fcx, e, t); }
|
||||
ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, tt)
|
||||
}
|
||||
_ {
|
||||
|
|
@ -1106,7 +1106,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
fcx.write_nil(expr.id);
|
||||
}
|
||||
ast::expr_unary(unop, oprnd) {
|
||||
let exp_inner = do unpack_expected(fcx, expected) {|sty|
|
||||
let exp_inner = do unpack_expected(fcx, expected) |sty| {
|
||||
alt unop {
|
||||
ast::box(_) | ast::uniq(_) {
|
||||
alt sty {
|
||||
|
|
@ -1182,9 +1182,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
fcx.write_ty(id, oprnd_t);
|
||||
}
|
||||
ast::expr_addr_of(mutbl, oprnd) {
|
||||
bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, {|ty|
|
||||
bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |ty|
|
||||
alt ty { ty::ty_rptr(_, mt) { some(mt.ty) } _ { none } }
|
||||
}));
|
||||
));
|
||||
let region = region_of(fcx, oprnd);
|
||||
let tm = { ty: fcx.expr_ty(oprnd), mutbl: mutbl };
|
||||
let oprnd_t = ty::mk_rptr(tcx, region, tm);
|
||||
|
|
@ -1280,9 +1280,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
ast::expr_fn_block(decl, body, cap_clause) {
|
||||
// Take the prototype from the expected type, but default to block:
|
||||
let proto = unpack_expected(fcx, expected, {|sty|
|
||||
let proto = unpack_expected(fcx, expected, |sty|
|
||||
alt sty { ty::ty_fn({proto, _}) { some(proto) } _ { none } }
|
||||
}).get_default(ast::proto_box);
|
||||
).get_default(ast::proto_box);
|
||||
check_expr_fn(fcx, expr, proto, decl, body, false, expected);
|
||||
capture::check_capture_clause(tcx, expr.id, cap_clause);
|
||||
}
|
||||
|
|
@ -1293,7 +1293,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// parameter. The catch here is that we need to validate two things:
|
||||
// 1. a closure that returns a bool is expected
|
||||
// 2. the cloure that was given returns unit
|
||||
let expected_sty = unpack_expected(fcx, expected, {|x|some(x)}).get();
|
||||
let expected_sty = unpack_expected(fcx, expected, |x| some(x)).get();
|
||||
let (inner_ty, proto) = alt expected_sty {
|
||||
ty::ty_fn(fty) {
|
||||
alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) {
|
||||
|
|
@ -1330,7 +1330,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
}
|
||||
ast::expr_do_body(b) {
|
||||
let expected_sty = unpack_expected(fcx, expected, {|x|some(x)}).get();
|
||||
let expected_sty = unpack_expected(fcx, expected, |x| some(x)).get();
|
||||
let (inner_ty, proto) = alt expected_sty {
|
||||
ty::ty_fn(fty) {
|
||||
(ty::mk_fn(tcx, fty), fty.proto)
|
||||
|
|
@ -1411,18 +1411,18 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
ast::expr_vec(args, mutbl) {
|
||||
let t: ty::t = fcx.infcx.next_ty_var();
|
||||
for args.each {|e| bot |= check_expr_with(fcx, e, t); }
|
||||
for args.each |e| { bot |= check_expr_with(fcx, e, t); }
|
||||
let typ = ty::mk_vec(tcx, {ty: t, mutbl: mutbl});
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
ast::expr_tup(elts) {
|
||||
let mut elt_ts = ~[];
|
||||
vec::reserve(elt_ts, vec::len(elts));
|
||||
let flds = unpack_expected(fcx, expected, {|sty|
|
||||
let flds = unpack_expected(fcx, expected, |sty| {
|
||||
alt sty { ty::ty_tup(flds) { some(flds) } _ { none } }
|
||||
});
|
||||
for elts.eachi {|i, e|
|
||||
check_expr(fcx, e, flds.map({|fs| fs[i]}));
|
||||
for elts.eachi |i, e| {
|
||||
check_expr(fcx, e, flds.map(|fs| fs[i]));
|
||||
let ety = fcx.expr_ty(e);
|
||||
vec::push(elt_ts, ety);
|
||||
}
|
||||
|
|
@ -1430,17 +1430,17 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
fcx.write_ty(id, typ);
|
||||
}
|
||||
ast::expr_rec(fields, base) {
|
||||
option::iter(base, {|b| check_expr(fcx, b, expected); });
|
||||
option::iter(base, |b| { check_expr(fcx, b, expected); });
|
||||
let expected = if expected == none && base != none {
|
||||
some(fcx.expr_ty(base.get()))
|
||||
} else { expected };
|
||||
let flds = unpack_expected(fcx, expected, {|sty|
|
||||
let flds = unpack_expected(fcx, expected, |sty|
|
||||
alt sty { ty::ty_rec(flds) { some(flds) } _ { none } }
|
||||
});
|
||||
let fields_t = vec::map(fields, {|f|
|
||||
bot |= check_expr(fcx, f.node.expr, flds.chain({|flds|
|
||||
vec::find(flds, {|tf| tf.ident == f.node.ident})
|
||||
}).map({|tf| tf.mt.ty}));
|
||||
);
|
||||
let fields_t = vec::map(fields, |f| {
|
||||
bot |= check_expr(fcx, f.node.expr, flds.chain(|flds|
|
||||
vec::find(flds, |tf| tf.ident == f.node.ident)
|
||||
).map(|tf| tf.mt.ty));
|
||||
let expr_t = fcx.expr_ty(f.node.expr);
|
||||
let expr_mt = {ty: expr_t, mutbl: f.node.mutbl};
|
||||
// for the most precise error message,
|
||||
|
|
@ -1463,9 +1463,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
};
|
||||
fcx.write_ty(id, bexpr_t);
|
||||
for fields_t.each {|f|
|
||||
for fields_t.each |f| {
|
||||
let mut found = false;
|
||||
for base_fields.each {|bf|
|
||||
for base_fields.each |bf| {
|
||||
if str::eq(*f.node.ident, *bf.ident) {
|
||||
demand::suptype(fcx, f.span, bf.mt.ty, f.node.mt.ty);
|
||||
found = true;
|
||||
|
|
@ -1533,7 +1533,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
_ {}
|
||||
}
|
||||
if !handled {
|
||||
let tps = vec::map(tys, { |ty| fcx.to_ty(ty) });
|
||||
let tps = vec::map(tys, |ty| fcx.to_ty(ty));
|
||||
let is_self_ref = self_ref(fcx, base.id);
|
||||
|
||||
// this will be the call or block that immediately
|
||||
|
|
@ -1698,7 +1698,7 @@ fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
|
|||
node_id = id;
|
||||
alt decl.node {
|
||||
ast::decl_local(ls) {
|
||||
for ls.each {|l| bot |= check_decl_local(fcx, l); }
|
||||
for ls.each |l| { bot |= check_decl_local(fcx, l); }
|
||||
}
|
||||
ast::decl_item(_) {/* ignore for now */ }
|
||||
}
|
||||
|
|
@ -1735,7 +1735,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
|||
vec::push(fcx.blocks, blk.node.id);
|
||||
let mut bot = false;
|
||||
let mut warned = false;
|
||||
for blk.node.stmts.each {|s|
|
||||
for blk.node.stmts.each |s| {
|
||||
if bot && !warned &&
|
||||
alt s.node {
|
||||
ast::stmt_decl(@{node: ast::decl_local(_), _}, _) |
|
||||
|
|
@ -1799,7 +1799,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
let mut disr_vals: ~[int] = ~[];
|
||||
let mut disr_val = 0;
|
||||
let mut variants = ~[];
|
||||
for vs.each {|v|
|
||||
for vs.each |v| {
|
||||
alt v.node.disr_expr {
|
||||
some(e) {
|
||||
check_expr(fcx, e, none);
|
||||
|
|
@ -1829,7 +1829,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
vec::push(disr_vals, disr_val);
|
||||
let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id);
|
||||
let arg_tys = if v.node.args.len() > 0u {
|
||||
ty::ty_fn_args(ctor_ty).map({|a| a.ty })
|
||||
ty::ty_fn_args(ctor_ty).map(|a| a.ty)
|
||||
} else { ~[] };
|
||||
vec::push(variants, @{args: arg_tys, ctor_ty: ctor_ty,
|
||||
name: v.node.name, id: local_def(v.node.id),
|
||||
|
|
@ -1842,7 +1842,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
|
||||
// Check that it is possible to represent this enum:
|
||||
let mut outer = true, did = local_def(id);
|
||||
if ty::type_structurally_contains(ccx.tcx, rty, {|sty|
|
||||
if ty::type_structurally_contains(ccx.tcx, rty, |sty| {
|
||||
alt sty {
|
||||
ty::ty_enum(id, _) if id == did {
|
||||
if outer { outer = false; false }
|
||||
|
|
@ -1887,7 +1887,7 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
|||
in constraint");
|
||||
}
|
||||
}
|
||||
for operands.each {|operand|
|
||||
for operands.each |operand| {
|
||||
if !ast_util::is_constraint_arg(operand) {
|
||||
let s =
|
||||
"constraint args must be slot variables or literals";
|
||||
|
|
@ -1910,9 +1910,9 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
|||
fn check_constraints(fcx: @fn_ctxt, cs: ~[@ast::constr],
|
||||
args: ~[ast::arg]) {
|
||||
let num_args = vec::len(args);
|
||||
for cs.each {|c|
|
||||
for cs.each |c| {
|
||||
let mut c_args = ~[];
|
||||
for c.node.args.each {|a|
|
||||
for c.node.args.each |a| {
|
||||
vec::push(c_args,
|
||||
// "base" should not occur in a fn type thing, as of
|
||||
// yet, b/c we don't allow constraints on the return type
|
||||
|
|
@ -2098,7 +2098,7 @@ fn instantiate_path(fcx: @fn_ctxt,
|
|||
(sp, "not enough type parameters provided for this item");
|
||||
fcx.infcx.next_ty_vars(ty_param_count)
|
||||
} else {
|
||||
pth.types.map({ |aty| fcx.to_ty(aty) })
|
||||
pth.types.map(|aty| fcx.to_ty(aty))
|
||||
};
|
||||
|
||||
let substs = {self_r: self_r, self_ty: none, tps: tps};
|
||||
|
|
@ -2182,13 +2182,13 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
|
|||
|
||||
ty::walk_regions_and_ty(
|
||||
ccx.tcx, ty,
|
||||
{ |r|
|
||||
|r| {
|
||||
alt r {
|
||||
ty::re_bound(_) { r_used = true; }
|
||||
_ { }
|
||||
}
|
||||
},
|
||||
{ |t|
|
||||
|t| {
|
||||
alt ty::get(t).struct {
|
||||
ty::ty_param(idx, _) { tps_used[idx] = true; }
|
||||
_ { }
|
||||
|
|
@ -2202,7 +2202,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
|
|||
reference-parameterized type");
|
||||
}
|
||||
|
||||
for tps_used.eachi { |i, b|
|
||||
for tps_used.eachi |i, b| {
|
||||
if !b {
|
||||
ccx.tcx.sess.span_err(
|
||||
span, #fmt["type parameter `%s` is unused", *tps[i].ident]);
|
||||
|
|
@ -2285,8 +2285,8 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
|||
} else {
|
||||
require_same_types(
|
||||
tcx, none, it.span, i_ty.ty, fty,
|
||||
{|| #fmt["intrinsic has wrong type: \
|
||||
|| #fmt["intrinsic has wrong type: \
|
||||
expected `%s`",
|
||||
ty_to_str(ccx.tcx, fty)]});
|
||||
ty_to_str(ccx.tcx, fty)]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ fn check_alt(fcx: @fn_ctxt,
|
|||
|
||||
// Typecheck the patterns first, so that we get types for all the
|
||||
// bindings.
|
||||
for arms.each {|arm|
|
||||
for arms.each |arm| {
|
||||
let pcx = {
|
||||
fcx: fcx,
|
||||
map: pat_id_map(tcx.def_map, arm.pats[0]),
|
||||
|
|
@ -22,12 +22,12 @@ fn check_alt(fcx: @fn_ctxt,
|
|||
pat_region: ty::re_scope(expr.id)
|
||||
};
|
||||
|
||||
for arm.pats.each {|p| check_pat(pcx, p, pattern_ty);}
|
||||
for arm.pats.each |p| { check_pat(pcx, p, pattern_ty);}
|
||||
}
|
||||
// Now typecheck the blocks.
|
||||
let mut result_ty = fcx.infcx.next_ty_var();
|
||||
let mut arm_non_bot = false;
|
||||
for arms.each {|arm|
|
||||
for arms.each |arm| {
|
||||
alt arm.guard {
|
||||
some(e) { check_expr_with(fcx, e, ty::mk_bool(tcx)); }
|
||||
none { }
|
||||
|
|
@ -79,7 +79,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
|||
let vinfo =
|
||||
ty::enum_variant_with_id(
|
||||
tcx, v_def_ids.enm, v_def_ids.var);
|
||||
vinfo.args.map({ |t| ty::subst(tcx, expected_substs, t) })
|
||||
vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) })
|
||||
};
|
||||
let arg_len = arg_types.len(), subpats_len = alt subpats {
|
||||
none { arg_len }
|
||||
|
|
@ -96,8 +96,8 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
|||
tcx.sess.span_fatal(pat.span, s);
|
||||
}
|
||||
|
||||
do option::iter(subpats) {|pats|
|
||||
do vec::iter2(pats, arg_types) {|subpat, arg_ty|
|
||||
do option::iter(subpats) |pats| {
|
||||
do vec::iter2(pats, arg_types) |subpat, arg_ty| {
|
||||
check_pat(pcx, subpat, arg_ty);
|
||||
}
|
||||
};
|
||||
|
|
@ -143,7 +143,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
#debug["pat_range ending type: %?", e_ty];
|
||||
if !require_same_types(
|
||||
tcx, some(fcx.infcx), pat.span, b_ty, e_ty,
|
||||
{|| "mismatched types in range" }) {
|
||||
|| "mismatched types in range") {
|
||||
// no-op
|
||||
} else if !ty::type_is_numeric(b_ty) {
|
||||
tcx.sess.span_err(pat.span, "non-numeric type used in range");
|
||||
|
|
@ -197,8 +197,8 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
fn matches(name: ast::ident, f: ty::field) -> bool {
|
||||
ret str::eq(*name, *f.ident);
|
||||
}
|
||||
for fields.each {|f|
|
||||
alt vec::find(ex_fields, {|a|matches(f.ident, a)}) {
|
||||
for fields.each |f| {
|
||||
alt vec::find(ex_fields, |a| matches(f.ident, a)) {
|
||||
some(field) {
|
||||
check_pat(pcx, f.pat, field.mt.ty);
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
fields", vec::len(ex_elts), e_count]);
|
||||
}
|
||||
let mut i = 0u;
|
||||
for elts.each {|elt|
|
||||
for elts.each |elt| {
|
||||
check_pat(pcx, elt, ex_elts[i]);
|
||||
i += 1u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class lookup {
|
|||
self.expr.span,
|
||||
"multiple applicable methods in scope");
|
||||
|
||||
for self.candidates.eachi { |i, candidate|
|
||||
for self.candidates.eachi |i, candidate| {
|
||||
alt candidate.entry.origin {
|
||||
method_static(did) {
|
||||
self.report_static_candidate(i, did);
|
||||
|
|
@ -163,7 +163,7 @@ class lookup {
|
|||
let tcx = self.tcx();
|
||||
let mut iface_bnd_idx = 0u; // count only iface bounds
|
||||
let bounds = tcx.ty_param_bounds.get(did.node);
|
||||
for vec::each(*bounds) {|bound|
|
||||
for vec::each(*bounds) |bound| {
|
||||
let (iid, bound_substs) = alt bound {
|
||||
ty::bound_copy | ty::bound_send | ty::bound_const {
|
||||
cont; /* ok */
|
||||
|
|
@ -176,7 +176,7 @@ class lookup {
|
|||
};
|
||||
|
||||
let ifce_methods = ty::iface_methods(tcx, iid);
|
||||
alt vec::position(*ifce_methods, {|m| m.ident == self.m_name}) {
|
||||
alt vec::position(*ifce_methods, |m| m.ident == self.m_name) {
|
||||
none {
|
||||
/* check next bound */
|
||||
iface_bnd_idx += 1u;
|
||||
|
|
@ -210,7 +210,7 @@ class lookup {
|
|||
#debug["method_from_iface"];
|
||||
|
||||
let ms = *ty::iface_methods(self.tcx(), did);
|
||||
for ms.eachi {|i, m|
|
||||
for ms.eachi |i, m| {
|
||||
if m.ident != self.m_name { cont; }
|
||||
|
||||
let m_fty = ty::mk_fn(self.tcx(), m.fty);
|
||||
|
|
@ -246,7 +246,7 @@ class lookup {
|
|||
|
||||
let ms = *ty::iface_methods(self.tcx(), did);
|
||||
|
||||
for ms.each {|m|
|
||||
for ms.each |m| {
|
||||
if m.ident != self.m_name { cont; }
|
||||
|
||||
if m.vis == ast::private && !self.include_private {
|
||||
|
|
@ -296,10 +296,10 @@ class lookup {
|
|||
|
||||
#debug["method_from_scope"];
|
||||
|
||||
for list::each(impls_vecs) {|impls|
|
||||
for vec::each(*impls) {|im|
|
||||
for list::each(impls_vecs) |impls| {
|
||||
for vec::each(*impls) |im| {
|
||||
// Check whether this impl has a method with the right name.
|
||||
for im.methods.find({|m| m.ident == self.m_name}).each {|m|
|
||||
for im.methods.find(|m| m.ident == self.m_name).each |m| {
|
||||
|
||||
// determine the `self` of the impl with fresh
|
||||
// variables for each parameter:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ fn visit_local(l: @ast::local, &&rcx: rcx, v: rvt) {
|
|||
}
|
||||
|
||||
v.visit_ty(l.node.ty, rcx, v);
|
||||
for l.node.init.each { |i|
|
||||
for l.node.init.each |i| {
|
||||
v.visit_expr(i.expr, rcx, v);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,8 +134,8 @@ fn visit_node(id: ast::node_id, span: span, rcx: rcx) -> bool {
|
|||
let e = rcx.errors_reported;
|
||||
ty::walk_regions_and_ty(
|
||||
tcx, ty,
|
||||
{ |r| constrain_region(rcx, encl_region, span, r); },
|
||||
{ |t| ty::type_has_regions(t) });
|
||||
|r| constrain_region(rcx, encl_region, span, r),
|
||||
|t| ty::type_has_regions(t));
|
||||
ret (e == rcx.errors_reported);
|
||||
|
||||
fn constrain_region(rcx: rcx,
|
||||
|
|
|
|||
|
|
@ -12,25 +12,25 @@ fn replace_bound_regions_in_fn_ty(
|
|||
fn_ty: ty::fn_ty} {
|
||||
|
||||
let mut all_tys = ty::tys_in_fn_ty(fn_ty);
|
||||
for self_ty.each { |t| vec::push(all_tys, t) }
|
||||
for self_ty.each |t| { vec::push(all_tys, t) }
|
||||
|
||||
#debug["replace_bound_regions_in_fn_ty(self_ty=%?, fn_ty=%s, all_tys=%?)",
|
||||
self_ty.map({ |t| ty_to_str(tcx, t) }),
|
||||
self_ty.map(|t| ty_to_str(tcx, t)),
|
||||
ty_to_str(tcx, ty::mk_fn(tcx, fn_ty)),
|
||||
all_tys.map({ |t| ty_to_str(tcx, t) })];
|
||||
all_tys.map(|t| ty_to_str(tcx, t))];
|
||||
let _i = indenter();
|
||||
|
||||
let isr = do create_bound_region_mapping(tcx, isr, all_tys) { |br|
|
||||
let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| {
|
||||
#debug["br=%?", br];
|
||||
mapf(br)
|
||||
};
|
||||
let t_fn = ty::fold_sty_to_ty(tcx, ty::ty_fn(fn_ty), { |t|
|
||||
let t_fn = ty::fold_sty_to_ty(tcx, ty::ty_fn(fn_ty), |t| {
|
||||
replace_bound_regions(tcx, isr, t)
|
||||
});
|
||||
let t_self = self_ty.map({ |t| replace_bound_regions(tcx, isr, t) });
|
||||
let t_self = self_ty.map(|t| replace_bound_regions(tcx, isr, t));
|
||||
|
||||
#debug["result of replace_bound_regions_in_fn_ty: self_ty=%?, fn_ty=%s",
|
||||
t_self.map({ |t| ty_to_str(tcx, t) }),
|
||||
t_self.map(|t| ty_to_str(tcx, t)),
|
||||
ty_to_str(tcx, t_fn)];
|
||||
|
||||
ret {isr: isr,
|
||||
|
|
@ -78,7 +78,7 @@ fn replace_bound_regions_in_fn_ty(
|
|||
}
|
||||
|
||||
// For each type `ty` in `tys`...
|
||||
do tys.foldl(isr) { |isr, ty|
|
||||
do tys.foldl(isr) |isr, ty| {
|
||||
let mut isr = isr;
|
||||
|
||||
// Using fold_regions is inefficient, because it
|
||||
|
|
@ -86,7 +86,7 @@ fn replace_bound_regions_in_fn_ty(
|
|||
// terms of locating all the regions within the various
|
||||
// kinds of types. This had already caused me several
|
||||
// bugs so I decided to switch over.
|
||||
do ty::fold_regions(tcx, ty) { |r, in_fn|
|
||||
do ty::fold_regions(tcx, ty) |r, in_fn| {
|
||||
if !in_fn { isr = append_isr(isr, to_r, r); }
|
||||
r
|
||||
};
|
||||
|
|
@ -104,7 +104,7 @@ fn replace_bound_regions_in_fn_ty(
|
|||
isr: isr_alist,
|
||||
ty: ty::t) -> ty::t {
|
||||
|
||||
do ty::fold_regions(tcx, ty) { |r, in_fn|
|
||||
do ty::fold_regions(tcx, ty) |r, in_fn| {
|
||||
alt r {
|
||||
// As long as we are not within a fn() type, `&T` is
|
||||
// mapped to the free region anon_r. But within a fn
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import check::{fn_ctxt, impl_self_ty, methods};
|
||||
|
||||
fn has_iface_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
vec::any(tps, {|bs|
|
||||
vec::any(*bs, {|b|
|
||||
vec::any(tps, |bs| {
|
||||
vec::any(*bs, |b| {
|
||||
alt b { ty::bound_iface(_) { true } _ { false } }
|
||||
})
|
||||
})
|
||||
|
|
@ -13,8 +13,8 @@ fn lookup_vtables(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
|||
allow_unsafe: bool) -> vtable_res {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
let mut result = ~[], i = 0u;
|
||||
for substs.tps.each {|ty|
|
||||
for vec::each(*bounds[i]) {|bound|
|
||||
for substs.tps.each |ty| {
|
||||
for vec::each(*bounds[i]) |bound| {
|
||||
alt bound {
|
||||
ty::bound_iface(i_ty) {
|
||||
let i_ty = ty::subst(tcx, substs, i_ty);
|
||||
|
|
@ -65,7 +65,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
|||
alt ty::get(ty).struct {
|
||||
ty::ty_param(n, did) {
|
||||
let mut n_bound = 0u;
|
||||
for vec::each(*tcx.ty_param_bounds.get(did.node)) { |bound|
|
||||
for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| {
|
||||
alt bound {
|
||||
ty::bound_send | ty::bound_copy | ty::bound_const {
|
||||
/* ignore */
|
||||
|
|
@ -88,7 +88,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
|||
ty::ty_iface(did, substs) if iface_id == did {
|
||||
relate_iface_tys(fcx, sp, iface_ty, ty);
|
||||
if !allow_unsafe {
|
||||
for vec::each(*ty::iface_methods(tcx, did)) {|m|
|
||||
for vec::each(*ty::iface_methods(tcx, did)) |m| {
|
||||
if ty::type_has_self(ty::mk_fn(tcx, m.fty)) {
|
||||
tcx.sess.span_err(
|
||||
sp, "a boxed iface with self types may not be \
|
||||
|
|
@ -107,9 +107,9 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
|||
_ {
|
||||
let mut found = ~[];
|
||||
|
||||
for list::each(isc) {|impls|
|
||||
for list::each(isc) |impls| {
|
||||
/* For each impl in scope... */
|
||||
for vec::each(*impls) {|im|
|
||||
for vec::each(*impls) |im| {
|
||||
// im = one specific impl
|
||||
// find the iface that im implements (if any)
|
||||
let of_ty = alt ty::impl_iface(tcx, im.did) {
|
||||
|
|
@ -189,7 +189,7 @@ fn connect_iface_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t],
|
|||
alt check ty::get(iface_ty).struct {
|
||||
ty::ty_iface(_, substs) {
|
||||
vec::iter2(substs.tps, iface_tys,
|
||||
{|a, b| demand::suptype(fcx, sp, a, b);});
|
||||
|a, b| demand::suptype(fcx, sp, a, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
|
|||
alt fcx.opt_node_ty_substs(id) {
|
||||
some(substs) {
|
||||
let mut new_tps = ~[];
|
||||
for substs.tps.each {|subst|
|
||||
for substs.tps.each |subst| {
|
||||
alt resolve_type_vars_in_type(fcx, sp, subst) {
|
||||
some(t) { vec::push(new_tps, t); }
|
||||
none { wbcx.success = false; ret none; }
|
||||
|
|
@ -83,7 +83,7 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
|
|||
alt e.node {
|
||||
ast::expr_fn(_, decl, _, _) |
|
||||
ast::expr_fn_block(decl, _, _) {
|
||||
do vec::iter(decl.inputs) {|input|
|
||||
do vec::iter(decl.inputs) |input| {
|
||||
let r_ty = resolve_type_vars_for_node(wbcx, e.span, input.id);
|
||||
|
||||
// Just in case we never constrained the mode to anything,
|
||||
|
|
@ -176,7 +176,7 @@ fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
|
|||
let wbcx = {fcx: fcx, mut success: true};
|
||||
let visit = mk_visitor();
|
||||
visit.visit_block(blk, wbcx, visit);
|
||||
for decl.inputs.each {|arg|
|
||||
for decl.inputs.each |arg| {
|
||||
resolve_type_vars_for_node(wbcx, arg.ty.span, arg.id);
|
||||
}
|
||||
ret wbcx.success;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
|||
// FIXME (#2592): hooking into the "intrinsic" root module is crude.
|
||||
// There ought to be a better approach. Attributes?
|
||||
|
||||
for crate.node.module.items.each {|crate_item|
|
||||
for crate.node.module.items.each |crate_item| {
|
||||
if *crate_item.ident == "intrinsic" {
|
||||
alt crate_item.node {
|
||||
ast::item_mod(m) {
|
||||
for m.items.each {|intrinsic_item|
|
||||
for m.items.each |intrinsic_item| {
|
||||
alt intrinsic_item.node {
|
||||
ast::item_iface(_, _, _) {
|
||||
let def_id = { crate: ast::local_crate,
|
||||
|
|
@ -53,8 +53,8 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
|||
}
|
||||
|
||||
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
|
||||
visit_item: {|a|convert(ccx, a)},
|
||||
visit_foreign_item: {|a|convert_foreign(ccx, a)}
|
||||
visit_item: |a|convert(ccx, a),
|
||||
visit_foreign_item: |a|convert_foreign(ccx, a)
|
||||
with *visit::default_simple_visitor()
|
||||
}));
|
||||
}
|
||||
|
|
@ -102,14 +102,14 @@ fn get_enum_variant_types(ccx: @crate_ctxt,
|
|||
let tcx = ccx.tcx;
|
||||
|
||||
// Create a set of parameter types shared among all the variants.
|
||||
for variants.each {|variant|
|
||||
for variants.each |variant| {
|
||||
// Nullary enum constructors get turned into constants; n-ary enum
|
||||
// constructors get turned into functions.
|
||||
let result_ty = if vec::len(variant.node.args) == 0u {
|
||||
enum_ty
|
||||
} else {
|
||||
let rs = type_rscope(rp);
|
||||
let args = variant.node.args.map({ |va|
|
||||
let args = variant.node.args.map(|va| {
|
||||
let arg_ty = ccx.to_ty(rs, va.ty);
|
||||
{mode: ast::expl(ast::by_copy), ty: arg_ty}
|
||||
});
|
||||
|
|
@ -137,7 +137,7 @@ fn ensure_iface_methods(ccx: @crate_ctxt, id: ast::node_id) {
|
|||
let tcx = ccx.tcx;
|
||||
alt check tcx.items.get(id) {
|
||||
ast_map::node_item(@{node: ast::item_iface(_, rp, ms), _}, _) {
|
||||
store_methods::<ast::ty_method>(ccx, id, ms, {|m|
|
||||
store_methods::<ast::ty_method>(ccx, id, ms, |m| {
|
||||
ty_of_ty_method(ccx, m, rp)
|
||||
});
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ fn ensure_iface_methods(ccx: @crate_ctxt, id: ast::node_id) {
|
|||
let (_,ms) = split_class_items(its);
|
||||
// All methods need to be stored, since lookup_method
|
||||
// relies on the same method cache for self-calls
|
||||
store_methods::<@ast::method>(ccx, id, ms, {|m|
|
||||
store_methods::<@ast::method>(ccx, id, ms, |m| {
|
||||
ty_of_method(ccx, m, rp)
|
||||
});
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
|
|||
replace_bound_self(tcx, impl_fty, dummy_self_r)
|
||||
};
|
||||
let if_fty = {
|
||||
let dummy_tps = do vec::from_fn((*if_m.tps).len()) { |i|
|
||||
let dummy_tps = do vec::from_fn((*if_m.tps).len()) |i| {
|
||||
// hack: we don't know the def id of the impl tp, but it
|
||||
// is not important for unification
|
||||
ty::mk_param(tcx, i + impl_tps, {crate: 0, node: 0})
|
||||
|
|
@ -211,13 +211,13 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
|
|||
};
|
||||
require_same_types(
|
||||
tcx, none, sp, impl_fty, if_fty,
|
||||
{|| "method `" + *if_m.ident + "` has an incompatible type"});
|
||||
|| "method `" + *if_m.ident + "` has an incompatible type");
|
||||
ret;
|
||||
|
||||
// Replaces bound references to the self region with `with_r`.
|
||||
fn replace_bound_self(tcx: ty::ctxt, ty: ty::t,
|
||||
with_r: ty::region) -> ty::t {
|
||||
do ty::fold_regions(tcx, ty) { |r, _in_fn|
|
||||
do ty::fold_regions(tcx, ty) |r, _in_fn| {
|
||||
if r == ty::re_bound(ty::br_self) {with_r} else {r}
|
||||
}
|
||||
}
|
||||
|
|
@ -235,8 +235,8 @@ fn check_methods_against_iface(ccx: @crate_ctxt,
|
|||
if did.crate == ast::local_crate {
|
||||
ensure_iface_methods(ccx, did.node);
|
||||
}
|
||||
for vec::each(*ty::iface_methods(tcx, did)) {|if_m|
|
||||
alt vec::find(ms, {|m| if_m.ident == m.mty.ident}) {
|
||||
for vec::each(*ty::iface_methods(tcx, did)) |if_m| {
|
||||
alt vec::find(ms, |m| if_m.ident == m.mty.ident) {
|
||||
some({mty: m, id, span}) {
|
||||
if m.purity != if_m.purity {
|
||||
ccx.tcx.sess.span_err(
|
||||
|
|
@ -276,7 +276,7 @@ fn convert_methods(ccx: @crate_ctxt,
|
|||
self_ty: ty::t) -> ~[converted_method] {
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
do vec::map(ms) { |m|
|
||||
do vec::map(ms) |m| {
|
||||
write_ty_to_tcx(tcx, m.self_id, self_ty);
|
||||
let bounds = ty_param_bounds(ccx, m.tps);
|
||||
let mty = ty_of_method(ccx, m, rp);
|
||||
|
|
@ -313,7 +313,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
ty: selfty});
|
||||
|
||||
let cms = convert_methods(ccx, ms, rp, i_bounds, selfty);
|
||||
for ifce.each { |t|
|
||||
for ifce.each |t| {
|
||||
check_methods_against_iface(ccx, tps, rp, selfty, t, cms);
|
||||
}
|
||||
}
|
||||
|
|
@ -330,8 +330,8 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
write_ty_to_tcx(tcx, it.id, tpt.ty);
|
||||
tcx.tcache.insert(local_def(it.id), tpt);
|
||||
// Write the ctor type
|
||||
let t_args = ctor.node.dec.inputs.map({|a|
|
||||
ty_of_arg(ccx, type_rscope(rp), a, none)});
|
||||
let t_args = ctor.node.dec.inputs.map(
|
||||
|a| ty_of_arg(ccx, type_rscope(rp), a, none) );
|
||||
let t_res = ty::mk_class(tcx, local_def(it.id),
|
||||
{self_r: alt rp {
|
||||
ast::rp_none { none }
|
||||
|
|
@ -350,7 +350,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
{bounds: tpt.bounds,
|
||||
rp: rp,
|
||||
ty: t_ctor});
|
||||
do option::iter(m_dtor) {|dtor|
|
||||
do option::iter(m_dtor) |dtor| {
|
||||
// Write the dtor type
|
||||
let t_dtor = ty::mk_fn(
|
||||
tcx,
|
||||
|
|
@ -366,13 +366,13 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
|
||||
// Write the type of each of the members
|
||||
let (fields, methods) = split_class_items(members);
|
||||
for fields.each {|f|
|
||||
for fields.each |f| {
|
||||
convert_class_item(ccx, rp, tpt.bounds, f);
|
||||
}
|
||||
let {bounds, substs} = mk_substs(ccx, tps, rp);
|
||||
let selfty = ty::mk_class(tcx, local_def(it.id), substs);
|
||||
let cms = convert_methods(ccx, methods, rp, bounds, selfty);
|
||||
for ifaces.each { |ifce|
|
||||
for ifaces.each |ifce| {
|
||||
check_methods_against_iface(ccx, tps, rp, selfty, ifce, cms);
|
||||
|
||||
// FIXME #2434---this is somewhat bogus, but it seems that
|
||||
|
|
@ -553,7 +553,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
|
|||
|
||||
fn compute_bounds(ccx: @crate_ctxt,
|
||||
param: ast::ty_param) -> ty::param_bounds {
|
||||
@do vec::flat_map(*param.bounds) { |b|
|
||||
@do vec::flat_map(*param.bounds) |b| {
|
||||
alt b {
|
||||
ast::bound_send { ~[ty::bound_send] }
|
||||
ast::bound_copy { ~[ty::bound_copy] }
|
||||
|
|
@ -576,7 +576,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
@do params.map { |param|
|
||||
@do params.map |param| {
|
||||
alt ccx.tcx.ty_param_bounds.find(param.id) {
|
||||
some(bs) { bs }
|
||||
none {
|
||||
|
|
@ -595,7 +595,7 @@ fn ty_of_foreign_fn_decl(ccx: @crate_ctxt,
|
|||
|
||||
let bounds = ty_param_bounds(ccx, ty_params);
|
||||
let rb = in_binding_rscope(empty_rscope);
|
||||
let input_tys = decl.inputs.map({ |a| ty_of_arg(ccx, rb, a, none) });
|
||||
let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, rb, a, none) );
|
||||
let output_ty = ast_ty_to_ty(ccx, rb, decl.output);
|
||||
|
||||
let t_fn = ty::mk_fn(ccx.tcx, {purity: decl.purity,
|
||||
|
|
@ -615,7 +615,7 @@ fn mk_ty_params(ccx: @crate_ctxt, atps: ~[ast::ty_param])
|
|||
let mut i = 0u;
|
||||
let bounds = ty_param_bounds(ccx, atps);
|
||||
{bounds: bounds,
|
||||
params: vec::map(atps, {|atp|
|
||||
params: vec::map(atps, |atp| {
|
||||
let t = ty::mk_param(ccx.tcx, i, local_def(atp.id));
|
||||
i += 1u;
|
||||
t
|
||||
|
|
|
|||
|
|
@ -355,31 +355,31 @@ fn new_infer_ctxt(tcx: ty::ctxt) -> infer_ctxt {
|
|||
|
||||
fn mk_subty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures {
|
||||
#debug["mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)];
|
||||
indent({|| cx.commit({|| sub(cx).tys(a, b) }) }).to_ures()
|
||||
indent(|| cx.commit(|| sub(cx).tys(a, b) ) ).to_ures()
|
||||
}
|
||||
|
||||
fn can_mk_subty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures {
|
||||
#debug["can_mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)];
|
||||
indent({|| cx.probe({|| sub(cx).tys(a, b) }) }).to_ures()
|
||||
indent(|| cx.probe(|| sub(cx).tys(a, b) ) ).to_ures()
|
||||
}
|
||||
|
||||
fn mk_subr(cx: infer_ctxt, a: ty::region, b: ty::region) -> ures {
|
||||
#debug["mk_subr(%s <: %s)", a.to_str(cx), b.to_str(cx)];
|
||||
indent({|| cx.commit({|| sub(cx).regions(a, b) }) }).to_ures()
|
||||
indent(|| cx.commit(|| sub(cx).regions(a, b) ) ).to_ures()
|
||||
}
|
||||
|
||||
fn mk_eqty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures {
|
||||
#debug["mk_eqty(%s <: %s)", a.to_str(cx), b.to_str(cx)];
|
||||
indent({|| cx.commit({|| cx.eq_tys(a, b) }) }).to_ures()
|
||||
indent(|| cx.commit(|| cx.eq_tys(a, b) ) ).to_ures()
|
||||
}
|
||||
|
||||
fn mk_assignty(cx: infer_ctxt, anmnt: assignment,
|
||||
a: ty::t, b: ty::t) -> ures {
|
||||
#debug["mk_assignty(%? / %s <: %s)",
|
||||
anmnt, a.to_str(cx), b.to_str(cx)];
|
||||
indent({|| cx.commit({||
|
||||
indent(|| cx.commit(||
|
||||
cx.assign_tys(anmnt, a, b)
|
||||
}) }).to_ures()
|
||||
) ).to_ures()
|
||||
}
|
||||
|
||||
fn can_mk_assignty(cx: infer_ctxt, anmnt: assignment,
|
||||
|
|
@ -392,9 +392,9 @@ fn can_mk_assignty(cx: infer_ctxt, anmnt: assignment,
|
|||
// used in method lookup, and there must be exactly one match or an
|
||||
// error is reported. Still, it should be fixed.
|
||||
|
||||
indent({|| cx.probe({||
|
||||
indent(|| cx.probe(||
|
||||
cx.assign_tys(anmnt, a, b)
|
||||
}) }).to_ures()
|
||||
) ).to_ures()
|
||||
}
|
||||
|
||||
// See comment on the type `resolve_state` below
|
||||
|
|
@ -418,7 +418,7 @@ fn resolve_deep(cx: infer_ctxt, a: ty::t, force_vars: force_level)
|
|||
impl methods for ures {
|
||||
fn then<T:copy>(f: fn() -> result<T,ty::type_err>)
|
||||
-> result<T,ty::type_err> {
|
||||
self.chain({|_i| f() })
|
||||
self.chain(|_i| f())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ impl methods<T:copy> for cres<T> {
|
|||
}
|
||||
|
||||
fn compare(t: T, f: fn() -> ty::type_err) -> cres<T> {
|
||||
do self.chain {|s|
|
||||
do self.chain |s| {
|
||||
if s == t {
|
||||
self
|
||||
} else {
|
||||
|
|
@ -520,7 +520,7 @@ impl of st for ty::t {
|
|||
|
||||
impl of st for ty::region {
|
||||
fn sub(infcx: infer_ctxt, &&b: ty::region) -> ures {
|
||||
sub(infcx).regions(self, b).chain({|_r| ok(()) })
|
||||
sub(infcx).regions(self, b).chain(|_r| ok(()))
|
||||
}
|
||||
|
||||
fn lub(infcx: infer_ctxt, &&b: ty::region) -> cres<ty::region> {
|
||||
|
|
@ -605,7 +605,7 @@ impl methods for infer_ctxt {
|
|||
}
|
||||
|
||||
fn next_ty_vars(n: uint) -> ~[ty::t] {
|
||||
vec::from_fn(n, {|_i| self.next_ty_var() })
|
||||
vec::from_fn(n, |_i| self.next_ty_var())
|
||||
}
|
||||
|
||||
fn next_ty_var_integral_id() -> tvi_vid {
|
||||
|
|
@ -706,7 +706,7 @@ impl unify_methods for infer_ctxt {
|
|||
ok(b)
|
||||
}
|
||||
(some(v_a), some(v_b)) {
|
||||
do merge_op(v_a, v_b).chain {|v|
|
||||
do merge_op(v_a, v_b).chain |v| {
|
||||
ok(some(v))
|
||||
}
|
||||
}
|
||||
|
|
@ -719,11 +719,11 @@ impl unify_methods for infer_ctxt {
|
|||
glb: fn(V,V) -> cres<V>) -> cres<bounds<V>> {
|
||||
|
||||
let _r = indenter();
|
||||
do self.merge_bnd(a.ub, b.ub, glb).chain {|ub|
|
||||
do self.merge_bnd(a.ub, b.ub, glb).chain |ub| {
|
||||
#debug["glb of ubs %s and %s is %s",
|
||||
a.ub.to_str(self), b.ub.to_str(self),
|
||||
ub.to_str(self)];
|
||||
do self.merge_bnd(a.lb, b.lb, lub).chain {|lb|
|
||||
do self.merge_bnd(a.lb, b.lb, lub).chain |lb| {
|
||||
#debug["lub of lbs %s and %s is %s",
|
||||
a.lb.to_str(self), b.lb.to_str(self),
|
||||
lb.to_str(self)];
|
||||
|
|
@ -771,11 +771,11 @@ impl unify_methods for infer_ctxt {
|
|||
// them explicitly gives the type inferencer more
|
||||
// information and helps to produce tighter bounds
|
||||
// when necessary.
|
||||
do indent {||
|
||||
do self.bnds(a.lb, b.ub).then {||
|
||||
do self.bnds(b.lb, a.ub).then {||
|
||||
do self.merge_bnd(a.ub, b.ub, {|x, y| x.glb(self, y)}).chain {|ub|
|
||||
do self.merge_bnd(a.lb, b.lb, {|x, y| x.lub(self, y)}).chain {|lb|
|
||||
do indent || {
|
||||
do self.bnds(a.lb, b.ub).then || {
|
||||
do self.bnds(b.lb, a.ub).then || {
|
||||
do self.merge_bnd(a.ub, b.ub, |x, y| x.glb(self, y) ).chain |ub| {
|
||||
do self.merge_bnd(a.lb, b.lb, |x, y| x.lub(self, y) ).chain |lb| {
|
||||
let bnds = {lb: lb, ub: ub};
|
||||
#debug["merge(%s): bnds=%s",
|
||||
v_id.to_str(),
|
||||
|
|
@ -783,10 +783,10 @@ impl unify_methods for infer_ctxt {
|
|||
|
||||
// the new bounds must themselves
|
||||
// be relatable:
|
||||
do self.bnds(bnds.lb, bnds.ub).then {||
|
||||
do self.bnds(bnds.lb, bnds.ub).then || {
|
||||
self.set(vb, v_id, root(bnds, rank));
|
||||
uok()
|
||||
}
|
||||
}
|
||||
}}}}}
|
||||
}
|
||||
|
||||
|
|
@ -812,7 +812,7 @@ impl unify_methods for infer_ctxt {
|
|||
// see if we can make those types subtypes.
|
||||
alt (a_bounds.ub, b_bounds.lb) {
|
||||
(some(a_ub), some(b_lb)) {
|
||||
let r = self.try({|| a_ub.sub(self, b_lb) });
|
||||
let r = self.try(|| a_ub.sub(self, b_lb));
|
||||
alt r {
|
||||
ok(()) { ret result::ok(()); }
|
||||
err(_) { /*fallthrough */ }
|
||||
|
|
@ -835,17 +835,13 @@ impl unify_methods for infer_ctxt {
|
|||
// i.e., b should redirect to a.
|
||||
self.set(vb, b_id, redirect(a_id));
|
||||
self.set_var_to_merged_bounds(
|
||||
vb, a_id, a_bounds, b_bounds, nde_a.rank).then({||
|
||||
uok()
|
||||
})
|
||||
vb, a_id, a_bounds, b_bounds, nde_a.rank).then(|| uok() )
|
||||
} else if nde_a.rank < nde_b.rank {
|
||||
#debug["vars(): b has smaller rank"];
|
||||
// b has greater rank, so a should redirect to b.
|
||||
self.set(vb, a_id, redirect(b_id));
|
||||
self.set_var_to_merged_bounds(
|
||||
vb, b_id, a_bounds, b_bounds, nde_b.rank).then({||
|
||||
uok()
|
||||
})
|
||||
vb, b_id, a_bounds, b_bounds, nde_b.rank).then(|| uok() )
|
||||
} else {
|
||||
#debug["vars(): a and b have equal rank"];
|
||||
assert nde_a.rank == nde_b.rank;
|
||||
|
|
@ -854,9 +850,8 @@ impl unify_methods for infer_ctxt {
|
|||
// to a and increment a's rank.
|
||||
self.set(vb, b_id, redirect(a_id));
|
||||
self.set_var_to_merged_bounds(
|
||||
vb, a_id, a_bounds, b_bounds, nde_a.rank + 1u).then({||
|
||||
uok()
|
||||
})
|
||||
vb, a_id, a_bounds, b_bounds, nde_a.rank + 1u
|
||||
).then(|| uok() )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +986,7 @@ impl unify_methods for infer_ctxt {
|
|||
let actual_arg_len = vec::len(actual_constr.node.args);
|
||||
if expected_arg_len != actual_arg_len { ret err_res; }
|
||||
let mut i = 0u;
|
||||
for expected.node.args.each {|a|
|
||||
for expected.node.args.each |a| {
|
||||
let actual = actual_constr.node.args[i];
|
||||
alt a.node {
|
||||
ast::carg_base {
|
||||
|
|
@ -1026,7 +1021,7 @@ impl unify_methods for infer_ctxt {
|
|||
a: bound<T>, b: bound<T>) -> ures {
|
||||
|
||||
#debug("bnds(%s <: %s)", a.to_str(self), b.to_str(self));
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (a, b) {
|
||||
(none, none) |
|
||||
(some(_), none) |
|
||||
|
|
@ -1044,7 +1039,7 @@ impl unify_methods for infer_ctxt {
|
|||
as: ~[@ty::type_constr], bs: ~[@ty::type_constr]) -> ures {
|
||||
|
||||
if check vec::same_length(as, bs) {
|
||||
do iter_vec2(as, bs) {|a,b|
|
||||
do iter_vec2(as, bs) |a,b| {
|
||||
self.constrs(a, b)
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1053,15 +1048,15 @@ impl unify_methods for infer_ctxt {
|
|||
}
|
||||
|
||||
fn sub_tys(a: ty::t, b: ty::t) -> ures {
|
||||
sub(self).tys(a, b).chain({|_t| ok(()) })
|
||||
sub(self).tys(a, b).chain(|_t| ok(()) )
|
||||
}
|
||||
|
||||
fn sub_regions(a: ty::region, b: ty::region) -> ures {
|
||||
sub(self).regions(a, b).chain({|_t| ok(()) })
|
||||
sub(self).regions(a, b).chain(|_t| ok(()) )
|
||||
}
|
||||
|
||||
fn eq_tys(a: ty::t, b: ty::t) -> ures {
|
||||
self.sub_tys(a, b).then({||
|
||||
self.sub_tys(a, b).then(|| {
|
||||
self.sub_tys(b, a)
|
||||
})
|
||||
}
|
||||
|
|
@ -1069,8 +1064,8 @@ impl unify_methods for infer_ctxt {
|
|||
fn eq_regions(a: ty::region, b: ty::region) -> ures {
|
||||
#debug["eq_regions(%s, %s)",
|
||||
a.to_str(self), b.to_str(self)];
|
||||
do indent {||
|
||||
do self.sub_regions(a, b).then {||
|
||||
do indent || {
|
||||
do self.sub_regions(a, b).then || {
|
||||
self.sub_regions(b, a)
|
||||
}
|
||||
}
|
||||
|
|
@ -1134,7 +1129,7 @@ impl methods for resolve_state {
|
|||
// allow us to pass back errors in any useful way.
|
||||
|
||||
assert vec::is_empty(self.v_seen) && vec::is_empty(self.r_seen);
|
||||
let rty = indent({|| self.resolve1(typ) });
|
||||
let rty = indent(|| self.resolve1(typ) );
|
||||
assert vec::is_empty(self.v_seen) && vec::is_empty(self.r_seen);
|
||||
alt self.err {
|
||||
none {
|
||||
|
|
@ -1166,9 +1161,9 @@ impl methods for resolve_state {
|
|||
_ {
|
||||
ty::fold_regions_and_ty(
|
||||
self.infcx.tcx, typ,
|
||||
{ |r| self.resolve_region(r) },
|
||||
{ |t| self.resolve_if_deep(t) },
|
||||
{ |t| self.resolve_if_deep(t) })
|
||||
|r| self.resolve_region(r),
|
||||
|t| self.resolve_if_deep(t),
|
||||
|t| self.resolve_if_deep(t))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -1462,11 +1457,11 @@ impl assignment for infer_ctxt {
|
|||
anmnt, a.to_str(self), nr_b.to_str(self),
|
||||
r_b.to_str(self)];
|
||||
|
||||
do indent {||
|
||||
do self.sub_tys(a, nr_b).then {||
|
||||
do indent || {
|
||||
do self.sub_tys(a, nr_b).then || {
|
||||
let r_a = ty::re_scope(anmnt.borrow_scope);
|
||||
#debug["anmnt=%?", anmnt];
|
||||
do sub(self).contraregions(r_a, r_b).chain {|_r|
|
||||
do sub(self).contraregions(r_a, r_b).chain |_r| {
|
||||
// if successful, add an entry indicating that
|
||||
// borrowing occurred
|
||||
#debug["borrowing expression #%?", anmnt];
|
||||
|
|
@ -1564,7 +1559,7 @@ fn super_substs<C:combine>(
|
|||
ok(none)
|
||||
}
|
||||
(some(a), some(b)) {
|
||||
do infcx.eq_regions(a, b).then {||
|
||||
do infcx.eq_regions(a, b).then || {
|
||||
ok(some(a))
|
||||
}
|
||||
}
|
||||
|
|
@ -1582,10 +1577,10 @@ fn super_substs<C:combine>(
|
|||
}
|
||||
}
|
||||
|
||||
do self.tps(a.tps, b.tps).chain { |tps|
|
||||
do self.self_tys(a.self_ty, b.self_ty).chain { |self_ty|
|
||||
do eq_opt_regions(self.infcx(), a.self_r, b.self_r).chain {
|
||||
|self_r|
|
||||
do self.tps(a.tps, b.tps).chain |tps| {
|
||||
do self.self_tys(a.self_ty, b.self_ty).chain |self_ty| {
|
||||
do eq_opt_regions(self.infcx(), a.self_r, b.self_r).chain
|
||||
|self_r| {
|
||||
ok({self_r: self_r, self_ty: self_ty, tps: tps})
|
||||
}
|
||||
}
|
||||
|
|
@ -1601,11 +1596,9 @@ fn super_tps<C:combine>(
|
|||
// variance.
|
||||
|
||||
if check vec::same_length(as, bs) {
|
||||
iter_vec2(as, bs, {|a, b|
|
||||
iter_vec2(as, bs, |a, b| {
|
||||
self.infcx().eq_tys(a, b)
|
||||
}).then({||
|
||||
ok(as)
|
||||
})
|
||||
}).then(|| ok(as) )
|
||||
} else {
|
||||
err(ty::terr_ty_param_size(bs.len(), as.len()))
|
||||
}
|
||||
|
|
@ -1622,9 +1615,7 @@ fn super_self_tys<C:combine>(
|
|||
ok(none)
|
||||
}
|
||||
(some(a), some(b)) {
|
||||
self.infcx().eq_tys(a, b).then({||
|
||||
ok(some(a))
|
||||
})
|
||||
self.infcx().eq_tys(a, b).then(|| ok(some(a)) )
|
||||
}
|
||||
(none, some(_)) |
|
||||
(some(_), none) {
|
||||
|
|
@ -1640,11 +1631,9 @@ fn super_flds<C:combine>(
|
|||
self: C, a: ty::field, b: ty::field) -> cres<ty::field> {
|
||||
|
||||
if a.ident == b.ident {
|
||||
self.mts(a.mt, b.mt).chain({|mt|
|
||||
ok({ident: a.ident, mt: mt})
|
||||
}).chain_err({|e|
|
||||
err(ty::terr_in_field(@e, a.ident))
|
||||
})
|
||||
self.mts(a.mt, b.mt)
|
||||
.chain(|mt| ok({ident: a.ident, mt: mt}) )
|
||||
.chain_err(|e| err(ty::terr_in_field(@e, a.ident)) )
|
||||
} else {
|
||||
err(ty::terr_record_fields(b.ident, a.ident))
|
||||
}
|
||||
|
|
@ -1662,8 +1651,8 @@ fn super_args<C:combine>(
|
|||
self: C, a: ty::arg, b: ty::arg)
|
||||
-> cres<ty::arg> {
|
||||
|
||||
do self.modes(a.mode, b.mode).chain {|m|
|
||||
do self.contratys(a.ty, b.ty).chain {|t|
|
||||
do self.modes(a.mode, b.mode).chain |m| {
|
||||
do self.contratys(a.ty, b.ty).chain |t| {
|
||||
ok({mode: m, ty: t})
|
||||
}
|
||||
}
|
||||
|
|
@ -1675,7 +1664,7 @@ fn super_vstores<C:combine>(
|
|||
|
||||
alt (a, b) {
|
||||
(ty::vstore_slice(a_r), ty::vstore_slice(b_r)) {
|
||||
do self.contraregions(a_r, b_r).chain {|r|
|
||||
do self.contraregions(a_r, b_r).chain |r| {
|
||||
ok(ty::vstore_slice(r))
|
||||
}
|
||||
}
|
||||
|
|
@ -1697,17 +1686,17 @@ fn super_fns<C:combine>(
|
|||
b_args: ~[ty::arg]) -> cres<~[ty::arg]> {
|
||||
|
||||
if check vec::same_length(a_args, b_args) {
|
||||
map_vec2(a_args, b_args, {|a, b| self.args(a, b) })
|
||||
map_vec2(a_args, b_args, |a, b| self.args(a, b) )
|
||||
} else {
|
||||
err(ty::terr_arg_count)
|
||||
}
|
||||
}
|
||||
|
||||
do self.protos(a_f.proto, b_f.proto).chain {|p|
|
||||
do self.ret_styles(a_f.ret_style, b_f.ret_style).chain {|rs|
|
||||
do argvecs(self, a_f.inputs, b_f.inputs).chain {|inputs|
|
||||
do self.tys(a_f.output, b_f.output).chain {|output|
|
||||
do self.purities(a_f.purity, b_f.purity).chain {|purity|
|
||||
do self.protos(a_f.proto, b_f.proto).chain |p| {
|
||||
do self.ret_styles(a_f.ret_style, b_f.ret_style).chain |rs| {
|
||||
do argvecs(self, a_f.inputs, b_f.inputs).chain |inputs| {
|
||||
do self.tys(a_f.output, b_f.output).chain |output| {
|
||||
do self.purities(a_f.purity, b_f.purity).chain |purity| {
|
||||
// FIXME: uncomment if #2588 doesn't get accepted:
|
||||
// self.infcx().constrvecs(a_f.constraints,
|
||||
// b_f.constraints).then {||
|
||||
|
|
@ -1744,18 +1733,18 @@ fn super_tys<C:combine>(
|
|||
|
||||
// Have to handle these first
|
||||
(ty::ty_var_integral(a_id), ty::ty_var_integral(b_id)) {
|
||||
self.infcx().vars_integral(self.infcx().tvib, a_id, b_id).then({||
|
||||
ok(a) })
|
||||
self.infcx().vars_integral(self.infcx().tvib, a_id, b_id)
|
||||
.then(|| ok(a) )
|
||||
}
|
||||
(ty::ty_var_integral(a_id), ty::ty_int(_)) |
|
||||
(ty::ty_var_integral(a_id), ty::ty_uint(_)) {
|
||||
self.infcx().vart_integral(self.infcx().tvib, a_id, b).then({||
|
||||
ok(a) })
|
||||
self.infcx().vart_integral(self.infcx().tvib, a_id, b)
|
||||
.then(|| ok(a) )
|
||||
}
|
||||
(ty::ty_int(_), ty::ty_var_integral(b_id)) |
|
||||
(ty::ty_uint(_), ty::ty_var_integral(b_id)) {
|
||||
self.infcx().tvar_integral(self.infcx().tvib, a, b_id).then({||
|
||||
ok(a) })
|
||||
self.infcx().tvar_integral(self.infcx().tvib, a, b_id)
|
||||
.then(|| ok(a) )
|
||||
}
|
||||
|
||||
(ty::ty_int(_), _) |
|
||||
|
|
@ -1787,78 +1776,76 @@ fn super_tys<C:combine>(
|
|||
|
||||
(ty::ty_enum(a_id, a_substs), ty::ty_enum(b_id, b_substs))
|
||||
if a_id == b_id {
|
||||
do self.substs(a_substs, b_substs).chain {|tps|
|
||||
do self.substs(a_substs, b_substs).chain |tps| {
|
||||
ok(ty::mk_enum(tcx, a_id, tps))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_iface(a_id, a_substs), ty::ty_iface(b_id, b_substs))
|
||||
if a_id == b_id {
|
||||
do self.substs(a_substs, b_substs).chain {|substs|
|
||||
do self.substs(a_substs, b_substs).chain |substs| {
|
||||
ok(ty::mk_iface(tcx, a_id, substs))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_class(a_id, a_substs), ty::ty_class(b_id, b_substs))
|
||||
if a_id == b_id {
|
||||
do self.substs(a_substs, b_substs).chain {|substs|
|
||||
do self.substs(a_substs, b_substs).chain |substs| {
|
||||
ok(ty::mk_class(tcx, a_id, substs))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_box(a_mt), ty::ty_box(b_mt)) {
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
ok(ty::mk_box(tcx, mt))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_uniq(a_mt), ty::ty_uniq(b_mt)) {
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
ok(ty::mk_uniq(tcx, mt))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_vec(a_mt), ty::ty_vec(b_mt)) {
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
ok(ty::mk_vec(tcx, mt))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_ptr(a_mt), ty::ty_ptr(b_mt)) {
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
ok(ty::mk_ptr(tcx, mt))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_rptr(a_r, a_mt), ty::ty_rptr(b_r, b_mt)) {
|
||||
do self.contraregions(a_r, b_r).chain {|r|
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.contraregions(a_r, b_r).chain |r| {
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
ok(ty::mk_rptr(tcx, r, mt))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_evec(a_mt, vs_a), ty::ty_evec(b_mt, vs_b)) {
|
||||
do self.mts(a_mt, b_mt).chain {|mt|
|
||||
do self.vstores(ty::terr_vec, vs_a, vs_b).chain {|vs|
|
||||
do self.mts(a_mt, b_mt).chain |mt| {
|
||||
do self.vstores(ty::terr_vec, vs_a, vs_b).chain |vs| {
|
||||
ok(ty::mk_evec(tcx, mt, vs))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_estr(vs_a), ty::ty_estr(vs_b)) {
|
||||
do self.vstores(ty::terr_str, vs_a, vs_b).chain {|vs|
|
||||
do self.vstores(ty::terr_str, vs_a, vs_b).chain |vs| {
|
||||
ok(ty::mk_estr(tcx,vs))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_rec(as), ty::ty_rec(bs)) {
|
||||
if check vec::same_length(as, bs) {
|
||||
map_vec2(as, bs, {|a,b|
|
||||
map_vec2(as, bs, |a,b| {
|
||||
self.flds(a, b)
|
||||
}).chain({|flds|
|
||||
ok(ty::mk_rec(tcx, flds))
|
||||
})
|
||||
}).chain(|flds| ok(ty::mk_rec(tcx, flds)) )
|
||||
} else {
|
||||
err(ty::terr_record_size(bs.len(), as.len()))
|
||||
}
|
||||
|
|
@ -1866,23 +1853,22 @@ fn super_tys<C:combine>(
|
|||
|
||||
(ty::ty_tup(as), ty::ty_tup(bs)) {
|
||||
if check vec::same_length(as, bs) {
|
||||
map_vec2(as, bs, {|a, b| self.tys(a, b) }).chain({|ts|
|
||||
ok(ty::mk_tup(tcx, ts))
|
||||
})
|
||||
map_vec2(as, bs, |a, b| self.tys(a, b) )
|
||||
.chain(|ts| ok(ty::mk_tup(tcx, ts)) )
|
||||
} else {
|
||||
err(ty::terr_tuple_size(bs.len(), as.len()))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_fn(a_fty), ty::ty_fn(b_fty)) {
|
||||
do self.fns(a_fty, b_fty).chain {|fty|
|
||||
do self.fns(a_fty, b_fty).chain |fty| {
|
||||
ok(ty::mk_fn(tcx, fty))
|
||||
}
|
||||
}
|
||||
|
||||
(ty::ty_constr(a_t, a_constrs), ty::ty_constr(b_t, b_constrs)) {
|
||||
do self.tys(a_t, b_t).chain {|t|
|
||||
do self.infcx().constrvecs(a_constrs, b_constrs).then {||
|
||||
do self.tys(a_t, b_t).chain |t| {
|
||||
do self.infcx().constrvecs(a_constrs, b_constrs).then || {
|
||||
ok(ty::mk_constr(tcx, t, a_constrs))
|
||||
}
|
||||
}
|
||||
|
|
@ -1911,25 +1897,25 @@ impl of combine for sub {
|
|||
self.tag(),
|
||||
a.to_str(self.infcx()),
|
||||
b.to_str(self.infcx())];
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (a, b) {
|
||||
(ty::re_var(a_id), ty::re_var(b_id)) {
|
||||
do self.infcx().vars(self.rb, a_id, b_id).then {||
|
||||
do self.infcx().vars(self.rb, a_id, b_id).then || {
|
||||
ok(a)
|
||||
}
|
||||
}
|
||||
(ty::re_var(a_id), _) {
|
||||
do self.infcx().vart(self.rb, a_id, b).then {||
|
||||
do self.infcx().vart(self.rb, a_id, b).then || {
|
||||
ok(a)
|
||||
}
|
||||
}
|
||||
(_, ty::re_var(b_id)) {
|
||||
do self.infcx().tvar(self.rb, a, b_id).then {||
|
||||
do self.infcx().tvar(self.rb, a, b_id).then || {
|
||||
ok(a)
|
||||
}
|
||||
}
|
||||
_ {
|
||||
do self.lub().regions(a, b).compare(b) {||
|
||||
do self.lub().regions(a, b).compare(b) || {
|
||||
ty::terr_regions_differ(b, a)
|
||||
}
|
||||
}
|
||||
|
|
@ -1948,29 +1934,29 @@ impl of combine for sub {
|
|||
m_mutbl {
|
||||
// If supertype is mut, subtype must match exactly
|
||||
// (i.e., invariant if mut):
|
||||
self.infcx().eq_tys(a.ty, b.ty).then({|| ok(a) })
|
||||
self.infcx().eq_tys(a.ty, b.ty).then(|| ok(a) )
|
||||
}
|
||||
m_imm | m_const {
|
||||
// Otherwise we can be covariant:
|
||||
self.tys(a.ty, b.ty).chain({|_t| ok(a) })
|
||||
self.tys(a.ty, b.ty).chain(|_t| ok(a) )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn protos(a: ast::proto, b: ast::proto) -> cres<ast::proto> {
|
||||
self.lub().protos(a, b).compare(b, {||
|
||||
self.lub().protos(a, b).compare(b, || {
|
||||
ty::terr_proto_mismatch(b, a)
|
||||
})
|
||||
}
|
||||
|
||||
fn purities(f1: purity, f2: purity) -> cres<purity> {
|
||||
self.lub().purities(f1, f2).compare(f2, {||
|
||||
self.lub().purities(f1, f2).compare(f2, || {
|
||||
ty::terr_purity_mismatch(f2, f1)
|
||||
})
|
||||
}
|
||||
|
||||
fn ret_styles(a: ret_style, b: ret_style) -> cres<ret_style> {
|
||||
self.lub().ret_styles(a, b).compare(b, {||
|
||||
self.lub().ret_styles(a, b).compare(b, || {
|
||||
ty::terr_ret_style_mismatch(b, a)
|
||||
})
|
||||
}
|
||||
|
|
@ -1979,19 +1965,19 @@ impl of combine for sub {
|
|||
#debug("%s.tys(%s, %s)", self.tag(),
|
||||
a.to_str(*self), b.to_str(*self));
|
||||
if a == b { ret ok(a); }
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
(ty::ty_bot, _) {
|
||||
ok(a)
|
||||
}
|
||||
(ty::ty_var(a_id), ty::ty_var(b_id)) {
|
||||
self.infcx().vars(self.tvb, a_id, b_id).then({|| ok(a) })
|
||||
self.infcx().vars(self.tvb, a_id, b_id).then(|| ok(a) )
|
||||
}
|
||||
(ty::ty_var(a_id), _) {
|
||||
self.infcx().vart(self.tvb, a_id, b).then({|| ok(a) })
|
||||
self.infcx().vart(self.tvb, a_id, b).then(|| ok(a) )
|
||||
}
|
||||
(_, ty::ty_var(b_id)) {
|
||||
self.infcx().tvar(self.tvb, a, b_id).then({|| ok(a) })
|
||||
self.infcx().tvar(self.tvb, a, b_id).then(|| ok(a) )
|
||||
}
|
||||
(_, ty::ty_bot) {
|
||||
err(ty::terr_sorts(b, a))
|
||||
|
|
@ -2012,7 +1998,7 @@ impl of combine for sub {
|
|||
// First, we instantiate each bound region in the subtype with a fresh
|
||||
// region variable.
|
||||
let {fn_ty: a_fn_ty, _} = {
|
||||
do replace_bound_regions_in_fn_ty(self.tcx, @nil, none, a) { |br|
|
||||
do replace_bound_regions_in_fn_ty(self.tcx, @nil, none, a) |br| {
|
||||
// N.B.: The name of the bound region doesn't have
|
||||
// anything to do with the region variable that's created
|
||||
// for it. The only thing we're doing with `br` here is
|
||||
|
|
@ -2028,7 +2014,7 @@ impl of combine for sub {
|
|||
// Second, we instantiate each bound region in the supertype with a
|
||||
// fresh concrete region.
|
||||
let {fn_ty: b_fn_ty, _} = {
|
||||
do replace_bound_regions_in_fn_ty(self.tcx, @nil, none, b) { |br|
|
||||
do replace_bound_regions_in_fn_ty(self.tcx, @nil, none, b) |br| {
|
||||
// FIXME: eventually re_skolemized (issue #2263)
|
||||
ty::re_bound(br)
|
||||
}
|
||||
|
|
@ -2094,18 +2080,16 @@ impl of combine for lub {
|
|||
|
||||
alt m {
|
||||
m_imm | m_const {
|
||||
self.tys(a.ty, b.ty).chain({|t|
|
||||
ok({ty: t, mutbl: m})
|
||||
})
|
||||
self.tys(a.ty, b.ty).chain(|t| ok({ty: t, mutbl: m}) )
|
||||
}
|
||||
|
||||
m_mutbl {
|
||||
self.infcx().try({||
|
||||
self.infcx().eq_tys(a.ty, b.ty).then({||
|
||||
self.infcx().try(|| {
|
||||
self.infcx().eq_tys(a.ty, b.ty).then(|| {
|
||||
ok({ty: a.ty, mutbl: m})
|
||||
})
|
||||
}).chain_err({|_e|
|
||||
self.tys(a.ty, b.ty).chain({|t|
|
||||
}).chain_err(|_e| {
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
ok({ty: t, mutbl: m_const})
|
||||
})
|
||||
})
|
||||
|
|
@ -2160,7 +2144,7 @@ impl of combine for lub {
|
|||
a.to_str(self.infcx()),
|
||||
b.to_str(self.infcx())];
|
||||
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (a, b) {
|
||||
(ty::re_static, _) | (_, ty::re_static) {
|
||||
ok(ty::re_static) // nothing lives longer than static
|
||||
|
|
@ -2273,17 +2257,17 @@ impl of combine for glb {
|
|||
// If one side or both is mut, then the GLB must use
|
||||
// the precise type from the mut side.
|
||||
(m_mutbl, m_const) {
|
||||
sub(*self).tys(a.ty, b.ty).chain({|_t|
|
||||
sub(*self).tys(a.ty, b.ty).chain(|_t| {
|
||||
ok({ty: a.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
(m_const, m_mutbl) {
|
||||
sub(*self).tys(b.ty, a.ty).chain({|_t|
|
||||
sub(*self).tys(b.ty, a.ty).chain(|_t| {
|
||||
ok({ty: b.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
(m_mutbl, m_mutbl) {
|
||||
self.infcx().eq_tys(a.ty, b.ty).then({||
|
||||
self.infcx().eq_tys(a.ty, b.ty).then(|| {
|
||||
ok({ty: a.ty, mutbl: m_mutbl})
|
||||
})
|
||||
}
|
||||
|
|
@ -2293,7 +2277,7 @@ impl of combine for glb {
|
|||
(m_imm, m_const) |
|
||||
(m_const, m_imm) |
|
||||
(m_imm, m_imm) {
|
||||
self.tys(a.ty, b.ty).chain({|t|
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
ok({ty: t, mutbl: m_imm})
|
||||
})
|
||||
}
|
||||
|
|
@ -2301,7 +2285,7 @@ impl of combine for glb {
|
|||
// If both sides are const, then we can use GLB of both
|
||||
// sides and mutbl of only `m_const`.
|
||||
(m_const, m_const) {
|
||||
self.tys(a.ty, b.ty).chain({|t|
|
||||
self.tys(a.ty, b.ty).chain(|t| {
|
||||
ok({ty: t, mutbl: m_const})
|
||||
})
|
||||
}
|
||||
|
|
@ -2357,7 +2341,7 @@ impl of combine for glb {
|
|||
a.to_str(self.infcx()),
|
||||
b.to_str(self.infcx())];
|
||||
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (a, b) {
|
||||
(ty::re_static, r) | (r, ty::re_static) {
|
||||
// static lives longer than everything else
|
||||
|
|
@ -2495,7 +2479,7 @@ fn lattice_tys<L:lattice_ops combine>(
|
|||
a.to_str(self.infcx()),
|
||||
b.to_str(self.infcx()));
|
||||
if a == b { ret ok(a); }
|
||||
do indent {||
|
||||
do indent || {
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
(ty::ty_bot, _) { self.ty_bot(b) }
|
||||
(_, ty::ty_bot) { self.ty_bot(a) }
|
||||
|
|
@ -2503,17 +2487,17 @@ fn lattice_tys<L:lattice_ops combine>(
|
|||
(ty::ty_var(a_id), ty::ty_var(b_id)) {
|
||||
lattice_vars(self, self.infcx().tvb,
|
||||
a, a_id, b_id,
|
||||
{|x, y| self.tys(x, y) })
|
||||
|x, y| self.tys(x, y) )
|
||||
}
|
||||
|
||||
(ty::ty_var(a_id), _) {
|
||||
lattice_var_t(self, self.infcx().tvb, a_id, b,
|
||||
{|x, y| self.tys(x, y) })
|
||||
|x, y| self.tys(x, y) )
|
||||
}
|
||||
|
||||
(_, ty::ty_var(b_id)) {
|
||||
lattice_var_t(self, self.infcx().tvb, b_id, a,
|
||||
{|x, y| self.tys(x, y) })
|
||||
|x, y| self.tys(x, y) )
|
||||
}
|
||||
_ {
|
||||
super_tys(self, a, b)
|
||||
|
|
@ -2530,13 +2514,13 @@ fn lattice_rvars<L:lattice_ops combine>(
|
|||
(ty::re_var(a_id), ty::re_var(b_id)) {
|
||||
lattice_vars(self, self.infcx().rb,
|
||||
a, a_id, b_id,
|
||||
{|x, y| self.regions(x, y) })
|
||||
|x, y| self.regions(x, y) )
|
||||
}
|
||||
|
||||
(ty::re_var(v_id), r) | (r, ty::re_var(v_id)) {
|
||||
lattice_var_t(self, self.infcx().rb,
|
||||
v_id, r,
|
||||
{|x, y| self.regions(x, y) })
|
||||
|x, y| self.regions(x, y) )
|
||||
}
|
||||
|
||||
_ {
|
||||
|
|
@ -2581,7 +2565,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
|||
let a_bnd = self.bnd(a_bounds), b_bnd = self.bnd(b_bounds);
|
||||
alt (a_bnd, b_bnd) {
|
||||
(some(a_ty), some(b_ty)) {
|
||||
alt self.infcx().try({|| c_ts(a_ty, b_ty) }) {
|
||||
alt self.infcx().try(|| c_ts(a_ty, b_ty) ) {
|
||||
ok(t) { ret ok(t); }
|
||||
err(_) { /*fallthrough */ }
|
||||
}
|
||||
|
|
@ -2591,9 +2575,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
|||
|
||||
// Otherwise, we need to merge A and B into one variable. We can
|
||||
// then use either variable as an upper bound:
|
||||
self.infcx().vars(vb, a_vid, b_vid).then({||
|
||||
ok(a_t)
|
||||
})
|
||||
self.infcx().vars(vb, a_vid, b_vid).then(|| ok(a_t) )
|
||||
}
|
||||
|
||||
fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
||||
|
|
@ -2624,7 +2606,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
|||
// and then return b.
|
||||
#debug["bnd=none"];
|
||||
let a_bounds = self.with_bnd(a_bounds, b);
|
||||
do self.infcx().bnds(a_bounds.lb, a_bounds.ub).then {||
|
||||
do self.infcx().bnds(a_bounds.lb, a_bounds.ub).then || {
|
||||
self.infcx().set(vb, a_id, root(a_bounds,
|
||||
nde_a.rank));
|
||||
ok(b)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl of region_scope for type_rscope {
|
|||
}
|
||||
}
|
||||
fn named_region(id: ast::ident) -> result<ty::region, str> {
|
||||
do empty_rscope.named_region(id).chain_err { |_e|
|
||||
do empty_rscope.named_region(id).chain_err |_e| {
|
||||
if *id == "self" { self.anon_region() }
|
||||
else {
|
||||
result::err("named regions other than `self` are not \
|
||||
|
|
@ -62,7 +62,7 @@ impl of region_scope for @binding_rscope {
|
|||
result::ok(ty::re_bound(ty::br_anon))
|
||||
}
|
||||
fn named_region(id: ast::ident) -> result<ty::region, str> {
|
||||
do self.base.named_region(id).chain_err {|_e|
|
||||
do self.base.named_region(id).chain_err |_e| {
|
||||
result::ok(ty::re_bound(ty::br_named(id)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; }
|
|||
|
||||
fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
|
||||
let mut es = ~[];
|
||||
for fields.each {|f| vec::push(es, f.node.expr); }
|
||||
for fields.each |f| { vec::push(es, f.node.expr); }
|
||||
ret es;
|
||||
}
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
|
|||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr = {|e: @ast::expr, &&flag: @mut bool,
|
||||
v: visit::vt<@mut bool>|
|
||||
let visit_expr =
|
||||
|e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| {
|
||||
*flag |= p(e.node);
|
||||
alt e.node {
|
||||
// Skip inner loops, since a break in the inner loop isn't a
|
||||
|
|
@ -56,13 +56,13 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
|||
}
|
||||
|
||||
fn has_nonlocal_exits(b: ast::blk) -> bool {
|
||||
do loop_query(b) {|e| alt e {
|
||||
do loop_query(b) |e| { alt e {
|
||||
ast::expr_break | ast::expr_cont { true }
|
||||
_ { false }}}
|
||||
}
|
||||
|
||||
fn may_break(b: ast::blk) -> bool {
|
||||
do loop_query(b) {|e| alt e {
|
||||
do loop_query(b) |e| { alt e {
|
||||
ast::expr_break { true }
|
||||
_ { false }}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> str {
|
|||
|
||||
fn tys_to_str(cx: ctxt, ts: ~[t]) -> str {
|
||||
let mut rs = "";
|
||||
for ts.each {|t| rs += ty_to_str(cx, t); }
|
||||
for ts.each |t| { rs += ty_to_str(cx, t); }
|
||||
rs
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
|||
alt ident { some(i) { s += " "; s += *i; } _ { } }
|
||||
s += "(";
|
||||
let mut strs = ~[];
|
||||
for inputs.each {|a| vec::push(strs, fn_input_to_str(cx, a)); }
|
||||
for inputs.each |a| { vec::push(strs, fn_input_to_str(cx, a)); }
|
||||
s += str::connect(strs, ", ");
|
||||
s += ")";
|
||||
if ty::get(output).struct != ty_nil {
|
||||
|
|
@ -156,7 +156,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
|||
}
|
||||
|
||||
// if there is an id, print that instead of the structural type:
|
||||
for ty::type_def_id(typ).each { |def_id|
|
||||
for ty::type_def_id(typ).each |def_id| {
|
||||
// note that this typedef cannot have type parameters
|
||||
ret ast_map::path_to_str(ty::item_path(cx, def_id));
|
||||
}
|
||||
|
|
@ -190,12 +190,12 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
|||
ty_type { "type" }
|
||||
ty_rec(elems) {
|
||||
let mut strs: ~[str] = ~[];
|
||||
for elems.each {|fld| vec::push(strs, field_to_str(cx, fld)); }
|
||||
for elems.each |fld| { vec::push(strs, field_to_str(cx, fld)); }
|
||||
"{" + str::connect(strs, ",") + "}"
|
||||
}
|
||||
ty_tup(elems) {
|
||||
let mut strs = ~[];
|
||||
for elems.each {|elem| vec::push(strs, ty_to_str(cx, elem)); }
|
||||
for elems.each |elem| { vec::push(strs, ty_to_str(cx, elem)); }
|
||||
"(" + str::connect(strs, ",") + ")"
|
||||
}
|
||||
ty_fn(f) {
|
||||
|
|
@ -244,7 +244,7 @@ fn parameterized(cx: ctxt,
|
|||
};
|
||||
|
||||
if vec::len(tps) > 0u {
|
||||
let strs = vec::map(tps, {|t| ty_to_str(cx, t)});
|
||||
let strs = vec::map(tps, |t| ty_to_str(cx, t) );
|
||||
#fmt["%s%s<%s>", base, r_str, str::connect(strs, ",")]
|
||||
} else {
|
||||
#fmt["%s%s", base, r_str]
|
||||
|
|
@ -265,7 +265,7 @@ fn constr_to_str(c: @constr) -> str {
|
|||
fn constrs_str(constrs: ~[@constr]) -> str {
|
||||
let mut s = "";
|
||||
let mut colon = true;
|
||||
for constrs.each {|c|
|
||||
for constrs.each |c| {
|
||||
if colon { s += " : "; colon = false; } else { s += ", "; }
|
||||
s += constr_to_str(c);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue