From 64fedfbc4ef37b56f7bb12e2864f4011e4031ac5 Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Wed, 6 Feb 2013 23:42:55 -0500 Subject: [PATCH 01/92] Fix sample program to compile in modern rust --- src/libstd/getopts.rs | 86 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 6e1a086103507..8ddefa401a84e 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -29,48 +29,50 @@ * The following example shows simple command line parsing for an application * that requires an input file to be specified, accepts an optional output * file name following -o, and accepts both -h and --help as optional flags. - * - * use std; - * import std::getopts::{optopt,optflag,getopts,opt_present,opt_maybe_str, - * fail_str}; - * - * fn do_work(in: str, out: Option) { - * // ... - * } - * - * fn print_usage(program: str) { - * io::println("Usage: " + program + " [options]"); - * io::println("-o\t\tOutput"); - * io::println("-h --help\tUsage"); - * } - * - * fn main(args: ~[str]) { - * check !args.is_empty() - * - * let program : str = vec::head(args); - * - * let opts = ~[ - * optopt("o"), - * optflag("h"), - * optflag("help") - * ]; - * let matches = match getopts(vec::tail(args), opts) { - * result::ok(m) { m } - * result::err(f) { die!(fail_str(f)) } - * }; - * if opt_present(matches, "h") || opt_present(matches, "help") { - * print_usage(program); - * return; - * } - * let output = opt_maybe_str(matches, "o"); - * let input = if !matches.free.is_empty() { - * matches.free[0] - * } else { - * print_usage(program); - * return; - * }; - * do_work(input, output); - * } + * extern mod std; + * use std::getopts::*; + * + * fn do_work(in: &str, out: Option<~str>) { + * io::println(in); + * io::println(match out { + * Some(move x) => x, + * None => ~"No Output" + * }); + * } + * + * fn print_usage(program: &str, _opts: &[std::getopts::Opt]) { + * io::println(fmt!("Usage: %s [options]", program)); + * io::println("-o\t\tOutput"); + * io::println("-h --help\tUsage"); + * } + * + * fn main() { + * let args = os::args(); + * + * let program = copy args[0]; + * + * let opts = ~[ + * optopt("o"), + * optflag("h"), + * optflag("help") + * ]; + * let matches = match getopts(vec::tail(args), opts) { + * result::Ok(m) => { m } + * result::Err(f) => { fail fail_str(f) } + * }; + * if opt_present(&matches, "h") || opt_present(&matches, "help") { + * print_usage(program, opts); + * return; + * } + * let output = opt_maybe_str(&matches, "o"); + * let input: &str = if !matches.free.is_empty() { + * matches.free[0] + * } else { + * print_usage(program, opts); + * return; + * }; + * do_work(input, output); + * } */ #[forbid(deprecated_mode)]; From fd98ea8129d0c4125c15bfc35c68a7c48ae551f3 Mon Sep 17 00:00:00 2001 From: Matthijs Hofstra Date: Sat, 9 Feb 2013 00:45:00 +0100 Subject: [PATCH 02/92] Fix for issue 2174 The function that formats and prints the squigly line that hilights errors counted tabs as spaces, which resulted in incorrect error messages when tabs were used for indentation. This change compares the highlight line with the previous line and inserts a tab instead of a space whenever such a tab exists on the previous line. Note that error messages will still highlight incorrectly when the previous line include characters that require more than one utf8 code point, as mentioned in issue 3260. --- src/libsyntax/diagnostic.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index cd42fc7a95335..1276d5e0ca2d0 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -263,14 +263,26 @@ fn highlight_lines(cm: @codemap::CodeMap, // indent past |name:## | and the 0-offset column location let mut left = str::len(fm.name) + digits + lo.col.to_uint() + 3u; let mut s = ~""; - while left > 0u { str::push_char(&mut s, ' '); left -= 1u; } - + // Skip is the number of characters we need to skip because they are + // part of the 'filename:line ' part of the previous line. + let skip = str::len(fm.name) + digits + 3u; + for skip.times() { + s += ~" "; + } + let orig = fm.get_line(lines.lines[0] as int); + for uint::range(0u,left-skip) |pos| { + let curChar = (orig[pos] as char); + s += match curChar { // Whenever a tab occurs on the previous + '\t' => "\t", // line, we insert one on the error-point- + _ => " " // -squigly-line as well (instead of a + }; // space). This way the squigly-line will + } // usually appear in the correct position. s += ~"^"; let hi = cm.lookup_char_pos(sp.hi); if hi.col != lo.col { // the ^ already takes up one space - let mut width = hi.col.to_uint() - lo.col.to_uint() - 1u; - while width > 0u { str::push_char(&mut s, '~'); width -= 1u; } + let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u; + for num_squiglies.times() { s += ~"~"; } } io::stderr().write_str(s + ~"\n"); } From 8d0c1cb406156379570b6a3c9911db758995fa4e Mon Sep 17 00:00:00 2001 From: Matthijs Hofstra Date: Sat, 9 Feb 2013 01:01:39 +0100 Subject: [PATCH 03/92] Added related FIXME for 3260 --- src/libsyntax/diagnostic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 1276d5e0ca2d0..51ef085839d6a 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -250,7 +250,7 @@ fn highlight_lines(cm: @codemap::CodeMap, io::stderr().write_str(out); } - + // FIXME (#3260) // If there's one line at fault we can easily point to the problem if vec::len(lines.lines) == 1u { let lo = cm.lookup_char_pos(sp.lo); From a32c5c73ee6aad9cb4b2e06867eafa09bc1ece3a Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 8 Feb 2013 17:08:02 -0500 Subject: [PATCH 04/92] oldmap: get rid of legacy _ref suffixes --- src/libcargo/cargo.rc | 18 +++--- src/librustc/back/rpath.rs | 2 +- src/librustc/metadata/cstore.rs | 6 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/borrowck/check_loans.rs | 6 +- src/librustc/middle/borrowck/gather_loans.rs | 4 +- src/librustc/middle/borrowck/preserve.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 8 +-- src/librustc/middle/freevars.rs | 2 +- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/lint.rs | 2 +- src/librustc/middle/mem_categorization.rs | 6 +- src/librustc/middle/moves.rs | 4 +- src/librustc/middle/region.rs | 4 +- src/librustc/middle/resolve.rs | 58 +++++++++---------- src/librustc/middle/trans/_match.rs | 8 +-- src/librustc/middle/trans/base.rs | 12 ++-- src/librustc/middle/trans/callee.rs | 7 +-- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/controlflow.rs | 2 +- src/librustc/middle/trans/datum.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 4 +- src/librustc/middle/trans/expr.rs | 6 +- src/librustc/middle/trans/glue.rs | 4 +- src/librustc/middle/trans/machine.rs | 2 +- src/librustc/middle/trans/meth.rs | 2 +- src/librustc/middle/trans/reachable.rs | 4 +- src/librustc/middle/trans/reflect.rs | 2 +- src/librustc/middle/trans/type_of.rs | 2 +- src/librustc/middle/ty.rs | 6 +- src/librustc/middle/typeck/check/_match.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 5 +- src/librustc/middle/typeck/check/mod.rs | 4 +- src/librustc/middle/typeck/check/regionck.rs | 4 +- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/check/writeback.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 6 +- src/librustc/middle/typeck/collect.rs | 2 +- .../middle/typeck/infer/region_inference.rs | 2 +- src/librustc/rustc.rc | 4 +- src/libstd/oldmap.rs | 22 +++---- src/libsyntax/attr.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/parse/common.rs | 8 +-- src/libsyntax/parse/obsolete.rs | 2 +- src/libsyntax/parse/token.rs | 6 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- 49 files changed, 135 insertions(+), 137 deletions(-) diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index af86911426fdb..f065f37f5a6c0 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo { need_dir(&c.libdir); need_dir(&c.bindir); - for sources.each_key_ref |&k| { + for sources.each_key |&k| { let mut s = sources.get(&k); load_source_packages(&c, s); sources.insert(k, s); @@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo { } pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { for v.packages.each |p| { b(v, p); } @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &mut Cargo) { } pub fn sync(c: &Cargo) { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { let mut s = c.sources.get(&k); sync_one(c, s); c.sources.insert(k, s); @@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) { } } } else { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { print_source(v); } } @@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) { result::Ok(writer) => { let mut hash = ~LinearMap::new(); - for c.sources.each_ref |&k, &v| { + for c.sources.each |&k, &v| { let mut chash = ~LinearMap::new(); chash.insert(~"url", json::String(v.url)); @@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) { pub fn cmd_sources(c: &Cargo) { if vec::len(c.opts.free) < 3u { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { info(fmt!("%s (%s) via %s", v.name, v.url, v.method)); } @@ -1686,7 +1686,7 @@ pub fn cmd_sources(c: &Cargo) { match action { ~"clear" => { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { c.sources.remove(&k); } @@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { error(fmt!("source already exists: %s", name)); } else { c.sources.insert(name, @Source { @@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { c.sources.remove(&name); info(fmt!("removed source: %s", name)); } else { diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index f6a5fec75aded..6fa90ac1ef0c9 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -191,7 +191,7 @@ pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { let mut minimized = ~[]; for rpaths.each |rpath| { let s = rpath.to_str(); - if !set.contains_key_ref(&s) { + if !set.contains_key(&s) { minimized.push(/*bad*/copy *rpath); set.insert(s, ()); } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index c144d2d8804ba..73ec872b6a6ec 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -86,13 +86,13 @@ pub fn set_crate_data(cstore: @mut CStore, } pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool { - return cstore.metas.contains_key_ref(&cnum); + cstore.metas.contains_key(&cnum) } pub fn iter_crate_data(cstore: @mut CStore, i: fn(ast::crate_num, crate_metadata)) { let metas = cstore.metas; - for metas.each_ref |&k, &v| { + for metas.each |&k, &v| { i(k, v); } } @@ -148,7 +148,7 @@ pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] { let mut result = ~[]; let use_crate_map = cstore.use_crate_map; - for use_crate_map.each_value_ref |&cnum| { + for 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); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 89b491a867b9a..fcc1a4e806dff 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -99,7 +99,7 @@ pub enum encode_ctxt = { }; pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool { - ecx.reachable.contains_key_ref(&id) + ecx.reachable.contains_key(&id) } fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 8d439f4ee9ff2..251fec684865c 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -689,7 +689,7 @@ fn check_loans_in_expr(expr: @ast::expr, self.check_for_conflicting_loans(expr.id); - if self.bccx.moves_map.contains_key_ref(&expr.id) { + if self.bccx.moves_map.contains_key(&expr.id) { self.check_move_out_from_expr(expr); } @@ -710,7 +710,7 @@ fn check_loans_in_expr(expr: @ast::expr, } ast::expr_index(_, rval) | ast::expr_binary(_, _, rval) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, @@ -718,7 +718,7 @@ fn check_loans_in_expr(expr: @ast::expr, ~[rval]); } ast::expr_unary(*) | ast::expr_index(*) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 6a61b2e2ee75c..d4c45828858be 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -207,7 +207,7 @@ fn req_loans_in_expr(ex: @ast::expr, ast::expr_binary(_, rcvr, _) | ast::expr_unary(_, rcvr) | ast::expr_assign_op(_, rcvr, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, in an overloaded operator, the call is this expression, @@ -244,7 +244,7 @@ fn req_loans_in_expr(ex: @ast::expr, // } ast::expr_field(rcvr, _, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, the field a.b is in fact a closure. Eventually, this diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 1946ba09ec7bf..097f0579362a9 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -375,7 +375,7 @@ impl PreserveCtxt { // scope_id;`. Though that would potentially re-introduce // the ICE. See #3511 for more details. let scope_to_use = if - self.bccx.stmt_map.contains_key_ref(&scope_id) { + self.bccx.stmt_map.contains_key(&scope_id) { // Root it in its parent scope, b/c // trans won't introduce a new scope for the // stmt diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index ad46d3b6f4de0..6cca576fa130b 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -102,7 +102,7 @@ pub fn check_expr(sess: Session, } expr_lit(@codemap::spanned {node: lit_str(_), _}) => { } expr_binary(_, _, _) | expr_unary(_, _) => { - if method_map.contains_key_ref(&e.id) { + if method_map.contains_key(&e.id) { sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 6f9fe1edca5be..1a3e42511295e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -59,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool { return false; } - !cx.moves_map.contains_key_ref(&expr.id) + !cx.moves_map.contains_key(&expr.id) } pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { @@ -734,7 +734,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, by_ref_span = Some(span); } bind_infer => { - if cx.moves_map.contains_key_ref(&id) { + if cx.moves_map.contains_key(&id) { any_by_move = true; } } @@ -774,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, if pat_is_binding(def_map, p) { match p.node { pat_ident(_, _, sub) => { - if cx.moves_map.contains_key_ref(&p.id) { + if cx.moves_map.contains_key(&p.id) { check_move(p, sub); } } @@ -800,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, behind_bad_pointer); if behind_bad_pointer && - cx.moves_map.contains_key_ref(&pat.id) + cx.moves_map.contains_key(&pat.id) { cx.tcx.sess.span_err( pat.span, diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index e609107721048..0d3b7c36f6d92 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -69,7 +69,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) } if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; - if !seen.contains_key_ref(&dnum) { + if !seen.contains_key(&dnum) { refs.push(@freevar_entry { def: def, span: expr.span, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b4500f87eb0b9..6bcc71514d4a3 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -391,7 +391,7 @@ impl LanguageItemCollector { } fn check_completeness() { - for self.item_refs.each_ref |&key, &item_ref| { + for self.item_refs.each |&key, &item_ref| { match self.items.items[item_ref] { None => { self.session.err(fmt!("no item found for `%s`", key)); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 51bbdfdc19cc3..69c2ffb636541 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -400,7 +400,7 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) { sess: sess}); // Install defaults. - for cx.dict.each_value_ref |&spec| { + for cx.dict.each_value |&spec| { cx.set_level(spec.lint, spec.default); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 07de99870964f..fd9271af6c6d8 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -340,7 +340,7 @@ pub impl &mem_categorization_ctxt { let expr_ty = tcx.ty(expr); match expr.node { ast::expr_unary(ast::deref, e_base) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -349,7 +349,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_field(base, f_name, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_method_ref(expr, expr_ty); } @@ -358,7 +358,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_index(base, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index aaa3156e27c25..bbe5ad8e5544e 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -668,7 +668,7 @@ impl VisitContext { arg_exprs: &[@expr], visitor: vt) -> bool { - if !self.method_map.contains_key_ref(&expr.id) { + if !self.method_map.contains_key(&expr.id) { return false; } @@ -799,7 +799,7 @@ impl VisitContext { for arm.pats.each |pat| { let mut found = false; do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| { - if moves_map.contains_key_ref(&node_id) { + if moves_map.contains_key(&node_id) { found = true; } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 49b373fe6b1ae..5b2d3c9bb96cd 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt) { _ => {} }; - if new_cx.root_exprs.contains_key_ref(&expr.id) { + if new_cx.root_exprs.contains_key(&expr.id) { new_cx.parent = Some(expr.id); } @@ -840,7 +840,7 @@ pub fn determine_rp_in_crate(sess: Session, debug!("%s", { debug!("Region variance results:"); let region_paramd_items = cx.region_paramd_items; - for region_paramd_items.each_ref |&key, &value| { + for region_paramd_items.each |&key, &value| { debug!("item %? (%s) is parameterized with variance %?", key, ast_map::node_id_to_str(ast_map, key, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 51df1d05d9e0c..ba550dbbde8ed 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1942,7 +1942,7 @@ pub impl Resolver { self.module_to_str(module_)); self.resolve_imports_for_module(module_); - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Nothing to do. @@ -1953,7 +1953,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.resolve_imports_for_module_subtree(child_module); } } @@ -2241,7 +2241,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match value_result { @@ -2400,7 +2400,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match module_result { @@ -2461,7 +2461,7 @@ pub impl Resolver { assert containing_module.glob_count == 0; // Add all resolved imports from the containing module. - for containing_module.import_resolutions.each_ref + for containing_module.import_resolutions.each |&ident, &target_import_resolution| { debug!("(resolving glob import) writing module resolution \ @@ -2512,7 +2512,7 @@ pub impl Resolver { } // Add all children from the containing module. - for containing_module.children.each_ref |&ident, &name_bindings| { + for containing_module.children.each |&ident, &name_bindings| { let mut dest_import_resolution; match module_.import_resolutions.find(&ident) { None => { @@ -3182,7 +3182,7 @@ pub impl Resolver { } // Descend into children and anonymous children. - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Continue. @@ -3193,7 +3193,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&module_| { + for module_.anonymous_children.each_value |&module_| { self.report_unresolved_imports(module_); } } @@ -3238,7 +3238,7 @@ pub impl Resolver { self.record_exports_for_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match child_name_bindings.get_module_if_available() { None => { // Nothing to do. @@ -3249,7 +3249,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.record_exports_for_module_subtree(child_module); } } @@ -3297,7 +3297,7 @@ pub impl Resolver { } fn add_exports_for_module(exports2: &mut ~[Export2], module_: @Module) { - for module_.children.each_ref |ident, namebindings| { + for module_.children.each |ident, namebindings| { debug!("(computing exports) maybe export '%s'", self.session.str_of(*ident)); self.add_exports_of_namebindings(&mut *exports2, @@ -3312,7 +3312,7 @@ pub impl Resolver { false); } - for module_.import_resolutions.each_ref |ident, importresolution| { + for module_.import_resolutions.each |ident, importresolution| { if importresolution.privacy != Public { debug!("(computing exports) not reexporting private `%s`", self.session.str_of(*ident)); @@ -4102,7 +4102,7 @@ pub impl Resolver { for arm.pats.eachi() |i, p| { let map_i = self.binding_mode_map(*p); - for map_0.each_ref |&key, &binding_0| { + for map_0.each |&key, &binding_0| { match map_i.find(&key) { None => { self.session.span_err( @@ -4123,8 +4123,8 @@ pub impl Resolver { } } - for map_i.each_ref |&key, &binding| { - if !map_0.contains_key_ref(&key) { + for map_i.each |&key, &binding| { + if !map_0.contains_key(&key) { self.session.span_err( binding.span, fmt!("variable `%s` from pattern #%u is \ @@ -4353,7 +4353,7 @@ pub impl Resolver { match bindings_list { Some(bindings_list) - if !bindings_list.contains_key_ref(&ident) + if !bindings_list.contains_key(&ident) => { let last_rib = (*self.value_ribs).last(); last_rib.bindings.insert(ident, @@ -4426,18 +4426,18 @@ pub impl Resolver { pat_struct(path, _, _) => { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(pattern.id, class_def); } Some(definition @ def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { self.record_def(pattern.id, definition); } Some(definition @ def_variant(_, variant_id)) - if self.structs.contains_key_ref(&variant_id) + if self.structs.contains_key(&variant_id) => { self.record_def(pattern.id, definition); } @@ -4886,12 +4886,12 @@ pub impl Resolver { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) | Some(def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(expr.id, class_def); } Some(definition @ def_variant(_, class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { self.record_def(expr.id, definition); } _ => { @@ -5035,7 +5035,7 @@ pub impl Resolver { } // Look for trait children. - for search_module.children.each_value_ref |&child_name_bindings| { + for search_module.children.each_value |&child_name_bindings| { match child_name_bindings.def_for_namespace(TypeNS) { Some(def) => { match def { @@ -5055,7 +5055,7 @@ pub impl Resolver { } // Look for imports. - for search_module.import_resolutions.each_value_ref + for search_module.import_resolutions.each_value |&import_resolution| { match import_resolution.target_for_namespace(TypeNS) { @@ -5115,7 +5115,7 @@ pub impl Resolver { self.session.str_of(name)); match self.trait_info.find(&trait_def_id) { - Some(trait_info) if trait_info.contains_key_ref(&name) => { + Some(trait_info) if trait_info.contains_key(&name) => { debug!("(adding trait info if containing method) found trait \ %d:%d for method '%s'", trait_def_id.crate, @@ -5223,7 +5223,7 @@ pub impl Resolver { self.check_for_unused_imports_in_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match (*child_name_bindings).get_module_if_available() { None => { // Nothing to do. @@ -5235,13 +5235,13 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.check_for_unused_imports_in_module_subtree(child_module); } } fn check_for_unused_imports_in_module(module_: @Module) { - for module_.import_resolutions.each_value_ref |&import_resolution| { + for module_.import_resolutions.each_value |&import_resolution| { // Ignore dummy spans for things like automatically injected // imports for the prelude, and also don't warn about the same // import statement being unused more than once. @@ -5306,12 +5306,12 @@ pub impl Resolver { debug!("Dump of module `%s`:", self.module_to_str(module_)); debug!("Children:"); - for module_.children.each_key_ref |&name| { + for module_.children.each_key |&name| { debug!("* %s", self.session.str_of(name)); } debug!("Import resolutions:"); - for module_.import_resolutions.each_ref |&name, &import_resolution| { + for module_.import_resolutions.each |&name, &import_resolution| { let mut value_repr; match (*import_resolution).target_for_namespace(ValueNS) { None => { value_repr = ~""; } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index ebd6d9f905642..2369a63e54489 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1096,7 +1096,7 @@ pub fn store_non_ref_bindings(bcx: block, */ let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(is_move, lldest) => { let llval = Load(bcx, binding_info.llmatch); // get a T* @@ -1130,7 +1130,7 @@ pub fn insert_lllocals(bcx: block, * the `fcx.lllocals` map. If add_cleans is true, then adds cleanups for * the bindings. */ - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { let llval = match binding_info.trmode { // By value bindings: use the stack slot that we // copied/moved the value into @@ -1203,7 +1203,7 @@ pub fn compile_guard(bcx: block, fn drop_bindings(bcx: block, data: &ArmData) -> block { let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(_, llval) => { bcx = glue::drop_ty(bcx, llval, binding_info.ty); @@ -1598,7 +1598,7 @@ pub fn trans_match_inner(scope_cx: block, // but during matching we need to store a *T as explained // above let is_move = - scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id); + scope_cx.ccx().maps.moves_map.contains_key(&p_id); llmatch = alloca(bcx, T_ptr(llvariable_ty)); trmode = TrByValue(is_move, alloca(bcx, llvariable_ty)); } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index acf33434b2f8b..ced47bb5681b1 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -169,7 +169,7 @@ pub fn get_extern_fn(externs: ExternMap, name: @str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let f = decl_fn(llmod, name, cc, ty); externs.insert(name, f); return f; @@ -178,7 +178,7 @@ pub fn get_extern_fn(externs: ExternMap, pub fn get_extern_const(externs: ExternMap, llmod: ModuleRef, name: @str, ty: TypeRef) -> ValueRef { unsafe { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let c = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(llmod, ty, buf) }); @@ -448,7 +448,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) { // silently mangles such symbols, breaking our linkage model. pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) { // XXX: Bad copy. - if ccx.all_llvm_symbols.contains_key_ref(&sym) { + if ccx.all_llvm_symbols.contains_key(&sym) { ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); @@ -2477,7 +2477,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ccx.sess.bug(~"get_item_val(): unexpected variant") } }; - if !(exprt || ccx.reachable.contains_key_ref(&id)) { + if !(exprt || ccx.reachable.contains_key(&id)) { lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage); } ccx.item_vals.insert(id, val); @@ -2800,7 +2800,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef { lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); } let mut elts: ~[ValueRef] = ~[]; - for ccx.module_data.each_ref |&key, &val| { + for ccx.module_data.each |&key, &val| { let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)), p2i(ccx, val)]); elts.push(elt); @@ -3084,7 +3084,7 @@ pub fn trans_crate(sess: session::Session, } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each_ref |&k, &v| { + for ccx.stats.llvm_insns.each |&k, &v| { io::println(fmt!("%-7u %s", v, k)); } } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 08bab21daaf92..81fa221aac4de 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -674,8 +674,7 @@ pub fn trans_arg_expr(bcx: block, // FIXME(#3548) use the adjustments table match autoref_arg { DoAutorefArg => { - assert !bcx.ccx().maps.moves_map.contains_key_ref( - &arg_expr.id); + assert !bcx.ccx().maps.moves_map.contains_key(&arg_expr.id); val = arg_datum.to_ref_llval(bcx); } DontAutorefArg => { @@ -685,7 +684,7 @@ pub fn trans_arg_expr(bcx: block, // the explicit self code currently passes by-ref, it // does not hold. // - //assert !bcx.ccx().maps.moves_map.contains_key_ref( + //assert !bcx.ccx().maps.moves_map.contains_key( // &arg_expr.id); val = arg_datum.to_ref_llval(bcx); } @@ -693,7 +692,7 @@ pub fn trans_arg_expr(bcx: block, ast::by_val => { // NB: avoid running the take glue. - assert !bcx.ccx().maps.moves_map.contains_key_ref( + assert !bcx.ccx().maps.moves_map.contains_key( &arg_expr.id); val = arg_datum.to_value_llval(bcx); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 515239883e2d8..bcf796caa7a4a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -132,7 +132,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef { if !ast_util::is_local(def_id) { cx.tcx.sess.bug(~"cross-crate constants"); } - if !cx.const_values.contains_key_ref(&def_id.node) { + if !cx.const_values.contains_key(&def_id.node) { match cx.tcx.items.get(&def_id.node) { ast_map::node_item(@ast::item { node: ast::item_const(_, subexpr), _ diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 0933eedd5e4bb..792c5958822e0 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -186,7 +186,7 @@ pub fn trans_log(log_ex: @ast::expr, // XXX: Bad copy. let modname = path_str(ccx.sess, copy modpath); - let global = if ccx.module_data.contains_key_ref(&modname) { + let global = if ccx.module_data.contains_key(&modname) { ccx.module_data.get(&modname) } else { let s = link::mangle_internal_name_by_path_and_seq( diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index af966e4df822a..d301a31357be3 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -223,7 +223,7 @@ pub impl Datum { * `id` is located in the move table, but copies otherwise. */ - if bcx.ccx().maps.moves_map.contains_key_ref(&id) { + if bcx.ccx().maps.moves_map.contains_key(&id) { self.move_to(bcx, action, dst) } else { self.copy_to(bcx, action, dst) diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 8556bee7e8473..f50cadc967124 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -117,7 +117,7 @@ pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt { } fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { - let existing = if cache.contains_key_ref(&mdtag) { + let existing = if cache.contains_key(&mdtag) { cache.get(&mdtag) } else { ~[] @@ -176,7 +176,7 @@ fn cached_metadata(cache: metadata_cache, eq_fn: fn(md: T) -> bool) -> Option { unsafe { - if cache.contains_key_ref(&mdtag) { + if cache.contains_key(&mdtag) { let items = cache.get(&mdtag); for items.each |item| { let md: T = md_from_metadata::(*item); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index f2da47eb0ecca..cab2adc43faa6 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -265,7 +265,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { } pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block { - if bcx.tcx().adjustments.contains_key_ref(&expr.id) { + if bcx.tcx().adjustments.contains_key(&expr.id) { // use trans_to_datum, which is mildly less efficient but // which will perform the adjustments: let datumblock = trans_to_datum(bcx, expr); @@ -426,7 +426,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } ast::expr_binary(op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&expr.id); return trans_binary(bcx, expr, op, lhs, rhs); } @@ -1215,7 +1215,7 @@ fn trans_unary_datum(bcx: block, assert op != ast::deref; // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&un_expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&un_expr.id); let un_ty = expr_ty(bcx, un_expr); let sub_ty = expr_ty(bcx, sub_expr); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 3cbc575b7c11c..08d22a4fbf0e2 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -384,7 +384,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; let ty_visitor_name = special_idents::ty_visitor; - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(&ty_visitor_name); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id); @@ -762,7 +762,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) { let _icx = ccx.insn_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs = true; - for ccx.tydescs.each_value_ref |&val| { + for ccx.tydescs.each_value |&val| { let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx)); let ti = val; diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index dfbc75376c7cd..75e494f7bfcd9 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -180,7 +180,7 @@ pub fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { - if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(&t); } + if cx.enum_sizes.contains_key(&t) { return cx.enum_sizes.get(&t); } match ty::get(t).sty { ty::ty_enum(tid, ref substs) => { // Compute max(variant sizes). diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 1d48d2dde6bc5..fb487b98e152f 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -871,7 +871,7 @@ pub fn trans_trait_cast(bcx: block, match vstore { ty::vstore_slice(*) | ty::vstore_box => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); - if bcx.tcx().legacy_boxed_traits.contains_key_ref(&id) { + if bcx.tcx().legacy_boxed_traits.contains_key(&id) { // Allocate an @ box and store the value into it let {bcx: new_bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 112b9ac4d0781..f77aa33407d10 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -95,7 +95,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: _mod) { } fn traverse_public_item(cx: ctx, item: @item) { - if cx.rmap.contains_key_ref(&item.id) { return; } + if cx.rmap.contains_key(&item.id) { return; } cx.rmap.insert(item.id, ()); match /*bad*/copy item.node { item_mod(m) => traverse_public_mod(cx, item.id, m), @@ -145,7 +145,7 @@ fn mk_ty_visitor() -> visit::vt { } fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt) { - if cx.rmap.contains_key_ref(&ty.id) { return; } + if cx.rmap.contains_key(&ty.id) { return; } cx.rmap.insert(ty.id, ()); match ty.node { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 3cd6a5d18364a..16677530ecd15 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -331,7 +331,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, -> block { use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, ~"final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index f727b5a2de074..84a19cd4c0477 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -93,7 +93,7 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. - if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(&t); } + if cx.lltypes.contains_key(&t) { return cx.lltypes.get(&t); } // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6455c5da98d35..c12071f401c23 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2793,7 +2793,7 @@ pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { } fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { - return cx.node_type_substs.contains_key_ref(&id); + cx.node_type_substs.contains_key(&id) } // Type accessors for substructures of types @@ -3097,7 +3097,7 @@ pub enum ExprKind { pub fn expr_kind(tcx: ctxt, method_map: typeck::method_map, expr: @ast::expr) -> ExprKind { - if method_map.contains_key_ref(&expr.id) { + if method_map.contains_key(&expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS. However, assign_op (e.g., `x += y`) is an // exception, as its result is always unit. @@ -4353,7 +4353,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt, let super_t = supertrait.tpt.ty; let d_id = ty_to_def_id(super_t).expect("supertrait \ should be a trait ty"); - if !supertrait_map.contains_key_ref(&d_id) { + if !supertrait_map.contains_key(&d_id) { supertrait_map.insert(d_id, super_t); trait_ty = super_t; seen_def_ids.push(d_id); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 3cd2be6450de9..95bed1140500d 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -239,7 +239,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, // Report an error if not all the fields were specified. if !etc { for class_fields.eachi |i, field| { - if found_fields.contains_key_ref(&i) { + if found_fields.contains_key(&i) { loop; } tcx.sess.span_err(span, diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 12e3778020a7c..463ae3201a447 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1172,12 +1172,11 @@ pub impl LookupContext { match candidate.origin { method_static(method_id) | method_self(method_id, _) | method_super(method_id, _) => { - bad = self.tcx().destructors.contains_key_ref(&method_id); + bad = self.tcx().destructors.contains_key(&method_id); } method_param(method_param { trait_id: trait_id, _ }) | method_trait(trait_id, _, _) => { - bad = self.tcx().destructor_for_type.contains_key_ref( - &trait_id); + bad = self.tcx().destructor_for_type.contains_key(&trait_id); } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 80be81a33b389..fda9702d58284 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3208,8 +3208,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~"visit_tydesc" => { let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); - assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name); - assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert tcx.intrinsic_defs.contains_key(&tydesc_name); + assert ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name); let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 9ceace0038591..c91607489ecec 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -213,7 +213,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { // `constrain_auto_ref()` on all exprs. But that causes a // lot of spurious errors because of how the region // hierarchy is setup. - if rcx.fcx.ccx.method_map.contains_key_ref(&callee.id) { + if rcx.fcx.ccx.method_map.contains_key(&callee.id) { match callee.node { ast::expr_field(base, _, _) => { constrain_auto_ref(rcx, base); @@ -749,7 +749,7 @@ pub mod guarantor { let _i = ::util::common::indenter(); let guarantor = { - if rcx.fcx.ccx.method_map.contains_key_ref(&expr.id) { + if rcx.fcx.ccx.method_map.contains_key(&expr.id) { None } else { guarantor(rcx, expr) diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index b72c42f6af73d..410b4a3e33d6e 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -268,7 +268,7 @@ pub fn lookup_vtable(vcx: &VtableContext, // im is one specific impl of trait_ty. // First, ensure we haven't processed this impl yet. - if impls_seen.contains_key_ref(&im.did) { + if impls_seen.contains_key(&im.did) { loop; } impls_seen.insert(im.did, ()); diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 835e0557e2ec9..1b27619938146 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -141,7 +141,7 @@ fn maybe_resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: span, id: ast::node_id) -> Option { - if wbcx.fcx.inh.node_types.contains_key_ref(&id) { + if wbcx.fcx.inh.node_types.contains_key(&id) { resolve_type_vars_for_node(wbcx, sp, id) } else { None diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 9f28cb6152037..2414a8657904c 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -418,7 +418,7 @@ pub impl CoherenceChecker { let coherence_info = &mut self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; - for extension_methods.each_key_ref |&trait_id| { + for extension_methods.each_key |&trait_id| { self.check_implementation_coherence_of(trait_id); } } @@ -503,7 +503,7 @@ pub impl CoherenceChecker { } for ty::trait_methods(tcx, trait_did).each |method| { - if provided_method_idents.contains_key_ref(&method.ident) { + if provided_method_idents.contains_key(&method.ident) { if !f(method) { break; } @@ -912,7 +912,7 @@ pub impl CoherenceChecker { let tcx = self.crate_context.tcx; let pmm = tcx.provided_methods; - if pmm.contains_key_ref(&trait_def_id) { return; } + if pmm.contains_key(&trait_def_id) { return; } debug!("(adding default methods for trait) processing trait"); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 68a0ca3890ee8..982a8d7d9574f 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -304,7 +304,7 @@ pub fn ensure_supertraits(ccx: @mut CrateCtxt, rp: Option, trait_refs: &[@ast::trait_ref]) { let tcx = ccx.tcx; - if tcx.supertraits.contains_key_ref(&local_def(id)) { return; } + if tcx.supertraits.contains_key(&local_def(id)) { return; } let instantiated = dvec::DVec(); for trait_refs.each |trait_ref| { diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 60f5f4406588c..027b99cc42192 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -1242,7 +1242,7 @@ impl RegionVarBindings { // It would be nice to write this using map(): let mut edges = vec::with_capacity(num_edges); - for self.constraints.each_ref |constraint, span| { + for self.constraints.each |constraint, span| { edges.push(GraphEdge { next_edge: [uint::max_value, uint::max_value], constraint: *constraint, diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index e91fd1c31ca0a..5273dbd30492f 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -177,7 +177,7 @@ Available lint options: let lint_dict = lint::get_lint_dict(); let mut max_key = 0; - for lint_dict.each_key_ref |&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 } @@ -186,7 +186,7 @@ Available lint options: padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(fmt!(" %s %7.7s %s\n", padded(max_key, ~"----"), ~"-------", ~"-------")); - for lint_dict.each_ref |&k, &v| { + for lint_dict.each |&k, &v| { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!(" %s %7.7s %s", padded(max_key, k), diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index ad7e8e50e38f0..fb594af494290 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -173,7 +173,7 @@ pub mod chained { } impl T { - pure fn contains_key_ref(&self, k: &K) -> bool { + pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { NotFound => false, @@ -314,18 +314,18 @@ pub mod chained { } } - pure fn each_ref(&self, blk: fn(key: &K, value: &V) -> bool) { + pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } } } - pure fn each_key_ref(&self, blk: fn(key: &K) -> bool) { - self.each_ref(|k, _v| blk(k)) + pure fn each_key(&self, blk: fn(key: &K) -> bool) { + self.each(|k, _v| blk(k)) } - pure fn each_value_ref(&self, blk: fn(value: &V) -> bool) { - self.each_ref(|_k, v| blk(v)) + pure fn each_value(&self, blk: fn(value: &V) -> bool) { + self.each(|_k, v| blk(v)) } } @@ -397,7 +397,7 @@ pub fn set_add(set: Set, key: K) -> bool { /// Convert a set into a vector. pub pure fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.len()) |push| { - for s.each_key_ref() |&k| { + for s.each_key() |&k| { push(k); } } @@ -628,9 +628,9 @@ mod tests { fn test_contains_key() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); map.insert(key, ~"val"); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); } #[test] @@ -648,10 +648,10 @@ mod tests { let mut map = HashMap::<~str, ~str>(); map.insert(key, ~"val"); assert (map.len() == 1); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); map.clear(); assert (map.len() == 0); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); } #[test] diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c347c04641f10..857453b2bf9d1 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -363,7 +363,7 @@ pub fn require_unique_names(diagnostic: span_handler, let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) - if map.contains_key_ref(&name) { + if map.contains_key(&name) { diagnostic.span_fatal(meta.span, fmt!("duplicate meta item `%s`", name)); } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 9548db70b94c3..4b1194bb5f174 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -197,7 +197,7 @@ pub fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) codemap::spanned { node: match_nonterminal(bind_name, _, idx), span: sp } => { - if ret_val.contains_key_ref(&bind_name) { + if ret_val.contains_key(&bind_name) { p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+ *p_s.interner.get(bind_name)) } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index d82a5a1803949..e0d53fadfa0b8 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -96,7 +96,7 @@ pub impl Parser { // A sanity check that the word we are asking for is a known keyword fn require_keyword(word: ~str) { - if !self.keywords.contains_key_ref(&word) { + if !self.keywords.contains_key(&word) { self.bug(fmt!("unknown keyword: %s", word)); } } @@ -120,7 +120,7 @@ pub impl Parser { fn is_any_keyword(tok: token::Token) -> bool { match tok { token::IDENT(sid, false) => { - self.keywords.contains_key_ref(self.id_to_str(sid)) + self.keywords.contains_key(self.id_to_str(sid)) } _ => false } @@ -146,7 +146,7 @@ pub impl Parser { } fn is_strict_keyword(word: ~str) -> bool { - self.strict_keywords.contains_key_ref(&word) + self.strict_keywords.contains_key(&word) } fn check_strict_keywords() { @@ -166,7 +166,7 @@ pub impl Parser { } fn is_reserved_keyword(word: ~str) -> bool { - self.reserved_keywords.contains_key_ref(&word) + self.reserved_keywords.contains_key(&word) } fn check_reserved_keywords() { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index cdde542bb1f32..9b2040fed1a1f 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -137,7 +137,7 @@ pub impl Parser { desc: &str) { self.span_err(sp, fmt!("obsolete syntax: %s", kind_str)); - if !self.obsolete_set.contains_key_ref(&kind) { + if !self.obsolete_set.contains_key(&kind) { self.sess.span_diagnostic.handler().note(fmt!("%s", desc)); self.obsolete_set.insert(kind, ()); } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2770d823bf377..5cc9a2adfa5dd 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -454,13 +454,13 @@ pub fn mk_fake_ident_interner() -> @ident_interner { */ pub fn keyword_table() -> HashMap<~str, ()> { let keywords = HashMap(); - for temporary_keyword_table().each_key_ref |&word| { + for temporary_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for strict_keyword_table().each_key_ref |&word| { + for strict_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for reserved_keyword_table().each_key_ref |&word| { + for reserved_keyword_table().each_key |&word| { keywords.insert(word, ()); } keywords diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 811f39e4343db..62341f08ce3be 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -49,7 +49,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { let mut pairs = ~[]; // map -> [(k,%)] - for mm.each_ref |&key, &val| { + for mm.each |&key, &val| { pairs.push((key, pct(val, total))); } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 5888dab3bb923..b19454ec230c2 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -134,7 +134,7 @@ fn writer(path: ~str, pport: pipes::Port, size: uint) done += 1_u; let mut prev = done; while prev <= i { - if lines.contains_key_ref(&prev) { + if lines.contains_key(&prev) { debug!("WS %u", prev); cout.write(lines.get(&prev)); done += 1_u; From 0127828b5bc5363e30f6f672e0465b7fa79c9907 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 8 Feb 2013 19:20:36 -0500 Subject: [PATCH 05/92] oldmap: separate out the methods that need Copy --- src/libstd/oldmap.rs | 66 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index fb594af494290..62ca25ed69d00 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -76,7 +76,7 @@ pub mod chained { FoundAfter(@Entry, @Entry) } - priv impl T { + priv impl T { pure fn search_rem(k: &K, h: uint, idx: uint, e_root: @Entry) -> SearchResult { let mut e0 = e_root; @@ -172,7 +172,7 @@ pub mod chained { } } - impl T { + impl T { pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { @@ -225,6 +225,38 @@ pub mod chained { } } + fn remove(k: &K) -> bool { + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => false, + FoundFirst(idx, entry) => { + self.count -= 1u; + self.chains[idx] = entry.next; + true + } + FoundAfter(eprev, entry) => { + self.count -= 1u; + eprev.next = entry.next; + true + } + } + } + + pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { + for self.each_entry |entry| { + if !blk(&entry.key, &entry.value) { break; } + } + } + + pure fn each_key(&self, blk: fn(key: &K) -> bool) { + self.each(|k, _v| blk(k)) + } + + pure fn each_value(&self, blk: fn(value: &V) -> bool) { + self.each(|_k, v| blk(v)) + } + } + + impl T { pure fn find(&self, k: &K) -> Option { unsafe { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { @@ -297,36 +329,6 @@ pub mod chained { } option::unwrap(move opt_v) } - - fn remove(k: &K) -> bool { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => false, - FoundFirst(idx, entry) => { - self.count -= 1u; - self.chains[idx] = entry.next; - true - } - FoundAfter(eprev, entry) => { - self.count -= 1u; - eprev.next = entry.next; - true - } - } - } - - pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { - for self.each_entry |entry| { - if !blk(&entry.key, &entry.value) { break; } - } - } - - pure fn each_key(&self, blk: fn(key: &K) -> bool) { - self.each(|k, _v| blk(k)) - } - - pure fn each_value(&self, blk: fn(value: &V) -> bool) { - self.each(|_k, v| blk(v)) - } } impl T { From 94fd95a4f1ed5a55e559bcfacc65aaa637a71cb7 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 8 Feb 2013 19:28:37 -0500 Subject: [PATCH 06/92] oldmap: rm unneeded unsafe --- src/libstd/oldmap.rs | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 62ca25ed69d00..cea6d17e35d77 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -90,15 +90,13 @@ pub mod chained { } Some(e1) => { comp += 1u; - unsafe { - if e1.hash == h && e1.key == *k { - debug!("search_tbl: present, comp %u, \ - hash %u, idx %u", - comp, h, idx); - return FoundAfter(e0, e1); - } else { - e0 = e1; - } + if e1.hash == h && e1.key == *k { + debug!( + "search_tbl: present, comp %u, hash %u, idx %u", + comp, h, idx); + return FoundAfter(e0, e1); + } else { + e0 = e1; } } } @@ -114,14 +112,12 @@ pub mod chained { return NotFound; } Some(e) => { - unsafe { - if e.hash == h && e.key == *k { - debug!("search_tbl: present, comp %u, hash %u, \ - idx %u", 1u, h, idx); - return FoundFirst(idx, e); - } else { - return self.search_rem(k, h, idx, e); - } + if e.hash == h && e.key == *k { + debug!("search_tbl: present, comp %u, hash %u, \ + idx %u", 1u, h, idx); + return FoundFirst(idx, e); + } else { + return self.search_rem(k, h, idx, e); } } } @@ -258,12 +254,10 @@ pub mod chained { impl T { pure fn find(&self, k: &K) -> Option { - unsafe { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => None, - FoundFirst(_, entry) => Some(entry.value), - FoundAfter(_, entry) => Some(entry.value) - } + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => None, + FoundFirst(_, entry) => Some(entry.value), + FoundAfter(_, entry) => Some(entry.value) } } @@ -364,9 +358,7 @@ pub mod chained { impl T: ops::Index { pure fn index(&self, k: K) -> V { - unsafe { - self.get(&k) - } + self.get(&k) } } From 0a062b50f11ffba17675912cf9ea475fdbdfa0f5 Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Fri, 8 Feb 2013 20:17:50 -0500 Subject: [PATCH 07/92] Remove trailing whitespace --- src/libstd/getopts.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index e34574a2e15b4..a778649f6f4b0 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -31,7 +31,7 @@ * file name following -o, and accepts both -h and --help as optional flags. * extern mod std; * use std::getopts::*; - * + * * fn do_work(in: &str, out: Option<~str>) { * io::println(in); * io::println(match out { @@ -39,18 +39,18 @@ * None => ~"No Output" * }); * } - * + * * fn print_usage(program: &str, _opts: &[std::getopts::Opt]) { * io::println(fmt!("Usage: %s [options]", program)); * io::println("-o\t\tOutput"); * io::println("-h --help\tUsage"); * } - * + * * fn main() { * let args = os::args(); - * + * * let program = copy args[0]; - * + * * let opts = ~[ * optopt("o"), * optflag("h"), From d30fdbb3575d668223a9f0b6a4a4d2854d194598 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 8 Feb 2013 20:54:30 -0500 Subject: [PATCH 08/92] libsyntax/attr.rs: switch from oldmap to LinearSet --- src/libsyntax/attr.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 857453b2bf9d1..d258393e3b954 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -24,8 +24,7 @@ use core::either::Either; use core::either; use core::option; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; use std; /* Constructors */ @@ -358,16 +357,15 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { pub fn require_unique_names(diagnostic: span_handler, metas: &[@ast::meta_item]) { - let map = oldmap::HashMap(); + let mut set = LinearSet::new(); for metas.each |meta| { let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) - if map.contains_key(&name) { + if !set.insert(name) { diagnostic.span_fatal(meta.span, fmt!("duplicate meta item `%s`", name)); } - map.insert(name, ()); } } From 4e6994dbfa3c32ef6a560c9ab2d940a5b032eef4 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 8 Feb 2013 21:04:28 -0500 Subject: [PATCH 09/92] librustc/back/rpath.rs: oldmap -> LinearSet --- src/librustc/back/rpath.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 6fa90ac1ef0c9..4cca6757cc394 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -18,8 +18,7 @@ use core::os; use core::uint; use core::util; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; pure fn not_win32(os: session::os) -> bool { match os { @@ -187,16 +186,14 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { } pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { - let set = oldmap::HashMap(); + let mut set = LinearSet::new(); let mut minimized = ~[]; for rpaths.each |rpath| { - let s = rpath.to_str(); - if !set.contains_key(&s) { - minimized.push(/*bad*/copy *rpath); - set.insert(s, ()); + if set.insert(rpath.to_str()) { + minimized.push(copy *rpath); } } - return minimized; + minimized } #[cfg(unix)] From ebd20b7944c3b427a90e89d3b4a9e43926336eb8 Mon Sep 17 00:00:00 2001 From: Zack Corr Date: Sat, 9 Feb 2013 19:19:31 +1000 Subject: [PATCH 10/92] Rename dec/inc_weak_task_count to inc/dec_live_count and remove register_task/unregister_task. Closes #4768 --- src/libcore/private/weak_task.rs | 12 +++++------ src/rt/rust_builtin.cpp | 8 +++---- src/rt/rust_kernel.cpp | 37 +++++++++----------------------- src/rt/rust_kernel.h | 6 ++---- src/rt/rust_scheduler.cpp | 4 ++-- src/rt/rustrt.def.in | 4 ++-- 6 files changed, 26 insertions(+), 45 deletions(-) diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 9d57cd5a466ac..1002fdb0c8c3e 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -40,12 +40,12 @@ pub unsafe fn weaken_task(f: &fn(Port)) { let task = get_task_id(); // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); - unsafe { rust_inc_weak_task_count(); } + unsafe { rust_inc_kernel_live_count(); } do fn&() { let shutdown_port = swap_unwrap(&mut *shutdown_port); f(shutdown_port) }.finally || { - unsafe { rust_dec_weak_task_count(); } + unsafe { rust_dec_kernel_live_count(); } // Service my have already exited service.send(UnregisterWeakTask(task)); } @@ -78,11 +78,11 @@ fn create_global_service() -> ~WeakTaskService { let port = swap_unwrap(&mut *port); // The weak task service is itself a weak task debug!("weakening the weak service task"); - unsafe { rust_inc_weak_task_count(); } + unsafe { rust_inc_kernel_live_count(); } run_weak_task_service(port); }.finally { debug!("unweakening the weak service task"); - unsafe { rust_dec_weak_task_count(); } + unsafe { rust_dec_kernel_live_count(); } } } @@ -126,8 +126,8 @@ fn run_weak_task_service(port: Port) { } extern { - unsafe fn rust_inc_weak_task_count(); - unsafe fn rust_dec_weak_task_count(); + unsafe fn rust_inc_kernel_live_count(); + unsafe fn rust_dec_kernel_live_count(); } #[test] diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 32f2c4ebde2ac..df54e47770bca 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -945,15 +945,15 @@ rust_get_global_data_ptr() { } extern "C" void -rust_inc_weak_task_count() { +rust_inc_kernel_live_count() { rust_task *task = rust_get_current_task(); - task->kernel->inc_weak_task_count(); + task->kernel->inc_live_count(); } extern "C" void -rust_dec_weak_task_count() { +rust_dec_kernel_live_count() { rust_task *task = rust_get_current_task(); - task->kernel->dec_weak_task_count(); + task->kernel->dec_live_count(); } // diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index e0494c9300bc3..6b7a82414161c 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -291,12 +291,20 @@ rust_kernel::set_exit_status(int code) { } void -rust_kernel::register_task() { - KLOG_("Registering task"); +rust_kernel::inc_live_count() { uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks); KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); } +void +rust_kernel::dec_live_count() { + uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); + KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); + if (new_non_weak_tasks == 0) { + begin_shutdown(); + } +} + void rust_kernel::allow_scheduler_exit() { scoped_lock with(sched_lock); @@ -315,31 +323,6 @@ rust_kernel::allow_scheduler_exit() { osmain_sched->allow_exit(); } -void -rust_kernel::unregister_task() { - KLOG_("Unregistering task"); - uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); - if (new_non_weak_tasks == 0) { - begin_shutdown(); - } -} - -void -rust_kernel::inc_weak_task_count() { - uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); - if (new_non_weak_tasks == 0) { - begin_shutdown(); - } -} - -void -rust_kernel::dec_weak_task_count() { - uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); -} - void rust_kernel::begin_shutdown() { { diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h index 11af02dace4a0..01ebf5ab57b95 100644 --- a/src/rt/rust_kernel.h +++ b/src/rt/rust_kernel.h @@ -160,10 +160,8 @@ class rust_kernel { rust_sched_id main_sched_id() { return main_scheduler; } rust_sched_id osmain_sched_id() { return osmain_scheduler; } - void register_task(); - void unregister_task(); - void inc_weak_task_count(); - void dec_weak_task_count(); + void inc_live_count(); + void dec_live_count(); void register_exit_function(spawn_fn runner, fn_env_pair *f); }; diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 22dae047e55df..e3a5d9db91ffa 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -123,7 +123,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) { cur_thread = (thread_no + 1) % max_num_threads; } KLOG(kernel, kern, "Creating task %s, on thread %d.", name, thread_no); - kernel->register_task(); + kernel->inc_live_count(); rust_sched_launcher *thread = threads[thread_no]; return thread->get_loop()->create_task(spawner, name); } @@ -138,7 +138,7 @@ rust_scheduler::release_task() { need_exit = true; } } - kernel->unregister_task(); + kernel->dec_live_count(); if (need_exit) { exit(); } diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 9076670392a85..7ab07df0bfef1 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -189,6 +189,6 @@ rust_raw_thread_start rust_raw_thread_join_delete rust_register_exit_function rust_get_global_data_ptr -rust_inc_weak_task_count -rust_dec_weak_task_count +rust_inc_kernel_live_count +rust_dec_kernel_live_count rust_get_exchange_count_ptr From 8ebdb3d0abefc5359e4fb986a0ecb17733f0f74a Mon Sep 17 00:00:00 2001 From: Seth Pink Date: Sat, 9 Feb 2013 23:00:55 +1000 Subject: [PATCH 11/92] Issue #4830 fix --- src/libsyntax/parse/obsolete.rs | 5 -- src/libsyntax/parse/parser.rs | 71 ++++++++---------------- src/test/compile-fail/obsolete-syntax.rs | 8 --- src/test/run-pass/issue-4830.rs | 16 ++++++ 4 files changed, 40 insertions(+), 60 deletions(-) create mode 100644 src/test/run-pass/issue-4830.rs diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index cdde542bb1f32..66ce36fa476cb 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -39,7 +39,6 @@ pub enum ObsoleteSyntax { ObsoleteFieldTerminator, ObsoleteStructCtor, ObsoleteWith, - ObsoleteClassMethod, ObsoleteClassTraits, ObsoletePrivSection, ObsoleteModeInFnType, @@ -85,10 +84,6 @@ pub impl Parser { "record update is done with `..`, e.g. \ `MyStruct { foo: bar, .. baz }`" ), - ObsoleteClassMethod => ( - "class method", - "methods should be defined inside impls" - ), ObsoleteClassTraits => ( "class traits", "implemented traits are specified on the impl, as in \ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7fb3064c388f1..6382413b08169 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -72,7 +72,7 @@ use parse::lexer::TokenAndSpan; use parse::obsolete::{ObsoleteClassTraits, ObsoleteModeInFnType}; use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator}; use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; -use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith, ObsoleteClassMethod}; +use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteUnsafeBlock}; use parse::prec::{as_prec, token_to_binop}; @@ -3002,52 +3002,29 @@ pub impl Parser { } fn parse_single_class_item(vis: visibility) -> @struct_field { - let obsolete_let = self.eat_obsolete_ident("let"); - if obsolete_let { self.obsolete(copy self.last_span, ObsoleteLet) } - - let parse_obsolete_method = - !((obsolete_let || self.is_keyword(~"mut") || - !self.is_any_keyword(copy self.token)) - && !self.token_is_pound_or_doc_comment(copy self.token)); + if self.eat_obsolete_ident("let") { + self.obsolete(copy self.last_span, ObsoleteLet); + } - if !parse_obsolete_method { - let a_var = self.parse_instance_var(vis); - match self.token { - token::SEMI => { - self.obsolete(copy self.span, ObsoleteFieldTerminator); - self.bump(); - } - token::COMMA => { - self.bump(); - } - token::RBRACE => {} - _ => { - self.span_fatal(copy self.span, - fmt!("expected `;`, `,`, or '}' but \ - found `%s`", - token_to_str(self.reader, - self.token))); - } - } - a_var - } else { - self.obsolete(copy self.span, ObsoleteClassMethod); - self.parse_method(); - // bogus value - @spanned( - self.span.lo, - self.span.hi, - ast::struct_field_ { - kind: unnamed_field, - id: self.get_id(), - ty: @ast::Ty { - id: self.get_id(), - node: ty_nil, - span: copy self.span, - } - } - ) + let a_var = self.parse_instance_var(vis); + match self.token { + token::SEMI => { + self.obsolete(copy self.span, ObsoleteFieldTerminator); + self.bump(); + } + token::COMMA => { + self.bump(); + } + token::RBRACE => {} + _ => { + self.span_fatal(copy self.span, + fmt!("expected `;`, `,`, or '}' but \ + found `%s`", + token_to_str(self.reader, + self.token))); + } } + a_var } fn parse_dtor(attrs: ~[attribute]) -> class_contents { @@ -3062,6 +3039,8 @@ pub impl Parser { return members(~[]); } + let attrs = self.parse_outer_attributes(); + if self.eat_keyword(~"priv") { return members(~[self.parse_single_class_item(private)]) } @@ -3070,8 +3049,6 @@ pub impl Parser { return members(~[self.parse_single_class_item(public)]); } - let attrs = self.parse_outer_attributes(); - if self.try_parse_obsolete_struct_ctor() { return members(~[]); } diff --git a/src/test/compile-fail/obsolete-syntax.rs b/src/test/compile-fail/obsolete-syntax.rs index 9001ca99ef287..d92b545d1701f 100644 --- a/src/test/compile-fail/obsolete-syntax.rs +++ b/src/test/compile-fail/obsolete-syntax.rs @@ -29,14 +29,6 @@ struct s { //~^ ERROR obsolete syntax: struct constructor } -struct ss { - fn foo() { } - //~^ ERROR obsolete syntax: class method - #[whatever] - fn foo() { } - //~^ ERROR obsolete syntax: class method -} - struct q : r { //~^ ERROR obsolete syntax: class traits } diff --git a/src/test/run-pass/issue-4830.rs b/src/test/run-pass/issue-4830.rs new file mode 100644 index 0000000000000..e8147a2ce8237 --- /dev/null +++ b/src/test/run-pass/issue-4830.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Scheduler { + /// The event loop used to drive the scheduler and perform I/O + priv event_loop: ~int +} + +pub fn main() { } From 6bfbdadd3bdb811c16f4aecd1f123c1a1eb0ee2e Mon Sep 17 00:00:00 2001 From: Brian Leibig Date: Sat, 9 Feb 2013 13:09:19 -0500 Subject: [PATCH 12/92] Add debug info tests --- configure | 1 + mk/tests.mk | 14 +++++++-- src/compiletest/common.rs | 5 +-- src/compiletest/compiletest.rc | 5 ++- src/compiletest/header.rs | 34 +++++++++++++++++--- src/compiletest/runtest.rs | 57 ++++++++++++++++++++++++++++++++-- src/test/debug-info/simple.rs | 21 +++++++++++++ src/test/debug-info/struct.rs | 33 ++++++++++++++++++++ 8 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 src/test/debug-info/simple.rs create mode 100644 src/test/debug-info/struct.rs diff --git a/configure b/configure index 531b3ce1efe06..56d40205b5cb7 100755 --- a/configure +++ b/configure @@ -619,6 +619,7 @@ do make_dir $h/test/bench make_dir $h/test/perf make_dir $h/test/pretty + make_dir $h/test/debug-info make_dir $h/test/doc-tutorial make_dir $h/test/doc-tutorial-ffi make_dir $h/test/doc-tutorial-macros diff --git a/mk/tests.mk b/mk/tests.mk index 2c1b19486af4b..b71c521c5c9a4 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -103,7 +103,8 @@ cleantestlibs: -name '*.dSYM' -o \ -name '*.libaux' -o \ -name '*.out' -o \ - -name '*.err' \ + -name '*.err' -o \ + -name '*.debugger.script' \ | xargs rm -rf @@ -284,6 +285,7 @@ CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc) CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs) BENCH_RS := $(wildcard $(S)src/test/bench/*.rs) PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs) +DEBUGINFO_RS := $(wildcard $(S)src/test/pretty/*.rs) # perf tests are the same as bench tests only they run under # a performance monitor. @@ -296,6 +298,7 @@ CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS) BENCH_TESTS := $(BENCH_RS) PERF_TESTS := $(PERF_RS) PRETTY_TESTS := $(PRETTY_RS) +DEBUGINFO_TESTS := $(DEBUGINFO_RS) CTEST_SRC_BASE_rpass = run-pass CTEST_BUILD_BASE_rpass = run-pass @@ -327,6 +330,11 @@ CTEST_BUILD_BASE_perf = perf CTEST_MODE_perf = run-pass CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL) +CTEST_SRC_BASE_debuginfo = debug-info +CTEST_BUILD_BASE_debuginfo = debug-info +CTEST_MODE_debuginfo = debug-info +CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL) + define DEF_CTEST_VARS # All the per-stage build rules you might want to call from the @@ -358,6 +366,7 @@ CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS) CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS) CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS) CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS) +CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS) endef @@ -388,7 +397,7 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ endef -CTEST_NAMES = rpass rpass-full rfail cfail bench perf +CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo $(foreach host,$(CFG_TARGET_TRIPLES), \ $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \ @@ -496,6 +505,7 @@ TEST_GROUPS = \ cfail \ bench \ perf \ + debuginfo \ doc \ $(foreach docname,$(DOC_TEST_NAMES),$(docname)) \ pretty \ diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 9d4becd63d390..679f9ab93bf08 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 mode { ~"run-fail" => mode_run_fail, ~"run-pass" => mode_run_pass, ~"pretty" => mode_pretty, + ~"debug-info" => mode_debug_info, _ => die!(~"invalid mode") } } @@ -140,7 +142,8 @@ pub fn mode_str(mode: mode) -> ~str { mode_compile_fail => ~"compile-fail", mode_run_fail => ~"run-fail", mode_run_pass => ~"run-pass", - mode_pretty => ~"pretty" + mode_pretty => ~"pretty", + mode_debug_info => ~"debug-info", } } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 0b9d67426ae35..5c33c66209a37 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 TestProps { let mut exec_env = ~[]; let mut compile_flags = None; let mut pp_exact = None; + let mut debugger_cmds = ~[]; + let mut check_lines = ~[]; for iter_header(testfile) |ln| { match parse_error_pattern(ln) { Some(ep) => error_patterns.push(ep), @@ -59,13 +65,25 @@ pub fn load_props(testfile: &Path) -> TestProps { do parse_exec_env(ln).iter |ee| { exec_env.push(*ee); } + + match parse_debugger_cmd(ln) { + Some(dc) => debugger_cmds.push(dc), + None => () + }; + + match parse_check_line(ln) { + Some(cl) => check_lines.push(cl), + None => () + }; }; return TestProps { error_patterns: error_patterns, compile_flags: compile_flags, pp_exact: pp_exact, aux_builds: aux_builds, - exec_env: exec_env + exec_env: exec_env, + debugger_cmds: debugger_cmds, + check_lines: check_lines }; } @@ -112,6 +130,14 @@ fn parse_compile_flags(line: ~str) -> Option<~str> { parse_name_value_directive(line, ~"compile-flags") } +fn parse_debugger_cmd(line: ~str) -> Option<~str> { + parse_name_value_directive(line, ~"debugger") +} + +fn parse_check_line(line: ~str) -> Option<~str> { + parse_name_value_directive(line, ~"check") +} + fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { do parse_name_value_directive(line, ~"exec-env").map |nv| { // nv is either FOO or FOO=BAR diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index a71b8a360a246..0f8c8761c427c 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 run_cfail_test(config, props, &testfile), mode_run_fail => run_rfail_test(config, props, &testfile), mode_run_pass => run_rpass_test(config, props, &testfile), - mode_pretty => run_pretty_test(config, props, &testfile) + mode_pretty => run_pretty_test(config, props, &testfile), + mode_debug_info => run_debuginfo_test(config, props, &testfile) } } @@ -224,6 +226,55 @@ actual:\n\ } } +fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) { + // compile test file (it shoud have 'compile-flags:-g' in the header) + let mut ProcRes = compile_test(config, props, testfile); + if ProcRes.status != 0 { + fatal_ProcRes(~"compilation failed!", ProcRes); + } + + // write debugger script + let script_str = str::append(str::connect(props.debugger_cmds, "\n"), + ~"\nquit\n"); + debug!("script_str = %s", script_str); + dump_output_file(config, testfile, script_str, ~"debugger.script"); + + // run debugger script with gdb + #[cfg(windows)] + fn debugger() -> ~str { ~"gdb.exe" } + #[cfg(unix)] + fn debugger() -> ~str { ~"gdb" } + let debugger_script = make_out_name(config, testfile, ~"debugger.script"); + let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx", + ~"-command=" + debugger_script.to_str(), + make_exe_name(config, testfile).to_str()]; + let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts}; + ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None); + if ProcRes.status != 0 { + fatal(~"gdb failed to execute"); + } + + let num_check_lines = vec::len(props.check_lines); + if num_check_lines > 0 { + // check if each line in props.check_lines appears in the + // output (in order) + let mut i = 0u; + for str::lines(ProcRes.stdout).each |line| { + if props.check_lines[i].trim() == line.trim() { + i += 1u; + } + if i == num_check_lines { + // all lines checked + break; + } + } + if i != num_check_lines { + fatal(fmt!("line not found in debugger output: %s", + props.check_lines[i])); + } + } +} + fn check_error_patterns(props: TestProps, testfile: &Path, ProcRes: ProcRes) { diff --git a/src/test/debug-info/simple.rs b/src/test/debug-info/simple.rs new file mode 100644 index 0000000000000..51bb177601ae1 --- /dev/null +++ b/src/test/debug-info/simple.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// compile-flags:-g +// debugger:break 20 +// debugger:run +// debugger:print x +// check:$1 = 42 + +fn main() { + let x = 42; + debug!("The answer is %d", x); +} diff --git a/src/test/debug-info/struct.rs b/src/test/debug-info/struct.rs new file mode 100644 index 0000000000000..b313291447794 --- /dev/null +++ b/src/test/debug-info/struct.rs @@ -0,0 +1,33 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// compile-flags:-g +// debugger:break 32 +// debugger:run +// debugger:print pair +// check:$1 = { +// check:x = 1, +// check:y = 2, +// check:} +// debugger:print pair.x +// check:$2 = 1 +// debugger:print pair.y +// check:$3 = 2 + +struct Pair { + x: int, + y: int +} + +fn main() { + let pair = Pair { x: 1, y: 2 }; + debug!("x = %d, y = %d", pair.x, pair.y); +} From 765961438d0a3f8f37f1e38160f6dca04870ae10 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 6 Feb 2013 16:20:41 -0800 Subject: [PATCH 13/92] fix typos in sample code, add enum to json encoder, add test case --- src/libstd/json.rs | 10 ++++-- src/libsyntax/ext/auto_encode.rs | 61 ++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 404f1bcda9902..2ad18fbced27a 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -122,9 +122,15 @@ pub impl Encoder: serialize::Encoder { fn emit_managed(&self, f: fn()) { f() } fn emit_enum(&self, name: &str, f: fn()) { - if name != "option" { die!(~"only supports option enum") } - f() + // emitting enums as arrays where the first + // element provides the enum variant name + self.wr.write_char('['); + self.wr.write_str(name); + self.wr.write_char(','); + f(); + self.wr.write_char(']'); } + fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { if id == 0 { self.emit_nil(); diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 21154bff01e9a..d8c15d09d98ea 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -23,23 +23,23 @@ For example, a type like: would generate two implementations like: - impl node_id: Encodable { - fn encode(s: &S) { - do s.emit_struct("Node", 1) { - s.emit_field("id", 0, || s.emit_uint(self)) - } +impl Node: Encodable { + fn encode(&self, s: &S) { + do s.emit_struct("Node", 1) { + s.emit_field("id", 0, || s.emit_uint(self.id)) } } +} - impl node_id: Decodable { - static fn decode(d: &D) -> Node { - do d.read_struct("Node", 1) { - Node { - id: d.read_field(~"x", 0, || decode(d)) - } +impl node_id: Decodable { + static fn decode(d: &D) -> Node { + do d.read_struct("Node", 1) { + Node { + id: d.read_field(~"x", 0, || decode(d)) } } } +} Other interesting scenarios are whe the item has type parameters or references other non-built-in types. A type definition like: @@ -1150,3 +1150,42 @@ fn mk_enum_deser_body( ] ) } + + +#[cfg(test)] +mod test { + use std::serialize::Encodable; + use core::dvec::*; + use util::testing::*; + use core::io; + use core::str; + use std; + + + #[auto_decode] + #[auto_encode] + struct Node {id: uint} + + fn to_json_str (val: Encodable) -> ~str{ + let bw = @io::BytesWriter {bytes: DVec(), pos: 0}; + val.encode(~std::json::Encoder(bw as io::Writer)); + str::from_bytes(bw.bytes.data) + } + + #[test] fn encode_test () { + check_equal (to_json_str(Node{id:34} as Encodable::),~"{\"id\":34}"); + } + + #[auto_encode] + enum written { + Book(int), + Magazine(~str) + } + + #[test] fn json_enum_encode_test () { + check_equal (to_json_str(Book(9) as Encodable::), + ~"[\"Book\",9]"); + check_equal (to_json_str(Magazine(~"Paris Match") as Encodable::), + ~"[\"Magazine\",\"Paris Match\"]"); + } +} From fe823743287fedd520e6c95b2380b7702c3fd966 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 6 Feb 2013 17:19:11 -0800 Subject: [PATCH 14/92] json bugfixes --- src/libstd/json.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 2ad18fbced27a..31f72c76e8c3c 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -122,24 +122,21 @@ pub impl Encoder: serialize::Encoder { fn emit_managed(&self, f: fn()) { f() } fn emit_enum(&self, name: &str, f: fn()) { + f() + } + + fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { // emitting enums as arrays where the first // element provides the enum variant name self.wr.write_char('['); - self.wr.write_str(name); + self.wr.write_str(escape_str(_name)); self.wr.write_char(','); f(); self.wr.write_char(']'); } - - fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { - if id == 0 { - self.emit_nil(); - } else { - f() - } - } fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { - f() + if _idx != 0 {self.wr.write_char(',');} + f(); } fn emit_borrowed_vec(&self, _len: uint, f: fn()) { From 394f8eeb7e658301b949759b105d846ae5847d51 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 6 Feb 2013 17:23:41 -0800 Subject: [PATCH 15/92] tidy --- src/libstd/json.rs | 12 ++++++------ src/libsyntax/ext/auto_encode.rs | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 31f72c76e8c3c..0d69730f1daa8 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -121,21 +121,21 @@ pub impl Encoder: serialize::Encoder { fn emit_owned(&self, f: fn()) { f() } fn emit_managed(&self, f: fn()) { f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, _name: &str, f: fn()) { f() } - - fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { + + fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) { // emitting enums as arrays where the first // element provides the enum variant name self.wr.write_char('['); - self.wr.write_str(escape_str(_name)); + self.wr.write_str(escape_str(name)); self.wr.write_char(','); f(); self.wr.write_char(']'); } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { - if _idx != 0 {self.wr.write_char(',');} + fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + if idx != 0 {self.wr.write_char(',');} f(); } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index d8c15d09d98ea..ae3b3ae0430ef 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -1160,8 +1160,7 @@ mod test { use core::io; use core::str; use std; - - + #[auto_decode] #[auto_encode] struct Node {id: uint} @@ -1171,9 +1170,11 @@ mod test { val.encode(~std::json::Encoder(bw as io::Writer)); str::from_bytes(bw.bytes.data) } - + #[test] fn encode_test () { - check_equal (to_json_str(Node{id:34} as Encodable::),~"{\"id\":34}"); + check_equal (to_json_str(Node{id:34} + as Encodable::), + ~"{\"id\":34}"); } #[auto_encode] @@ -1185,7 +1186,8 @@ mod test { #[test] fn json_enum_encode_test () { check_equal (to_json_str(Book(9) as Encodable::), ~"[\"Book\",9]"); - check_equal (to_json_str(Magazine(~"Paris Match") as Encodable::), + check_equal (to_json_str(Magazine(~"Paris Match") + as Encodable::), ~"[\"Magazine\",\"Paris Match\"]"); } } From 0e9495b980363eab634ec54bb177443e874d2508 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 7 Feb 2013 14:39:02 -0800 Subject: [PATCH 16/92] json bugfix --- src/libstd/json.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 0d69730f1daa8..e6156def61b32 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -130,12 +130,11 @@ pub impl Encoder: serialize::Encoder { // element provides the enum variant name self.wr.write_char('['); self.wr.write_str(escape_str(name)); - self.wr.write_char(','); f(); self.wr.write_char(']'); } fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { - if idx != 0 {self.wr.write_char(',');} + self.wr.write_char(','); f(); } From f91160b687e88c24e5163c8e6b1bd70d9619f8c3 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 7 Feb 2013 17:06:26 -0800 Subject: [PATCH 17/92] json add enum encoder test case --- src/libstd/json.rs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index e6156def61b32..dce4f421caa48 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -133,7 +133,8 @@ pub impl Encoder: serialize::Encoder { f(); self.wr.write_char(']'); } - fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + + fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { self.wr.write_char(','); f(); } @@ -1182,6 +1183,8 @@ mod tests { use core::result; use core::hashmap::linear::LinearMap; + use core::cmp; + fn mk_object(items: &[(~str, Json)]) -> Json { let mut d = ~LinearMap::new(); @@ -1249,6 +1252,43 @@ mod tests { assert a == b; } + // two fns copied from libsyntax/util/testing.rs. + // Should they be in their own crate? + pub pure fn check_equal_ptr (given : &T, expected: &T) { + if !((given == expected) && (expected == given )) { + die!(fmt!("given %?, expected %?",given,expected)); + } + } + + pub pure fn check_equal (given : T, expected: T) { + if !((given == expected) && (expected == given )) { + die!(fmt!("given %?, expected %?",given,expected)); + } + } + + // testing both auto_encode's calling patterns + // and json... not sure where to put these tests. + #[test] + fn test_write_enum () { + let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; + let bww : @io::Writer = (bw as @io::Writer); + let encoder = (@Encoder(bww) as @serialize::Encoder); + do encoder.emit_enum(~"animal") { + do encoder.emit_enum_variant (~"frog",37,1242) { + // name of frog: + do encoder.emit_enum_variant_arg (0) { + encoder.emit_owned_str(~"Henry") + } + // mass of frog in grams: + do encoder.emit_enum_variant_arg (1) { + encoder.emit_int(349); + } + } + } + check_equal(str::from_bytes(bw.bytes.data), + ~"[\"frog\",\"Henry\",349]"); + } + #[test] fn test_trailing_characters() { assert from_str(~"nulla") == From c952c0446294d59a5926268f60fb6a2076a7c97f Mon Sep 17 00:00:00 2001 From: John Clements Date: Fri, 8 Feb 2013 15:36:40 -0800 Subject: [PATCH 18/92] re-special-case Option in JSON encoding --- src/libstd/json.rs | 73 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index dce4f421caa48..07dbef64d2e4f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -126,16 +126,42 @@ pub impl Encoder: serialize::Encoder { } fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) { - // emitting enums as arrays where the first - // element provides the enum variant name - self.wr.write_char('['); - self.wr.write_str(escape_str(name)); - f(); - self.wr.write_char(']'); + // encoding of enums is special-cased for Option. Specifically: + // Some(34) => 34 + // None => null + + // other enums are encoded as vectors: + // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] + + // the default expansion for enums is more verbose than I'd like; + // specifically, the inner pair of brackets seems superfluous, + // BUT the design of the enumeration framework and the requirements + // of the special-case for Option mean that a first argument must + // be encoded "naked"--with no commas--and that the option name + // can't be followed by just a comma, because there might not + // be any elements in the tuple. + + // FIXME : this would be more precise and less frightening + // with fully-qualified option names. To get that information, + // we'd have to change the expansion of auto-encode to pass those along. + + if (name == ~"Some") { + f(); + } else if (name == ~"None") { + self.wr.write_str(~"null"); + } else { + self.wr.write_char('['); + self.wr.write_str(escape_str(name)); + self.wr.write_char(','); + self.wr.write_char('['); + f(); + self.wr.write_char(']'); + self.wr.write_char(']'); + } } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { - self.wr.write_char(','); + fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + if (idx != 0) {self.wr.write_char(',');} f(); } @@ -1286,7 +1312,36 @@ mod tests { } } check_equal(str::from_bytes(bw.bytes.data), - ~"[\"frog\",\"Henry\",349]"); + ~"[\"frog\",[\"Henry\",349]]"); + } + + #[test] + fn test_write_some () { + let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; + let bww : @io::Writer = (bw as @io::Writer); + let encoder = (@Encoder(bww) as @serialize::Encoder); + do encoder.emit_enum(~"Option") { + do encoder.emit_enum_variant (~"Some",37,1242) { + do encoder.emit_enum_variant_arg (0) { + encoder.emit_owned_str(~"jodhpurs") + } + } + } + check_equal(str::from_bytes(bw.bytes.data), + ~"\"jodhpurs\""); + } + + #[test] + fn test_write_none () { + let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; + let bww : @io::Writer = (bw as @io::Writer); + let encoder = (@Encoder(bww) as @serialize::Encoder); + do encoder.emit_enum(~"Option") { + do encoder.emit_enum_variant (~"None",37,1242) { + } + } + check_equal(str::from_bytes(bw.bytes.data), + ~"null"); } #[test] From 7736ed6c6251fcb3544d50c15290df6ac9542216 Mon Sep 17 00:00:00 2001 From: John Clements Date: Fri, 8 Feb 2013 18:58:33 -0800 Subject: [PATCH 19/92] json tidy --- src/libstd/json.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 07dbef64d2e4f..b6c4e3f11da6f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -132,7 +132,7 @@ pub impl Encoder: serialize::Encoder { // other enums are encoded as vectors: // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] - + // the default expansion for enums is more verbose than I'd like; // specifically, the inner pair of brackets seems superfluous, // BUT the design of the enumeration framework and the requirements @@ -140,10 +140,11 @@ pub impl Encoder: serialize::Encoder { // be encoded "naked"--with no commas--and that the option name // can't be followed by just a comma, because there might not // be any elements in the tuple. - - // FIXME : this would be more precise and less frightening + + // this would be more precise and less frightening // with fully-qualified option names. To get that information, - // we'd have to change the expansion of auto-encode to pass those along. + // we'd have to change the expansion of auto-encode to pass + // those along. if (name == ~"Some") { f(); @@ -170,6 +171,7 @@ pub impl Encoder: serialize::Encoder { f(); self.wr.write_char(']'); } + fn emit_owned_vec(&self, len: uint, f: fn()) { self.emit_borrowed_vec(len, f) } From 3742b62f64c8b2a01457b70ee37d3dc167a86a07 Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Mon, 7 Jan 2013 03:42:49 -0800 Subject: [PATCH 20/92] Omit discriminant from nullary univariant enums. If an enum is isomorphic to unit, there's no need to use any bits to represent it. The only obvious reason this wasn't the case was because the enum could be C-like and have a user-specified discriminant -- but that value is constant, so it doesn't need to be stored. This change means that all newtype-like enums have the same size (and layout) as their underlying type, which might be a useful property to have, at least in terms of making programs' low-level behavior less surprising. --- src/librustc/middle/trans/consts.rs | 11 +++++++---- src/librustc/middle/trans/expr.rs | 25 ++++++++++++++++++++----- src/librustc/middle/trans/type_of.rs | 7 ++----- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index bcf796caa7a4a..d86d4c97c3bed 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -407,6 +407,10 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { // variant or we wouldn't have gotten here -- the constant // checker forbids paths that don't map to C-like enum // variants. + if ty::enum_is_univariant(cx.tcx, enum_did) { + // Univariants have no discriminant field. + C_struct(~[]) + } else { let lldiscrim = base::get_discrim_val(cx, e.span, enum_did, variant_did); @@ -418,6 +422,7 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let padding = C_null(T_array(T_i8(), size)); C_struct(~[lldiscrim, padding]) } + } Some(ast::def_struct(_)) => { let ety = ty::expr_ty(cx.tcx, e); let llty = type_of::type_of(cx, ety); @@ -442,14 +447,14 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { } Some(ast::def_variant(tid, vid)) => { let ety = ty::expr_ty(cx.tcx, e); - let degen = ty::enum_is_univariant(cx.tcx, tid); + let univar = ty::enum_is_univariant(cx.tcx, tid); let size = machine::static_size_of_enum(cx, ety); let discrim = base::get_discrim_val(cx, e.span, tid, vid); let c_args = C_struct(args.map(|a| const_expr(cx, *a))); // FIXME (#1645): enum body alignment is generaly wrong. - if !degen { + if !univar { // Pad out the data to the size of its type_of; // this is necessary if the enum is contained // within an aggregate (tuple, struct, vector) so @@ -464,8 +469,6 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { // without affecting its internal alignment or // changing the alignment of the enum. C_struct(~[discrim, C_packed_struct(~[c_args]), padding]) - } else if size == 0 { - C_struct(~[discrim]) } else { C_struct(~[c_args]) } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index cab2adc43faa6..30ba0e7feeec8 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -674,12 +674,15 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: @ast::expr, // N-ary variant. let fn_data = callee::trans_fn_ref(bcx, vid, ref_expr.id); return fn_data_to_datum(bcx, vid, fn_data, lldest); - } else { + } else if !ty::enum_is_univariant(ccx.tcx, tid) { // Nullary variant. let lldiscrimptr = GEPi(bcx, lldest, [0u, 0u]); let lldiscrim = C_int(bcx.ccx(), variant_info.disr_val); Store(bcx, lldiscrim, lldiscrimptr); return bcx; + } else { + // Nullary univariant. + return bcx; } } ast::def_struct(*) => { @@ -1591,10 +1594,22 @@ fn trans_imm_cast(bcx: block, expr: @ast::expr, {in: cast_enum, out: cast_integral} | {in: cast_enum, out: cast_float} => { let bcx = bcx; - let llenumty = T_opaque_enum_ptr(ccx); - let av_enum = PointerCast(bcx, llexpr, llenumty); - let lldiscrim_a_ptr = GEPi(bcx, av_enum, [0u, 0u]); - let lldiscrim_a = Load(bcx, lldiscrim_a_ptr); + let in_tid = match ty::get(t_in).sty { + ty::ty_enum(did, _) => did, + _ => ccx.sess.bug(~"enum cast source is not enum") + }; + let variants = ty::enum_variants(ccx.tcx, in_tid); + let lldiscrim_a = if variants.len() == 1 { + // Univariants don't have a discriminant field, + // because there's only one value it could have: + C_integral(T_enum_discrim(ccx), + variants[0].disr_val as u64, True) + } else { + let llenumty = T_opaque_enum_ptr(ccx); + let av_enum = PointerCast(bcx, llexpr, llenumty); + let lldiscrim_a_ptr = GEPi(bcx, av_enum, [0u, 0u]); + Load(bcx, lldiscrim_a_ptr) + }; match k_out { cast_integral => int_cast(bcx, ll_t_out, val_ty(lldiscrim_a), diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 84a19cd4c0477..972f702c18a81 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -242,14 +242,11 @@ pub fn fill_type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t, debug!("type_of_enum %?: %?", t, ty::get(t)); let lltys = { - let degen = ty::enum_is_univariant(cx.tcx, did); + let univar = ty::enum_is_univariant(cx.tcx, did); let size = machine::static_size_of_enum(cx, t); - if !degen { + if !univar { ~[T_enum_discrim(cx), T_array(T_i8(), size)] } - else if size == 0u { - ~[T_enum_discrim(cx)] - } else { ~[T_array(T_i8(), size)] } From 4f843763a19ff50b8422c19e2c6e6743f3c84a9c Mon Sep 17 00:00:00 2001 From: Zack Corr Date: Sun, 10 Feb 2013 18:09:09 +1000 Subject: [PATCH 21/92] core: Remove GenericChan/Port from prelude. Closes #4762 --- src/libcore/prelude.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index a798d8c866a3f..9cf683fb9b677 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -34,7 +34,6 @@ pub use path::GenericPath; pub use path::Path; pub use path::PosixPath; pub use path::WindowsPath; -pub use pipes::{GenericChan, GenericPort}; pub use ptr::Ptr; pub use str::{StrSlice, Trimmable, OwnedStr}; pub use to_bytes::IterBytes; From e93a58d526e37c963f70e737080f1810c4c3388b Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Sun, 10 Feb 2013 11:16:54 -0800 Subject: [PATCH 22/92] rust-mode.el uses the 'cl macros, so it should actually require them Without this change, rust-mode doesn't work if 'cl hasn't been required by something else, apparently. I'm not entirely sure what changed such that I started seeing this problem instead of not, but maybe the emacs world has been making progress towards not loading 'cl at runtime if it's only needed at compile time. --- src/etc/emacs/rust-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el index d9ee135ac47b8..ef98fa669e346 100644 --- a/src/etc/emacs/rust-mode.el +++ b/src/etc/emacs/rust-mode.el @@ -7,6 +7,7 @@ (require 'cm-mode) (require 'cc-mode) +(eval-when-compile (require 'cl)) (defun rust-electric-brace (arg) (interactive "*P") From c05954a76bd601acda06807e80664c94831bae31 Mon Sep 17 00:00:00 2001 From: John Clements Date: Sun, 10 Feb 2013 11:25:46 -0800 Subject: [PATCH 23/92] added issue for reference in FIXME --- src/libstd/json.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index b6c4e3f11da6f..d5ad2f7fce735 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -141,7 +141,7 @@ pub impl Encoder: serialize::Encoder { // can't be followed by just a comma, because there might not // be any elements in the tuple. - // this would be more precise and less frightening + // FIXME #4872: this would be more precise and less frightening // with fully-qualified option names. To get that information, // we'd have to change the expansion of auto-encode to pass // those along. From 3a813e29b64dac9502f16b8cbaae6a6d16f9a687 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Wed, 30 Jan 2013 09:56:54 -0800 Subject: [PATCH 24/92] etc: rework of how libuv is integrated into the build - thanks to work in libuv's upstream, we can call libuv's Makefile directly with parameters, instead of descending in gyp-uv madness and generating our own. --- configure | 2 +- mk/libuv/arm/unix/android/Makefile | 354 ---------------- .../src/libuv/run-benchmarks.target.mk | 115 ------ .../android/src/libuv/run-tests.target.mk | 158 -------- .../arm/unix/android/src/libuv/uv.Makefile | 6 - .../arm/unix/android/src/libuv/uv.target.mk | 184 --------- mk/libuv/ia32/mac/Makefile | 379 ------------------ mk/libuv/ia32/mac/gyp-mac-tool | 193 --------- .../mac/src/libuv/run-benchmarks.target.mk | 149 ------- .../ia32/mac/src/libuv/run-tests.target.mk | 192 --------- mk/libuv/ia32/mac/src/libuv/uv.Makefile | 6 - mk/libuv/ia32/mac/src/libuv/uv.target.mk | 202 ---------- mk/libuv/ia32/unix/linux/Makefile | 354 ---------------- .../linux/src/libuv/run-benchmarks.target.mk | 122 ------ .../unix/linux/src/libuv/run-tests.target.mk | 165 -------- .../ia32/unix/linux/src/libuv/uv.Makefile | 6 - .../ia32/unix/linux/src/libuv/uv.target.mk | 189 --------- mk/libuv/ia32/win/Makefile | 354 ---------------- .../win/src/libuv/run-benchmarks.target.mk | 110 ----- .../ia32/win/src/libuv/run-tests.target.mk | 153 ------- mk/libuv/ia32/win/src/libuv/uv.Makefile | 6 - mk/libuv/ia32/win/src/libuv/uv.target.mk | 171 -------- mk/libuv/x86_64/mac/Makefile | 379 ------------------ mk/libuv/x86_64/mac/gyp-mac-tool | 193 --------- .../mac/src/libuv/run-benchmarks.target.mk | 149 ------- .../x86_64/mac/src/libuv/run-tests.target.mk | 192 --------- mk/libuv/x86_64/mac/src/libuv/uv.Makefile | 6 - mk/libuv/x86_64/mac/src/libuv/uv.target.mk | 202 ---------- mk/libuv/x86_64/unix/freebsd/Makefile | 354 ---------------- .../src/libuv/run-benchmarks.target.mk | 120 ------ .../freebsd/src/libuv/run-tests.target.mk | 163 -------- .../x86_64/unix/freebsd/src/libuv/uv.Makefile | 6 - .../unix/freebsd/src/libuv/uv.target.mk | 188 --------- mk/libuv/x86_64/unix/linux/Makefile | 354 ---------------- .../linux/src/libuv/run-benchmarks.target.mk | 122 ------ .../unix/linux/src/libuv/run-tests.target.mk | 165 -------- .../x86_64/unix/linux/src/libuv/uv.Makefile | 6 - .../x86_64/unix/linux/src/libuv/uv.target.mk | 189 --------- mk/libuv/x86_64/win/Makefile | 354 ---------------- .../win/src/libuv/run-benchmarks.target.mk | 110 ----- .../x86_64/win/src/libuv/run-tests.target.mk | 153 ------- mk/libuv/x86_64/win/src/libuv/uv.Makefile | 6 - mk/libuv/x86_64/win/src/libuv/uv.target.mk | 171 -------- mk/rt.mk | 12 +- src/etc/gyp-uv | 62 --- 45 files changed, 7 insertions(+), 7219 deletions(-) delete mode 100755 mk/libuv/arm/unix/android/Makefile delete mode 100755 mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk delete mode 100755 mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk delete mode 100755 mk/libuv/arm/unix/android/src/libuv/uv.Makefile delete mode 100755 mk/libuv/arm/unix/android/src/libuv/uv.target.mk delete mode 100644 mk/libuv/ia32/mac/Makefile delete mode 100755 mk/libuv/ia32/mac/gyp-mac-tool delete mode 100644 mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/ia32/mac/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/ia32/mac/src/libuv/uv.Makefile delete mode 100644 mk/libuv/ia32/mac/src/libuv/uv.target.mk delete mode 100644 mk/libuv/ia32/unix/linux/Makefile delete mode 100644 mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile delete mode 100644 mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk delete mode 100644 mk/libuv/ia32/win/Makefile delete mode 100644 mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/ia32/win/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/ia32/win/src/libuv/uv.Makefile delete mode 100644 mk/libuv/ia32/win/src/libuv/uv.target.mk delete mode 100644 mk/libuv/x86_64/mac/Makefile delete mode 100755 mk/libuv/x86_64/mac/gyp-mac-tool delete mode 100644 mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/x86_64/mac/src/libuv/uv.Makefile delete mode 100644 mk/libuv/x86_64/mac/src/libuv/uv.target.mk delete mode 100644 mk/libuv/x86_64/unix/freebsd/Makefile delete mode 100644 mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile delete mode 100644 mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk delete mode 100644 mk/libuv/x86_64/unix/linux/Makefile delete mode 100644 mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile delete mode 100644 mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk delete mode 100644 mk/libuv/x86_64/win/Makefile delete mode 100644 mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk delete mode 100644 mk/libuv/x86_64/win/src/libuv/run-tests.target.mk delete mode 100644 mk/libuv/x86_64/win/src/libuv/uv.Makefile delete mode 100644 mk/libuv/x86_64/win/src/libuv/uv.target.mk delete mode 100755 src/etc/gyp-uv diff --git a/configure b/configure index 531b3ce1efe06..15f005e0da6e6 100755 --- a/configure +++ b/configure @@ -578,7 +578,7 @@ do make_dir rt/$t for i in \ isaac linenoise sync test arch/i386 arch/x86_64 \ - libuv libuv/src/ares libuv/src/eio libuv/src/ev + libuv do make_dir rt/$t/$i done diff --git a/mk/libuv/arm/unix/android/Makefile b/mk/libuv/arm/unix/android/Makefile deleted file mode 100755 index 16323af2cd75c..0000000000000 --- a/mk/libuv/arm/unix/android/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/arm/unix/android" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=arm" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk b/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk deleted file mode 100755 index 20ff9609d8fd7..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,115 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk b/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk deleted file mode 100755 index c4d8c207c0884..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,158 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/arm/unix/android/src/libuv/uv.Makefile b/mk/libuv/arm/unix/android/src/libuv/uv.Makefile deleted file mode 100755 index ba3abfe493648..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/arm/unix/android/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/arm/unix/android/src/libuv/uv.target.mk b/mk/libuv/arm/unix/android/src/libuv/uv.target.mk deleted file mode 100755 index 2c23caef29ccb..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/uv.target.mk +++ /dev/null @@ -1,184 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_android.h"' \ - '-DEIO_CONFIG_H="config_android.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_android - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_android.h"' \ - '-DEIO_CONFIG_H="config_android.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_android - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/mac/Makefile b/mk/libuv/ia32/mac/Makefile deleted file mode 100644 index 002fef0390ab8..0000000000000 --- a/mk/libuv/ia32/mac/Makefile +++ /dev/null @@ -1,379 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_objc = CXX($(TOOLSET)) $@ -cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< - -quiet_cmd_objcxx = CXX($(TOOLSET)) $@ -cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# Commands for precompiled header files. -quiet_cmd_pch_c = CXX($(TOOLSET)) $@ -cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ -cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_m = CXX($(TOOLSET)) $@ -cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< -quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ -cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# gyp-mac-tool is written next to the root Makefile by gyp. -# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -# already. -quiet_cmd_mac_tool = MACTOOL $(4) $< -cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" - -quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ -cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) - -quiet_cmd_infoplist = INFOPLIST $@ -cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = LIBTOOL-STATIC $@ -cmd_alink = rm -f $@ && libtool -static -o $@ $(filter %.o,$^) - -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): Find out and document the difference between shared_library and -# loadable_module on mac. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass -# -bundle -single_module here (for osmesa.so). -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 2,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/mac" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=mac" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/mac/gyp-mac-tool b/mk/libuv/ia32/mac/gyp-mac-tool deleted file mode 100755 index bd4059840ea8a..0000000000000 --- a/mk/libuv/ia32/mac/gyp-mac-tool +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# Generated by gyp. Do not edit. -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Utility functions to perform Xcode-style build steps. - -These functions are executed via gyp-mac-tool when using the Makefile generator. -""" - -import os -import fcntl -import plistlib -import shutil -import string -import subprocess -import sys - - -def main(args): - executor = MacTool() - executor.Dispatch(args) - - -class MacTool(object): - """This class performs all the Mac tooling steps. The methods can either be - executed directly, or dispatched from an argument list.""" - - def Dispatch(self, args): - """Dispatches a string command to a method.""" - if len(args) < 1: - raise Exception("Not enough arguments") - - method = "Exec%s" % self._CommandifyName(args[0]) - getattr(self, method)(*args[1:]) - - def _CommandifyName(self, name_string): - """Transforms a tool name like copy-info-plist to CopyInfoPlist""" - return name_string.title().replace('-', '') - - def ExecFlock(self, lockfile, *cmd_list): - """Emulates the most basic behavior of Linux's flock(1).""" - # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - return subprocess.call(cmd_list) - - def ExecCopyInfoPlist(self, source, dest): - """Copies the |source| Info.plist to the destination directory |dest|.""" - # Read the source Info.plist into memory. - fd = open(source, 'r') - lines = fd.read() - fd.close() - - # Go through all the environment variables and replace them as variables in - # the file. - for key in os.environ: - if key.startswith('_'): - continue - evar = '${%s}' % key - lines = string.replace(lines, evar, os.environ[key]) - - # Write out the file with variables replaced. - fd = open(dest, 'w') - fd.write(lines) - fd.close() - - # Now write out PkgInfo file now that the Info.plist file has been - # "compiled". - self._WritePkgInfo(dest) - - def _WritePkgInfo(self, info_plist): - """This writes the PkgInfo file from the data stored in Info.plist.""" - plist = plistlib.readPlist(info_plist) - if not plist: - return - - # Only create PkgInfo for executable types. - package_type = plist['CFBundlePackageType'] - if package_type != 'APPL': - return - - # The format of PkgInfo is eight characters, representing the bundle type - # and bundle signature, each four characters. If that is missing, four - # '?' characters are used instead. - signature_code = plist['CFBundleSignature'] - if len(signature_code) != 4: - signature_code = '?' * 4 - - dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') - fp = open(dest, 'w') - fp.write('%s%s' % (package_type, signature_code)) - fp.close() - - def ExecPackageFramework(self, framework, version): - """Takes a path to Something.framework and the Current version of that and - sets up all the symlinks.""" - # Find the name of the binary based on the part before the ".framework". - binary = os.path.basename(framework).split('.')[0] - - CURRENT = 'Current' - RESOURCES = 'Resources' - VERSIONS = 'Versions' - - if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): - # Binary-less frameworks don't seem to contain symlinks (see e.g. - # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). - return - - # Move into the framework directory to set the symlinks correctly. - pwd = os.getcwd() - os.chdir(framework) - - # Set up the Current version. - self._Relink(version, os.path.join(VERSIONS, CURRENT)) - - # Set up the root symlinks. - self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) - self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) - - # Back to where we were before! - os.chdir(pwd) - - def _Relink(self, dest, link): - """Creates a symlink to |dest| named |link|. If |link| already exists, - it is overwritten.""" - if os.path.lexists(link): - os.remove(link) - os.symlink(dest, link) - - def ExecCopyBundleResource(self, source, dest): - """Copies a resource file to the bundle/Resources directory, performing any - necessary compilation on each resource.""" - extension = os.path.splitext(source)[1].lower() - if os.path.isdir(source): - # Copy tree. - if os.path.exists(dest): - shutil.rmtree(dest) - shutil.copytree(source, dest) - elif extension == '.xib': - self._CopyXIBFile(source, dest) - elif extension == '.strings': - self._CopyStringsFile(source, dest) - # TODO: Given that files with arbitrary extensions can be copied to the - # bundle, we will want to get rid of this whitelist eventually. - elif extension in [ - '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', - '.ttf', '.sdef']: - shutil.copyfile(source, dest) - else: - raise NotImplementedError( - "Don't know how to copy bundle resources of type %s while copying " - "%s to %s)" % (extension, source, dest)) - - def _CopyXIBFile(self, source, dest): - """Compiles a XIB file with ibtool into a binary plist in the bundle.""" - args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', - '--notices', '--output-format', 'human-readable-text', '--compile', - dest, source] - subprocess.call(args) - - def _CopyStringsFile(self, source, dest): - """Copies a .strings file using iconv to reconvert the input into UTF-16.""" - input_code = self._DetectInputEncoding(source) or "UTF-8" - fp = open(dest, 'w') - args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', - 'UTF-16', source] - subprocess.call(args, stdout=fp) - fp.close() - - def _DetectInputEncoding(self, file_name): - """Reads the first few bytes from file_name and tries to guess the text - encoding. Returns None as a guess if it can't detect it.""" - fp = open(file_name, 'rb') - try: - header = fp.read(3) - except e: - fp.close() - return None - fp.close() - if header.startswith("\xFE\xFF"): - return "UTF-16BE" - elif header.startswith("\xFF\xFE"): - return "UTF-16LE" - elif header.startswith("\xEF\xBB\xBF"): - return "UTF-8" - else: - return None - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index b8cc0a1c483ec..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,149 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk b/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk deleted file mode 100644 index be0c2c6085633..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,192 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/mac/src/libuv/uv.Makefile b/mk/libuv/ia32/mac/src/libuv/uv.Makefile deleted file mode 100644 index cef4568a6d0ba..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/mac/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/mac/src/libuv/uv.target.mk b/mk/libuv/ia32/mac/src/libuv/uv.target.mk deleted file mode 100644 index 9838606098248..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/uv.target.mk +++ /dev/null @@ -1,202 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/darwin.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -arch i386 \ - -L$(builddir) - -LIBS := -lm - -$(builddir)/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/libuv.a: LIBS := $(LIBS) -$(builddir)/libuv.a: TOOLSET := $(TOOLSET) -$(builddir)/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(builddir)/libuv.a -# Add target alias -.PHONY: uv -uv: $(builddir)/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/unix/linux/Makefile b/mk/libuv/ia32/unix/linux/Makefile deleted file mode 100644 index 1afa619357014..0000000000000 --- a/mk/libuv/ia32/unix/linux/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/unix/linux" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25b01014e79d4..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,122 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk deleted file mode 100644 index a2fe0d2065e23..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,165 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile b/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile deleted file mode 100644 index fb013a6f4b16b..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/unix/linux/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk deleted file mode 100644 index 60e0e8fd2def6..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk +++ /dev/null @@ -1,189 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/win/Makefile b/mk/libuv/ia32/win/Makefile deleted file mode 100644 index 8a6222228d891..0000000000000 --- a/mk/libuv/ia32/win/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/win" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=win" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25bf58f854886..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,110 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/win/src/libuv/run-tests.target.mk b/mk/libuv/ia32/win/src/libuv/run-tests.target.mk deleted file mode 100644 index 51b62f7a3e2d5..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,153 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/win/src/libuv/uv.Makefile b/mk/libuv/ia32/win/src/libuv/uv.Makefile deleted file mode 100644 index 65df03050e5ce..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/win/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/win/src/libuv/uv.target.mk b/mk/libuv/ia32/win/src/libuv/uv.target.mk deleted file mode 100644 index 53576a0f93570..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/uv.target.mk +++ /dev/null @@ -1,171 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getenv.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_platform.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/async.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/handle.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/loop-watcher.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/req.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/timer.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/util.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winapi.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winsock.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/mac/Makefile b/mk/libuv/x86_64/mac/Makefile deleted file mode 100644 index bae2ca0016bfd..0000000000000 --- a/mk/libuv/x86_64/mac/Makefile +++ /dev/null @@ -1,379 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_objc = CXX($(TOOLSET)) $@ -cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< - -quiet_cmd_objcxx = CXX($(TOOLSET)) $@ -cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# Commands for precompiled header files. -quiet_cmd_pch_c = CXX($(TOOLSET)) $@ -cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ -cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_m = CXX($(TOOLSET)) $@ -cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< -quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ -cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# gyp-mac-tool is written next to the root Makefile by gyp. -# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -# already. -quiet_cmd_mac_tool = MACTOOL $(4) $< -cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" - -quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ -cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) - -quiet_cmd_infoplist = INFOPLIST $@ -cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = LIBTOOL-STATIC $@ -cmd_alink = rm -f $@ && libtool -static -o $@ $(filter %.o,$^) - -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): Find out and document the difference between shared_library and -# loadable_module on mac. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass -# -bundle -single_module here (for osmesa.so). -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 2,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/mac" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=mac" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/mac/gyp-mac-tool b/mk/libuv/x86_64/mac/gyp-mac-tool deleted file mode 100755 index bd4059840ea8a..0000000000000 --- a/mk/libuv/x86_64/mac/gyp-mac-tool +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# Generated by gyp. Do not edit. -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Utility functions to perform Xcode-style build steps. - -These functions are executed via gyp-mac-tool when using the Makefile generator. -""" - -import os -import fcntl -import plistlib -import shutil -import string -import subprocess -import sys - - -def main(args): - executor = MacTool() - executor.Dispatch(args) - - -class MacTool(object): - """This class performs all the Mac tooling steps. The methods can either be - executed directly, or dispatched from an argument list.""" - - def Dispatch(self, args): - """Dispatches a string command to a method.""" - if len(args) < 1: - raise Exception("Not enough arguments") - - method = "Exec%s" % self._CommandifyName(args[0]) - getattr(self, method)(*args[1:]) - - def _CommandifyName(self, name_string): - """Transforms a tool name like copy-info-plist to CopyInfoPlist""" - return name_string.title().replace('-', '') - - def ExecFlock(self, lockfile, *cmd_list): - """Emulates the most basic behavior of Linux's flock(1).""" - # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - return subprocess.call(cmd_list) - - def ExecCopyInfoPlist(self, source, dest): - """Copies the |source| Info.plist to the destination directory |dest|.""" - # Read the source Info.plist into memory. - fd = open(source, 'r') - lines = fd.read() - fd.close() - - # Go through all the environment variables and replace them as variables in - # the file. - for key in os.environ: - if key.startswith('_'): - continue - evar = '${%s}' % key - lines = string.replace(lines, evar, os.environ[key]) - - # Write out the file with variables replaced. - fd = open(dest, 'w') - fd.write(lines) - fd.close() - - # Now write out PkgInfo file now that the Info.plist file has been - # "compiled". - self._WritePkgInfo(dest) - - def _WritePkgInfo(self, info_plist): - """This writes the PkgInfo file from the data stored in Info.plist.""" - plist = plistlib.readPlist(info_plist) - if not plist: - return - - # Only create PkgInfo for executable types. - package_type = plist['CFBundlePackageType'] - if package_type != 'APPL': - return - - # The format of PkgInfo is eight characters, representing the bundle type - # and bundle signature, each four characters. If that is missing, four - # '?' characters are used instead. - signature_code = plist['CFBundleSignature'] - if len(signature_code) != 4: - signature_code = '?' * 4 - - dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') - fp = open(dest, 'w') - fp.write('%s%s' % (package_type, signature_code)) - fp.close() - - def ExecPackageFramework(self, framework, version): - """Takes a path to Something.framework and the Current version of that and - sets up all the symlinks.""" - # Find the name of the binary based on the part before the ".framework". - binary = os.path.basename(framework).split('.')[0] - - CURRENT = 'Current' - RESOURCES = 'Resources' - VERSIONS = 'Versions' - - if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): - # Binary-less frameworks don't seem to contain symlinks (see e.g. - # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). - return - - # Move into the framework directory to set the symlinks correctly. - pwd = os.getcwd() - os.chdir(framework) - - # Set up the Current version. - self._Relink(version, os.path.join(VERSIONS, CURRENT)) - - # Set up the root symlinks. - self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) - self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) - - # Back to where we were before! - os.chdir(pwd) - - def _Relink(self, dest, link): - """Creates a symlink to |dest| named |link|. If |link| already exists, - it is overwritten.""" - if os.path.lexists(link): - os.remove(link) - os.symlink(dest, link) - - def ExecCopyBundleResource(self, source, dest): - """Copies a resource file to the bundle/Resources directory, performing any - necessary compilation on each resource.""" - extension = os.path.splitext(source)[1].lower() - if os.path.isdir(source): - # Copy tree. - if os.path.exists(dest): - shutil.rmtree(dest) - shutil.copytree(source, dest) - elif extension == '.xib': - self._CopyXIBFile(source, dest) - elif extension == '.strings': - self._CopyStringsFile(source, dest) - # TODO: Given that files with arbitrary extensions can be copied to the - # bundle, we will want to get rid of this whitelist eventually. - elif extension in [ - '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', - '.ttf', '.sdef']: - shutil.copyfile(source, dest) - else: - raise NotImplementedError( - "Don't know how to copy bundle resources of type %s while copying " - "%s to %s)" % (extension, source, dest)) - - def _CopyXIBFile(self, source, dest): - """Compiles a XIB file with ibtool into a binary plist in the bundle.""" - args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', - '--notices', '--output-format', 'human-readable-text', '--compile', - dest, source] - subprocess.call(args) - - def _CopyStringsFile(self, source, dest): - """Copies a .strings file using iconv to reconvert the input into UTF-16.""" - input_code = self._DetectInputEncoding(source) or "UTF-8" - fp = open(dest, 'w') - args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', - 'UTF-16', source] - subprocess.call(args, stdout=fp) - fp.close() - - def _DetectInputEncoding(self, file_name): - """Reads the first few bytes from file_name and tries to guess the text - encoding. Returns None as a guess if it can't detect it.""" - fp = open(file_name, 'rb') - try: - header = fp.read(3) - except e: - fp.close() - return None - fp.close() - if header.startswith("\xFE\xFF"): - return "UTF-16BE" - elif header.startswith("\xFF\xFE"): - return "UTF-16LE" - elif header.startswith("\xEF\xBB\xBF"): - return "UTF-8" - else: - return None - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index f5930c9dc564d..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,149 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk deleted file mode 100644 index 4694c7cfd4d6a..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,192 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/mac/src/libuv/uv.Makefile b/mk/libuv/x86_64/mac/src/libuv/uv.Makefile deleted file mode 100644 index 48cdc76e17524..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/mac/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/mac/src/libuv/uv.target.mk b/mk/libuv/x86_64/mac/src/libuv/uv.target.mk deleted file mode 100644 index 385a64c9f538b..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/uv.target.mk +++ /dev/null @@ -1,202 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/darwin.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -arch x86_64 \ - -L$(builddir) - -LIBS := -lm - -$(builddir)/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/libuv.a: LIBS := $(LIBS) -$(builddir)/libuv.a: TOOLSET := $(TOOLSET) -$(builddir)/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(builddir)/libuv.a -# Add target alias -.PHONY: uv -uv: $(builddir)/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/unix/freebsd/Makefile b/mk/libuv/x86_64/unix/freebsd/Makefile deleted file mode 100644 index d77345c740e8e..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/unix/freebsd" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=freebsd" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index d65e86b00d34b..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,120 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lkvm - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk deleted file mode 100644 index 67f22eabb9323..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,163 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lkvm - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile b/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile deleted file mode 100644 index f49a7fb5ebf51..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/unix/freebsd/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk deleted file mode 100644 index 49319f7c02387..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk +++ /dev/null @@ -1,188 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_freebsd.h"' \ - '-DEIO_CONFIG_H="config_freebsd.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_freebsd - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_freebsd.h"' \ - '-DEIO_CONFIG_H="config_freebsd.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_freebsd - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/freebsd.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/unix/linux/Makefile b/mk/libuv/x86_64/unix/linux/Makefile deleted file mode 100644 index 72da220759968..0000000000000 --- a/mk/libuv/x86_64/unix/linux/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/unix/linux" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25b01014e79d4..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,122 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk deleted file mode 100644 index a2fe0d2065e23..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,165 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile b/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile deleted file mode 100644 index bd68c31a92062..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/unix/linux/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk deleted file mode 100644 index 60e0e8fd2def6..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk +++ /dev/null @@ -1,189 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/win/Makefile b/mk/libuv/x86_64/win/Makefile deleted file mode 100644 index d40391e0f8988..0000000000000 --- a/mk/libuv/x86_64/win/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/win" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=win" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25bf58f854886..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,110 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk deleted file mode 100644 index 51b62f7a3e2d5..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,153 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/win/src/libuv/uv.Makefile b/mk/libuv/x86_64/win/src/libuv/uv.Makefile deleted file mode 100644 index 5c4f359e86ad2..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/win/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/win/src/libuv/uv.target.mk b/mk/libuv/x86_64/win/src/libuv/uv.target.mk deleted file mode 100644 index 53576a0f93570..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/uv.target.mk +++ /dev/null @@ -1,171 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getenv.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_platform.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/async.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/handle.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/loop-watcher.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/req.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/timer.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/util.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winapi.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winsock.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/rt.mk b/mk/rt.mk index eff16f510f9ae..2841ff25a0c6e 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -88,16 +88,16 @@ endif ifeq ($$(CFG_WINDOWSY), 1) LIBUV_OSTYPE_$(1) := win - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else ifeq ($(CFG_OSTYPE), apple-darwin) LIBUV_OSTYPE_$(1) := mac - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else ifeq ($(CFG_OSTYPE), unknown-freebsd) LIBUV_OSTYPE_$(1) := unix/freebsd - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else LIBUV_OSTYPE_$(1) := unix/linux - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a endif RUNTIME_DEF_$(1) := rt/rustrt$$(CFG_DEF_SUFFIX) @@ -158,7 +158,7 @@ LIBUV_DEPS := $$(wildcard \ endif $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) - $$(Q)$$(MAKE) -C $$(S)mk/libuv/$$(LIBUV_ARCH_$(1))/$$(LIBUV_OSTYPE_$(1)) \ + $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \ CC="$$(CFG_GCCISH_CROSS)$$(CC)" \ @@ -166,7 +166,7 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) AR="$$(CFG_GCCISH_CROSS)$$(AR)" \ BUILDTYPE=Release \ builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ - V=$$(VERBOSE) FLOCK= uv + V=$$(VERBOSE) FLOCK= # These could go in rt.mk or rustllvm.mk, they're needed for both. diff --git a/src/etc/gyp-uv b/src/etc/gyp-uv deleted file mode 100755 index e64ed4f30597c..0000000000000 --- a/src/etc/gyp-uv +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -# This script generates rust compatible makefiles from libuv. When upgrading -# libuv, do: -# -# cd $RUST_DIR -# cd src/libuv -# git checkout master -# git pull -# svn co http://gyp.googlecode.com/svn/trunk build/gyp -# cd ../.. -# rm -r mk/libuv -# ./src/etc/gyp-uv -# -# Note: you must not run gyp on windows. It will get the backslashes -# incorrect in its rules, and not work. - -set -e - -cd `dirname $0` -cd ../.. - -GYPFILE=src/libuv/uv.gyp -INCLUDES="-I src/libuv/common.gypi" - -for ARCH in ia32 x86_64 -do - ARGS="$GYPFILE \ - $INCLUDES \ - --depth . \ - -Dcomponent=static_library \ - -Dlibrary=static_library \ - -Dtarget_arch=$ARCH" - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-mac \ - --generator-output mk/libuv/$ARCH/mac \ - -DOS=mac - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-linux \ - --generator-output mk/libuv/$ARCH/unix \ - -DOS=linux - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-linux \ - --generator-output mk/libuv/$ARCH/win \ - -DOS=win - -done - -# On Mac, GYP hardcodes a -arch i386 into the output. Fix that. -sed -i \ - -e 's/-arch i386/-arch x86_64/' \ - mk/libuv/x86_64/mac/src/libuv/*.mk - -MKFILES=$(find mk/libuv -name \*.mk -o -name Makefile) - -# Comment out the gyp auto regeneration -perl -i -p -e 's@^(Makefile:.*)@#\1@go' $MKFILES -perl -i -p -e 's@^(Makefile:.*)@#\1@go' $MKFILES -perl -i -p -e 's@(.*regen_makefile.*)@#\1@go' $MKFILES From dfcdb6eb729fa51cac47f219a90a9f894819f343 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Wed, 30 Jan 2013 10:28:27 -0800 Subject: [PATCH 25/92] rt/std: update of libuv API glue for libuv submodule update --- src/libstd/uv_iotask.rs | 14 ++- src/libstd/uv_ll.rs | 215 ++++++++++++++++++---------------------- src/rt/rust_uv.cpp | 12 +-- src/rt/rustrt.def.in | 2 +- 4 files changed, 111 insertions(+), 132 deletions(-) diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index a44fef54b726a..da5fbc3438a1c 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -185,15 +185,19 @@ fn begin_teardown(data: *IoTaskLoopData) { ll::close(async_handle as *c_void, tear_down_close_cb); } } +extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) { + log(debug, ~"IN TEARDOWN WALK CB BOYEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); + // pretty much, if we still have an active handle and it is *not* + // the async handle that facilities global loop communication, we + // want to barf out and fail + assert handle == arg; +} extern fn tear_down_close_cb(handle: *ll::uv_async_t) { unsafe { let loop_ptr = ll::get_loop_for_uv_handle(handle); - let loop_refs = ll::loop_refcount(loop_ptr); - log(debug, - fmt!("tear_down_close_cb called, closing handle at %? refs %?", - handle, loop_refs)); - assert loop_refs == 1i32; + log(debug, ~"in tear_down_close_cb"); + ll::walk(loop_ptr, tear_down_walk_cb, handle as *libc::c_void); } } diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index a3e02ca707066..fb8bbcebf7fc9 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -90,7 +90,7 @@ pub struct uv_stream_t { fields: uv_handle_fields, } -// 64bit unix size: 272 +// 64bit unix size: 216 #[cfg(unix)] pub struct uv_tcp_t { fields: uv_handle_fields, @@ -99,10 +99,8 @@ pub struct uv_tcp_t { a08: *u8, a09: *u8, a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8, a16: *u8, a17: *u8, a18: *u8, a19: *u8, - a20: *u8, a21: *u8, a22: *u8, a23: *u8, - a24: *u8, a25: *u8, a26: *u8, a27: *u8, - a28: *u8, - a30: uv_tcp_t_32bit_unix_riders, + a20: *u8, a21: *u8, + a22: uv_tcp_t_32bit_unix_riders, } // 32bit unix size: 328 (164) #[cfg(target_arch="x86_64")] @@ -113,8 +111,6 @@ pub struct uv_tcp_t_32bit_unix_riders { #[cfg(target_arch="arm")] pub struct uv_tcp_t_32bit_unix_riders { a29: *u8, a30: *u8, a31: *u8, - a32: *u8, a33: *u8, a34: *u8, - a35: *u8, a36: *u8, } // 32bit win32 size: 240 (120) @@ -130,11 +126,11 @@ pub struct uv_tcp_t { a24: *u8, a25: *u8, } -// unix size: 48 +// unix size: 64 #[cfg(unix)] pub struct uv_connect_t { a00: *u8, a01: *u8, a02: *u8, a03: *u8, - a04: *u8, a05: *u8, + a04: *u8, a05: *u8, a06: *u8, a07: *u8 } // win32 size: 88 (44) #[cfg(windows)] @@ -152,7 +148,7 @@ pub struct uv_buf_t { // no gen stub method.. should create // it via uv::direct::buf_init() -// unix size: 144 +// unix size: 160 #[cfg(unix)] pub struct uv_write_t { fields: uv_handle_fields, @@ -164,12 +160,13 @@ pub struct uv_write_t { } #[cfg(target_arch="x86_64")] pub struct uv_write_t_32bit_unix_riders { - a13: *u8, + a13: *u8, a14: *u8, a15: *u8 } #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_write_t_32bit_unix_riders { - a13: *u8, a14: *u8, + a13: *u8, a14: *u8, a15: *u8, + a16: *u8, } // win32 size: 136 (68) #[cfg(windows)] @@ -180,15 +177,14 @@ pub struct uv_write_t { a08: *u8, a09: *u8, a10: *u8, a11: *u8, a12: *u8, } -// 64bit unix size: 120 +// 64bit unix size: 96 // 32bit unix size: 152 (76) #[cfg(unix)] pub struct uv_async_t { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, - a04: *u8, a05: *u8, a06: *u8, a07: *u8, - a08: *u8, a09: *u8, - a11: uv_async_t_32bit_unix_riders, + a04: *u8, a05: *u8, a06: *u8, + a07: uv_async_t_32bit_unix_riders, } #[cfg(target_arch="x86_64")] pub struct uv_async_t_32bit_unix_riders { @@ -197,7 +193,7 @@ pub struct uv_async_t_32bit_unix_riders { #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_async_t_32bit_unix_riders { - a10: *u8, a11: *u8, a12: *u8, a13: *u8, + a10: *u8, } // win32 size 132 (68) #[cfg(windows)] @@ -209,7 +205,7 @@ pub struct uv_async_t { a12: *u8, } -// 64bit unix size: 128 +// 64bit unix size: 120 // 32bit unix size: 84 #[cfg(unix)] pub struct uv_timer_t { @@ -221,13 +217,12 @@ pub struct uv_timer_t { } #[cfg(target_arch="x86_64")] pub struct uv_timer_t_32bit_unix_riders { - a10: *u8, a11: *u8, + a10: *u8, } #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_timer_t_32bit_unix_riders { - a10: *u8, a11: *u8, a12: *u8, a13: *u8, - a14: *u8, a15: *u8, a16: *u8, + a10: *u8, a11: *u8, a12: *u8 } // win32 size: 64 #[cfg(windows)] @@ -325,7 +320,8 @@ pub mod addrinfo_impl { // unix size: 72 pub struct uv_getaddrinfo_t { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, - a06: *u8, a07: *u8, a08: *u8, + a06: *u8, a07: *u8, a08: *u8, a09: *u8, + a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8 } pub mod uv_ll_struct_stubgen { @@ -378,12 +374,8 @@ pub mod uv_ll_struct_stubgen { a15: 0 as *u8, a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, a19: 0 as *u8, - a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, - a23: 0 as *u8, - a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, - a27: 0 as *u8, - a28: 0 as *u8, - a30: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8 }, + a20: 0 as *u8, a21: 0 as *u8, + a22: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8 }, } } #[cfg(target_arch="x86")] @@ -405,15 +397,9 @@ pub mod uv_ll_struct_stubgen { a15: 0 as *u8, a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, a19: 0 as *u8, - a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, - a23: 0 as *u8, - a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, - a27: 0 as *u8, - a28: 0 as *u8, - a30: uv_tcp_t_32bit_unix_riders { + a20: 0 as *u8, a21: 0 as *u8, + a22: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8, a30: 0 as *u8, a31: 0 as *u8, - a32: 0 as *u8, a33: 0 as *u8, a34: 0 as *u8, - a35: 0 as *u8, a36: 0 as *u8, }, } } @@ -447,7 +433,8 @@ pub mod uv_ll_struct_stubgen { uv_connect_t { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, - a04: 0 as *u8, a05: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8 } } #[cfg(windows)] @@ -474,9 +461,7 @@ pub mod uv_ll_struct_stubgen { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, - a07: 0 as *u8, - a08: 0 as *u8, a09: 0 as *u8, - a11: uv_async_t_32bit_unix_riders { a10: 0 as *u8 }, + a07: uv_async_t_32bit_unix_riders { a10: 0 as *u8 }, } } #[cfg(target_arch = "x86")] @@ -491,11 +476,8 @@ pub mod uv_ll_struct_stubgen { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, - a07: 0 as *u8, - a08: 0 as *u8, a09: 0 as *u8, - a11: uv_async_t_32bit_unix_riders { - a10: 0 as *u8, a11: 0 as *u8, - a12: 0 as *u8, a13: 0 as *u8 + a07: uv_async_t_32bit_unix_riders { + a10: 0 as *u8, } } } @@ -534,7 +516,7 @@ pub mod uv_ll_struct_stubgen { a07: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a11: uv_timer_t_32bit_unix_riders { - a10: 0 as *u8, a11: 0 as *u8 + a10: 0 as *u8 }, } } @@ -554,9 +536,7 @@ pub mod uv_ll_struct_stubgen { a08: 0 as *u8, a09: 0 as *u8, a11: uv_timer_t_32bit_unix_riders { a10: 0 as *u8, a11: 0 as *u8, - a12: 0 as *u8, a13: 0 as *u8, - a14: 0 as *u8, a15: 0 as *u8, - a16: 0 as *u8, + a12: 0 as *u8, }, } } @@ -595,7 +575,9 @@ pub mod uv_ll_struct_stubgen { a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a11: 0 as *u8, a12: 0 as *u8, - a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8 }, + a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8, + a14: 0 as *u8, + a15: 0 as *u8}, } } #[cfg(target_arch="x86")] @@ -617,6 +599,8 @@ pub mod uv_ll_struct_stubgen { a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, } } } @@ -642,7 +626,9 @@ pub mod uv_ll_struct_stubgen { uv_getaddrinfo_t { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a07: 0 as *u8, - a08: 0 as *u8 + a08: 0 as *u8, a09: 0 as *u8, + a10: 1 as *u8, a11: 1 as *u8, a12: 1 as *u8, a13: 1 as *u8, + a14: 1 as *u8, a15: 1 as *u8 } } } @@ -652,9 +638,10 @@ extern mod rustrt { // libuv public API unsafe fn rust_uv_loop_new() -> *libc::c_void; unsafe fn rust_uv_loop_delete(lp: *libc::c_void); - unsafe fn rust_uv_loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int; unsafe fn rust_uv_run(loop_handle: *libc::c_void); unsafe fn rust_uv_close(handle: *libc::c_void, cb: *u8); + unsafe fn rust_uv_walk(loop_handle: *libc::c_void, cb: *u8, + arg: *libc::c_void); unsafe fn rust_uv_async_send(handle: *uv_async_t); unsafe fn rust_uv_async_init(loop_handle: *libc::c_void, async_handle: *uv_async_t, @@ -796,10 +783,6 @@ pub unsafe fn loop_delete(loop_handle: *libc::c_void) { rustrt::rust_uv_loop_delete(loop_handle); } -pub unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { - return rustrt::rust_uv_loop_refcount(loop_ptr); -} - pub unsafe fn run(loop_handle: *libc::c_void) { rustrt::rust_uv_run(loop_handle); } @@ -808,6 +791,10 @@ pub unsafe fn close(handle: *T, cb: *u8) { rustrt::rust_uv_close(handle as *libc::c_void, cb); } +pub unsafe fn walk(loop_handle: *libc::c_void, cb: *u8, arg: *libc::c_void) { + rustrt::rust_uv_walk(loop_handle, cb, arg); +} + pub unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) -> libc::c_int { return rustrt::rust_uv_tcp_init(loop_handle, handle); @@ -1126,7 +1113,7 @@ pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { rustrt::rust_uv_addrinfo_as_sockaddr_in6(input) } -#[cfg(test)] +//#[cfg(test)] pub mod test { use core::prelude::*; @@ -1693,66 +1680,66 @@ pub mod test { } } + fn struct_size_check_common(t_name: ~str, + foreign_size: libc::c_uint) { + unsafe { + let rust_size = sys::size_of::(); + let sizes_match = foreign_size as uint == rust_size; + if !sizes_match { + let output = fmt!( + "STRUCT_SIZE FAILURE: %s -- actual: %u expected: %u", + t_name, rust_size, foreign_size as uint); + log(debug, output); + } + assert sizes_match; + } + } + // struct size tests #[test] fn test_uv_ll_struct_size_uv_tcp_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_tcp_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_tcp_t", + ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_connect_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_connect_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_connect_t", + ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_buf_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_buf_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_buf_t", + ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_write_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_write_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_write_t", + ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size() + ); } } #[test] fn test_uv_ll_struct_size_sockaddr_in() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("sockaddr_in -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"sockaddr_in", + ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size() + ); } } #[test] @@ -1790,26 +1777,20 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_async_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_async_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_async_t", + ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_timer_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_timer_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_timer_t", + ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size() + ); } } @@ -1817,13 +1798,10 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_uv_getaddrinfo_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_getaddrinfo_t", + ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size() + ); } } #[test] @@ -1831,13 +1809,10 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_addrinfo() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_addrinfo_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("addrinfo -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"addrinfo", + ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size() + ); } } } diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 2dc70088628f6..f08261c336dcd 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -121,11 +121,6 @@ rust_uv_loop_delete(uv_loop_t* loop) { uv_loop_delete(loop); } -extern "C" int -rust_uv_loop_refcount(uv_loop_t* loop) { - return uv_loop_refcount(loop); -} - extern "C" void rust_uv_loop_set_data(uv_loop_t* loop, void* data) { loop->data = data; @@ -151,7 +146,7 @@ rust_uv_stop_op_cb(uv_handle_t* op_handle) { extern "C" void rust_uv_run(uv_loop_t* loop) { - uv_run(loop); + uv_run(loop, UV_RUN_DEFAULT); } extern "C" void @@ -159,6 +154,11 @@ rust_uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_close(handle, cb); } +extern "C" void +rust_uv_walk(uv_loop_t* loop, uv_walk_cb cb, void* arg) { + uv_walk(loop, cb, arg); +} + extern "C" void rust_uv_hilvl_close(uv_handle_t* handle, extern_close_cb cb) { handle_data* data = (handle_data*)handle->data; diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 818eb5f83a7b5..2e687472a8d6f 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -73,7 +73,7 @@ rust_upcall_free rust_upcall_malloc rust_uv_loop_new rust_uv_loop_delete -rust_uv_loop_refcount +rust_uv_walk rust_uv_loop_set_data rust_uv_bind_op_cb rust_uv_stop_op_cb From a38b16651f0d900b1f1ed3b251488922fccd1f71 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Sat, 2 Feb 2013 07:40:40 -0800 Subject: [PATCH 26/92] build: tweak rt.mk, as per graydon.. CFLAGS had to stay --- mk/rt.mk | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mk/rt.mk b/mk/rt.mk index 2841ff25a0c6e..eed5615f82a57 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -157,16 +157,17 @@ LIBUV_DEPS := $$(wildcard \ $$(S)src/libuv/*/*/*/*) endif +ifdef CFG_WINDOWSY +LIBUV_OS := 'OS=mingw' +else +LIBUV_OS := +endif + $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ - LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \ - CC="$$(CFG_GCCISH_CROSS)$$(CC)" \ - CXX="$$(CFG_GCCISH_CROSS)$$(CXX)" \ - AR="$$(CFG_GCCISH_CROSS)$$(AR)" \ - BUILDTYPE=Release \ - builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ - V=$$(VERBOSE) FLOCK= + builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" $$(LIBUV_OS) \ + V=$$(VERBOSE) # These could go in rt.mk or rustllvm.mk, they're needed for both. From 4942fe9c1e92ae90878910337011507b07073975 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Mon, 4 Feb 2013 14:37:48 -0800 Subject: [PATCH 27/92] build: point libuv at olsonjeffery/libuv, temporarily --- .gitmodules | 2 +- src/libuv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index d750f8eb5b781..3b2d9a709ac3c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = git://github.com/brson/llvm.git [submodule "src/libuv"] path = src/libuv - url = git://github.com/graydon/libuv.git + url = git://github.com/olsonjeffery/libuv.git diff --git a/src/libuv b/src/libuv index 4d392c86feb63..42cc78fb6b9fe 160000 --- a/src/libuv +++ b/src/libuv @@ -1 +1 @@ -Subproject commit 4d392c86feb6389f550d8110d36fa90d66c09251 +Subproject commit 42cc78fb6b9feb0c6f95dd3700f4dff714dc00d6 From a74296a39fe9988516dde322a61374c65fc86b25 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Sat, 2 Feb 2013 12:14:04 -0800 Subject: [PATCH 28/92] build: ifdef for mingw/non-mingw builds --- mk/rt.mk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mk/rt.mk b/mk/rt.mk index eed5615f82a57..23dc64dbca52e 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -158,16 +158,19 @@ LIBUV_DEPS := $$(wildcard \ endif ifdef CFG_WINDOWSY -LIBUV_OS := 'OS=mingw' +$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) + $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ + builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ + OS=mingw \ + V=$$(VERBOSE) else -LIBUV_OS := -endif - $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ - builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" $$(LIBUV_OS) \ + builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ V=$$(VERBOSE) +endif + # These could go in rt.mk or rustllvm.mk, they're needed for both. From 73507c1961f7e8f5b6aef2a6d15867360906cd7f Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Mon, 4 Feb 2013 18:00:21 -0800 Subject: [PATCH 29/92] std: strip sillyness from debug comment in iotask teardown --- src/libstd/uv_iotask.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index da5fbc3438a1c..ccb3175eef499 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -186,7 +186,7 @@ fn begin_teardown(data: *IoTaskLoopData) { } } extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) { - log(debug, ~"IN TEARDOWN WALK CB BOYEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); + log(debug, ~"IN TEARDOWN WALK CB"); // pretty much, if we still have an active handle and it is *not* // the async handle that facilities global loop communication, we // want to barf out and fail From 1cbbb58d87aca14856a891eb48ce4b58ad5faa2a Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Thu, 7 Feb 2013 16:50:43 -0800 Subject: [PATCH 30/92] build: change libuv to point at joyent's repo and make unpatched build libuv work on mingw --- .gitmodules | 2 +- mk/platform.mk | 4 ++-- src/libuv | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3b2d9a709ac3c..e840f4adaebbd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = git://github.com/brson/llvm.git [submodule "src/libuv"] path = src/libuv - url = git://github.com/olsonjeffery/libuv.git + url = git://github.com/joyent/libuv.git diff --git a/mk/platform.mk b/mk/platform.mk index d2f874561b185..e45b29995a92d 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -198,7 +198,7 @@ else endif CFG_RUN_TARG=$(call CFG_RUN,$(HLIB$(1)_H_$(CFG_HOST_TRIPLE)),$(2)) CFG_RUN_TEST=$(call CFG_RUN,$(call CFG_TESTLIB,$(1),$(3)),$(1)) - CFG_LIBUV_LINK_FLAGS=-lWs2_32 + CFG_LIBUV_LINK_FLAGS=-lWs2_32 -lpsapi -liphlpapi ifndef CFG_ENABLE_MINGW_CROSS CFG_PATH_MUNGE := $(strip perl -i.bak -p \ @@ -322,4 +322,4 @@ define CFG_MAKE_ASSEMBLER endef $(foreach target,$(CFG_TARGET_TRIPLES),\ - $(eval $(call CFG_MAKE_ASSEMBLER,$(target)))) \ No newline at end of file + $(eval $(call CFG_MAKE_ASSEMBLER,$(target)))) diff --git a/src/libuv b/src/libuv index 42cc78fb6b9fe..da33bba7c04e0 160000 --- a/src/libuv +++ b/src/libuv @@ -1 +1 @@ -Subproject commit 42cc78fb6b9feb0c6f95dd3700f4dff714dc00d6 +Subproject commit da33bba7c04e0873b457a9a4290bed2adf620154 From a3516ae834897c23f5a2e9bd4ca418b2390ca6b0 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Thu, 7 Feb 2013 21:08:26 -0800 Subject: [PATCH 31/92] build: add link flag for freebsd libuv build --- mk/platform.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mk/platform.mk b/mk/platform.mk index e45b29995a92d..0488f2f8cde0e 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -46,6 +46,7 @@ ifneq ($(findstring freebsd,$(CFG_OSTYPE)),) CFG_GCCISH_CFLAGS_x86_64 += -m64 CFG_GCCISH_LINK_FLAGS_x86_64 += -m64 CFG_UNIXY := 1 + CFG_FBSD := 1 CFG_LDENV := LD_LIBRARY_PATH CFG_DEF_SUFFIX := .bsd.def CFG_INSTALL_NAME = @@ -147,6 +148,9 @@ ifdef CFG_UNIXY CFG_RUN_TARG=$(call CFG_RUN,,$(2)) CFG_RUN_TEST=$(call CFG_RUN,,$(CFG_VALGRIND) $(1)) CFG_LIBUV_LINK_FLAGS=-lpthread + ifdef CFG_FBSD + CFG_LIBUV_LINK_FLAGS=-lpthread -lkvm + endif ifdef CFG_ENABLE_MINGW_CROSS CFG_WINDOWSY := 1 From 99ff74c1bd4d982cfc49f8ed962cd31f3c8d9ae7 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 10 Feb 2013 16:30:17 -0500 Subject: [PATCH 32/92] make Option's iter method use a lifetime --- src/libcore/option.rs | 4 ++-- src/libstd/treemap.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index cfc2cba922602..c2af5f8b73b1c 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -201,7 +201,7 @@ pub pure fn map_default(opt: &r/Option, def: U, } #[inline(always)] -pub pure fn iter(opt: &Option, f: fn(x: &T)) { +pub pure fn iter(opt: &r/Option, f: fn(x: &r/T)) { //! Performs an operation on the contained value by reference match *opt { None => (), Some(ref t) => f(t) } } @@ -313,7 +313,7 @@ impl Option { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn iter(&self, f: fn(x: &T)) { iter(self, f) } + pure fn iter(&self, f: fn(x: &self/T)) { iter(self, f) } /** Gets an immutable reference to the value inside an option. diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index d8deea60725a0..59787c8036ddb 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -561,18 +561,18 @@ impl TreeNode { pure fn each(node: &r/Option<~TreeNode>, f: fn(&(&r/K, &r/V)) -> bool) { - do node.map |x| { + do node.iter |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } - }; + } } pure fn each_reverse(node: &r/Option<~TreeNode>, f: fn(&(&r/K, &r/V)) -> bool) { - do node.map |x| { + do node.iter |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } - }; + } } // Remove left horizontal link by rotating right From 85d7b3c154b0fa08c54c1edeefc8f36654764d99 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 10 Feb 2013 13:35:20 -0800 Subject: [PATCH 33/92] mk: Typo --- mk/tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/tests.mk b/mk/tests.mk index b71c521c5c9a4..08a4c1c171835 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -285,7 +285,7 @@ CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc) CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs) BENCH_RS := $(wildcard $(S)src/test/bench/*.rs) PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs) -DEBUGINFO_RS := $(wildcard $(S)src/test/pretty/*.rs) +DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs) # perf tests are the same as bench tests only they run under # a performance monitor. From 79e9b6d6a13a8634734c85c653b3850427081ea3 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 10 Feb 2013 14:17:28 -0800 Subject: [PATCH 34/92] mk: Run debuginfo tests by default, but only if gdb is available --- configure | 1 + mk/tests.mk | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 56d40205b5cb7..4828e59b82151 100755 --- a/configure +++ b/configure @@ -394,6 +394,7 @@ probe CFG_PDFLATEX pdflatex probe CFG_XETEX xetex probe CFG_LUATEX luatex probe CFG_NODE nodejs node +probe CFG_GDB gdb if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ] then probe CFG_PAXCTL paxctl /sbin/paxctl diff --git a/mk/tests.mk b/mk/tests.mk index 08a4c1c171835..abe9ba60ecda4 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -171,6 +171,7 @@ check-stage$(1)-T-$(2)-H-$(3)-exec: \ check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \ check-stage$(1)-T-$(2)-H-$(3)-crates-exec \ check-stage$(1)-T-$(2)-H-$(3)-bench-exec \ + check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \ check-stage$(1)-T-$(2)-H-$(3)-doc-exec \ check-stage$(1)-T-$(2)-H-$(3)-pretty-exec @@ -335,6 +336,10 @@ CTEST_BUILD_BASE_debuginfo = debug-info CTEST_MODE_debuginfo = debug-info CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL) +ifeq ($(CFG_GDB),) +CTEST_DISABLE_debuginfo = "no gdb found" +endif + define DEF_CTEST_VARS # All the per-stage build rules you might want to call from the @@ -357,7 +362,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ - --rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2)" \ + --rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS) @@ -386,6 +391,8 @@ CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)) +ifeq ($$(CTEST_DISABLE_$(4)),) + $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) @@ -395,6 +402,17 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \ && touch $$@ +else + +$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ + $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ + $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) + @$$(call E, run $(4): $$<) + @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4))) + touch $$@ + +endif + endef CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo From 4696fb367cb32f56bbb9cfaf715d0bd69699bbb7 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Sun, 10 Feb 2013 14:30:07 -0800 Subject: [PATCH 35/92] std: fix libuv structs on macos --- src/libstd/uv_ll.rs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index fb8bbcebf7fc9..e066f8c0bbfe7 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -91,7 +91,19 @@ pub struct uv_stream_t { } // 64bit unix size: 216 -#[cfg(unix)] +#[cfg(target_os="macos")] +pub struct uv_tcp_t { + fields: uv_handle_fields, + a00: *u8, a01: *u8, a02: *u8, a03: *u8, + a04: *u8, a05: *u8, a06: *u8, a07: *u8, + a08: *u8, a09: *u8, a10: *u8, a11: *u8, + a12: *u8, a13: *u8, a14: *u8, a15: *u8, + a16: *u8, a17: *u8, a18: *u8, a19: *u8, + a20: *u8, a21: *u8, a22: *u8, a23: *u8 +} +#[cfg(target_os="linux")] +#[cfg(target_os="freebsd")] +#[cfg(target_os="android")] pub struct uv_tcp_t { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -352,7 +364,6 @@ pub mod uv_ll_struct_stubgen { return gen_stub_os(); #[cfg(target_os = "linux")] #[cfg(target_os = "android")] - #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] pub fn gen_stub_os() -> uv_tcp_t { return gen_stub_arch(); @@ -427,6 +438,28 @@ pub mod uv_ll_struct_stubgen { a24: 0 as *u8, a25: 0 as *u8, } } + #[cfg(target_os = "macos")] + pub fn gen_stub_os() -> uv_tcp_t { + uv_tcp_t { + fields: uv_handle_fields { + loop_handle: ptr::null(), type_: 0u32, + close_cb: ptr::null(), + data: ptr::null(), + }, + a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, + a03: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8, + a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, + a11: 0 as *u8, + a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, + a19: 0 as *u8, + a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, + a23: 0 as *u8, + } + } } #[cfg(unix)] pub fn gen_stub_uv_connect_t() -> uv_connect_t { From fed5df8f2edbdd78573a54bb5baec71c0056fc9b Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 10 Feb 2013 13:56:03 -0800 Subject: [PATCH 36/92] libcore: LinearMap doesn't need to pass around the bucket vec --- src/libcore/hashmap.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index a69cf4611bb7f..81cfe2702398d 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -108,19 +108,17 @@ pub mod linear { } #[inline(always)] - pure fn bucket_for_key(&self, buckets: &[Option>], - k: &K) -> SearchResult { + pure fn bucket_for_key(&self, k: &K) -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; - self.bucket_for_key_with_hash(buckets, hash, k) + self.bucket_for_key_with_hash(hash, k) } #[inline(always)] pure fn bucket_for_key_with_hash(&self, - buckets: &[Option>], hash: uint, k: &K) -> SearchResult { let _ = for self.bucket_sequence(hash) |i| { - match buckets[i] { + match self.buckets[i] { Some(ref bkt) => if bkt.hash == hash && *k == bkt.key { return FoundEntry(i); }, @@ -161,7 +159,7 @@ pub mod linear { /// Assumes that there will be a bucket. /// True if there was no previous entry with that key fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { - match self.bucket_for_key_with_hash(self.buckets, hash, &k) { + match self.bucket_for_key_with_hash(hash, &k) { TableFull => { die!(~"Internal logic error"); } FoundHole(idx) => { debug!("insert fresh (%?->%?) at idx %?, hash %?", @@ -196,8 +194,7 @@ pub mod linear { // // I found this explanation elucidating: // http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf - let mut idx = match self.bucket_for_key_with_hash(self.buckets, - hash, k) { + let mut idx = match self.bucket_for_key_with_hash(hash, k) { TableFull | FoundHole(_) => return None, FoundEntry(idx) => idx }; @@ -273,7 +270,7 @@ pub mod linear { impl LinearMap: Map { /// Return true if the map contains a value for the specified key pure fn contains_key(&self, k: &K) -> bool { - match self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(k) { FoundEntry(_) => {true} TableFull | FoundHole(_) => {false} } @@ -291,7 +288,7 @@ pub mod linear { /// Return the value corresponding to the key in the map pure fn find(&self, k: &K) -> Option<&self/V> { - match self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(k) { FoundEntry(idx) => { match self.buckets[idx] { Some(ref bkt) => { From 849644b5bc6b1fe836d96bed61b55cba92e5b5e1 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 10 Feb 2013 14:39:38 -0800 Subject: [PATCH 37/92] core: rename hashmap test functions --- src/libcore/hashmap.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 81cfe2702398d..b8906e126a8d8 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -518,7 +518,7 @@ mod test_map { use uint; #[test] - pub fn inserts() { + pub fn test_insert() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert m.insert(2, 4); @@ -527,7 +527,7 @@ mod test_map { } #[test] - pub fn overwrite() { + pub fn test_insert_overwrite() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert *m.get(&1) == 2; @@ -536,7 +536,7 @@ mod test_map { } #[test] - pub fn conflicts() { + pub fn test_insert_conflicts() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert m.insert(5, 3); @@ -547,7 +547,7 @@ mod test_map { } #[test] - pub fn conflict_remove() { + pub fn test_conflict_remove() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert m.insert(5, 3); @@ -558,7 +558,7 @@ mod test_map { } #[test] - pub fn empty() { + pub fn test_is_empty() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert !m.is_empty(); @@ -567,7 +567,7 @@ mod test_map { } #[test] - pub fn pops() { + pub fn test_pop() { let mut m = LinearMap::new(); m.insert(1, 2); assert m.pop(&1) == Some(2); @@ -575,7 +575,7 @@ mod test_map { } #[test] - pub fn swaps() { + pub fn test_swap() { let mut m = LinearMap::new(); assert m.swap(1, 2) == None; assert m.swap(1, 3) == Some(2); @@ -583,7 +583,7 @@ mod test_map { } #[test] - pub fn consumes() { + pub fn test_consume() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert m.insert(2, 3); @@ -598,7 +598,7 @@ mod test_map { } #[test] - pub fn iterate() { + pub fn test_iterate() { let mut m = linear::linear_map_with_capacity(4); for uint::range(0, 32) |i| { assert m.insert(i, i*2); @@ -612,7 +612,7 @@ mod test_map { } #[test] - pub fn find() { + pub fn test_find() { let mut m = LinearMap::new(); assert m.find(&1).is_none(); m.insert(1, 2); From 4fb4a4b66d5c988d79f77b081dabd8f62b880dfe Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 10 Feb 2013 15:30:44 -0800 Subject: [PATCH 38/92] core: add LinearMap::find_or_insert{,_with} This allows for inserting a new value into the map only if it doesn't already exist in the map. --- src/libcore/hashmap.rs | 94 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index b8906e126a8d8..70358bab46874 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -155,6 +155,14 @@ pub mod linear { } } + #[inline(always)] + pure fn value_for_bucket(&self, idx: uint) -> &self/V { + match self.buckets[idx] { + Some(ref bkt) => &bkt.value, + None => die!(~"LinearMap::find: internal logic error"), + } + } + /// Inserts the key value pair into the buckets. /// Assumes that there will be a bucket. /// True if there was no previous entry with that key @@ -289,19 +297,8 @@ pub mod linear { /// Return the value corresponding to the key in the map pure fn find(&self, k: &K) -> Option<&self/V> { match self.bucket_for_key(k) { - FoundEntry(idx) => { - match self.buckets[idx] { - Some(ref bkt) => { - Some(&bkt.value) - } - None => { - die!(~"LinearMap::find: internal logic error") - } - } - } - TableFull | FoundHole(_) => { - None - } + FoundEntry(idx) => Some(self.value_for_bucket(idx)), + TableFull | FoundHole(_) => None, } } @@ -361,6 +358,63 @@ pub mod linear { old_value } + /// Return the value corresponding to the key in the map, or insert + /// and return the value if it doesn't exist. + fn find_or_insert(&mut self, k: K, v: V) -> &self/V { + if self.size >= self.resize_at { + // n.b.: We could also do this after searching, so + // that we do not resize if this call to insert is + // simply going to update a key in place. My sense + // though is that it's worse to have to search through + // buckets to find the right spot twice than to just + // resize in this corner case. + self.expand(); + } + + let hash = k.hash_keyed(self.k0, self.k1) as uint; + let idx = match self.bucket_for_key_with_hash(hash, &k) { + TableFull => die!(~"Internal logic error"), + FoundEntry(idx) => idx, + FoundHole(idx) => { + self.buckets[idx] = Some(Bucket{hash: hash, key: k, + value: v}); + self.size += 1; + idx + }, + }; + + self.value_for_bucket(idx) + } + + /// Return the value corresponding to the key in the map, or create, + /// insert, and return a new value if it doesn't exist. + fn find_or_insert_with(&mut self, k: K, f: fn(&K) -> V) -> &self/V { + if self.size >= self.resize_at { + // n.b.: We could also do this after searching, so + // that we do not resize if this call to insert is + // simply going to update a key in place. My sense + // though is that it's worse to have to search through + // buckets to find the right spot twice than to just + // resize in this corner case. + self.expand(); + } + + let hash = k.hash_keyed(self.k0, self.k1) as uint; + let idx = match self.bucket_for_key_with_hash(hash, &k) { + TableFull => die!(~"Internal logic error"), + FoundEntry(idx) => idx, + FoundHole(idx) => { + let v = f(&k); + self.buckets[idx] = Some(Bucket{hash: hash, key: k, + value: v}); + self.size += 1; + idx + }, + }; + + self.value_for_bucket(idx) + } + fn consume(&mut self, f: fn(K, V)) { let mut buckets = ~[]; self.buckets <-> buckets; @@ -582,6 +636,20 @@ mod test_map { assert m.swap(1, 4) == Some(3); } + #[test] + pub fn test_find_or_insert() { + let mut m = LinearMap::new::(); + assert m.find_or_insert(1, 2) == &2; + assert m.find_or_insert(1, 3) == &2; + } + + #[test] + pub fn test_find_or_insert_with() { + let mut m = LinearMap::new::(); + assert m.find_or_insert_with(1, |_| 2) == &2; + assert m.find_or_insert_with(1, |_| 3) == &2; + } + #[test] pub fn test_consume() { let mut m = LinearMap::new(); From 48b2141b83bd3afe6aee3adf170ef6e985ab1353 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Mon, 11 Feb 2013 12:33:05 +1100 Subject: [PATCH 39/92] Add NumCast trait for generic numeric type casts --- src/libcore/core.rc | 2 +- src/libcore/num/f32.rs | 87 ++++++++++++++++-- src/libcore/num/f64.rs | 83 ++++++++++++++++- src/libcore/num/float.rs | 98 ++++++++++++++++----- src/libcore/num/int-template.rs | 31 ++----- src/libcore/num/int-template/i16.rs | 71 +++++++++++++++ src/libcore/num/int-template/i32.rs | 71 +++++++++++++++ src/libcore/num/int-template/i64.rs | 71 +++++++++++++++ src/libcore/num/int-template/i8.rs | 71 +++++++++++++++ src/libcore/num/int-template/int.rs | 71 +++++++++++++++ src/libcore/num/num.rs | 69 +++++++++++---- src/libcore/num/uint-template.rs | 17 ++-- src/libcore/num/uint-template/u16.rs | 71 +++++++++++++++ src/libcore/num/uint-template/u32.rs | 71 +++++++++++++++ src/libcore/num/uint-template/u64.rs | 71 +++++++++++++++ src/libcore/num/uint-template/u8.rs | 71 +++++++++++++++ src/libcore/num/uint-template/uint.rs | 71 +++++++++++++++ src/libcore/prelude.rs | 2 +- src/test/run-pass/trait-inheritance-num.rs | 8 +- src/test/run-pass/trait-inheritance-num0.rs | 6 +- src/test/run-pass/trait-inheritance-num1.rs | 6 +- src/test/run-pass/trait-inheritance-num2.rs | 4 +- src/test/run-pass/trait-inheritance-num3.rs | 6 +- src/test/run-pass/trait-inheritance-num5.rs | 6 +- 24 files changed, 1044 insertions(+), 91 deletions(-) diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 64b480818b1e7..7bf64d5b6684b 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -199,7 +199,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector}; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::Num; +pub use num::{Num, NumCast}; pub use ptr::Ptr; pub use to_str::ToStr; pub use clone::Clone; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 738445b5cd946..6bea9e81197d3 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -14,6 +14,7 @@ use cmath; use cmp; use libc::{c_float, c_int}; use num; +use num::NumCast; use option::Option; use from_str; use to_str; @@ -283,11 +284,6 @@ impl f32: num::Num { pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; } #[inline(always)] pure fn neg(&self) -> f32 { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> f32 { return n as f32; } } impl f32: num::Zero { @@ -300,6 +296,30 @@ impl f32: num::One { static pure fn one() -> f32 { 1.0 } } +pub impl f32: NumCast { + /** + * Cast `n` to an `f32` + */ + #[inline(always)] + static pure fn from(n: N) -> f32 { n.to_f32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + #[abi="rust-intrinsic"] pub extern { fn floorf32(val: f32) -> f32; @@ -545,6 +565,63 @@ impl f32: num::FromStrRadix { } } +#[test] +pub fn test_num() { + let ten: f32 = num::cast(10); + let two: f32 = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f32.to_uint()); + assert (20u8 == 20f32.to_u8()); + assert (20u16 == 20f32.to_u16()); + assert (20u32 == 20f32.to_u32()); + assert (20u64 == 20f32.to_u64()); + assert (20i == 20f32.to_int()); + assert (20i8 == 20f32.to_i8()); + assert (20i16 == 20f32.to_i16()); + assert (20i32 == 20f32.to_i32()); + assert (20i64 == 20f32.to_i64()); + assert (20f == 20f32.to_float()); + assert (20f32 == 20f32.to_f32()); + assert (20f64 == 20f32.to_f64()); + + assert (20f32 == NumCast::from(20u)); + assert (20f32 == NumCast::from(20u8)); + assert (20f32 == NumCast::from(20u16)); + assert (20f32 == NumCast::from(20u32)); + assert (20f32 == NumCast::from(20u64)); + assert (20f32 == NumCast::from(20i)); + assert (20f32 == NumCast::from(20i8)); + assert (20f32 == NumCast::from(20i16)); + assert (20f32 == NumCast::from(20i32)); + assert (20f32 == NumCast::from(20i64)); + assert (20f32 == NumCast::from(20f)); + assert (20f32 == NumCast::from(20f32)); + assert (20f32 == NumCast::from(20f64)); + + assert (20f32 == num::cast(20u)); + assert (20f32 == num::cast(20u8)); + assert (20f32 == num::cast(20u16)); + assert (20f32 == num::cast(20u32)); + assert (20f32 == num::cast(20u64)); + assert (20f32 == num::cast(20i)); + assert (20f32 == num::cast(20i8)); + assert (20f32 == num::cast(20i16)); + assert (20f32 == num::cast(20i32)); + assert (20f32 == num::cast(20i64)); + assert (20f32 == num::cast(20f)); + assert (20f32 == num::cast(20f32)); + assert (20f32 == num::cast(20f64)); +} + // // Local Variables: // mode: rust diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index f09d874803c3d..7cde210265324 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -15,6 +15,7 @@ use cmp; use libc::{c_double, c_int}; use libc; use num; +use num::NumCast; use option::Option; use to_str; use from_str; @@ -307,11 +308,30 @@ impl f64: num::Num { pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; } #[inline(always)] pure fn neg(&self) -> f64 { return -*self; } +} +pub impl f64: NumCast { + /** + * Cast `n` to an `f64` + */ #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> f64 { return n as f64; } + static pure fn from(n: N) -> f64 { n.to_f64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } } impl f64: num::Zero { @@ -569,6 +589,63 @@ impl f64: num::FromStrRadix { } } +#[test] +pub fn test_num() { + let ten: f64 = num::cast(10); + let two: f64 = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f64.to_uint()); + assert (20u8 == 20f64.to_u8()); + assert (20u16 == 20f64.to_u16()); + assert (20u32 == 20f64.to_u32()); + assert (20u64 == 20f64.to_u64()); + assert (20i == 20f64.to_int()); + assert (20i8 == 20f64.to_i8()); + assert (20i16 == 20f64.to_i16()); + assert (20i32 == 20f64.to_i32()); + assert (20i64 == 20f64.to_i64()); + assert (20f == 20f64.to_float()); + assert (20f32 == 20f64.to_f32()); + assert (20f64 == 20f64.to_f64()); + + assert (20f64 == NumCast::from(20u)); + assert (20f64 == NumCast::from(20u8)); + assert (20f64 == NumCast::from(20u16)); + assert (20f64 == NumCast::from(20u32)); + assert (20f64 == NumCast::from(20u64)); + assert (20f64 == NumCast::from(20i)); + assert (20f64 == NumCast::from(20i8)); + assert (20f64 == NumCast::from(20i16)); + assert (20f64 == NumCast::from(20i32)); + assert (20f64 == NumCast::from(20i64)); + assert (20f64 == NumCast::from(20f)); + assert (20f64 == NumCast::from(20f32)); + assert (20f64 == NumCast::from(20f64)); + + assert (20f64 == num::cast(20u)); + assert (20f64 == num::cast(20u8)); + assert (20f64 == num::cast(20u16)); + assert (20f64 == num::cast(20u32)); + assert (20f64 == num::cast(20u64)); + assert (20f64 == num::cast(20i)); + assert (20f64 == num::cast(20i8)); + assert (20f64 == num::cast(20i16)); + assert (20f64 == num::cast(20i32)); + assert (20f64 == num::cast(20i64)); + assert (20f64 == num::cast(20f)); + assert (20f64 == num::cast(20f32)); + assert (20f64 == num::cast(20f64)); +} + // // Local Variables: // mode: rust diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f5ae05ebffb4e..74bf50737f563 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -26,7 +26,7 @@ use cmp::{Eq, Ord}; use cmp; use f64; use num; -use num::Num::from_int; +use num::NumCast; use option::{None, Option, Some}; use str; use uint; @@ -417,11 +417,6 @@ impl float: num::Num { pure fn modulo(&self, other: &float) -> float { return *self % *other; } #[inline(always)] pure fn neg(&self) -> float { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(&self, n: int) -> float { return n as float; } } impl float: num::Zero { @@ -434,6 +429,30 @@ impl float: num::One { static pure fn one() -> float { 1.0 } } +pub impl float: NumCast { + /** + * Cast `n` to a `float` + */ + #[inline(always)] + static pure fn from(n: N) -> float { n.to_float() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self } +} + impl float: num::Round { #[inline(always)] pure fn round(&self, mode: num::RoundMode) -> float { @@ -657,21 +676,60 @@ pub fn test_round() { } #[test] -pub fn test_traits() { - fn test(ten: &U) { - assert (ten.to_int() == 10); - - let two: U = from_int(2); - assert (two.to_int() == 2); - - assert (ten.add(&two) == from_int(12)); - assert (ten.sub(&two) == from_int(8)); - assert (ten.mul(&two) == from_int(20)); - assert (ten.div(&two) == from_int(5)); - assert (ten.modulo(&two) == from_int(0)); - } +pub fn test_num() { + let ten: float = num::cast(10); + let two: float = num::cast(2); - test(&10.0); + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f.to_uint()); + assert (20u8 == 20f.to_u8()); + assert (20u16 == 20f.to_u16()); + assert (20u32 == 20f.to_u32()); + assert (20u64 == 20f.to_u64()); + assert (20i == 20f.to_int()); + assert (20i8 == 20f.to_i8()); + assert (20i16 == 20f.to_i16()); + assert (20i32 == 20f.to_i32()); + assert (20i64 == 20f.to_i64()); + assert (20f == 20f.to_float()); + assert (20f32 == 20f.to_f32()); + assert (20f64 == 20f.to_f64()); + + assert (20f == NumCast::from(20u)); + assert (20f == NumCast::from(20u8)); + assert (20f == NumCast::from(20u16)); + assert (20f == NumCast::from(20u32)); + assert (20f == NumCast::from(20u64)); + assert (20f == NumCast::from(20i)); + assert (20f == NumCast::from(20i8)); + assert (20f == NumCast::from(20i16)); + assert (20f == NumCast::from(20i32)); + assert (20f == NumCast::from(20i64)); + assert (20f == NumCast::from(20f)); + assert (20f == NumCast::from(20f32)); + assert (20f == NumCast::from(20f64)); + + assert (20f == num::cast(20u)); + assert (20f == num::cast(20u8)); + assert (20f == num::cast(20u16)); + assert (20f == num::cast(20u32)); + assert (20f == num::cast(20u64)); + assert (20f == num::cast(20i)); + assert (20f == num::cast(20i8)); + assert (20f == num::cast(20i16)); + assert (20f == num::cast(20i32)); + assert (20f == num::cast(20i64)); + assert (20f == num::cast(20f)); + assert (20f == num::cast(20f32)); + assert (20f == num::cast(20f64)); } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 1856781b1d779..b616a08246b67 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -17,7 +17,6 @@ use to_str::ToStr; use from_str::FromStr; use num::{ToStrRadix, FromStrRadix}; use num; -use num::Num::from_int; use prelude::*; use str; use uint; @@ -184,11 +183,6 @@ impl T: num::Num { pure fn modulo(&self, other: &T) -> T { return *self % *other; } #[inline(always)] pure fn neg(&self) -> T { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> T { return n as T; } } impl T: num::Zero { @@ -411,22 +405,15 @@ fn test_int_from_str_overflow() { } #[test] -fn test_interfaces() { - fn test(ten: U) { - assert (ten.to_int() == 10); - - let two: U = from_int(2); - assert (two.to_int() == 2); - - assert (ten.add(&two) == from_int(12)); - assert (ten.sub(&two) == from_int(8)); - assert (ten.mul(&two) == from_int(20)); - assert (ten.div(&two) == from_int(5)); - assert (ten.modulo(&two) == from_int(0)); - assert (ten.neg() == from_int(-10)); - } - - test(10 as T); +pub fn test_num() { + let ten: T = num::cast(10); + let two: T = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); } #[test] diff --git a/src/libcore/num/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index da60b567f665a..572cce92ea1d7 100644 --- a/src/libcore/num/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i16` +use num::NumCast; + mod inst { pub type T = i16; pub const bits: uint = ::u16::bits; } + +pub impl i16: NumCast { + /** + * Cast `n` to a `i16` + */ + #[inline(always)] + static pure fn from(n: N) -> i16 { n.to_i16() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i16.to_uint()); + assert (20u8 == 20i16.to_u8()); + assert (20u16 == 20i16.to_u16()); + assert (20u32 == 20i16.to_u32()); + assert (20u64 == 20i16.to_u64()); + assert (20i == 20i16.to_int()); + assert (20i8 == 20i16.to_i8()); + assert (20i16 == 20i16.to_i16()); + assert (20i32 == 20i16.to_i32()); + assert (20i64 == 20i16.to_i64()); + assert (20f == 20i16.to_float()); + assert (20f32 == 20i16.to_f32()); + assert (20f64 == 20i16.to_f64()); + + assert (20i16 == NumCast::from(20u)); + assert (20i16 == NumCast::from(20u8)); + assert (20i16 == NumCast::from(20u16)); + assert (20i16 == NumCast::from(20u32)); + assert (20i16 == NumCast::from(20u64)); + assert (20i16 == NumCast::from(20i)); + assert (20i16 == NumCast::from(20i8)); + assert (20i16 == NumCast::from(20i16)); + assert (20i16 == NumCast::from(20i32)); + assert (20i16 == NumCast::from(20i64)); + assert (20i16 == NumCast::from(20f)); + assert (20i16 == NumCast::from(20f32)); + assert (20i16 == NumCast::from(20f64)); + + assert (20i16 == num::cast(20u)); + assert (20i16 == num::cast(20u8)); + assert (20i16 == num::cast(20u16)); + assert (20i16 == num::cast(20u32)); + assert (20i16 == num::cast(20u64)); + assert (20i16 == num::cast(20i)); + assert (20i16 == num::cast(20i8)); + assert (20i16 == num::cast(20i16)); + assert (20i16 == num::cast(20i32)); + assert (20i16 == num::cast(20i64)); + assert (20i16 == num::cast(20f)); + assert (20i16 == num::cast(20f32)); + assert (20i16 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index 1bc45bb71af7e..de2e467d02ab1 100644 --- a/src/libcore/num/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i32` +use num::NumCast; + mod inst { pub type T = i32; pub const bits: uint = ::u32::bits; } + +pub impl i32: NumCast { + /** + * Cast `n` to a `i32` + */ + #[inline(always)] + static pure fn from(n: N) -> i32 { n.to_i32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i32.to_uint()); + assert (20u8 == 20i32.to_u8()); + assert (20u16 == 20i32.to_u16()); + assert (20u32 == 20i32.to_u32()); + assert (20u64 == 20i32.to_u64()); + assert (20i == 20i32.to_int()); + assert (20i8 == 20i32.to_i8()); + assert (20i16 == 20i32.to_i16()); + assert (20i32 == 20i32.to_i32()); + assert (20i64 == 20i32.to_i64()); + assert (20f == 20i32.to_float()); + assert (20f32 == 20i32.to_f32()); + assert (20f64 == 20i32.to_f64()); + + assert (20i32 == NumCast::from(20u)); + assert (20i32 == NumCast::from(20u8)); + assert (20i32 == NumCast::from(20u16)); + assert (20i32 == NumCast::from(20u32)); + assert (20i32 == NumCast::from(20u64)); + assert (20i32 == NumCast::from(20i)); + assert (20i32 == NumCast::from(20i8)); + assert (20i32 == NumCast::from(20i16)); + assert (20i32 == NumCast::from(20i32)); + assert (20i32 == NumCast::from(20i64)); + assert (20i32 == NumCast::from(20f)); + assert (20i32 == NumCast::from(20f32)); + assert (20i32 == NumCast::from(20f64)); + + assert (20i32 == num::cast(20u)); + assert (20i32 == num::cast(20u8)); + assert (20i32 == num::cast(20u16)); + assert (20i32 == num::cast(20u32)); + assert (20i32 == num::cast(20u64)); + assert (20i32 == num::cast(20i)); + assert (20i32 == num::cast(20i8)); + assert (20i32 == num::cast(20i16)); + assert (20i32 == num::cast(20i32)); + assert (20i32 == num::cast(20i64)); + assert (20i32 == num::cast(20f)); + assert (20i32 == num::cast(20f32)); + assert (20i32 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index 83d15aa857d95..d7413920a64f1 100644 --- a/src/libcore/num/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i64` +use num::NumCast; + mod inst { pub type T = i64; pub const bits: uint = ::u64::bits; } + +pub impl i64: NumCast { + /** + * Cast `n` to a `i64` + */ + #[inline(always)] + static pure fn from(n: N) -> i64 { n.to_i64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i64.to_uint()); + assert (20u8 == 20i64.to_u8()); + assert (20u16 == 20i64.to_u16()); + assert (20u32 == 20i64.to_u32()); + assert (20u64 == 20i64.to_u64()); + assert (20i == 20i64.to_int()); + assert (20i8 == 20i64.to_i8()); + assert (20i16 == 20i64.to_i16()); + assert (20i32 == 20i64.to_i32()); + assert (20i64 == 20i64.to_i64()); + assert (20f == 20i64.to_float()); + assert (20f32 == 20i64.to_f32()); + assert (20f64 == 20i64.to_f64()); + + assert (20i64 == NumCast::from(20u)); + assert (20i64 == NumCast::from(20u8)); + assert (20i64 == NumCast::from(20u16)); + assert (20i64 == NumCast::from(20u32)); + assert (20i64 == NumCast::from(20u64)); + assert (20i64 == NumCast::from(20i)); + assert (20i64 == NumCast::from(20i8)); + assert (20i64 == NumCast::from(20i16)); + assert (20i64 == NumCast::from(20i32)); + assert (20i64 == NumCast::from(20i64)); + assert (20i64 == NumCast::from(20f)); + assert (20i64 == NumCast::from(20f32)); + assert (20i64 == NumCast::from(20f64)); + + assert (20i64 == num::cast(20u)); + assert (20i64 == num::cast(20u8)); + assert (20i64 == num::cast(20u16)); + assert (20i64 == num::cast(20u32)); + assert (20i64 == num::cast(20u64)); + assert (20i64 == num::cast(20i)); + assert (20i64 == num::cast(20i8)); + assert (20i64 == num::cast(20i16)); + assert (20i64 == num::cast(20i32)); + assert (20i64 == num::cast(20i64)); + assert (20i64 == num::cast(20f)); + assert (20i64 == num::cast(20f32)); + assert (20i64 == num::cast(20f64)); +} diff --git a/src/libcore/num/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index 740442ed725be..f2577020128bd 100644 --- a/src/libcore/num/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i8` +use num::NumCast; + mod inst { pub type T = i8; pub const bits: uint = ::u8::bits; } + +pub impl i8: NumCast { + /** + * Cast `n` to a `i8` + */ + #[inline(always)] + static pure fn from(n: N) -> i8 { n.to_i8() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i8.to_uint()); + assert (20u8 == 20i8.to_u8()); + assert (20u16 == 20i8.to_u16()); + assert (20u32 == 20i8.to_u32()); + assert (20u64 == 20i8.to_u64()); + assert (20i == 20i8.to_int()); + assert (20i8 == 20i8.to_i8()); + assert (20i16 == 20i8.to_i16()); + assert (20i32 == 20i8.to_i32()); + assert (20i64 == 20i8.to_i64()); + assert (20f == 20i8.to_float()); + assert (20f32 == 20i8.to_f32()); + assert (20f64 == 20i8.to_f64()); + + assert (20i8 == NumCast::from(20u)); + assert (20i8 == NumCast::from(20u8)); + assert (20i8 == NumCast::from(20u16)); + assert (20i8 == NumCast::from(20u32)); + assert (20i8 == NumCast::from(20u64)); + assert (20i8 == NumCast::from(20i)); + assert (20i8 == NumCast::from(20i8)); + assert (20i8 == NumCast::from(20i16)); + assert (20i8 == NumCast::from(20i32)); + assert (20i8 == NumCast::from(20i64)); + assert (20i8 == NumCast::from(20f)); + assert (20i8 == NumCast::from(20f32)); + assert (20i8 == NumCast::from(20f64)); + + assert (20i8 == num::cast(20u)); + assert (20i8 == num::cast(20u8)); + assert (20i8 == num::cast(20u16)); + assert (20i8 == num::cast(20u32)); + assert (20i8 == num::cast(20u64)); + assert (20i8 == num::cast(20i)); + assert (20i8 == num::cast(20i8)); + assert (20i8 == num::cast(20i16)); + assert (20i8 == num::cast(20i32)); + assert (20i8 == num::cast(20i64)); + assert (20i8 == num::cast(20f)); + assert (20i8 == num::cast(20f32)); + assert (20i8 == num::cast(20f64)); +} diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index 224da0dc062d3..4ba1570e1359a 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -10,6 +10,8 @@ //! Operations and constants for `int` +use num::NumCast; + pub use self::inst::pow; mod inst { @@ -55,3 +57,72 @@ mod inst { assert (::int::min_value + ::int::max_value + 1 == 0); } } + +pub impl int: NumCast { + /** + * Cast `n` to a `int` + */ + #[inline(always)] + static pure fn from(n: N) -> int { n.to_int() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i.to_uint()); + assert (20u8 == 20i.to_u8()); + assert (20u16 == 20i.to_u16()); + assert (20u32 == 20i.to_u32()); + assert (20u64 == 20i.to_u64()); + assert (20i == 20i.to_int()); + assert (20i8 == 20i.to_i8()); + assert (20i16 == 20i.to_i16()); + assert (20i32 == 20i.to_i32()); + assert (20i64 == 20i.to_i64()); + assert (20f == 20i.to_float()); + assert (20f32 == 20i.to_f32()); + assert (20f64 == 20i.to_f64()); + + assert (20i == NumCast::from(20u)); + assert (20i == NumCast::from(20u8)); + assert (20i == NumCast::from(20u16)); + assert (20i == NumCast::from(20u32)); + assert (20i == NumCast::from(20u64)); + assert (20i == NumCast::from(20i)); + assert (20i == NumCast::from(20i8)); + assert (20i == NumCast::from(20i16)); + assert (20i == NumCast::from(20i32)); + assert (20i == NumCast::from(20i64)); + assert (20i == NumCast::from(20f)); + assert (20i == NumCast::from(20f32)); + assert (20i == NumCast::from(20f64)); + + assert (20i == num::cast(20u)); + assert (20i == num::cast(20u8)); + assert (20i == num::cast(20u16)); + assert (20i == num::cast(20u32)); + assert (20i == num::cast(20u64)); + assert (20i == num::cast(20i)); + assert (20i == num::cast(20i8)); + assert (20i == num::cast(20i16)); + assert (20i == num::cast(20i32)); + assert (20i == num::cast(20i64)); + assert (20i == num::cast(20f)); + assert (20i == num::cast(20f32)); + assert (20i == num::cast(20f64)); +} diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 05b03a53dcdea..eb722b441c7a6 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -24,9 +24,6 @@ pub trait Num { pure fn div(&self, other: &Self) -> Self; pure fn modulo(&self, other: &Self) -> Self; pure fn neg(&self) -> Self; - - pure fn to_int(&self) -> int; - static pure fn from_int(n: int) -> Self; } pub trait IntConvertible { @@ -50,6 +47,44 @@ pub trait Round { pure fn fract(&self) -> Self; } +/** + * Cast a number the the enclosing type + * + * # Example + * + * ~~~ + * let twenty: f32 = num::cast(0x14); + * assert twenty == 20f32; + * ~~~ + */ +#[inline(always)] +pub pure fn cast(n: T) -> U { + NumCast::from(n) +} + +/** + * An interface for generic numeric type casts + */ +pub trait NumCast { + static pure fn from(n: T) -> Self; + + pure fn to_u8(&self) -> u8; + pure fn to_u16(&self) -> u16; + pure fn to_u32(&self) -> u32; + pure fn to_u64(&self) -> u64; + pure fn to_uint(&self) -> uint; + + pure fn to_i8(&self) -> i8; + pure fn to_i16(&self) -> i16; + pure fn to_i32(&self) -> i32; + pure fn to_i64(&self) -> i64; + pure fn to_int(&self) -> int; + + pure fn to_f32(&self) -> f32; + pure fn to_f64(&self) -> f64; + pure fn to_float(&self) -> float; +} + pub enum RoundMode { RoundDown, RoundUp, @@ -135,8 +170,8 @@ pub pure fn is_neg_zero(num: &T) -> bool { * - If code written to use this function doesn't care about it, it's * probably assuming that `x^0` always equals `1`. */ -pub pure fn pow_with_uint(radix: uint, - pow: uint) -> T { +pub pure fn pow_with_uint(radix: uint, + pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -144,7 +179,7 @@ pub pure fn pow_with_uint(radix: uint, if radix == 0u { return _0; } let mut my_pow = pow; let mut total = _1; - let mut multiplier = Num::from_int(radix as int); + let mut multiplier = cast(radix as int); while (my_pow > 0u) { if my_pow % 2u == 1u { total *= multiplier; @@ -217,7 +252,7 @@ pub enum SignFormat { * those special values, and `special` is `false`, because then the * algorithm just does normal calculations on them. */ -pub pure fn to_str_bytes_common( +pub pure fn to_str_bytes_common( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if radix as int < 2 { @@ -250,7 +285,7 @@ pub pure fn to_str_bytes_common( let neg = *num < _0 || (negative_zero && *num == _0 && special && is_neg_zero(num)); let mut buf: ~[u8] = ~[]; - let radix_gen = Num::from_int::(radix as int); + let radix_gen: T = cast(radix as int); let mut deccum; @@ -439,7 +474,7 @@ pub pure fn to_str_bytes_common( * `to_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn to_str_common( +pub pure fn to_str_common( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { let (bytes, special) = to_str_bytes_common(num, radix, special, @@ -494,7 +529,7 @@ priv const DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; * - Could accept option to allow ignoring underscores, allowing for numbers * formated like `FF_AE_FF_FF`. */ -pub pure fn from_str_bytes_common( +pub pure fn from_str_bytes_common( buf: &[u8], radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { @@ -519,7 +554,7 @@ pub pure fn from_str_bytes_common( let _0: T = Zero::zero(); let _1: T = One::one(); - let radix_gen: T = Num::from_int(radix as int); + let radix_gen: T = cast(radix as int); let len = buf.len(); @@ -570,9 +605,9 @@ pub pure fn from_str_bytes_common( // add/subtract current digit depending on sign if accum_positive { - accum += Num::from_int(digit as int); + accum += cast(digit as int); } else { - accum -= Num::from_int(digit as int); + accum -= cast(digit as int); } // Detect overflow by comparing to last value @@ -609,11 +644,13 @@ pub pure fn from_str_bytes_common( // Decrease power one order of magnitude power /= radix_gen; + let digit_t: T = cast(digit); + // add/subtract current digit depending on sign if accum_positive { - accum += Num::from_int::(digit as int) * power; + accum += digit_t * power; } else { - accum -= Num::from_int::(digit as int) * power; + accum -= digit_t * power; } // Detect overflow by comparing to last value @@ -679,7 +716,7 @@ pub pure fn from_str_bytes_common( * `from_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn from_str_common( +pub pure fn from_str_common( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index f8bbb35204add..0a219660fb946 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -146,11 +146,6 @@ impl T: num::Num { pure fn modulo(&self, other: &T) -> T { return *self % *other; } #[inline(always)] pure fn neg(&self) -> T { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> T { return n as T; } } impl T: num::Zero { @@ -409,6 +404,18 @@ pub fn test_ranges() { } } +#[test] +pub fn test_num() { + let ten: T = num::cast(10); + let two: T = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + #[test] #[should_fail] #[ignore(cfg(windows))] diff --git a/src/libcore/num/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index b9a007af2f67a..e2e8e2bc9fce2 100644 --- a/src/libcore/num/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u16` +use num::NumCast; + mod inst { pub type T = u16; #[allow(non_camel_case_types)] pub type T_SIGNED = i16; pub const bits: uint = 16; } + +pub impl u16: NumCast { + /** + * Cast `n` to a `u16` + */ + #[inline(always)] + static pure fn from(n: N) -> u16 { n.to_u16() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u16.to_uint()); + assert (20u8 == 20u16.to_u8()); + assert (20u16 == 20u16.to_u16()); + assert (20u32 == 20u16.to_u32()); + assert (20u64 == 20u16.to_u64()); + assert (20i == 20u16.to_int()); + assert (20i8 == 20u16.to_i8()); + assert (20i16 == 20u16.to_i16()); + assert (20i32 == 20u16.to_i32()); + assert (20i64 == 20u16.to_i64()); + assert (20f == 20u16.to_float()); + assert (20f32 == 20u16.to_f32()); + assert (20f64 == 20u16.to_f64()); + + assert (20u16 == NumCast::from(20u)); + assert (20u16 == NumCast::from(20u8)); + assert (20u16 == NumCast::from(20u16)); + assert (20u16 == NumCast::from(20u32)); + assert (20u16 == NumCast::from(20u64)); + assert (20u16 == NumCast::from(20i)); + assert (20u16 == NumCast::from(20i8)); + assert (20u16 == NumCast::from(20i16)); + assert (20u16 == NumCast::from(20i32)); + assert (20u16 == NumCast::from(20i64)); + assert (20u16 == NumCast::from(20f)); + assert (20u16 == NumCast::from(20f32)); + assert (20u16 == NumCast::from(20f64)); + + assert (20u16 == num::cast(20u)); + assert (20u16 == num::cast(20u8)); + assert (20u16 == num::cast(20u16)); + assert (20u16 == num::cast(20u32)); + assert (20u16 == num::cast(20u64)); + assert (20u16 == num::cast(20i)); + assert (20u16 == num::cast(20i8)); + assert (20u16 == num::cast(20i16)); + assert (20u16 == num::cast(20i32)); + assert (20u16 == num::cast(20i64)); + assert (20u16 == num::cast(20f)); + assert (20u16 == num::cast(20f32)); + assert (20u16 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 141509c49e555..ac2727bff0996 100644 --- a/src/libcore/num/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u32` +use num::NumCast; + mod inst { pub type T = u32; #[allow(non_camel_case_types)] pub type T_SIGNED = i32; pub const bits: uint = 32; +} + +pub impl u32: NumCast { + /** + * Cast `n` to a `u32` + */ + #[inline(always)] + static pure fn from(n: N) -> u32 { n.to_u32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u64.to_uint()); + assert (20u8 == 20u64.to_u8()); + assert (20u16 == 20u64.to_u16()); + assert (20u32 == 20u64.to_u32()); + assert (20u64 == 20u64.to_u64()); + assert (20i == 20u64.to_int()); + assert (20i8 == 20u64.to_i8()); + assert (20i16 == 20u64.to_i16()); + assert (20i32 == 20u64.to_i32()); + assert (20i64 == 20u64.to_i64()); + assert (20f == 20u64.to_float()); + assert (20f32 == 20u64.to_f32()); + assert (20f64 == 20u64.to_f64()); + + assert (20u64 == NumCast::from(20u)); + assert (20u64 == NumCast::from(20u8)); + assert (20u64 == NumCast::from(20u16)); + assert (20u64 == NumCast::from(20u32)); + assert (20u64 == NumCast::from(20u64)); + assert (20u64 == NumCast::from(20i)); + assert (20u64 == NumCast::from(20i8)); + assert (20u64 == NumCast::from(20i16)); + assert (20u64 == NumCast::from(20i32)); + assert (20u64 == NumCast::from(20i64)); + assert (20u64 == NumCast::from(20f)); + assert (20u64 == NumCast::from(20f32)); + assert (20u64 == NumCast::from(20f64)); + + assert (20u64 == num::cast(20u)); + assert (20u64 == num::cast(20u8)); + assert (20u64 == num::cast(20u16)); + assert (20u64 == num::cast(20u32)); + assert (20u64 == num::cast(20u64)); + assert (20u64 == num::cast(20i)); + assert (20u64 == num::cast(20i8)); + assert (20u64 == num::cast(20i16)); + assert (20u64 == num::cast(20i32)); + assert (20u64 == num::cast(20i64)); + assert (20u64 == num::cast(20f)); + assert (20u64 == num::cast(20f32)); + assert (20u64 == num::cast(20f64)); } \ No newline at end of file diff --git a/src/libcore/num/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index 35210eae9a75c..345f81c147c77 100644 --- a/src/libcore/num/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u64` +use num::NumCast; + mod inst { pub type T = u64; #[allow(non_camel_case_types)] pub type T_SIGNED = i64; pub const bits: uint = 64; +} + +pub impl u64: num::NumCast { + /** + * Cast `n` to a `u64` + */ + #[inline(always)] + static pure fn from(n: N) -> u64 { n.to_u64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u64.to_uint()); + assert (20u8 == 20u64.to_u8()); + assert (20u16 == 20u64.to_u16()); + assert (20u32 == 20u64.to_u32()); + assert (20u64 == 20u64.to_u64()); + assert (20i == 20u64.to_int()); + assert (20i8 == 20u64.to_i8()); + assert (20i16 == 20u64.to_i16()); + assert (20i32 == 20u64.to_i32()); + assert (20i64 == 20u64.to_i64()); + assert (20f == 20u64.to_float()); + assert (20f32 == 20u64.to_f32()); + assert (20f64 == 20u64.to_f64()); + + assert (20u64 == NumCast::from(20u)); + assert (20u64 == NumCast::from(20u8)); + assert (20u64 == NumCast::from(20u16)); + assert (20u64 == NumCast::from(20u32)); + assert (20u64 == NumCast::from(20u64)); + assert (20u64 == NumCast::from(20i)); + assert (20u64 == NumCast::from(20i8)); + assert (20u64 == NumCast::from(20i16)); + assert (20u64 == NumCast::from(20i32)); + assert (20u64 == NumCast::from(20i64)); + assert (20u64 == NumCast::from(20f)); + assert (20u64 == NumCast::from(20f32)); + assert (20u64 == NumCast::from(20f64)); + + assert (20u64 == num::cast(20u)); + assert (20u64 == num::cast(20u8)); + assert (20u64 == num::cast(20u16)); + assert (20u64 == num::cast(20u32)); + assert (20u64 == num::cast(20u64)); + assert (20u64 == num::cast(20i)); + assert (20u64 == num::cast(20i8)); + assert (20u64 == num::cast(20i16)); + assert (20u64 == num::cast(20i32)); + assert (20u64 == num::cast(20i64)); + assert (20u64 == num::cast(20f)); + assert (20u64 == num::cast(20f32)); + assert (20u64 == num::cast(20f64)); } \ No newline at end of file diff --git a/src/libcore/num/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index e273a20321326..71be36d901961 100644 --- a/src/libcore/num/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs @@ -12,6 +12,8 @@ pub use self::inst::is_ascii; +use num::NumCast; + mod inst { pub type T = u8; #[allow(non_camel_case_types)] @@ -23,3 +25,72 @@ mod inst { pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } } + +pub impl u8: NumCast { + /** + * Cast `n` to a `u8` + */ + #[inline(always)] + static pure fn from(n: N) -> u8 { n.to_u8() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u8.to_uint()); + assert (20u8 == 20u8.to_u8()); + assert (20u16 == 20u8.to_u16()); + assert (20u32 == 20u8.to_u32()); + assert (20u64 == 20u8.to_u64()); + assert (20i == 20u8.to_int()); + assert (20i8 == 20u8.to_i8()); + assert (20i16 == 20u8.to_i16()); + assert (20i32 == 20u8.to_i32()); + assert (20i64 == 20u8.to_i64()); + assert (20f == 20u8.to_float()); + assert (20f32 == 20u8.to_f32()); + assert (20f64 == 20u8.to_f64()); + + assert (20u8 == NumCast::from(20u)); + assert (20u8 == NumCast::from(20u8)); + assert (20u8 == NumCast::from(20u16)); + assert (20u8 == NumCast::from(20u32)); + assert (20u8 == NumCast::from(20u64)); + assert (20u8 == NumCast::from(20i)); + assert (20u8 == NumCast::from(20i8)); + assert (20u8 == NumCast::from(20i16)); + assert (20u8 == NumCast::from(20i32)); + assert (20u8 == NumCast::from(20i64)); + assert (20u8 == NumCast::from(20f)); + assert (20u8 == NumCast::from(20f32)); + assert (20u8 == NumCast::from(20f64)); + + assert (20u8 == num::cast(20u)); + assert (20u8 == num::cast(20u8)); + assert (20u8 == num::cast(20u16)); + assert (20u8 == num::cast(20u32)); + assert (20u8 == num::cast(20u64)); + assert (20u8 == num::cast(20i)); + assert (20u8 == num::cast(20i8)); + assert (20u8 == num::cast(20i16)); + assert (20u8 == num::cast(20i32)); + assert (20u8 == num::cast(20i64)); + assert (20u8 == num::cast(20f)); + assert (20u8 == num::cast(20f32)); + assert (20u8 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 93f59cd2d9f97..66689f18dfe99 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -10,6 +10,8 @@ //! Operations and constants for `uint` +use num::NumCast; + pub use self::inst::{ div_ceil, div_round, div_floor, iterate, next_power_of_two @@ -206,3 +208,72 @@ pub mod inst { assert (accum == 10); } } + +pub impl uint: NumCast { + /** + * Cast `n` to a `uint` + */ + #[inline(always)] + static pure fn from(n: N) -> uint { n.to_uint() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u.to_uint()); + assert (20u8 == 20u.to_u8()); + assert (20u16 == 20u.to_u16()); + assert (20u32 == 20u.to_u32()); + assert (20u64 == 20u.to_u64()); + assert (20i == 20u.to_int()); + assert (20i8 == 20u.to_i8()); + assert (20i16 == 20u.to_i16()); + assert (20i32 == 20u.to_i32()); + assert (20i64 == 20u.to_i64()); + assert (20f == 20u.to_float()); + assert (20f32 == 20u.to_f32()); + assert (20f64 == 20u.to_f64()); + + assert (20u == NumCast::from(20u)); + assert (20u == NumCast::from(20u8)); + assert (20u == NumCast::from(20u16)); + assert (20u == NumCast::from(20u32)); + assert (20u == NumCast::from(20u64)); + assert (20u == NumCast::from(20i)); + assert (20u == NumCast::from(20i8)); + assert (20u == NumCast::from(20i16)); + assert (20u == NumCast::from(20i32)); + assert (20u == NumCast::from(20i64)); + assert (20u == NumCast::from(20f)); + assert (20u == NumCast::from(20f32)); + assert (20u == NumCast::from(20f64)); + + assert (20u == num::cast(20u)); + assert (20u == num::cast(20u8)); + assert (20u == num::cast(20u16)); + assert (20u == num::cast(20u32)); + assert (20u == num::cast(20u64)); + assert (20u == num::cast(20i)); + assert (20u == num::cast(20i8)); + assert (20u == num::cast(20i16)); + assert (20u == num::cast(20i32)); + assert (20u == num::cast(20i64)); + assert (20u == num::cast(20f)); + assert (20u == num::cast(20f32)); + assert (20u == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index a798d8c866a3f..7ae7d0cd87404 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -29,7 +29,7 @@ pub use container::{Container, Mutable, Map, Set}; pub use hash::Hash; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::Num; +pub use num::{Num, NumCast}; pub use path::GenericPath; pub use path::Path; pub use path::PosixPath; diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index ca720c27d77ad..c7a049b2f34e0 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -11,16 +11,16 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; -pub trait NumExt: Num Eq Ord {} +pub trait NumExt: Num NumCast Eq Ord {} pub trait FloatExt: NumExt FuzzyEq {} -fn greater_than_one(n: &T) -> bool { *n > from_int(1) } -fn greater_than_one_float(n: &T) -> bool { *n > from_int(1) } +fn greater_than_one(n: &T) -> bool { *n > from(1) } +fn greater_than_one_float(n: &T) -> bool { *n > from(1) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index c7f43e055a4d3..1996e05618a0d 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -12,17 +12,17 @@ // Extending Num and using inherited static methods -use Num::from_int; +use num::NumCast::from; trait Num { static fn from_int(i: int) -> Self; fn gt(&self, other: &Self) -> bool; } -pub trait NumExt: Num { } +pub trait NumExt: Num NumCast { } fn greater_than_one(n: &T) -> bool { - n.gt(&from_int(1)) + n.gt(&from(1)) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 7546735993677..a9cbd4e622c40 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -11,12 +11,12 @@ // Using the real Num from core use cmp::Ord; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Num Ord { } +pub trait NumExt: Num NumCast Ord { } fn greater_than_one(n: &T) -> bool { - *n > from_int(1) + *n > from(1) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index ecedaac8daaab..6829990bc5acd 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -13,7 +13,7 @@ // A more complex example of numeric extensions use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; @@ -38,7 +38,7 @@ pub impl f64: TypeExt {} pub impl float: TypeExt {} -pub trait NumExt: TypeExt Eq Ord Num {} +pub trait NumExt: TypeExt Eq Ord Num NumCast {} pub impl u8: NumExt {} pub impl u16: NumExt {} diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index 939b074e2dd54..32775164d35ef 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -9,13 +9,13 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Eq Ord Num {} +pub trait NumExt: Eq Ord Num NumCast {} pub impl f32: NumExt {} -fn num_eq_one(n: T) { io::println(fmt!("%?", n == from_int(1))) } +fn num_eq_one(n: T) { io::println(fmt!("%?", n == from(1))) } pub fn main() { num_eq_one(1f32); // you need to actually use the function to trigger the ICE diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index bb9b57d4afb67..13c75224e5f88 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -9,15 +9,15 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Eq Num {} +pub trait NumExt: Eq Num NumCast {} pub impl f32: NumExt {} pub impl int: NumExt {} fn num_eq_one() -> T { - from_int(1) + from(1) } pub fn main() { From f9c15de1fd271032ff44288fa2f0599edd9dd204 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 10 Feb 2013 20:37:21 -0500 Subject: [PATCH 40/92] treemap: use an &mut parameter for skew and split results in a small performance improvement and reduces the compiled code size --- src/libstd/treemap.rs | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index d8deea60725a0..c3cb45a2bfb38 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -576,29 +576,25 @@ pure fn each_reverse(node: &r/Option<~TreeNode>, } // Remove left horizontal link by rotating right -fn skew(mut node: ~TreeNode) -> ~TreeNode { +fn skew(node: &mut ~TreeNode) { if node.left.map_default(false, |x| x.level == node.level) { let mut save = node.left.swap_unwrap(); node.left <-> save.right; // save.right now None - save.right = Some(node); - save - } else { - node // nothing to do + *node <-> save; + node.right = Some(save); } } // Remove dual horizontal link by rotating left and increasing level of // the parent -fn split(mut node: ~TreeNode) -> ~TreeNode { +fn split(node: &mut ~TreeNode) { if node.right.map_default(false, |x| x.right.map_default(false, |y| y.level == node.level)) { let mut save = node.right.swap_unwrap(); node.right <-> save.left; // save.left now None - save.left = Some(node); save.level += 1; - save - } else { - node // nothing to do + *node <-> save; + node.left = Some(save); } } @@ -611,11 +607,15 @@ fn insert(node: &mut Option<~TreeNode>, key: K, let mut save = node.swap_unwrap(); if key < save.key { let inserted = insert(&mut save.left, key, value); - *node = Some(split(skew(save))); // re-balance, if necessary + skew(&mut save); + split(&mut save); + *node = Some(save); // re-balance, if necessary inserted } else if save.key < key { let inserted = insert(&mut save.right, key, value); - *node = Some(split(skew(save))); // re-balance, if necessary + skew(&mut save); + split(&mut save); + *node = Some(save); // re-balance, if necessary inserted } else { save.key = key; @@ -684,15 +684,24 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { do save.right.mutate |mut x| { x.level = save.level; x } } - save = skew(save); + skew(&mut save); + + match save.right { + Some(ref mut right) => { + skew(right); + match right.right { + Some(ref mut x) => { skew(x) }, + None => () + } + } + None => () + } - do save.right.mutate |mut right| { - right = skew(right); - right.right.mutate(skew); - right + split(&mut save); + match save.right { + Some(ref mut x) => { split(x) }, + None => () } - save = split(save); - save.right.mutate(split); } *node = Some(save); From 195a969bb3e42e82e647e6ffead557f29884ff41 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 10 Feb 2013 20:44:15 -0500 Subject: [PATCH 41/92] treemap: avoid swap_unwrap in insert Performance before: std::treemap::TreeMap sequential_ints 0.151877 s random_ints 0.160926 s delete_ints 0.08694 s sequential_strings 0.316458 s random_strings 0.290778 s delete_strings 0.169892 s Performance after: std::treemap::TreeMap sequential_ints 0.083971 s random_ints 0.095861 s delete_ints 0.083931 s sequential_strings 0.278272 s random_strings 0.240286 s delete_strings 0.173581 s --- src/libstd/treemap.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index c3cb45a2bfb38..4b02a13583f8c 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -600,29 +600,28 @@ fn split(node: &mut ~TreeNode) { fn insert(node: &mut Option<~TreeNode>, key: K, value: V) -> bool { - if node.is_none() { - *node = Some(~TreeNode::new(key, value)); - true - } else { - let mut save = node.swap_unwrap(); + match *node { + Some(ref mut save) => { if key < save.key { let inserted = insert(&mut save.left, key, value); - skew(&mut save); - split(&mut save); - *node = Some(save); // re-balance, if necessary + skew(save); + split(save); inserted } else if save.key < key { let inserted = insert(&mut save.right, key, value); - skew(&mut save); - split(&mut save); - *node = Some(save); // re-balance, if necessary + skew(save); + split(save); inserted } else { save.key = key; save.value = value; - *node = Some(save); false } + } + None => { + *node = Some(~TreeNode::new(key, value)); + true + } } } From 33ae05871cc4366897e6461a26265ae0e12ef600 Mon Sep 17 00:00:00 2001 From: Zack Corr Date: Mon, 11 Feb 2013 12:11:23 +1000 Subject: [PATCH 42/92] core: Fix files that needed GenericChan/Port from prelude --- src/libcore/private.rs | 2 +- src/libcore/private/weak_task.rs | 3 ++- src/libcore/run.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 56e3325edba3e..6864572adfff6 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -14,7 +14,7 @@ use cast; use iter; use libc; use option; -use pipes; +use pipes::{GenericChan, GenericPort}; use prelude::*; use ptr; use result; diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 9d57cd5a466ac..e330bda0a61b1 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -22,7 +22,8 @@ use option::{Some, None, swap_unwrap}; use private::at_exit::at_exit; use private::global::global_data_clone_create; use private::finally::Finally; -use pipes::{Port, Chan, SharedChan, GenericSmartChan, stream}; +use pipes::{Port, Chan, SharedChan, GenericChan, GenericPort, + GenericSmartChan, stream}; use task::{Task, task, spawn}; use task::rt::{task_id, get_task_id}; use hashmap::linear::LinearMap; diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 43ecf350ff3cb..ae5c4d19b1c05 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -14,7 +14,7 @@ use io; use io::ReaderUtil; use libc; use libc::{pid_t, c_void, c_int}; -use pipes::{stream, SharedChan}; +use pipes::{stream, SharedChan, GenericChan, GenericPort}; use option::{Some, None}; use os; use prelude::*; From b0f58f6e684ca9076fac99e8f3917d01eeb5775e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 10 Feb 2013 21:11:33 -0500 Subject: [PATCH 43/92] avoid explicit reborrow in heir_swap --- src/libstd/treemap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 4b02a13583f8c..c100d8ca85dcd 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -631,7 +631,7 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { // *could* be done without recursion, but it won't borrow check do child.mutate |mut child| { if child.right.is_some() { - heir_swap(&mut *node, &mut child.right); + heir_swap(node, &mut child.right); } else { node.key <-> child.key; node.value <-> child.value; From f9c7ba009b51f39629d74ac67781c034643e74e8 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 10 Feb 2013 22:03:26 -0500 Subject: [PATCH 44/92] treemap: cut down on swap_unwrap in remove Performance before: std::treemap::TreeMap sequential_ints 0.083971 s random_ints 0.095861 s delete_ints 0.083931 s sequential_strings 0.278272 s random_strings 0.240286 s delete_strings 0.173581 s Performance after: std::treemap::TreeMap sequential_ints 0.083297 s random_ints 0.097644 s delete_ints 0.052602 s sequential_strings 0.287326 s random_strings 0.242372 s delete_strings 0.142269 s --- src/libstd/treemap.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index c100d8ca85dcd..d3583828f9aed 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -626,7 +626,7 @@ fn insert(node: &mut Option<~TreeNode>, key: K, } fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { - fn heir_swap(node: &mut TreeNode, + fn heir_swap(node: &mut ~TreeNode, child: &mut Option<~TreeNode>) { // *could* be done without recursion, but it won't borrow check do child.mutate |mut child| { @@ -640,15 +640,15 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { } } - if node.is_none() { + match *node { + None => { return false // bottom of tree - } else { - let mut save = node.swap_unwrap(); - - let removed = if save.key < *key { - remove(&mut save.right, key) + } + Some(ref mut save) => { + let (removed, this) = if save.key < *key { + (remove(&mut save.right, key), false) } else if *key < save.key { - remove(&mut save.left, key) + (remove(&mut save.left, key), false) } else { if save.left.is_some() { if save.right.is_some() { @@ -662,16 +662,22 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { save.left = Some(left); remove(&mut save.left, key); } else { - save = save.left.swap_unwrap(); + *save = save.left.swap_unwrap(); } + (true, false) } else if save.right.is_some() { - save = save.right.swap_unwrap(); + *save = save.right.swap_unwrap(); + (true, false) } else { - return true // leaf + (true, true) } - true }; + if this { + *node = None; + return true; + } + let left_level = save.left.map_default(0, |x| x.level); let right_level = save.right.map_default(0, |x| x.level); @@ -683,7 +689,7 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { do save.right.mutate |mut x| { x.level = save.level; x } } - skew(&mut save); + skew(save); match save.right { Some(ref mut right) => { @@ -696,15 +702,15 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { None => () } - split(&mut save); + split(save); match save.right { Some(ref mut x) => { split(x) }, None => () } } - *node = Some(save); removed + } } } From f2a8a712669911eb36166c35199fe18ce19ed7e9 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Mon, 11 Feb 2013 18:13:18 +0200 Subject: [PATCH 45/92] Use topmost span for macro expansion location. Fixes behaviour of file!, line! and col! --- src/libsyntax/ext/source_util.rs | 35 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 07dacc7c1b3b5..aa05e9a51198b 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -9,7 +9,7 @@ // except according to those terms. use codemap; -use codemap::{FileMap, Loc, Pos, span}; +use codemap::{FileMap, Loc, Pos, ExpandedFrom, span}; use ext::base::*; use ext::base; use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str}; @@ -21,20 +21,39 @@ use core::result; use core::str; use core::vec; +fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { + let ExpandedFrom({call_site, _}) = *expn_info; + match call_site.expn_info { + Some(next_expn_info) => { + let ExpandedFrom({callie: {name, _}, _}) = *next_expn_info; + // Don't recurse into file using "include!" + if name == ~"include" { return expn_info; } + + topmost_expn_info(next_expn_info) + }, + None => expn_info + } +} + /* line!(): expands to the current line number */ pub fn expand_line(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); - let loc = cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_uint(cx, sp, loc.line)) + + let topmost = topmost_expn_info(cx.backtrace().get()); + let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); + + base::MRExpr(mk_uint(cx, topmost.call_site, loc.line)) } /* col!(): expands to the current column number */ pub fn expand_col(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); - let loc = cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_uint(cx, sp, loc.col.to_uint())) + + let topmost = topmost_expn_info(cx.backtrace().get()); + let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); + base::MRExpr(mk_uint(cx, topmost.call_site, loc.col.to_uint())) } /* file!(): expands to the current filename */ @@ -43,9 +62,11 @@ pub fn expand_col(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) pub fn expand_file(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); + + let topmost = topmost_expn_info(cx.backtrace().get()); let Loc { file: @FileMap { name: filename, _ }, _ } = - cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_base_str(cx, sp, filename)) + cx.codemap().lookup_char_pos(topmost.call_site.lo); + base::MRExpr(mk_base_str(cx, topmost.call_site, filename)) } pub fn expand_stringify(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) From d48bc263b57c5b621f214fecf323362341682c02 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Mon, 11 Feb 2013 20:26:40 +0200 Subject: [PATCH 46/92] Add test for using line! in a macro --- src/test/run-pass/syntax-extension-source-utils.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 342ee4e351064..11effcf330f7c 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -17,9 +17,12 @@ pub mod m1 { } } +macro_rules! indirect_line( () => ( line!() ) ) + pub fn main() { - assert(line!() == 21); + assert(line!() == 23); assert(col!() == 11); + assert(indirect_line!() == 25); assert(file!().to_owned().ends_with(~"syntax-extension-source-utils.rs")); assert(stringify!((2*3) + 5).to_owned() == ~"( 2 * 3 ) + 5"); assert(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() From ca030b4fc85b4273c025287fb38c4d83432f5bf2 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Mon, 11 Feb 2013 21:02:36 +0200 Subject: [PATCH 47/92] Update copyright years --- src/libsyntax/ext/source_util.rs | 2 +- src/test/run-pass/syntax-extension-source-utils.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index aa05e9a51198b..a061c0dfafd47 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 11effcf330f7c..65ef3cc4f69fc 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // From 8ed1c15845a7970493ca4bd6a7415a7b5b47c96c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 11 Feb 2013 13:06:37 -0800 Subject: [PATCH 48/92] Fix license block --- src/libsyntax/ext/source_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index a061c0dfafd47..dadc2e527b601 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -1,5 +1,5 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 Date: Mon, 11 Feb 2013 15:02:16 -0800 Subject: [PATCH 49/92] Add Mikko Perttunen to AUTHORS --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index a7b55520b8d45..3c62ba0843765 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -114,6 +114,7 @@ Michael Arntzenius Michael Bebenita Michael Neumann Michael Sullivan +Mikko Perttunen Nick Desaulniers Niko Matsakis Or Brostovski From 0db527e2f8033e49ee588b3be71f3cd7a0d13b7c Mon Sep 17 00:00:00 2001 From: Zack Corr Date: Tue, 12 Feb 2013 12:27:19 +1000 Subject: [PATCH 50/92] core: Fix dec/inc_kernel_live_count mixup --- src/libcore/private/weak_task.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 1002fdb0c8c3e..7b9dfd9b457c9 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -40,12 +40,12 @@ pub unsafe fn weaken_task(f: &fn(Port)) { let task = get_task_id(); // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); - unsafe { rust_inc_kernel_live_count(); } + unsafe { rust_dec_kernel_live_count(); } do fn&() { let shutdown_port = swap_unwrap(&mut *shutdown_port); f(shutdown_port) }.finally || { - unsafe { rust_dec_kernel_live_count(); } + unsafe { rust_inc_kernel_live_count(); } // Service my have already exited service.send(UnregisterWeakTask(task)); } @@ -78,11 +78,11 @@ fn create_global_service() -> ~WeakTaskService { let port = swap_unwrap(&mut *port); // The weak task service is itself a weak task debug!("weakening the weak service task"); - unsafe { rust_inc_kernel_live_count(); } + unsafe { rust_dec_kernel_live_count(); } run_weak_task_service(port); }.finally { debug!("unweakening the weak service task"); - unsafe { rust_dec_kernel_live_count(); } + unsafe { rust_inc_kernel_live_count(); } } } From 970151770366a23cf206eb659ab6f29ec0d8d22b Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 11 Feb 2013 18:25:11 -0800 Subject: [PATCH 51/92] std: Fix uv_tcp_t size on i686-apple-darwin --- src/libstd/uv_ll.rs | 85 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 19 deletions(-) diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index e066f8c0bbfe7..be6b79059a9f2 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -99,7 +99,18 @@ pub struct uv_tcp_t { a08: *u8, a09: *u8, a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8, a16: *u8, a17: *u8, a18: *u8, a19: *u8, - a20: *u8, a21: *u8, a22: *u8, a23: *u8 + a20: *u8, a21: *u8, a22: *u8, + a23: uv_tcp_t_osx_riders +} +#[cfg(target_arch="x86_64")] +pub struct uv_tcp_t_osx_riders { + a23: *u8, +} +#[cfg(target_arch="x86")] +#[cfg(target_arch="arm")] +pub struct uv_tcp_t_osx_riders { + a23: *u8, + a24: *u8, a25: *u8, } #[cfg(target_os="linux")] #[cfg(target_os="freebsd")] @@ -440,24 +451,60 @@ pub mod uv_ll_struct_stubgen { } #[cfg(target_os = "macos")] pub fn gen_stub_os() -> uv_tcp_t { - uv_tcp_t { - fields: uv_handle_fields { - loop_handle: ptr::null(), type_: 0u32, - close_cb: ptr::null(), - data: ptr::null(), - }, - a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, - a03: 0 as *u8, - a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, - a07: 0 as *u8, - a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, - a11: 0 as *u8, - a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, - a15: 0 as *u8, - a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, - a19: 0 as *u8, - a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, - a23: 0 as *u8, + use super::uv_tcp_t_osx_riders; + + return gen_stub_arch(); + + #[cfg(target_arch = "x86_64")] + fn gen_stub_arch() -> uv_tcp_t { + uv_tcp_t { + fields: uv_handle_fields { + loop_handle: ptr::null(), type_: 0u32, + close_cb: ptr::null(), + data: ptr::null(), + }, + a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, + a03: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8, + a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, + a11: 0 as *u8, + a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, + a19: 0 as *u8, + a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, + a23: uv_tcp_t_osx_riders { + a23: 0 as *u8, + } + } + } + + #[cfg(target_arch = "x86")] + #[cfg(target_arch = "arm")] + fn gen_stub_arch() -> uv_tcp_t { + uv_tcp_t { + fields: uv_handle_fields { + loop_handle: ptr::null(), type_: 0u32, + close_cb: ptr::null(), + data: ptr::null(), + }, + a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, + a03: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8, + a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, + a11: 0 as *u8, + a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, + a19: 0 as *u8, + a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, + a23: uv_tcp_t_osx_riders { + a23: 0 as *u8, + a24: 0 as *u8, a25: 0 as *u8, + } + } } } } From a8f039a085c7d7622899b7a4d1bebfe2d7621165 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 11 Feb 2013 16:28:39 -0800 Subject: [PATCH 52/92] librustc: Make monomorphic newtype structs work cross-crate --- src/librustc/metadata/common.rs | 2 + src/librustc/metadata/csearch.rs | 5 +- src/librustc/metadata/decoder.rs | 24 ++++++--- src/librustc/metadata/encoder.rs | 69 +++++++++++++++++-------- src/librustc/middle/resolve.rs | 17 ++++-- src/librustc/middle/trans/base.rs | 9 +++- src/librustc/middle/trans/reachable.rs | 3 ++ src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/test/auxiliary/newtype_struct_xc.rs | 4 ++ src/test/run-pass/newtype-struct-xc.rs | 9 ++++ 11 files changed, 109 insertions(+), 37 deletions(-) create mode 100644 src/test/auxiliary/newtype_struct_xc.rs create mode 100644 src/test/run-pass/newtype-struct-xc.rs diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 37c19e80600b7..62bfdf4c3aa1b 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -153,5 +153,7 @@ pub const tag_lang_items_item: uint = 0x73; pub const tag_lang_items_item_id: uint = 0x74; pub const tag_lang_items_item_node_id: uint = 0x75; +pub const tag_item_unnamed_field: uint = 0x76; + pub type link_meta = {name: @str, vers: @str, extras_hash: @str}; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 2cb5cfbddd730..fa82e6c92c098 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -166,8 +166,9 @@ pub fn get_item_attrs(cstore: @mut cstore::CStore, decoder::get_item_attrs(cdata, def_id.node, f) } -pub fn get_struct_fields(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::field_ty] { - let cstore = tcx.cstore; +pub fn get_struct_fields(cstore: @mut cstore::CStore, + def: ast::def_id) + -> ~[ty::field_ty] { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_struct_fields(cstore.intr, cdata, def.node) } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 67498ad5aafe6..14dda96228206 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -42,7 +42,7 @@ use std::serialize::Decodable; use syntax::ast_map; use syntax::attr; use syntax::diagnostic::span_handler; -use syntax::parse::token::ident_interner; +use syntax::parse::token::{ident_interner, special_idents}; use syntax::print::pprust; use syntax::{ast, ast_util}; use syntax::codemap; @@ -231,7 +231,9 @@ pub fn item_type(item_id: ast::def_id, item: ebml::Doc, let t = doc_type(item, tcx, cdata); if family_names_type(item_family(item)) { ty::mk_with_id(tcx, t, item_id) - } else { t } + } else { + t + } } fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { @@ -661,11 +663,12 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, rslt } -pub fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, - m_id: ast::node_id, name: Option, - get_cdata: fn(ast::crate_num) -> cmd) +pub fn get_impls_for_mod(intr: @ident_interner, + cdata: cmd, + m_id: ast::node_id, + name: Option, + get_cdata: &fn(ast::crate_num) -> cmd) -> @~[@_impl] { - let data = cdata.data; let mod_item = lookup_item(m_id, data); let mut result = ~[]; @@ -887,6 +890,15 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) }); } } + for reader::tagged_docs(item, tag_item_unnamed_field) |an_item| { + let did = item_def_id(an_item, cdata); + result.push(ty::field_ty { + ident: special_idents::unnamed_field, + id: did, + vis: ast::inherited, + mutability: ast::struct_immutable, + }); + } result } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index fcc1a4e806dff..e6dcf17f34c98 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -46,6 +46,7 @@ use syntax::ast_map; use syntax::ast_util::*; use syntax::attr; use syntax::diagnostic::span_handler; +use syntax::parse::token::special_idents; use syntax::print::pprust; use syntax::{ast_util, visit}; use syntax; @@ -328,7 +329,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder, // Encode info about all the module children. for md.items.each |item| { match item.node { - item_impl(*) | item_struct(*) => { + item_impl(*) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl %s \ (%?/%?)", @@ -432,25 +433,28 @@ fn encode_info_for_struct(ecx: @encode_ctxt, ebml_w: writer::Encoder, /* We encode both private and public fields -- need to include private fields to get the offsets right */ for fields.each |field| { - match field.node.kind { - named_field(nm, mt, vis) => { - let id = field.node.id; - index.push({val: id, pos: ebml_w.writer.tell()}); - global_index.push({val: id, - pos: ebml_w.writer.tell()}); - ebml_w.start_tag(tag_items_data_item); - debug!("encode_info_for_struct: doing %s %d", - tcx.sess.str_of(nm), id); - encode_visibility(ebml_w, vis); - encode_name(ecx, ebml_w, nm); - encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); - encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); - encode_mutability(ebml_w, mt); - encode_def_id(ebml_w, local_def(id)); - ebml_w.end_tag(); - } - unnamed_field => {} - } + let (nm, mt, vis) = match field.node.kind { + named_field(nm, mt, vis) => (nm, mt, vis), + unnamed_field => ( + special_idents::unnamed_field, + struct_immutable, + inherited + ) + }; + + let id = field.node.id; + index.push({val: id, pos: ebml_w.writer.tell()}); + global_index.push({val: id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + debug!("encode_info_for_struct: doing %s %d", + tcx.sess.str_of(nm), id); + encode_visibility(ebml_w, vis); + encode_name(ecx, ebml_w, nm); + encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); + encode_mutability(ebml_w, mt); + encode_def_id(ebml_w, local_def(id)); + ebml_w.end_tag(); } /*bad*/copy *index } @@ -673,7 +677,24 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_def_id(ebml_w, local_def(item.id)); encode_family(ebml_w, 'S'); encode_type_param_bounds(ebml_w, ecx, tps); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + + // If this is a tuple- or enum-like struct, encode the type of the + // constructor. Otherwise, encode the type of the struct. + if struct_def.fields.len() > 0 && + struct_def.fields[0].node.kind == ast::unnamed_field { + // Tuple- or enum-like struct. + let ctor_id = match struct_def.ctor_id { + Some(ctor_id) => ctor_id, + None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), + }; + encode_type(ecx, ebml_w, node_id_to_type(tcx, ctor_id)); + + // Also encode the symbol. + encode_symbol(ecx, ebml_w, ctor_id); + } else { + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + } + encode_name(ecx, ebml_w, item.ident); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_region_param(ecx, ebml_w, item); @@ -697,7 +718,11 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); } - unnamed_field => {} + unnamed_field => { + ebml_w.start_tag(tag_item_unnamed_field); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index ba550dbbde8ed..14e27f328d1e9 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -13,7 +13,8 @@ use core::prelude::*; use driver::session; use driver::session::Session; use metadata::csearch::{each_path, get_method_names_if_trait}; -use metadata::csearch::{get_static_methods_if_impl, get_type_name_if_impl}; +use metadata::csearch::{get_static_methods_if_impl, get_struct_fields}; +use metadata::csearch::{get_type_name_if_impl}; use metadata::cstore::find_use_stmt_cnum; use metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; use middle::lang_items::LanguageItems; @@ -1659,6 +1660,14 @@ pub impl Resolver { crate) building type %s", final_ident); child_name_bindings.define_type(Public, def, dummy_sp()); + + // Define the struct constructor if this is a tuple-like struct. + let fields = get_struct_fields(self.session.cstore, def_id); + if fields.len() != 0 && + fields[0].ident == special_idents::unnamed_field { + child_name_bindings.define_value(Public, def, dummy_sp()); + } + self.structs.insert(def_id, ()); } def_self(*) | def_arg(*) | def_local(*) | @@ -1745,10 +1754,12 @@ pub impl Resolver { OverwriteDuplicates, dummy_sp()); - self.handle_external_def(def, modules, + self.handle_external_def(def, + modules, child_name_bindings, self.session.str_of(final_ident), - final_ident, new_parent); + final_ident, + new_parent); } dl_impl(def) => { // We only process static methods of impls here. diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index ced47bb5681b1..c61ff7d5e0267 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1905,8 +1905,13 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt, } }; - let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, ctor_id, None, - param_substs, None); + let fcx = new_fn_ctxt_w_id(ccx, + ~[], + llfndecl, + ctor_id, + None, + param_substs, + None); // XXX: Bad copy. let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index f77aa33407d10..bf417e9a5f4f9 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -122,6 +122,9 @@ fn traverse_public_item(cx: ctx, item: @item) { } } item_struct(struct_def, tps) => { + for struct_def.ctor_id.each |&ctor_id| { + cx.rmap.insert(ctor_id, ()); + } do option::iter(&struct_def.dtor) |dtor| { cx.rmap.insert(dtor.node.id, ()); if tps.len() > 0u || attr::find_inline_attr(dtor.node.attrs) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 4350c62af6fc3..136a2f055651f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4011,7 +4011,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } } else { - return csearch::get_struct_fields(cx, did); + return csearch::get_struct_fields(cx.sess.cstore, did); } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 5e51c21609300..fdf936f7aec62 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -828,7 +828,7 @@ pub impl CoherenceChecker { let implementations = get_impls_for_mod(crate_store, module_def_id, None); - for (*implementations).each |implementation| { + for implementations.each |implementation| { debug!("coherence: adding impl from external crate: %s", ty::item_path_str(self.crate_context.tcx, implementation.did)); diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs new file mode 100644 index 0000000000000..90036e0f96cd8 --- /dev/null +++ b/src/test/auxiliary/newtype_struct_xc.rs @@ -0,0 +1,4 @@ +#[crate_type="lib"]; + +pub struct Au(int); + diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs new file mode 100644 index 0000000000000..8b15d73dc933d --- /dev/null +++ b/src/test/run-pass/newtype-struct-xc.rs @@ -0,0 +1,9 @@ +// xfail-fast +// aux-build:newtype_struct_xc.rs + +extern mod newtype_struct_xc; + +fn main() { + let _ = newtype_struct_xc::Au(2); +} + From 9877d98b8f91be7e1494e84d685882996b84c877 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Mon, 11 Feb 2013 20:07:25 -0500 Subject: [PATCH 53/92] core: Rewrite last_os_error in Rust for unix and provide access to errno (unix) and GetLastError (windows). --- src/libcore/os.rs | 112 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 9 deletions(-) diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 38469c35cfa6c..8abbce0649d11 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -66,7 +66,7 @@ extern mod rustrt { unsafe fn rust_set_exit_status(code: libc::intptr_t); } -pub const tmpbuf_sz : uint = 1000u; +pub const TMPBUF_SZ : uint = 1000u; pub fn getcwd() -> Path { unsafe { @@ -80,7 +80,7 @@ pub fn as_c_charp(s: &str, f: fn(*c_char) -> T) -> T { pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) -> Option<~str> { - let buf = vec::cast_to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char)); + let buf = vec::cast_to_mut(vec::from_elem(TMPBUF_SZ, 0u8 as c_char)); do vec::as_mut_buf(buf) |b, sz| { if f(b, sz as size_t) { unsafe { @@ -99,19 +99,19 @@ pub mod win32 { use str; use option::{None, Option}; use option; - use os::tmpbuf_sz; + use os::TMPBUF_SZ; use libc::types::os::arch::extra::DWORD; pub fn fill_utf16_buf_and_decode(f: fn(*mut u16, DWORD) -> DWORD) -> Option<~str> { unsafe { - let mut n = tmpbuf_sz as DWORD; + let mut n = TMPBUF_SZ as DWORD; let mut res = None; let mut done = false; while !done { let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16)); do vec::as_mut_buf(buf) |b, _sz| { - let k : DWORD = f(b, tmpbuf_sz as DWORD); + let k : DWORD = f(b, TMPBUF_SZ as DWORD); if k == (0 as DWORD) { done = true; } else if (k == n && @@ -387,11 +387,11 @@ pub fn self_exe_path() -> Option { unsafe { use libc::funcs::posix01::unistd::readlink; - let mut path_str = str::with_capacity(tmpbuf_sz); + let mut path_str = str::with_capacity(TMPBUF_SZ); let len = do str::as_c_str(path_str) |buf| { let buf = buf as *mut c_char; do as_c_charp("/proc/self/exe") |proc_self_buf| { - readlink(proc_self_buf, buf, tmpbuf_sz as size_t) + readlink(proc_self_buf, buf, TMPBUF_SZ as size_t) } }; if len == -1 { @@ -766,11 +766,105 @@ pub fn remove_file(p: &Path) -> bool { } } +#[cfg(unix)] +pub fn errno() -> int { + #[cfg(target_os = "macos")] + #[cfg(target_os = "freebsd")] + fn errno_location() -> *c_int { + #[nolink] + extern { + unsafe fn __error() -> *c_int; + } + unsafe { + __error() + } + } + + #[cfg(target_os = "linux")] + #[cfg(target_os = "android")] + fn errno_location() -> *c_int { + #[nolink] + extern { + unsafe fn __errno_location() -> *c_int; + } + unsafe { + __errno_location() + } + } + + unsafe { + (*errno_location()) as int + } +} + +#[cfg(windows)] +pub fn errno() -> uint { + use libc::types::os::arch::extra::DWORD; + + #[link_name = "kernel32"] + #[abi = "stdcall"] + extern { + unsafe fn GetLastError() -> DWORD; + } + + unsafe { + GetLastError() as uint; + } +} + /// Get a string representing the platform-dependent last error pub fn last_os_error() -> ~str { - unsafe { - rustrt::last_os_error() + #[cfg(unix)] + fn strerror() -> ~str { + #[cfg(target_os = "macos")] + #[cfg(target_os = "android")] + #[cfg(target_os = "freebsd")] + fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int { + #[nolink] + extern { + unsafe fn strerror_r(errnum: c_int, buf: *c_char, + buflen: size_t) -> c_int; + } + unsafe { + strerror_r(errnum, buf, buflen) + } + } + + // GNU libc provides a non-compliant version of strerror_r by default + // and requires macros to instead use the POSIX compliant variant. + // So instead we just use __xpg_strerror_r which is always POSIX compliant + #[cfg(target_os = "linux")] + fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int { + #[nolink] + extern { + unsafe fn __xpg_strerror_r(errnum: c_int, buf: *c_char, + buflen: size_t) -> c_int; + } + unsafe { + __xpg_strerror_r(errnum, buf, buflen) + } + } + + let mut buf = [0 as c_char, ..TMPBUF_SZ]; + unsafe { + let err = strerror_r(errno() as c_int, &buf[0], + TMPBUF_SZ as size_t); + if err < 0 { + die!(~"strerror_r failure"); + } + + str::raw::from_c_str(&buf[0]) + } } + + #[cfg(windows)] + fn strerror() -> ~str { + unsafe { + rustrt::last_os_error() + } + } + + strerror() } /** From 625fac3c7eea1d28a38f0636b100b60dd4be15aa Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Mon, 11 Feb 2013 23:07:29 -0500 Subject: [PATCH 54/92] core: Rewrite last_os_error in Rust for windows as well. --- src/libcore/os.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 8abbce0649d11..d067a83c2e6ea 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -808,7 +808,7 @@ pub fn errno() -> uint { } unsafe { - GetLastError() as uint; + GetLastError() as uint } } @@ -852,15 +852,45 @@ pub fn last_os_error() -> ~str { if err < 0 { die!(~"strerror_r failure"); } - + str::raw::from_c_str(&buf[0]) } } #[cfg(windows)] fn strerror() -> ~str { + use libc::types::os::arch::extra::DWORD; + use libc::types::os::arch::extra::LPSTR; + use libc::types::os::arch::extra::LPVOID; + + #[link_name = "kernel32"] + #[abi = "stdcall"] + extern { + unsafe fn FormatMessageA(flags: DWORD, lpSrc: LPVOID, + msgId: DWORD, langId: DWORD, + buf: LPSTR, nsize: DWORD, + args: *c_void) -> DWORD; + } + + const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; + const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; + + let mut buf = [0 as c_char, ..TMPBUF_SZ]; + + // This value is calculated from the macro + // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) + let langId = 0x0800 as DWORD; + let err = errno() as DWORD; unsafe { - rustrt::last_os_error() + let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + ptr::mut_null(), err, langId, + &mut buf[0], TMPBUF_SZ as DWORD, ptr::null()); + if res == 0 { + die!(fmt!("[%?] FormatMessage failure", errno())); + } + + str::raw::from_c_str(&buf[0]) } } From 70185fdcc22e2cd11ee5d6171395f3c223bc21e6 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Mon, 11 Feb 2013 23:27:12 -0500 Subject: [PATCH 55/92] rt: remove last_os_error and adjust tests. --- src/libcore/os.rs | 1 - src/rt/rust_builtin.cpp | 44 ------------------- .../anon-extern-mod-cross-crate-1.rs | 2 +- src/test/auxiliary/foreign_lib.rs | 2 +- src/test/run-fail/morestack2.rs | 4 +- .../run-pass/anon-extern-mod-cross-crate-2.rs | 2 +- src/test/run-pass/anon-extern-mod.rs | 4 +- src/test/run-pass/foreign-dupe.rs | 8 ++-- src/test/run-pass/invoke-external-foreign.rs | 2 +- src/test/run-pass/morestack6.rs | 4 +- 10 files changed, 14 insertions(+), 59 deletions(-) diff --git a/src/libcore/os.rs b/src/libcore/os.rs index d067a83c2e6ea..dba3293a22830 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -62,7 +62,6 @@ extern mod rustrt { unsafe fn rust_path_exists(path: *libc::c_char) -> c_int; unsafe fn rust_list_files2(&&path: ~str) -> ~[~str]; unsafe fn rust_process_wait(handle: c_int) -> c_int; - unsafe fn last_os_error() -> ~str; unsafe fn rust_set_exit_status(code: libc::intptr_t); } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index e14f62ffae936..24d7a5b287a46 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -52,50 +52,6 @@ timegm(struct tm *tm) } #endif - -extern "C" CDECL rust_str* -last_os_error() { - rust_task *task = rust_get_current_task(); - - LOG(task, task, "last_os_error()"); - -#if defined(__WIN32__) - LPTSTR buf; - DWORD err = GetLastError(); - DWORD res = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buf, 0, NULL); - if (!res) { - task->fail(); - return NULL; - } -#elif defined(_GNU_SOURCE) && !defined(__ANDROID__) - char cbuf[BUF_BYTES]; - char *buf = strerror_r(errno, cbuf, sizeof(cbuf)); - if (!buf) { - task->fail(); - return NULL; - } -#else - char buf[BUF_BYTES]; - int err = strerror_r(errno, buf, sizeof(buf)); - if (err) { - task->fail(); - return NULL; - } -#endif - - rust_str * st = make_str(task->kernel, buf, strlen(buf), - "last_os_error"); -#ifdef __WIN32__ - LocalFree((HLOCAL)buf); -#endif - return st; -} - extern "C" CDECL rust_str * rust_getcwd() { rust_task *task = rust_get_current_task(); diff --git a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs index bbe36f18d6c34..bccbb8173aad1 100644 --- a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -15,5 +15,5 @@ #[crate_type = "lib"]; extern { - fn last_os_error() -> ~str; + fn rust_get_argc() -> libc::c_int; } diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index eb3397a8a5f46..1d9c1cdbf83f0 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -11,5 +11,5 @@ #[link(name="foreign_lib", vers="0.0")]; pub extern mod rustrt { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 58957aac2038a..8236489834d11 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -18,7 +18,7 @@ extern mod std; extern mod rustrt { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } fn getbig_call_c_and_fail(i: int) { @@ -26,7 +26,7 @@ fn getbig_call_c_and_fail(i: int) { getbig_call_c_and_fail(i - 1); } else { unsafe { - rustrt::last_os_error(); + rustrt::rust_get_argc(); die!(); } } diff --git a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs index 939903b3b124a..ed57b32b3d9e5 100644 --- a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs +++ b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs @@ -15,5 +15,5 @@ extern mod anonexternmod; use anonexternmod::*; pub fn main() { - last_os_error(); + rust_get_argc(); } diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs index 525e6b9fbd6d9..6e73022fad2e1 100644 --- a/src/test/run-pass/anon-extern-mod.rs +++ b/src/test/run-pass/anon-extern-mod.rs @@ -11,11 +11,11 @@ #[abi = "cdecl"] #[link_name = "rustrt"] extern { - fn last_os_error() -> ~str; + fn rust_get_argc() -> libc::c_int; } pub fn main() { unsafe { - let _ = last_os_error(); + let _ = rust_get_argc(); } } diff --git a/src/test/run-pass/foreign-dupe.rs b/src/test/run-pass/foreign-dupe.rs index 77ed95a809980..6230fe11363ad 100644 --- a/src/test/run-pass/foreign-dupe.rs +++ b/src/test/run-pass/foreign-dupe.rs @@ -14,18 +14,18 @@ #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt1 { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt2 { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } pub fn main() { unsafe { - rustrt1::last_os_error(); - rustrt2::last_os_error(); + rustrt1::rust_get_argc(); + rustrt2::rust_get_argc(); } } diff --git a/src/test/run-pass/invoke-external-foreign.rs b/src/test/run-pass/invoke-external-foreign.rs index cc50e06199db4..69fce9e541e06 100644 --- a/src/test/run-pass/invoke-external-foreign.rs +++ b/src/test/run-pass/invoke-external-foreign.rs @@ -18,5 +18,5 @@ extern mod foreign_lib; pub fn main() { - let foo = foreign_lib::rustrt::last_os_error(); + let foo = foreign_lib::rustrt::rust_get_argc(); } diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index 9b852cbc635aa..d56d9c30b7066 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -15,7 +15,7 @@ extern mod rustrt { pub fn debug_get_stk_seg() -> *u8; pub fn rust_get_sched_id() -> libc::intptr_t; - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; pub fn rust_getcwd() -> ~str; pub fn get_task_id() -> libc::intptr_t; pub fn rust_sched_threads(); @@ -23,7 +23,7 @@ extern mod rustrt { } fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } } -fn calllink02() { unsafe { rustrt::last_os_error(); } } +fn calllink02() { unsafe { rustrt::rust_get_argc(); } } fn calllink03() { unsafe { rustrt::rust_getcwd(); } } fn calllink08() { unsafe { rustrt::get_task_id(); } } fn calllink09() { unsafe { rustrt::rust_sched_threads(); } } From 44b80ed0d6de641cd95a8b9d0b8f8844ea46accf Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Mon, 11 Feb 2013 23:49:20 -0500 Subject: [PATCH 56/92] Long lines. --- src/libcore/os.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/os.rs b/src/libcore/os.rs index dba3293a22830..0efc17354dd58 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -831,7 +831,7 @@ pub fn last_os_error() -> ~str { // GNU libc provides a non-compliant version of strerror_r by default // and requires macros to instead use the POSIX compliant variant. - // So instead we just use __xpg_strerror_r which is always POSIX compliant + // So we just use __xpg_strerror_r which is always POSIX compliant #[cfg(target_os = "linux")] fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int { #[nolink] @@ -884,7 +884,8 @@ pub fn last_os_error() -> ~str { let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, ptr::mut_null(), err, langId, - &mut buf[0], TMPBUF_SZ as DWORD, ptr::null()); + &mut buf[0], TMPBUF_SZ as DWORD, + ptr::null()); if res == 0 { die!(fmt!("[%?] FormatMessage failure", errno())); } From 2180fe25520727a747c5a73b4d582a120ad116bd Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 12 Feb 2013 00:22:58 -0500 Subject: [PATCH 57/92] rt: remove last_os_error from rustrt.def.in --- src/rt/rustrt.def.in | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 2e687472a8d6f..b49aa89b6c8df 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -14,7 +14,6 @@ rust_gmtime rust_localtime rust_timegm rust_mktime -last_os_error new_task precise_time_ns rand_free From 1d82d8dd5def0713a78f864f47a4c9a65f8bf6cc Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 12 Feb 2013 09:02:17 -0800 Subject: [PATCH 58/92] Revert "librustc: Make monomorphic newtype structs work cross-crate" This reverts commit a8f039a085c7d7622899b7a4d1bebfe2d7621165. --- src/librustc/metadata/common.rs | 2 - src/librustc/metadata/csearch.rs | 5 +- src/librustc/metadata/decoder.rs | 24 +++------ src/librustc/metadata/encoder.rs | 69 ++++++++----------------- src/librustc/middle/resolve.rs | 17 ++---- src/librustc/middle/trans/base.rs | 9 +--- src/librustc/middle/trans/reachable.rs | 3 -- src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/test/auxiliary/newtype_struct_xc.rs | 4 -- src/test/run-pass/newtype-struct-xc.rs | 9 ---- 11 files changed, 37 insertions(+), 109 deletions(-) delete mode 100644 src/test/auxiliary/newtype_struct_xc.rs delete mode 100644 src/test/run-pass/newtype-struct-xc.rs diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 62bfdf4c3aa1b..37c19e80600b7 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -153,7 +153,5 @@ pub const tag_lang_items_item: uint = 0x73; pub const tag_lang_items_item_id: uint = 0x74; pub const tag_lang_items_item_node_id: uint = 0x75; -pub const tag_item_unnamed_field: uint = 0x76; - pub type link_meta = {name: @str, vers: @str, extras_hash: @str}; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index fa82e6c92c098..2cb5cfbddd730 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -166,9 +166,8 @@ pub fn get_item_attrs(cstore: @mut cstore::CStore, decoder::get_item_attrs(cdata, def_id.node, f) } -pub fn get_struct_fields(cstore: @mut cstore::CStore, - def: ast::def_id) - -> ~[ty::field_ty] { +pub fn get_struct_fields(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::field_ty] { + let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_struct_fields(cstore.intr, cdata, def.node) } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 14dda96228206..67498ad5aafe6 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -42,7 +42,7 @@ use std::serialize::Decodable; use syntax::ast_map; use syntax::attr; use syntax::diagnostic::span_handler; -use syntax::parse::token::{ident_interner, special_idents}; +use syntax::parse::token::ident_interner; use syntax::print::pprust; use syntax::{ast, ast_util}; use syntax::codemap; @@ -231,9 +231,7 @@ pub fn item_type(item_id: ast::def_id, item: ebml::Doc, let t = doc_type(item, tcx, cdata); if family_names_type(item_family(item)) { ty::mk_with_id(tcx, t, item_id) - } else { - t - } + } else { t } } fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { @@ -663,12 +661,11 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, rslt } -pub fn get_impls_for_mod(intr: @ident_interner, - cdata: cmd, - m_id: ast::node_id, - name: Option, - get_cdata: &fn(ast::crate_num) -> cmd) +pub fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, + m_id: ast::node_id, name: Option, + get_cdata: fn(ast::crate_num) -> cmd) -> @~[@_impl] { + let data = cdata.data; let mod_item = lookup_item(m_id, data); let mut result = ~[]; @@ -890,15 +887,6 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) }); } } - for reader::tagged_docs(item, tag_item_unnamed_field) |an_item| { - let did = item_def_id(an_item, cdata); - result.push(ty::field_ty { - ident: special_idents::unnamed_field, - id: did, - vis: ast::inherited, - mutability: ast::struct_immutable, - }); - } result } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e6dcf17f34c98..fcc1a4e806dff 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -46,7 +46,6 @@ use syntax::ast_map; use syntax::ast_util::*; use syntax::attr; use syntax::diagnostic::span_handler; -use syntax::parse::token::special_idents; use syntax::print::pprust; use syntax::{ast_util, visit}; use syntax; @@ -329,7 +328,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder, // Encode info about all the module children. for md.items.each |item| { match item.node { - item_impl(*) => { + item_impl(*) | item_struct(*) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl %s \ (%?/%?)", @@ -433,28 +432,25 @@ fn encode_info_for_struct(ecx: @encode_ctxt, ebml_w: writer::Encoder, /* We encode both private and public fields -- need to include private fields to get the offsets right */ for fields.each |field| { - let (nm, mt, vis) = match field.node.kind { - named_field(nm, mt, vis) => (nm, mt, vis), - unnamed_field => ( - special_idents::unnamed_field, - struct_immutable, - inherited - ) - }; - - let id = field.node.id; - index.push({val: id, pos: ebml_w.writer.tell()}); - global_index.push({val: id, pos: ebml_w.writer.tell()}); - ebml_w.start_tag(tag_items_data_item); - debug!("encode_info_for_struct: doing %s %d", - tcx.sess.str_of(nm), id); - encode_visibility(ebml_w, vis); - encode_name(ecx, ebml_w, nm); - encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); - encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); - encode_mutability(ebml_w, mt); - encode_def_id(ebml_w, local_def(id)); - ebml_w.end_tag(); + match field.node.kind { + named_field(nm, mt, vis) => { + let id = field.node.id; + index.push({val: id, pos: ebml_w.writer.tell()}); + global_index.push({val: id, + pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + debug!("encode_info_for_struct: doing %s %d", + tcx.sess.str_of(nm), id); + encode_visibility(ebml_w, vis); + encode_name(ecx, ebml_w, nm); + encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); + encode_mutability(ebml_w, mt); + encode_def_id(ebml_w, local_def(id)); + ebml_w.end_tag(); + } + unnamed_field => {} + } } /*bad*/copy *index } @@ -677,24 +673,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_def_id(ebml_w, local_def(item.id)); encode_family(ebml_w, 'S'); encode_type_param_bounds(ebml_w, ecx, tps); - - // If this is a tuple- or enum-like struct, encode the type of the - // constructor. Otherwise, encode the type of the struct. - if struct_def.fields.len() > 0 && - struct_def.fields[0].node.kind == ast::unnamed_field { - // Tuple- or enum-like struct. - let ctor_id = match struct_def.ctor_id { - Some(ctor_id) => ctor_id, - None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), - }; - encode_type(ecx, ebml_w, node_id_to_type(tcx, ctor_id)); - - // Also encode the symbol. - encode_symbol(ecx, ebml_w, ctor_id); - } else { - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - } - + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); encode_name(ecx, ebml_w, item.ident); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_region_param(ecx, ebml_w, item); @@ -718,11 +697,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); } - unnamed_field => { - ebml_w.start_tag(tag_item_unnamed_field); - encode_def_id(ebml_w, local_def(f.node.id)); - ebml_w.end_tag(); - } + unnamed_field => {} } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 14e27f328d1e9..ba550dbbde8ed 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -13,8 +13,7 @@ use core::prelude::*; use driver::session; use driver::session::Session; use metadata::csearch::{each_path, get_method_names_if_trait}; -use metadata::csearch::{get_static_methods_if_impl, get_struct_fields}; -use metadata::csearch::{get_type_name_if_impl}; +use metadata::csearch::{get_static_methods_if_impl, get_type_name_if_impl}; use metadata::cstore::find_use_stmt_cnum; use metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; use middle::lang_items::LanguageItems; @@ -1660,14 +1659,6 @@ pub impl Resolver { crate) building type %s", final_ident); child_name_bindings.define_type(Public, def, dummy_sp()); - - // Define the struct constructor if this is a tuple-like struct. - let fields = get_struct_fields(self.session.cstore, def_id); - if fields.len() != 0 && - fields[0].ident == special_idents::unnamed_field { - child_name_bindings.define_value(Public, def, dummy_sp()); - } - self.structs.insert(def_id, ()); } def_self(*) | def_arg(*) | def_local(*) | @@ -1754,12 +1745,10 @@ pub impl Resolver { OverwriteDuplicates, dummy_sp()); - self.handle_external_def(def, - modules, + self.handle_external_def(def, modules, child_name_bindings, self.session.str_of(final_ident), - final_ident, - new_parent); + final_ident, new_parent); } dl_impl(def) => { // We only process static methods of impls here. diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c61ff7d5e0267..ced47bb5681b1 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1905,13 +1905,8 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt, } }; - let fcx = new_fn_ctxt_w_id(ccx, - ~[], - llfndecl, - ctor_id, - None, - param_substs, - None); + let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, ctor_id, None, + param_substs, None); // XXX: Bad copy. let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index bf417e9a5f4f9..f77aa33407d10 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -122,9 +122,6 @@ fn traverse_public_item(cx: ctx, item: @item) { } } item_struct(struct_def, tps) => { - for struct_def.ctor_id.each |&ctor_id| { - cx.rmap.insert(ctor_id, ()); - } do option::iter(&struct_def.dtor) |dtor| { cx.rmap.insert(dtor.node.id, ()); if tps.len() > 0u || attr::find_inline_attr(dtor.node.attrs) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 136a2f055651f..4350c62af6fc3 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4011,7 +4011,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } } else { - return csearch::get_struct_fields(cx.sess.cstore, did); + return csearch::get_struct_fields(cx, did); } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index fdf936f7aec62..5e51c21609300 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -828,7 +828,7 @@ pub impl CoherenceChecker { let implementations = get_impls_for_mod(crate_store, module_def_id, None); - for implementations.each |implementation| { + for (*implementations).each |implementation| { debug!("coherence: adding impl from external crate: %s", ty::item_path_str(self.crate_context.tcx, implementation.did)); diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs deleted file mode 100644 index 90036e0f96cd8..0000000000000 --- a/src/test/auxiliary/newtype_struct_xc.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[crate_type="lib"]; - -pub struct Au(int); - diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs deleted file mode 100644 index 8b15d73dc933d..0000000000000 --- a/src/test/run-pass/newtype-struct-xc.rs +++ /dev/null @@ -1,9 +0,0 @@ -// xfail-fast -// aux-build:newtype_struct_xc.rs - -extern mod newtype_struct_xc; - -fn main() { - let _ = newtype_struct_xc::Au(2); -} - From a165f882726d86ad4c65a5b72daa5b457af12e6c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Feb 2013 16:16:23 -0800 Subject: [PATCH 59/92] librustc: Speed up moves a lot. r=nmatsakis --- src/librustc/middle/ty.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 4350c62af6fc3..6ba3aa505e0de 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1932,6 +1932,10 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { Some(tc) => { return *tc; } None => {} } + match cx.tc_cache.find(&ty_id) { // Must check both caches! + Some(tc) => { return *tc; } + None => {} + } cache.insert(ty_id, TC_NONE); debug!("computing contents of %s", ty_to_str(cx, ty)); From 46d2be1bd4fed62e7d1d48fdc223b948eafc2728 Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 12 Feb 2013 17:18:29 -0800 Subject: [PATCH 60/92] added rather elaborate test framework --- src/libsyntax/ext/auto_encode.rs | 143 +++++++++++++++++++++++++++---- 1 file changed, 126 insertions(+), 17 deletions(-) diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index ae3b3ae0430ef..d8c8629410c63 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -1155,39 +1155,148 @@ fn mk_enum_deser_body( #[cfg(test)] mod test { use std::serialize::Encodable; + use std::serialize::Encoder; use core::dvec::*; use util::testing::*; use core::io; use core::str; + use core::option::Option; + use core::option::Some; + use core::option::None; use std; + // just adding the ones I want to test, for now: + #[deriving_eq] + pub enum call { + CallToEmitEnum(~str), + CallToEmitEnumVariant(~str, uint, uint), + CallToEmitEnumVariantArg(uint), + CallToEmitUint(uint), + CallToEmitNil, + // all of the ones I was too lazy to handle: + CallToOther + } + // using a mutable field rather than changing the + // type of self in every method of every encoder everywhere. + pub struct TestEncoder {mut call_log : ~[call]} + + pub impl TestEncoder { + // these self's should be &mut self's, as well.... + fn add_to_log (&self, c : call) { + self.call_log.push(copy c); + } + fn add_unknown_to_log (&self) { + self.add_to_log (CallToOther) + } + } + + pub impl Encoder for TestEncoder { + fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } + + fn emit_uint(&self, +v: uint) {self.add_to_log(CallToEmitUint(v)); } + fn emit_u64(&self, +_v: u64) { self.add_unknown_to_log(); } + fn emit_u32(&self, +_v: u32) { self.add_unknown_to_log(); } + fn emit_u16(&self, +_v: u16) { self.add_unknown_to_log(); } + fn emit_u8(&self, +_v: u8) { self.add_unknown_to_log(); } + + fn emit_int(&self, +_v: int) { self.add_unknown_to_log(); } + fn emit_i64(&self, +_v: i64) { self.add_unknown_to_log(); } + fn emit_i32(&self, +_v: i32) { self.add_unknown_to_log(); } + fn emit_i16(&self, +_v: i16) { self.add_unknown_to_log(); } + fn emit_i8(&self, +_v: i8) { self.add_unknown_to_log(); } + + fn emit_bool(&self, +_v: bool) { self.add_unknown_to_log(); } + + fn emit_f64(&self, +_v: f64) { self.add_unknown_to_log(); } + fn emit_f32(&self, +_v: f32) { self.add_unknown_to_log(); } + fn emit_float(&self, +_v: float) { self.add_unknown_to_log(); } + + fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); } + + fn emit_borrowed_str(&self, +_v: &str) { self.add_unknown_to_log(); } + fn emit_owned_str(&self, +_v: &str) { self.add_unknown_to_log(); } + fn emit_managed_str(&self, +_v: &str) { self.add_unknown_to_log(); } + + fn emit_borrowed(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_owned(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_managed(&self, f: fn()) { self.add_unknown_to_log(); f() } + + fn emit_enum(&self, name: &str, f: fn()) { + self.add_to_log(CallToEmitEnum(name.to_str())); f(); } + + fn emit_enum_variant(&self, name: &str, +id: uint, +cnt: uint, f: fn()) { + self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); f(); + } + + fn emit_enum_variant_arg(&self, +idx: uint, f: fn()) { + self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); + } + + fn emit_borrowed_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + + fn emit_owned_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_managed_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_vec_elt(&self, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + + fn emit_rec(&self, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_struct(&self, _name: &str, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_field(&self, _name: &str, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + + fn emit_tup(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_tup_elt(&self, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } +} + + #[auto_decode] #[auto_encode] struct Node {id: uint} - fn to_json_str (val: Encodable) -> ~str{ - let bw = @io::BytesWriter {bytes: DVec(), pos: 0}; - val.encode(~std::json::Encoder(bw as io::Writer)); - str::from_bytes(bw.bytes.data) + + fn to_call_log (val: Encodable) -> ~[call] { + let mut te = TestEncoder {call_log: ~[]}; + val.encode(&te); + te.call_log } - +/* #[test] fn encode_test () { - check_equal (to_json_str(Node{id:34} + check_equal (to_call_log(Node{id:34} as Encodable::), - ~"{\"id\":34}"); + ~[CallToEnum (~"Node"), + CallToEnumVariant]); } - +*/ #[auto_encode] - enum written { - Book(int), + enum Written { + Book(uint,uint), Magazine(~str) } - #[test] fn json_enum_encode_test () { - check_equal (to_json_str(Book(9) as Encodable::), - ~"[\"Book\",9]"); - check_equal (to_json_str(Magazine(~"Paris Match") - as Encodable::), - ~"[\"Magazine\",\"Paris Match\"]"); - } + #[test] fn encode_enum_test () { + check_equal (to_call_log(Book(34,44) + as Encodable::), + ~[CallToEmitEnum (~"Written"), + CallToEmitEnumVariant (~"Book",0,2), + CallToEmitEnumVariantArg (0), + CallToEmitUint (34), + CallToEmitEnumVariantArg (1), + CallToEmitUint (44)]); + } } From ab2534974caf39e69b401442ff1a9077b94c46c1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 8 Feb 2013 22:21:45 -0800 Subject: [PATCH 61/92] Adjust borrow checker algorithm to address #4856 unsoundness, and then adjust code to match. rs=unsound (will review post-landing) --- src/libcore/hashmap.rs | 8 +- src/libcore/private.rs | 28 +-- src/libcore/str.rs | 8 +- src/libcore/vec.rs | 17 +- src/librustc/middle/borrowck/check_loans.rs | 62 +++--- src/librustc/middle/borrowck/gather_loans.rs | 68 +++--- src/librustc/middle/borrowck/loan.rs | 192 +++++++---------- src/librustc/middle/borrowck/mod.rs | 47 ++++- src/librustc/middle/borrowck/preserve.rs | 15 +- src/librustc/middle/mem_categorization.rs | 195 ++++++++++++------ src/librustc/middle/trans/reflect.rs | 168 ++++++++------- src/librustc/middle/ty.rs | 3 - src/librustc/middle/typeck/infer/lattice.rs | 9 +- .../middle/typeck/infer/region_inference.rs | 112 +++++----- src/librustc/middle/typeck/infer/unify.rs | 90 ++++---- src/libstd/arc.rs | 85 ++++---- src/libstd/priority_queue.rs | 6 +- src/libstd/smallintmap.rs | 9 +- src/libstd/treemap.rs | 56 ++--- .../borrowck-borrow-from-owned-ptr.rs | 124 +++++++++++ .../borrowck-borrow-from-stack-variable.rs | 124 +++++++++++ .../compile-fail/borrowck-confuse-region.rs | 26 --- .../borrowck-imm-field-mut-base.rs | 30 --- ...base.rs => borrowck-insert-during-each.rs} | 27 ++- .../borrowck-reborrow-from-mut.rs | 106 ++++++++++ 25 files changed, 1043 insertions(+), 572 deletions(-) create mode 100644 src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs create mode 100644 src/test/compile-fail/borrowck-borrow-from-stack-variable.rs delete mode 100644 src/test/compile-fail/borrowck-confuse-region.rs delete mode 100644 src/test/compile-fail/borrowck-imm-field-mut-base.rs rename src/test/compile-fail/{borrowck-imm-field-imm-base.rs => borrowck-insert-during-each.rs} (57%) create mode 100644 src/test/compile-fail/borrowck-reborrow-from-mut.rs diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 70358bab46874..f8793f7e2aeae 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -383,7 +383,9 @@ pub mod linear { }, }; - self.value_for_bucket(idx) + unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker + ::cast::transmute_region(self.value_for_bucket(idx)) + } } /// Return the value corresponding to the key in the map, or create, @@ -412,7 +414,9 @@ pub mod linear { }, }; - self.value_for_bucket(idx) + unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker + ::cast::transmute_region(self.value_for_bucket(idx)) + } } fn consume(&mut self, f: fn(K, V)) { diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 6864572adfff6..038f61350b2ae 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -256,15 +256,15 @@ pub unsafe fn shared_mutable_state(data: T) -> } #[inline(always)] -pub unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) - -> &a/mut T { +pub unsafe fn get_shared_mutable_state( + rc: *SharedMutableState) -> *mut T +{ unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); assert ptr.count > 0; - // Cast us back into the correct region - let r = cast::transmute_region(option::get_ref(&ptr.data)); + let r = cast::transmute(option::get_ref(&ptr.data)); cast::forget(move ptr); - return cast::transmute_mut(r); + return r; } } #[inline(always)] @@ -376,15 +376,17 @@ impl Exclusive { // the exclusive. Supporting that is a work in progress. #[inline(always)] unsafe fn with(f: fn(x: &mut T) -> U) -> U { - let rec = unsafe { get_shared_mutable_state(&self.x) }; - do rec.lock.lock { - if rec.failed { - die!(~"Poisoned exclusive - another task failed inside!"); + unsafe { + let rec = get_shared_mutable_state(&self.x); + do (*rec).lock.lock { + if (*rec).failed { + die!(~"Poisoned exclusive - another task failed inside!"); + } + (*rec).failed = true; + let result = f(&mut (*rec).data); + (*rec).failed = false; + move result } - rec.failed = true; - let result = f(&mut rec.data); - rec.failed = false; - move result } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 47e68401485ed..6665ab6c6f7ed 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2071,17 +2071,19 @@ pub mod raw { /// Appends a byte to a string. (Not UTF-8 safe). pub unsafe fn push_byte(s: &mut ~str, b: u8) { - reserve_at_least(&mut *s, s.len() + 1); + let new_len = s.len() + 1; + reserve_at_least(&mut *s, new_len); do as_buf(*s) |buf, len| { let buf: *mut u8 = ::cast::reinterpret_cast(&buf); *ptr::mut_offset(buf, len) = b; } - set_len(&mut *s, s.len() + 1); + set_len(&mut *s, new_len); } /// Appends a vector of bytes to a string. (Not UTF-8 safe). unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) { - reserve_at_least(&mut *s, s.len() + bytes.len()); + let new_len = s.len() + bytes.len(); + reserve_at_least(&mut *s, new_len); for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); } } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 9ad5d9f32da36..16cad87c0603a 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -623,13 +623,15 @@ unsafe fn push_fast(v: &mut ~[T], initval: T) { #[inline(never)] fn push_slow(v: &mut ~[T], initval: T) { - reserve_at_least(&mut *v, v.len() + 1u); + let new_len = v.len() + 1; + reserve_at_least(&mut *v, new_len); unsafe { push_fast(v, initval) } } #[inline(always)] pub fn push_all(v: &mut ~[T], rhs: &[const T]) { - reserve(&mut *v, v.len() + rhs.len()); + let new_len = v.len() + rhs.len(); + reserve(&mut *v, new_len); for uint::range(0u, rhs.len()) |i| { push(&mut *v, unsafe { raw::get(rhs, i) }) @@ -638,7 +640,8 @@ pub fn push_all(v: &mut ~[T], rhs: &[const T]) { #[inline(always)] pub fn push_all_move(v: &mut ~[T], mut rhs: ~[T]) { - reserve(&mut *v, v.len() + rhs.len()); + let new_len = v.len() + rhs.len(); + reserve(&mut *v, new_len); unsafe { do as_mut_buf(rhs) |p, len| { for uint::range(0, len) |i| { @@ -663,9 +666,9 @@ pub fn truncate(v: &mut ~[T], newlen: uint) { let mut dropped = rusti::init(); dropped <-> *ptr::mut_offset(p, i); } - raw::set_len(&mut *v, newlen); } } + unsafe { raw::set_len(&mut *v, newlen); } } /** @@ -740,7 +743,8 @@ pub pure fn append_mut(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { * * initval - The value for the new elements */ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { - reserve_at_least(&mut *v, v.len() + n); + let new_len = v.len() + n; + reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; while i < n { @@ -763,7 +767,8 @@ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { * value */ pub fn grow_fn(v: &mut ~[T], n: uint, op: iter::InitOp) { - reserve_at_least(&mut *v, v.len() + n); + let new_len = v.len() + n; + reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; while i < n { v.push(op(i)); diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 251fec684865c..b6b94faa3db7e 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -305,22 +305,31 @@ impl CheckLoanCtxt { return; } - match (old_loan.mutbl, new_loan.mutbl) { - (m_const, _) | (_, m_const) | (m_imm, m_imm) => { - /*ok*/ + match (old_loan.kind, new_loan.kind) { + (PartialFreeze, PartialTake) | (PartialTake, PartialFreeze) | + (TotalFreeze, PartialFreeze) | (PartialFreeze, TotalFreeze) | + (Immobile, _) | (_, Immobile) | + (PartialFreeze, PartialFreeze) | + (PartialTake, PartialTake) | + (TotalFreeze, TotalFreeze) => { + /* ok */ } - (m_mutbl, m_mutbl) | (m_mutbl, m_imm) | (m_imm, m_mutbl) => { + (PartialTake, TotalFreeze) | (TotalFreeze, PartialTake) | + (TotalTake, TotalFreeze) | (TotalFreeze, TotalTake) | + (TotalTake, PartialFreeze) | (PartialFreeze, TotalTake) | + (TotalTake, PartialTake) | (PartialTake, TotalTake) | + (TotalTake, TotalTake) => { self.bccx.span_err( new_loan.cmt.span, fmt!("loan of %s as %s \ conflicts with prior loan", self.bccx.cmt_to_str(new_loan.cmt), - self.bccx.mut_to_str(new_loan.mutbl))); + self.bccx.loan_kind_to_str(new_loan.kind))); self.bccx.span_note( old_loan.cmt.span, fmt!("prior loan as %s granted here", - self.bccx.mut_to_str(old_loan.mutbl))); + self.bccx.loan_kind_to_str(old_loan.kind))); } } } @@ -348,13 +357,13 @@ impl CheckLoanCtxt { // are only assigned once } else { match cmt.mutbl { - m_mutbl => { /*ok*/ } - m_const | m_imm => { - self.bccx.span_err( - ex.span, - at.ing_form(self.bccx.cmt_to_str(cmt))); - return; - } + McDeclared | McInherited => { /*ok*/ } + McReadOnly | McImmutable => { + self.bccx.span_err( + ex.span, + at.ing_form(self.bccx.cmt_to_str(cmt))); + return; + } } } @@ -428,19 +437,20 @@ impl CheckLoanCtxt { cmt: cmt, lp: @loan_path) { for self.walk_loans_of(ex.id, lp) |loan| { - match loan.mutbl { - m_const => { /*ok*/ } - m_mutbl | m_imm => { - self.bccx.span_err( - ex.span, - fmt!("%s prohibited due to outstanding loan", - at.ing_form(self.bccx.cmt_to_str(cmt)))); - self.bccx.span_note( - loan.cmt.span, - fmt!("loan of %s granted here", - self.bccx.cmt_to_str(loan.cmt))); - return; - } + match loan.kind { + Immobile => { /* ok */ } + TotalFreeze | PartialFreeze | + TotalTake | PartialTake => { + self.bccx.span_err( + ex.span, + fmt!("%s prohibited due to outstanding loan", + at.ing_form(self.bccx.cmt_to_str(cmt)))); + self.bccx.span_note( + loan.cmt.span, + fmt!("loan of %s granted here", + self.bccx.cmt_to_str(loan.cmt))); + return; + } } } diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index d4c45828858be..65518398eb752 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -20,7 +20,10 @@ use core::prelude::*; use middle::borrowck::preserve::{PreserveCondition, PcOk, PcIfPure}; use middle::borrowck::{Loan, bckerr, bckres, BorrowckCtxt, err_mutbl}; +use middle::borrowck::{LoanKind, TotalFreeze, PartialFreeze, + TotalTake, PartialTake, Immobile}; use middle::borrowck::{req_maps}; +use middle::borrowck::loan; use middle::mem_categorization::{cat_binding, cat_discr, cmt, comp_variant}; use middle::mem_categorization::{mem_categorization_ctxt}; use middle::mem_categorization::{opt_deref_kind}; @@ -340,13 +343,22 @@ impl GatherLoanCtxt { fn guarantee_valid(@mut self, cmt: cmt, req_mutbl: ast::mutability, - scope_r: ty::Region) { + scope_r: ty::Region) + { + + let loan_kind = match req_mutbl { + m_mutbl => TotalTake, + m_imm => TotalFreeze, + m_const => Immobile + }; self.bccx.stats.guaranteed_paths += 1; - debug!("guarantee_valid(cmt=%s, req_mutbl=%s, scope_r=%s)", + debug!("guarantee_valid(cmt=%s, req_mutbl=%?, \ + loan_kind=%?, scope_r=%s)", self.bccx.cmt_to_repr(cmt), - self.bccx.mut_to_str(req_mutbl), + req_mutbl, + loan_kind, region_to_str(self.tcx(), scope_r)); let _i = indenter(); @@ -362,10 +374,10 @@ impl GatherLoanCtxt { // it within that scope, the loan will be detected and an // error will be reported. Some(_) => { - match self.bccx.loan(cmt, scope_r, req_mutbl) { + match loan::loan(self.bccx, cmt, scope_r, loan_kind) { Err(ref e) => { self.bccx.report((*e)); } Ok(move loans) => { - self.add_loans(cmt, req_mutbl, scope_r, move loans); + self.add_loans(cmt, loan_kind, scope_r, move loans); } } } @@ -378,7 +390,7 @@ impl GatherLoanCtxt { // pointer is desired, that is ok as long as we are pure) None => { let result: bckres = { - do self.check_mutbl(req_mutbl, cmt).chain |pc1| { + do self.check_mutbl(loan_kind, cmt).chain |pc1| { do self.bccx.preserve(cmt, scope_r, self.item_ub, self.root_ub).chain |pc2| { @@ -446,37 +458,41 @@ impl GatherLoanCtxt { // reqires an immutable pointer, but `f` lives in (aliased) // mutable memory. fn check_mutbl(@mut self, - req_mutbl: ast::mutability, + loan_kind: LoanKind, cmt: cmt) -> bckres { - debug!("check_mutbl(req_mutbl=%?, cmt.mutbl=%?)", - req_mutbl, cmt.mutbl); + debug!("check_mutbl(loan_kind=%?, cmt.mutbl=%?)", + loan_kind, cmt.mutbl); - if req_mutbl == m_const || req_mutbl == cmt.mutbl { - debug!("required is const or they are the same"); - Ok(PcOk) - } else { - let e = bckerr { cmt: cmt, code: err_mutbl(req_mutbl) }; - if req_mutbl == m_imm { - // if this is an @mut box, then it's generally OK to borrow as - // &imm; this will result in a write guard - if cmt.cat.is_mutable_box() { + match loan_kind { + Immobile => Ok(PcOk), + + TotalTake | PartialTake => { + if cmt.mutbl.is_mutable() { Ok(PcOk) } else { - // you can treat mutable things as imm if you are pure - debug!("imm required, must be pure"); + Err(bckerr { cmt: cmt, code: err_mutbl(loan_kind) }) + } + } + TotalFreeze | PartialFreeze => { + if cmt.mutbl.is_immutable() { + Ok(PcOk) + } else if cmt.cat.is_mutable_box() { + Ok(PcOk) + } else { + // Eventually: + let e = bckerr {cmt: cmt, + code: err_mutbl(loan_kind)}; Ok(PcIfPure(e)) } - } else { - Err(e) } } } fn add_loans(@mut self, cmt: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, scope_r: ty::Region, +loans: ~[Loan]) { if loans.len() == 0 { @@ -526,7 +542,7 @@ impl GatherLoanCtxt { self.add_loans_to_scope_id(scope_id, move loans); - if req_mutbl == m_imm && cmt.mutbl != m_imm { + if loan_kind.is_freeze() && !cmt.mutbl.is_immutable() { self.bccx.stats.loaned_paths_imm += 1; if self.tcx().sess.borrowck_note_loan() { @@ -542,7 +558,9 @@ impl GatherLoanCtxt { fn add_loans_to_scope_id(@mut self, scope_id: ast::node_id, +loans: ~[Loan]) { - debug!("adding %u loans to scope_id %?", loans.len(), scope_id); + debug!("adding %u loans to scope_id %?: %s", + loans.len(), scope_id, + str::connect(loans.map(|l| self.bccx.loan_to_repr(l)), ", ")); match self.req_maps.req_loan_map.find(&scope_id) { Some(req_loans) => { req_loans.push_all(loans); diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index da22b20fd1daa..3b6d735ae781f 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -44,6 +44,8 @@ FIXME #4730 --- much more needed, don't have time to write this all up now use core::prelude::*; use middle::borrowck::{Loan, bckerr, bckres, BorrowckCtxt, err_mutbl}; +use middle::borrowck::{LoanKind, TotalFreeze, PartialFreeze, + TotalTake, PartialTake, Immobile}; use middle::borrowck::{err_out_of_scope}; use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp}; use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self}; @@ -57,27 +59,26 @@ use core::result::{Err, Ok, Result}; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; -impl BorrowckCtxt { - fn loan(&self, +pub fn loan(bccx: @BorrowckCtxt, cmt: cmt, scope_region: ty::Region, - mutbl: ast::mutability) -> bckres<~[Loan]> { - let mut lc = LoanContext { - bccx: self, - scope_region: scope_region, - loans: ~[] - }; - match lc.loan(cmt, mutbl, true) { - Err(ref e) => return Err((*e)), - Ok(()) => {} - } - // XXX: Workaround for borrow check bug. - Ok(copy lc.loans) + loan_kind: LoanKind) -> bckres<~[Loan]> +{ + let mut lc = LoanContext { + bccx: bccx, + scope_region: scope_region, + loans: ~[] + }; + match lc.loan(cmt, loan_kind, true) { + Err(ref e) => return Err((*e)), + Ok(()) => {} } + // XXX: Workaround for borrow check bug. + Ok(copy lc.loans) } struct LoanContext { - bccx: &BorrowckCtxt, + bccx: @BorrowckCtxt, // the region scope for which we must preserve the memory scope_region: ty::Region, @@ -87,12 +88,13 @@ struct LoanContext { } impl LoanContext { - fn tcx(&mut self) -> ty::ctxt { self.bccx.tcx } + fn tcx(&self) -> ty::ctxt { self.bccx.tcx } fn loan(&mut self, cmt: cmt, - req_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { + loan_kind: LoanKind, + owns_lent_data: bool) -> bckres<()> + { /*! * * The main routine. @@ -107,9 +109,9 @@ impl LoanContext { * discussion in `issue_loan()`. */ - debug!("loan(%s, %s)", + debug!("loan(%s, %?)", self.bccx.cmt_to_repr(cmt), - self.bccx.mut_to_str(req_mutbl)); + loan_kind); let _i = indenter(); // see stable() above; should only be called when `cmt` is lendable @@ -127,15 +129,16 @@ impl LoanContext { ~"rvalue with a non-none lp"); } cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => { - let local_scope_id = self.tcx().region_map.get(&local_id); - self.issue_loan(cmt, ty::re_scope(local_scope_id), req_mutbl, + // FIXME(#4903) + let local_scope_id = self.bccx.tcx.region_map.get(&local_id); + self.issue_loan(cmt, ty::re_scope(local_scope_id), loan_kind, owns_lent_data) } cat_stack_upvar(cmt) => { - self.loan(cmt, req_mutbl, owns_lent_data) + self.loan(cmt, loan_kind, owns_lent_data) } cat_discr(base, _) => { - self.loan(base, req_mutbl, owns_lent_data) + self.loan(base, loan_kind, owns_lent_data) } cat_comp(cmt_base, comp_field(_, m)) | cat_comp(cmt_base, comp_index(_, m)) => { @@ -145,13 +148,13 @@ impl LoanContext { // that case, it must also be embedded in an immutable // location, or else the whole structure could be // overwritten and the component along with it. - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m, owns_lent_data) } cat_comp(cmt_base, comp_tuple) | cat_comp(cmt_base, comp_anon_field) => { // As above. - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m_imm, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m_imm, owns_lent_data) } cat_comp(cmt_base, comp_variant(enum_did)) => { @@ -159,10 +162,10 @@ impl LoanContext { // variants, because if the enum value is overwritten then // the memory changes type. if ty::enum_is_univariant(self.bccx.tcx, enum_did) { - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m_imm, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m_imm, owns_lent_data) } else { - self.loan_unstable_deref(cmt, cmt_base, req_mutbl, + self.loan_unstable_deref(cmt, cmt_base, loan_kind, owns_lent_data) } } @@ -170,7 +173,7 @@ impl LoanContext { // For unique pointers, the memory being pointed out is // unstable because if the unique pointer is overwritten // then the memory is freed. - self.loan_unstable_deref(cmt, cmt_base, req_mutbl, + self.loan_unstable_deref(cmt, cmt_base, loan_kind, owns_lent_data) } cat_deref(cmt_base, _, region_ptr(ast::m_mutbl, region)) => { @@ -178,8 +181,8 @@ impl LoanContext { // loan out the base as well as the main memory. For example, // if someone borrows `*b`, we want to borrow `b` as immutable // as well. - do self.loan(cmt_base, m_imm, false).chain |_| { - self.issue_loan(cmt, region, m_const, owns_lent_data) + do self.loan(cmt_base, TotalFreeze, false).chain |_| { + self.issue_loan(cmt, region, loan_kind, owns_lent_data) } } cat_deref(_, _, unsafe_ptr) | @@ -199,66 +202,38 @@ impl LoanContext { fn loan_stable_comp(&mut self, cmt: cmt, cmt_base: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, comp_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { - // Determine the mutability that the base component must have, - // given the required mutability of the pointer (`req_mutbl`) - // and the declared mutability of the component (`comp_mutbl`). - // This is surprisingly subtle. - // - // Note that the *declared* mutability of the component is not - // necessarily the same as cmt.mutbl, since a component - // declared as immutable but embedded in a mutable context - // becomes mutable. It's best to think of comp_mutbl as being - // either MUTABLE or DEFAULT, not MUTABLE or IMMUTABLE. We - // should really patch up the AST to reflect this distinction. - // - // Let's consider the cases below: - // - // 1. mut required, mut declared: In this case, the base - // component must merely be const. The reason is that it - // does not matter if the base component is borrowed as - // mutable or immutable, as the mutability of the base - // component is overridden in the field declaration itself - // (see `compile-fail/borrowck-mut-field-imm-base.rs`) - // - // 2. mut required, imm declared: This would only be legal if - // the component is embeded in a mutable context. However, - // we detect mismatches between the mutability of the value - // as a whole and the required mutability in `issue_loan()` - // above. In any case, presuming that the component IS - // embedded in a mutable context, both the component and - // the base must be loaned as MUTABLE. This is to ensure - // that there is no loan of the base as IMMUTABLE, which - // would imply that the component must be IMMUTABLE too - // (see `compile-fail/borrowck-imm-field-imm-base.rs`). - // - // 3. mut required, const declared: this shouldn't really be - // possible, since I don't think you can declare a const - // field, but I guess if we DID permit such a declaration - // it would be equivalent to the case above? - // - // 4. imm required, * declared: In this case, the base must be - // immutable. This is true regardless of what was declared - // for this subcomponent, this if the base is mutable, the - // subcomponent must be mutable. - // (see `compile-fail/borrowck-imm-field-mut-base.rs`). - // - // 5. const required, * declared: In this case, the base need - // only be const, since we don't ultimately care whether - // the subcomponent is mutable or not. - let base_mutbl = match (req_mutbl, comp_mutbl) { - (m_mutbl, m_mutbl) => m_const, // (1) - (m_mutbl, _) => m_mutbl, // (2, 3) - (m_imm, _) => m_imm, // (4) - (m_const, _) => m_const // (5) + owns_lent_data: bool) -> bckres<()> + { + let base_kind = match (comp_mutbl, loan_kind) { + // Declared as "immutable" means: inherited mutability and + // hence mutable iff parent is mutable. So propagate + // mutability on up. + (m_imm, TotalFreeze) | (m_imm, PartialFreeze) => PartialFreeze, + (m_imm, TotalTake) | (m_imm, PartialTake) => PartialTake, + + // Declared as "mutable" means: always mutable no matter + // what the mutability of the base is. So that means we + // can weaken the condition on the base to PartialFreeze. + // This implies that the user could freeze the base, but + // that is ok since the even with an &T base, the mut + // field will still be considered mutable. + (_, TotalTake) | (_, PartialTake) | + (_, TotalFreeze) | (_, PartialFreeze) => { + PartialFreeze + } + + // If we just need to guarantee the value won't be moved, + // it doesn't matter what mutability the component was + // declared with. + (_, Immobile) => Immobile, }; - do self.loan(cmt_base, base_mutbl, owns_lent_data).chain |_ok| { + do self.loan(cmt_base, base_kind, owns_lent_data).chain |_ok| { // can use static for the scope because the base // determines the lifetime, ultimately - self.issue_loan(cmt, ty::re_static, req_mutbl, + self.issue_loan(cmt, ty::re_static, loan_kind, owns_lent_data) } } @@ -269,23 +244,23 @@ impl LoanContext { fn loan_unstable_deref(&mut self, cmt: cmt, cmt_base: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, owns_lent_data: bool) -> bckres<()> { // Variant components: the base must be immutable, because // if it is overwritten, the types of the embedded data // could change. - do self.loan(cmt_base, m_imm, owns_lent_data).chain |_| { + do self.loan(cmt_base, PartialFreeze, owns_lent_data).chain |_| { // can use static, as in loan_stable_comp() - self.issue_loan(cmt, ty::re_static, req_mutbl, + self.issue_loan(cmt, ty::re_static, loan_kind, owns_lent_data) } } fn issue_loan(&mut self, - cmt: cmt, - scope_ub: ty::Region, - req_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { + +cmt: cmt, + +scope_ub: ty::Region, + +loan_kind: LoanKind, + +owns_lent_data: bool) -> bckres<()> { // Subtle: the `scope_ub` is the maximal lifetime of `cmt`. // Therefore, if `cmt` owns the data being lent, then the // scope of the loan must be less than `scope_ub`, or else the @@ -297,25 +272,15 @@ impl LoanContext { // reborrowed. if !owns_lent_data || - self.bccx.is_subregion_of(/*bad*/copy self.scope_region, - scope_ub) { - match req_mutbl { - m_mutbl => { - // We do not allow non-mutable data to be loaned - // out as mutable under any circumstances. - if cmt.mutbl != m_mutbl { - return Err(bckerr { - cmt:cmt, - code:err_mutbl(req_mutbl) - }); - } - } - m_const | m_imm => { - // However, mutable data can be loaned out as - // immutable (and any data as const). The - // `check_loans` pass will then guarantee that no - // writes occur for the duration of the loan. - } + self.bccx.is_subregion_of(self.scope_region, scope_ub) + { + if loan_kind.is_take() && !cmt.mutbl.is_mutable() { + // We do not allow non-mutable data to be "taken" + // under any circumstances. + return Err(bckerr { + cmt:cmt, + code:err_mutbl(loan_kind) + }); } self.loans.push(Loan { @@ -323,8 +288,9 @@ impl LoanContext { // loan process does not apply at all. lp: cmt.lp.get(), cmt: cmt, - mutbl: req_mutbl + kind: loan_kind }); + return Ok(()); } else { // The loan being requested lives longer than the data diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 3d45ee461dcb7..dd8f889a05732 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -368,7 +368,7 @@ pub enum bckerr_code { err_mut_uniq, err_mut_variant, err_root_not_permitted, - err_mutbl(ast::mutability), + err_mutbl(LoanKind), err_out_of_root_scope(ty::Region, ty::Region), // superscope, subscope err_out_of_scope(ty::Region, ty::Region) // superscope, subscope } @@ -390,8 +390,19 @@ pub enum MoveError { // shorthand for something that fails with `bckerr` or succeeds with `T` pub type bckres = Result; +#[deriving_eq] +pub enum LoanKind { + TotalFreeze, // Entire path is frozen (borrowed as &T) + PartialFreeze, // Some subpath is frozen (borrowed as &T) + TotalTake, // Entire path is "taken" (borrowed as &mut T) + PartialTake, // Some subpath is "taken" (borrowed as &mut T) + Immobile // Path cannot be moved (borrowed as &const T) +} + /// a complete record of a loan that was granted -pub struct Loan {lp: @loan_path, cmt: cmt, mutbl: ast::mutability} +pub struct Loan {lp: @loan_path, + cmt: cmt, + kind: LoanKind} /// maps computed by `gather_loans` that are then used by `check_loans` /// @@ -420,6 +431,22 @@ pub fn save_and_restore_managed(save_and_restore_t: @mut T, move u } +impl LoanKind { + fn is_freeze(&self) -> bool { + match *self { + TotalFreeze | PartialFreeze => true, + _ => false + } + } + + fn is_take(&self) -> bool { + match *self { + TotalTake | PartialTake => true, + _ => false + } + } +} + /// Creates and returns a new root_map pub impl root_map_key : to_bytes::IterBytes { @@ -520,9 +547,9 @@ pub impl BorrowckCtxt { fn bckerr_to_str(&self, err: bckerr) -> ~str { match err.code { - err_mutbl(req) => { + err_mutbl(lk) => { fmt!("creating %s alias to %s", - self.mut_to_str(req), + self.loan_kind_to_str(lk), self.cmt_to_str(err.cmt)) } err_mut_uniq => { @@ -599,9 +626,17 @@ pub impl BorrowckCtxt { mc.mut_to_str(mutbl) } + fn loan_kind_to_str(&self, lk: LoanKind) -> ~str { + match lk { + TotalFreeze | PartialFreeze => ~"immutable", + TotalTake | PartialTake => ~"mutable", + Immobile => ~"read-only" + } + } + fn loan_to_repr(&self, loan: &Loan) -> ~str { - fmt!("Loan(lp=%?, cmt=%s, mutbl=%?)", - loan.lp, self.cmt_to_repr(loan.cmt), loan.mutbl) + fmt!("Loan(lp=%?, cmt=%s, kind=%?)", + loan.lp, self.cmt_to_repr(loan.cmt), loan.kind) } } diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 097f0579362a9..a123793e20b29 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -190,10 +190,10 @@ impl PreserveCtxt { // otherwise we have no guarantee the pointer will stay // live, so we must root the pointer (i.e., inc the ref // count) for the duration of the loan. - debug!("base.mutbl = %?", self.bccx.mut_to_str(base.mutbl)); + debug!("base.mutbl = %?", base.mutbl); if cmt.cat.derefs_through_mutable_box() { self.attempt_root(cmt, base, derefs) - } else if base.mutbl == m_imm { + } else if base.mutbl.is_immutable() { let non_rooting_ctxt = PreserveCtxt { root_managed_data: false, ..*self @@ -293,14 +293,11 @@ impl PreserveCtxt { // the base is preserved, but if we are not mutable then // purity is required Ok(PcOk) => { - match cmt_base.mutbl { - m_mutbl | m_const => { - Ok(PcIfPure(bckerr {cmt:cmt, code:code})) + if !cmt_base.mutbl.is_immutable() { + Ok(PcIfPure(bckerr {cmt:cmt, code:code})) + } else { + Ok(PcOk) } - m_imm => { - Ok(PcOk) - } - } } // the base requires purity too, that's fine diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index fd9271af6c6d8..c4612e7602417 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -108,6 +108,14 @@ pub enum special_kind { sk_heap_upvar } +#[deriving_eq] +pub enum MutabilityCategory { + McImmutable, // Immutable. + McReadOnly, // Read-only (`const`) + McDeclared, // Directly declared as mutable. + McInherited // Inherited from the fact that owner is mutable. +} + // a complete categorization of a value indicating where it originated // and how it is located, as well as the mutability of the memory in // which the value is stored. @@ -115,12 +123,12 @@ pub enum special_kind { // note: cmt stands for "categorized mutable type". #[deriving_eq] pub struct cmt_ { - id: ast::node_id, // id of expr/pat producing this value - span: span, // span of same expr/pat - cat: categorization, // categorization of expr - lp: Option<@loan_path>, // loan path for expr, if any - mutbl: ast::mutability, // mutability of expr as lvalue - ty: ty::t // type of the expr + id: ast::node_id, // id of expr/pat producing this value + span: span, // span of same expr/pat + cat: categorization, // categorization of expr + lp: Option<@loan_path>, // loan path for expr, if any + mutbl: MutabilityCategory, // mutability of expr as lvalue + ty: ty::t // type of the expr } pub type cmt = @cmt_; @@ -298,8 +306,55 @@ pub struct mem_categorization_ctxt { method_map: typeck::method_map, } -pub impl &mem_categorization_ctxt { - fn cat_expr(expr: @ast::expr) -> cmt { +impl ToStr for MutabilityCategory { + pure fn to_str(&self) -> ~str { + fmt!("%?", *self) + } +} + +impl MutabilityCategory { + static fn from_mutbl(m: ast::mutability) -> MutabilityCategory { + match m { + m_imm => McImmutable, + m_const => McReadOnly, + m_mutbl => McDeclared + } + } + + fn inherit(&self) -> MutabilityCategory { + match *self { + McImmutable => McImmutable, + McReadOnly => McReadOnly, + McDeclared => McInherited, + McInherited => McInherited + } + } + + fn is_mutable(&self) -> bool { + match *self { + McImmutable | McReadOnly => false, + McDeclared | McInherited => true + } + } + + fn is_immutable(&self) -> bool { + match *self { + McImmutable => true, + McReadOnly | McDeclared | McInherited => false + } + } + + fn to_user_str(&self) -> ~str { + match *self { + McDeclared | McInherited => ~"mutable", + McImmutable => ~"immutable", + McReadOnly => ~"const" + } + } +} + +pub impl mem_categorization_ctxt { + fn cat_expr(&self, expr: @ast::expr) -> cmt { match self.tcx.adjustments.find(&expr.id) { None => { // No adjustments. @@ -323,7 +378,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_expr_autoderefd(expr: @ast::expr, + fn cat_expr_autoderefd(&self, + expr: @ast::expr, adjustment: &ty::AutoAdjustment) -> cmt { let mut cmt = self.cat_expr_unadjusted(expr); for uint::range(1, adjustment.autoderefs+1) |deref| { @@ -332,7 +388,7 @@ pub impl &mem_categorization_ctxt { return cmt; } - fn cat_expr_unadjusted(expr: @ast::expr) -> cmt { + fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt { debug!("cat_expr: id=%d expr=%s", expr.id, pprust::expr_to_str(expr, self.tcx.sess.intr())); @@ -392,7 +448,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_def(id: ast::node_id, + fn cat_def(&self, + id: ast::node_id, span: span, expr_ty: ty::t, def: ast::def) -> cmt { @@ -409,7 +466,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_special(sk_static_item), lp:None, - mutbl:m_imm, + mutbl: McImmutable, ty:expr_ty } } @@ -420,7 +477,7 @@ pub impl &mem_categorization_ctxt { // m: mutability of the argument // lp: loan path, must be none for aliasable things - let m = if mutbl {m_mutbl} else {m_imm}; + let m = if mutbl {McDeclared} else {McImmutable}; let lp = match ty::resolved_mode(self.tcx, mode) { ast::by_copy => Some(@lp_arg(vid)), ast::by_ref => None, @@ -438,7 +495,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_arg(vid), lp:lp, - mutbl:m, + mutbl: m, ty:expr_ty } } @@ -458,7 +515,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat, lp:loan_path, - mutbl:m_imm, + mutbl: McImmutable, ty:expr_ty } } @@ -485,7 +542,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_special(sk_heap_upvar), lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } @@ -493,7 +550,7 @@ pub impl &mem_categorization_ctxt { } ast::def_local(vid, mutbl) => { - let m = if mutbl {m_mutbl} else {m_imm}; + let m = if mutbl {McDeclared} else {McImmutable}; @cmt_ { id:id, span:span, @@ -511,14 +568,15 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_local(vid), lp:Some(@lp_local(vid)), - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } } } - fn cat_variant(arg: N, + fn cat_variant(&self, + arg: N, enum_did: ast::def_id, cmt: cmt) -> cmt { @cmt_ { @@ -526,18 +584,18 @@ pub impl &mem_categorization_ctxt { span: arg.span(), cat: cat_comp(cmt, 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 + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(arg) } } - fn cat_rvalue(elt: N, expr_ty: ty::t) -> cmt { + fn cat_rvalue(&self, elt: N, expr_ty: ty::t) -> cmt { @cmt_ { id:elt.id(), span:elt.span(), cat:cat_rvalue, lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } @@ -546,17 +604,21 @@ pub impl &mem_categorization_ctxt { /// component is inherited from the base it is a part of. For /// example, a record field is mutable if it is declared mutable /// or if the container is mutable. - fn inherited_mutability(base_m: ast::mutability, - comp_m: ast::mutability) -> ast::mutability { + fn inherited_mutability(&self, + base_m: MutabilityCategory, + comp_m: ast::mutability) -> MutabilityCategory + { match comp_m { - m_imm => {base_m} // imm: as mutable as the container - m_mutbl | m_const => {comp_m} + m_imm => base_m.inherit(), + m_const => McReadOnly, + m_mutbl => McDeclared } } /// The `field_id` parameter is the ID of the enclosing expression or /// pattern. It is used to determine which variant of an enum is in use. - fn cat_field(node: N, + fn cat_field(&self, + node: N, base_cmt: cmt, f_name: ast::ident, field_id: ast::node_id) -> cmt { @@ -584,7 +646,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_deref_fn(node: N, + fn cat_deref_fn(&self, + node: N, base_cmt: cmt, deref_cnt: uint) -> cmt { @@ -594,11 +657,13 @@ pub impl &mem_categorization_ctxt { // know what type lies at the other end, so we just call it // `()` (the empty tuple). - let mt = ty::mt {ty: ty::mk_tup(self.tcx, ~[]), mutbl: m_imm}; + let mt = ty::mt {ty: ty::mk_tup(self.tcx, ~[]), + mutbl: m_imm}; return self.cat_deref_common(node, base_cmt, deref_cnt, mt); } - fn cat_deref(node: N, + fn cat_deref(&self, + node: N, base_cmt: cmt, deref_cnt: uint) -> cmt { @@ -615,7 +680,8 @@ pub impl &mem_categorization_ctxt { return self.cat_deref_common(node, base_cmt, deref_cnt, mt); } - fn cat_deref_common(node: N, + fn cat_deref_common(&self, + node: N, base_cmt: cmt, deref_cnt: uint, mt: ty::mt) -> cmt @@ -644,7 +710,7 @@ pub impl &mem_categorization_ctxt { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } gc_ptr(*) | region_ptr(_, _) | unsafe_ptr => { - mt.mutbl + MutabilityCategory::from_mutbl(mt.mutbl) } }; @@ -673,7 +739,9 @@ pub impl &mem_categorization_ctxt { } } - fn cat_index(elt: N, base_cmt: cmt) -> cmt { + fn cat_index(&self, + elt: N, + base_cmt: cmt) -> cmt { let mt = match ty::index(self.tcx, base_cmt.ty) { Some(mt) => mt, None => { @@ -700,7 +768,7 @@ pub impl &mem_categorization_ctxt { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } gc_ptr(_) | region_ptr(_, _) | unsafe_ptr => { - mt.mutbl + MutabilityCategory::from_mutbl(mt.mutbl) } }; @@ -714,21 +782,21 @@ pub impl &mem_categorization_ctxt { ty:mt.ty }; - comp(elt, deref_cmt, base_cmt.ty, m, mt.ty) + comp(elt, deref_cmt, base_cmt.ty, m, mt) } deref_comp(_) => { // fixed-length vectors have no deref let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl); - comp(elt, base_cmt, base_cmt.ty, m, mt.ty) + comp(elt, base_cmt, base_cmt.ty, m, mt) } }; fn comp(elt: N, of_cmt: cmt, - vect: ty::t, mutbl: ast::mutability, - ty: ty::t) -> cmt + vect: ty::t, mutbl: MutabilityCategory, + mt: ty::mt) -> cmt { - let comp = comp_index(vect, mutbl); + let comp = comp_index(vect, mt.mutbl); let index_lp = of_cmt.lp.map(|lp| @lp_comp(*lp, comp) ); @cmt_ { id:elt.id(), @@ -736,46 +804,55 @@ pub impl &mem_categorization_ctxt { cat:cat_comp(of_cmt, comp), lp:index_lp, mutbl:mutbl, - ty:ty + ty:mt.ty } } } - fn cat_tuple_elt(elt: N, cmt: cmt) -> cmt { + fn cat_tuple_elt(&self, + elt: N, + cmt: 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) ), - mutbl: cmt.mutbl, // imm iff in an immutable context + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(elt) } } - fn cat_anon_struct_field(elt: N, cmt: cmt) -> cmt { + fn cat_anon_struct_field(&self, + elt: N, + cmt: cmt) -> cmt { @cmt_ { id: elt.id(), span: elt.span(), cat: cat_comp(cmt, comp_anon_field), lp: cmt.lp.map(|l| @lp_comp(*l, comp_anon_field)), - mutbl: cmt.mutbl, // imm iff in an immutable context + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(elt) } } - fn cat_method_ref(expr: @ast::expr, expr_ty: ty::t) -> cmt { + fn cat_method_ref(&self, + expr: @ast::expr, + expr_ty: ty::t) -> cmt { @cmt_ { id:expr.id, span:expr.span, cat:cat_special(sk_method), lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } - fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) { - + fn cat_pattern(&self, + cmt: cmt, + pat: @ast::pat, + op: fn(cmt, @ast::pat)) + { // Here, `cmt` is the categorization for the value being // matched and pat is the pattern it is being matched against. // @@ -901,7 +978,7 @@ pub impl &mem_categorization_ctxt { } } - fn cat_to_repr(cat: categorization) -> ~str { + fn cat_to_repr(&self, cat: categorization) -> ~str { match cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static_item", @@ -924,7 +1001,7 @@ pub impl &mem_categorization_ctxt { } } - fn mut_to_str(mutbl: ast::mutability) -> ~str { + fn mut_to_str(&self, mutbl: ast::mutability) -> ~str { match mutbl { m_mutbl => ~"mutable", m_const => ~"const", @@ -932,7 +1009,7 @@ pub impl &mem_categorization_ctxt { } } - fn ptr_sigil(ptr: ptr_kind) -> ~str { + fn ptr_sigil(&self, ptr: ptr_kind) -> ~str { match ptr { uniq_ptr => ~"~", gc_ptr(_) => ~"@", @@ -941,7 +1018,7 @@ pub impl &mem_categorization_ctxt { } } - fn comp_to_repr(comp: comp_kind) -> ~str { + fn comp_to_repr(&self, comp: comp_kind) -> ~str { match comp { comp_field(fld, _) => self.tcx.sess.str_of(fld), comp_index(*) => ~"[]", @@ -951,7 +1028,7 @@ pub impl &mem_categorization_ctxt { } } - fn lp_to_str(lp: @loan_path) -> ~str { + fn lp_to_str(&self, lp: @loan_path) -> ~str { match *lp { lp_local(node_id) => { fmt!("local(%d)", node_id) @@ -971,17 +1048,17 @@ pub impl &mem_categorization_ctxt { } } - fn cmt_to_repr(cmt: cmt) -> ~str { - fmt!("{%s id:%d m:%s lp:%s ty:%s}", + fn cmt_to_repr(&self, cmt: cmt) -> ~str { + fmt!("{%s id:%d m:%? lp:%s ty:%s}", self.cat_to_repr(cmt.cat), cmt.id, - self.mut_to_str(cmt.mutbl), + cmt.mutbl, cmt.lp.map_default(~"none", |p| self.lp_to_str(*p) ), ty_to_str(self.tcx, cmt.ty)) } - fn cmt_to_str(cmt: cmt) -> ~str { - let mut_str = self.mut_to_str(cmt.mutbl); + fn cmt_to_str(&self, cmt: cmt) -> ~str { + let mut_str = cmt.mutbl.to_user_str(); match cmt.cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static item", @@ -1016,7 +1093,7 @@ pub impl &mem_categorization_ctxt { } } - fn region_to_str(r: ty::Region) -> ~str { + fn region_to_str(&self, r: ty::Region) -> ~str { region_to_str(self.tcx, r) } } diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 16677530ecd15..83fcc17583703 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -116,26 +116,26 @@ pub impl Reflector { fn bracketed(&mut self, bracket_name: ~str, +extra: ~[ValueRef], - inner: &fn()) { + inner: &fn(&mut Reflector)) { // XXX: Bad copy. self.visit(~"enter_" + bracket_name, copy extra); - inner(); + inner(self); self.visit(~"leave_" + bracket_name, extra); } fn vstore_name_and_extra(&mut self, t: ty::t, - vstore: ty::vstore, - f: fn(+s: ~str,+v: ~[ValueRef])) { + vstore: ty::vstore) -> (~str, ~[ValueRef]) + { match vstore { - ty::vstore_fixed(n) => { - let extra = vec::append(~[self.c_uint(n)], - self.c_size_and_align(t)); - f(~"fixed", extra) - } - ty::vstore_slice(_) => f(~"slice", ~[]), - ty::vstore_uniq => f(~"uniq", ~[]), - ty::vstore_box => f(~"box", ~[]) + ty::vstore_fixed(n) => { + let extra = vec::append(~[self.c_uint(n)], + self.c_size_and_align(t)); + (~"fixed", extra) + } + ty::vstore_slice(_) => (~"slice", ~[]), + ty::vstore_uniq => (~"uniq", ~[]), + ty::vstore_box => (~"box", ~[]) } } @@ -168,47 +168,60 @@ pub impl Reflector { ty::ty_float(ast::ty_f32) => self.leaf(~"f32"), ty::ty_float(ast::ty_f64) => self.leaf(~"f64"), - ty::ty_unboxed_vec(mt) => self.visit(~"vec", self.c_mt(mt)), + ty::ty_unboxed_vec(mt) => { + let values = self.c_mt(mt); + self.visit(~"vec", values) + } + ty::ty_estr(vst) => { - do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit(~"estr_" + name, extra) - } + let (name, extra) = self.vstore_name_and_extra(t, vst); + self.visit(~"estr_" + name, extra) } ty::ty_evec(mt, vst) => { - do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit(~"evec_" + name, extra + - self.c_mt(mt)) - } + let (name, extra) = self.vstore_name_and_extra(t, vst); + let extra = extra + self.c_mt(mt); + self.visit(~"evec_" + name, extra) + } + ty::ty_box(mt) => { + let extra = self.c_mt(mt); + self.visit(~"box", extra) + } + ty::ty_uniq(mt) => { + let extra = self.c_mt(mt); + self.visit(~"uniq", extra) + } + ty::ty_ptr(mt) => { + let extra = self.c_mt(mt); + self.visit(~"ptr", extra) + } + ty::ty_rptr(_, mt) => { + let extra = self.c_mt(mt); + self.visit(~"rptr", extra) } - ty::ty_box(mt) => self.visit(~"box", self.c_mt(mt)), - ty::ty_uniq(mt) => self.visit(~"uniq", self.c_mt(mt)), - ty::ty_ptr(mt) => self.visit(~"ptr", self.c_mt(mt)), - ty::ty_rptr(_, mt) => self.visit(~"rptr", self.c_mt(mt)), ty::ty_rec(fields) => { - do self.bracketed(~"rec", - ~[self.c_uint(vec::len(fields))] - + self.c_size_and_align(t)) { + let extra = ~[self.c_uint(vec::len(fields))] + + self.c_size_and_align(t); + do self.bracketed(~"rec", extra) |this| { for fields.eachi |i, field| { - self.visit(~"rec_field", - ~[self.c_uint(i), - self.c_slice( - bcx.ccx().sess.str_of(field.ident))] - + self.c_mt(field.mt)); + let extra = ~[this.c_uint(i), + this.c_slice( + bcx.ccx().sess.str_of(field.ident))] + + this.c_mt(field.mt); + this.visit(~"rec_field", extra); } } } ty::ty_tup(tys) => { - do self.bracketed(~"tup", - ~[self.c_uint(vec::len(tys))] - + self.c_size_and_align(t)) { - for tys.eachi |i, t| { - self.visit(~"tup_field", - ~[self.c_uint(i), - self.c_tydesc(*t)]); - } - } + let extra = ~[self.c_uint(vec::len(tys))] + + self.c_size_and_align(t); + do self.bracketed(~"tup", extra) |this| { + for tys.eachi |i, t| { + let extra = ~[this.c_uint(i), this.c_tydesc(*t)]; + this.visit(~"tup_field", extra); + } + } } // FIXME (#2594): fetch constants out of intrinsic @@ -242,20 +255,21 @@ pub impl Reflector { } ty::ty_struct(did, ref substs) => { - let bcx = self.bcx; - let tcx = bcx.ccx().tcx; - let fields = ty::struct_fields(tcx, did, substs); + let bcx = self.bcx; + let tcx = bcx.ccx().tcx; + let fields = ty::struct_fields(tcx, did, substs); - do self.bracketed(~"class", ~[self.c_uint(fields.len())] - + self.c_size_and_align(t)) { - for fields.eachi |i, field| { - self.visit(~"class_field", - ~[self.c_uint(i), - self.c_slice( - bcx.ccx().sess.str_of(field.ident))] - + self.c_mt(field.mt)); - } - } + let extra = ~[self.c_uint(fields.len())] + + self.c_size_and_align(t); + do self.bracketed(~"class", extra) |this| { + for fields.eachi |i, field| { + let extra = ~[this.c_uint(i), + this.c_slice( + bcx.ccx().sess.str_of(field.ident))] + + this.c_mt(field.mt); + this.visit(~"class_field", extra); + } + } } // FIXME (#2595): visiting all the variants in turn is probably @@ -267,20 +281,20 @@ pub impl Reflector { let tcx = bcx.ccx().tcx; let variants = ty::substd_enum_variants(tcx, did, substs); - do self.bracketed(~"enum", - ~[self.c_uint(vec::len(variants))] - + self.c_size_and_align(t)) { + let extra = ~[self.c_uint(vec::len(variants))] + + self.c_size_and_align(t); + do self.bracketed(~"enum", extra) |this| { for variants.eachi |i, v| { - do self.bracketed(~"enum_variant", - ~[self.c_uint(i), - self.c_int(v.disr_val), - self.c_uint(vec::len(v.args)), - self.c_slice( - bcx.ccx().sess.str_of(v.name))]) { + let extra1 = ~[this.c_uint(i), + this.c_int(v.disr_val), + this.c_uint(vec::len(v.args)), + this.c_slice( + bcx.ccx().sess.str_of(v.name))]; + do this.bracketed(~"enum_variant", extra1) |this| { for v.args.eachi |j, a| { - self.visit(~"enum_variant_field", - ~[self.c_uint(j), - self.c_tydesc(*a)]); + let extra = ~[this.c_uint(j), + this.c_tydesc(*a)]; + this.visit(~"enum_variant_field", extra); } } } @@ -291,13 +305,17 @@ pub impl Reflector { ty::ty_trait(_, _, _) => self.leaf(~"trait"), ty::ty_infer(_) => self.leaf(~"infer"), ty::ty_err => self.leaf(~"err"), - ty::ty_param(p) => self.visit(~"param", ~[self.c_uint(p.idx)]), + ty::ty_param(p) => { + let extra = ~[self.c_uint(p.idx)]; + self.visit(~"param", extra) + } ty::ty_self => self.leaf(~"self"), ty::ty_type => self.leaf(~"type"), ty::ty_opaque_box => self.leaf(~"opaque_box"), ty::ty_opaque_closure_ptr(ck) => { - let ckval = ast_sigil_constant(ck); - self.visit(~"closure_ptr", ~[self.c_uint(ckval)]) + let ckval = ast_sigil_constant(ck); + let extra = ~[self.c_uint(ckval)]; + self.visit(~"closure_ptr", extra) } } } @@ -312,14 +330,14 @@ pub impl Reflector { ast::by_copy => 5u } }; - self.visit(~"fn_input", - ~[self.c_uint(i), + let extra = ~[self.c_uint(i), self.c_uint(modeval), - self.c_tydesc(arg.ty)]); + self.c_tydesc(arg.ty)]; + self.visit(~"fn_input", extra); } - self.visit(~"fn_output", - ~[self.c_uint(retval), - self.c_tydesc(sig.output)]); + let extra = ~[self.c_uint(retval), + self.c_tydesc(sig.output)]; + self.visit(~"fn_output", extra); } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 4350c62af6fc3..d60360f554671 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1934,7 +1934,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } cache.insert(ty_id, TC_NONE); - debug!("computing contents of %s", ty_to_str(cx, ty)); let _i = indenter(); let mut result = match get(ty).sty { @@ -2085,8 +2084,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { result = result + TC_BIG; } - debug!("result = %s", result.to_str()); - cache.insert(ty_id, result); return result; } diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 4bf8a0bae8623..709864c0d13e2 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -118,11 +118,10 @@ pub impl CombineFields { // A remains a subtype of B. Actually, there are other options, // but that's the route we choose to take. - self.infcx.unify(&node_a, &node_b, |new_root, new_rank| { - self.set_var_to_merged_bounds(new_root, - &a_bounds, &b_bounds, - new_rank) - }) + let (new_root, new_rank) = self.infcx.unify(&node_a, &node_b); + self.set_var_to_merged_bounds(new_root, + &a_bounds, &b_bounds, + new_rank) } /// make variable a subtype of T diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 027b99cc42192..230bfe693e093 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -832,7 +832,7 @@ pub impl RegionVarBindings { (re_infer(ReVar(*)), _) | (_, re_infer(ReVar(*))) => { self.combine_vars( self.lubs, a, b, span, - |old_r, new_r| self.make_subregion(span, old_r, new_r)) + |this, old_r, new_r| this.make_subregion(span, old_r, new_r)) } _ => { @@ -859,7 +859,7 @@ pub impl RegionVarBindings { (re_infer(ReVar(*)), _) | (_, re_infer(ReVar(*))) => { self.combine_vars( self.glbs, a, b, span, - |old_r, new_r| self.make_subregion(span, new_r, old_r)) + |this, old_r, new_r| this.make_subregion(span, new_r, old_r)) } _ => { @@ -915,7 +915,9 @@ pub impl RegionVarBindings { a: Region, b: Region, span: span, - relate: &fn(old_r: Region, new_r: Region) -> cres<()>) + relate: &fn(self: &mut RegionVarBindings, + old_r: Region, + new_r: Region) -> cres<()>) -> cres { let vars = TwoRegions { a: a, b: b }; match combines.find(&vars) { @@ -926,8 +928,8 @@ pub impl RegionVarBindings { if self.in_snapshot() { self.undo_log.push(AddCombination(combines, vars)); } - do relate(a, re_infer(ReVar(c))).then { - do relate(b, re_infer(ReVar(c))).then { + do relate(self, a, re_infer(ReVar(c))).then { + do relate(self, b, re_infer(ReVar(c))).then { debug!("combine_vars() c=%?", c); Ok(re_infer(ReVar(c))) } @@ -1035,7 +1037,8 @@ pub impl RegionVarBindings { */ fn resolve_regions(&mut self) { debug!("RegionVarBindings: resolve_regions()"); - self.values.put_back(self.infer_variable_values()); + let v = self.infer_variable_values(); + self.values.put_back(v); } } @@ -1220,7 +1223,7 @@ impl RegionVarBindings { let mut graph = self.construct_graph(); self.expansion(&mut graph); self.contraction(&mut graph); - self.extract_values_and_report_conflicts(&mut graph) + self.extract_values_and_report_conflicts(&graph) } fn construct_graph(&mut self) -> Graph { @@ -1257,14 +1260,14 @@ impl RegionVarBindings { for uint::range(0, num_edges) |edge_idx| { match graph.edges[edge_idx].constraint { - ConstrainVarSubVar(copy a_id, copy b_id) => { + ConstrainVarSubVar(a_id, b_id) => { insert_edge(&mut graph, a_id, Outgoing, edge_idx); insert_edge(&mut graph, b_id, Incoming, edge_idx); } - ConstrainRegSubVar(_, copy b_id) => { + ConstrainRegSubVar(_, b_id) => { insert_edge(&mut graph, b_id, Incoming, edge_idx); } - ConstrainVarSubReg(copy a_id, _) => { + ConstrainVarSubReg(a_id, _) => { insert_edge(&mut graph, a_id, Outgoing, edge_idx); } } @@ -1285,17 +1288,17 @@ impl RegionVarBindings { } fn expansion(&mut self, graph: &mut Graph) { - do self.iterate_until_fixed_point(~"Expansion", graph) |edge| { + do iterate_until_fixed_point(~"Expansion", graph) |nodes, edge| { match edge.constraint { - ConstrainRegSubVar(copy a_region, copy b_vid) => { - let b_node = &mut graph.nodes[*b_vid]; + ConstrainRegSubVar(a_region, b_vid) => { + let b_node = &mut nodes[*b_vid]; self.expand_node(a_region, b_vid, b_node) } - ConstrainVarSubVar(copy a_vid, copy b_vid) => { - match graph.nodes[*a_vid].value { + ConstrainVarSubVar(a_vid, b_vid) => { + match nodes[*a_vid].value { NoValue | ErrorValue => false, - Value(copy a_region) => { - let b_node = &mut graph.nodes[*b_vid]; + Value(a_region) => { + let b_node = &mut nodes[*b_vid]; self.expand_node(a_region, b_vid, b_node) } } @@ -1325,7 +1328,7 @@ impl RegionVarBindings { return true; } - Value(copy cur_region) => { + Value(cur_region) => { let lub = self.lub_concrete_regions(a_region, cur_region); if lub == cur_region { return false; @@ -1345,23 +1348,23 @@ impl RegionVarBindings { } fn contraction(&mut self, graph: &mut Graph) { - do self.iterate_until_fixed_point(~"Contraction", graph) |edge| { + do iterate_until_fixed_point(~"Contraction", graph) |nodes, edge| { match edge.constraint { ConstrainRegSubVar(*) => { // This is an expansion constraint. Ignore. false } - ConstrainVarSubVar(copy a_vid, copy b_vid) => { - match graph.nodes[*b_vid].value { + ConstrainVarSubVar(a_vid, b_vid) => { + match nodes[*b_vid].value { NoValue | ErrorValue => false, - Value(copy b_region) => { - let a_node = &mut graph.nodes[*a_vid]; + Value(b_region) => { + let a_node = &mut nodes[*a_vid]; self.contract_node(a_vid, a_node, b_region) } } } - ConstrainVarSubReg(copy a_vid, copy b_region) => { - let a_node = &mut graph.nodes[*a_vid]; + ConstrainVarSubReg(a_vid, b_region) => { + let a_node = &mut nodes[*a_vid]; self.contract_node(a_vid, a_node, b_region) } } @@ -1387,7 +1390,7 @@ impl RegionVarBindings { false // no change } - Value(copy a_region) => { + Value(a_region) => { match a_node.classification { Expanding => { check_node(self, a_vid, a_node, a_region, b_region) @@ -1438,29 +1441,10 @@ impl RegionVarBindings { } } - fn iterate_until_fixed_point(&mut self, - tag: ~str, - graph: &mut Graph, - body: &fn(edge: &GraphEdge) -> bool) { - let mut iteration = 0; - let mut changed = true; - let num_edges = graph.edges.len(); - while changed { - changed = false; - iteration += 1; - debug!("---- %s Iteration #%u", tag, iteration); - for uint::range(0, num_edges) |edge_idx| { - changed |= body(&graph.edges[edge_idx]); - debug!(" >> Change after edge #%?: %?", - edge_idx, graph.edges[edge_idx]); - } - } - debug!("---- %s Complete after %u iteration(s)", tag, iteration); - } - - fn extract_values_and_report_conflicts(&mut self, - graph: &mut Graph) - -> ~[GraphNodeValue] { + fn extract_values_and_report_conflicts( + &mut self, + graph: &Graph) -> ~[GraphNodeValue] + { let dup_map = TwoRegionsMap(); graph.nodes.mapi(|idx, node| { match node.value { @@ -1525,7 +1509,7 @@ impl RegionVarBindings { } fn report_error_for_expanding_node(&mut self, - graph: &mut Graph, + graph: &Graph, dup_map: TwoRegionsMap, node_idx: RegionVid) { // Errors in expanding nodes result from a lower-bound that is @@ -1578,7 +1562,7 @@ impl RegionVarBindings { } fn report_error_for_contracting_node(&mut self, - graph: &mut Graph, + graph: &Graph, dup_map: TwoRegionsMap, node_idx: RegionVid) { // Errors in contracting nodes result from two upper-bounds @@ -1632,7 +1616,7 @@ impl RegionVarBindings { } fn collect_concrete_regions(&mut self, - graph: &mut Graph, + graph: &Graph, orig_node_idx: RegionVid, dir: Direction) -> ~[SpannedRegion] { @@ -1676,7 +1660,7 @@ impl RegionVarBindings { } fn each_edge(&mut self, - graph: &mut Graph, + graph: &Graph, node_idx: RegionVid, dir: Direction, op: fn(edge: &GraphEdge) -> bool) { @@ -1690,3 +1674,25 @@ impl RegionVarBindings { } } } + +fn iterate_until_fixed_point( + tag: ~str, + graph: &mut Graph, + body: &fn(nodes: &mut [GraphNode], edge: &GraphEdge) -> bool) +{ + let mut iteration = 0; + let mut changed = true; + let num_edges = graph.edges.len(); + while changed { + changed = false; + iteration += 1; + debug!("---- %s Iteration #%u", tag, iteration); + for uint::range(0, num_edges) |edge_idx| { + changed |= body(graph.nodes, &graph.edges[edge_idx]); + debug!(" >> Change after edge #%?: %?", + edge_idx, graph.edges[edge_idx]); + } + } + debug!("---- %s Complete after %u iteration(s)", tag, iteration); +} + diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 7668388e323a8..69e4f373f9742 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -43,9 +43,10 @@ pub trait UnifyVid { } pub impl InferCtxt { - fn get>(&mut self, - +vid: V) - -> Node { + fn get>( + &mut self, + +vid: V) -> Node + { /*! * * Find the root node for `vid`. This uses the standard @@ -53,27 +54,38 @@ pub impl InferCtxt { * http://en.wikipedia.org/wiki/Disjoint-set_data_structure */ + let tcx = self.tcx; let vb = UnifyVid::appropriate_vals_and_bindings(self); - let vid_u = vid.to_uint(); - match vb.vals.find(vid_u) { - None => { - self.tcx.sess.bug(fmt!("failed lookup of vid `%u`", vid_u)); - } - Some(ref var_val) => { - match (*var_val) { - Redirect(vid) => { - let node: Node = self.get(vid); - if node.root != vid { - // Path compression - vb.vals.insert(vid.to_uint(), Redirect(node.root)); + return helper(tcx, vb, vid); + + fn helper( + tcx: ty::ctxt, + vb: &mut ValsAndBindings, + vid: V) -> Node + { + let vid_u = vid.to_uint(); + match vb.vals.find(vid_u) { + None => { + tcx.sess.bug(fmt!( + "failed lookup of vid `%u`", vid_u)); + } + Some(ref var_val) => { + match *var_val { + Redirect(vid) => { + let node: Node = helper(tcx, vb, vid); + if node.root != vid { + // Path compression + vb.vals.insert(vid.to_uint(), + Redirect(node.root)); + } + node + } + Root(ref pt, rk) => { + Node {root: vid, possible_types: *pt, rank: rk} + } + } } - node - } - Root(ref pt, rk) => { - Node {root: vid, possible_types: *pt, rank: rk} - } } - } } } @@ -86,21 +98,22 @@ pub impl InferCtxt { * Sets the value for `vid` to `new_v`. `vid` MUST be a root node! */ - let vb = UnifyVid::appropriate_vals_and_bindings(self); - let old_v = vb.vals.get(vid.to_uint()); - vb.bindings.push((vid, old_v)); - vb.vals.insert(vid.to_uint(), new_v); + debug!("Updating variable %s to %s", + vid.to_str(), new_v.inf_str(self)); - debug!("Updating variable %s from %s to %s", - vid.to_str(), old_v.inf_str(self), new_v.inf_str(self)); + { // FIXME(#4903)---borrow checker is not flow sensitive + let vb = UnifyVid::appropriate_vals_and_bindings(self); + let old_v = vb.vals.get(vid.to_uint()); + vb.bindings.push((vid, old_v)); + vb.vals.insert(vid.to_uint(), new_v); + } } - fn unify, R>( - &mut self, - node_a: &Node, - node_b: &Node, - op: &fn(new_root: V, new_rank: uint) -> R - ) -> R { + fn unify>( + &mut self, + node_a: &Node, + node_b: &Node) -> (V, uint) + { // Rank optimization: if you don't know what it is, check // out @@ -113,17 +126,17 @@ pub impl InferCtxt { // a has greater rank, so a should become b's parent, // i.e., b should redirect to a. self.set(node_b.root, Redirect(node_a.root)); - op(node_a.root, node_a.rank) + (node_a.root, node_a.rank) } else if node_a.rank < node_b.rank { // b has greater rank, so a should redirect to b. self.set(node_a.root, Redirect(node_b.root)); - op(node_b.root, node_b.rank) + (node_b.root, node_b.rank) } else { // If equal, redirect one to the other and increment the // other's rank. assert node_a.rank == node_b.rank; self.set(node_b.root, Redirect(node_a.root)); - op(node_a.root, node_a.rank + 1) + (node_a.root, node_a.rank + 1) } } @@ -183,9 +196,8 @@ pub impl InferCtxt { } }; - self.unify(&node_a, &node_b, |new_root, new_rank| { - self.set(new_root, Root(combined, new_rank)); - }); + let (new_root, new_rank) = self.unify(&node_a, &node_b); + self.set(new_root, Root(combined, new_rank)); return uok(); } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index a1fd7a66f7ec8..ff28d2cbebf6f 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -184,25 +184,30 @@ impl &MutexARC { */ #[inline(always)] unsafe fn access(blk: fn(x: &mut T) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - // Borrowck would complain about this if the function were not already - // unsafe. See borrow_rwlock, far below. - do (&state.lock).lock { - check_poison(true, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data) + unsafe { + let state = get_shared_mutable_state(&self.x); + // Borrowck would complain about this if the function were + // not already unsafe. See borrow_rwlock, far below. + do (&(*state).lock).lock { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) + } } } /// As access(), but with a condvar, as sync::mutex.lock_cond(). #[inline(always)] unsafe fn access_cond(blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do (&state.lock).lock_cond |cond| { - check_poison(true, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data, - &Condvar { is_mutex: true, failed: &mut state.failed, - cond: cond }) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (&(*state).lock).lock_cond |cond| { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: true, + failed: &mut (*state).failed, + cond: cond }) + } } } } @@ -285,8 +290,10 @@ pub fn RWARC(user_data: T) -> RWARC { * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars(user_data: T, - num_condvars: uint) -> RWARC { +pub fn rw_arc_with_condvars( + user_data: T, + num_condvars: uint) -> RWARC +{ let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), failed: false, data: move user_data }; @@ -315,23 +322,28 @@ impl &RWARC { */ #[inline(always)] fn write(blk: fn(x: &mut T) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write { - check_poison(false, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write { + check_poison(false, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) + } } } /// As write(), but with a condvar, as sync::rwlock.write_cond(). #[inline(always)] fn write_cond(blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write_cond |cond| { - check_poison(false, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data, - &Condvar { is_mutex: false, failed: &mut state.failed, - cond: cond }) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write_cond |cond| { + check_poison(false, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: false, + failed: &mut (*state).failed, + cond: cond}) + } } } /** @@ -369,11 +381,14 @@ impl &RWARC { * ~~~ */ fn write_downgrade(blk: fn(v: RWWriteMode) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write_downgrade |write_mode| { - check_poison(false, state.failed); - blk(RWWriteMode((&mut state.data, move write_mode, - PoisonOnFail(&mut state.failed)))) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write_downgrade |write_mode| { + check_poison(false, (*state).failed); + blk(RWWriteMode((&mut (*state).data, + move write_mode, + PoisonOnFail(&mut (*state).failed)))) + } } } @@ -417,8 +432,8 @@ pub fn unwrap_rw_arc(arc: RWARC) -> T { // lock it. This wraps the unsafety, with the justification that the 'lock' // field is never overwritten; only 'failed' and 'data'. #[doc(hidden)] -fn borrow_rwlock(state: &r/mut RWARCInner) -> &r/RWlock { - unsafe { cast::transmute(&mut state.lock) } +fn borrow_rwlock(state: *const RWARCInner) -> *RWlock { + unsafe { cast::transmute(&const (*state).lock) } } // FIXME (#3154) ice with struct/& prevents these from being structs. diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 5248ab1742eb6..a64aa5e968742 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -81,7 +81,8 @@ impl PriorityQueue { /// Push an item onto the queue fn push(&mut self, item: T) { self.data.push(item); - self.siftup(0, self.len() - 1); + let new_len = self.len() - 1; + self.siftup(0, new_len); } /// Optimized version of a push followed by a pop @@ -179,7 +180,8 @@ impl PriorityQueue { } priv fn siftdown(&mut self, pos: uint) { - self.siftdown_range(pos, self.len()); + let len = self.len(); + self.siftdown_range(pos, len); } } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 9642dd0c3dd0f..2e5cd8956cd9d 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -134,10 +134,11 @@ pub impl SmallIntMap { pub impl SmallIntMap { fn update_with_key(&mut self, key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { - match self.find(&key) { - None => self.insert(key, val), - Some(orig) => self.insert(key, ff(key, copy *orig, val)), - } + let new_val = match self.find(&key) { + None => val, + Some(orig) => ff(key, *orig, val) + }; + self.insert(key, new_val) } fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 26bf232adf5de..2fdaeb545a286 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -673,45 +673,45 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { } }; - if this { - *node = None; - return true; - } + if !this { + let left_level = save.left.map_default(0, |x| x.level); + let right_level = save.right.map_default(0, |x| x.level); - let left_level = save.left.map_default(0, |x| x.level); - let right_level = save.right.map_default(0, |x| x.level); + // re-balance, if necessary + if left_level < save.level - 1 || right_level < save.level - 1 { + save.level -= 1; - // re-balance, if necessary - if left_level < save.level - 1 || right_level < save.level - 1 { - save.level -= 1; + if right_level > save.level { + do save.right.mutate |mut x| { x.level = save.level; x } + } - if right_level > save.level { - do save.right.mutate |mut x| { x.level = save.level; x } - } + skew(save); - skew(save); + match save.right { + Some(ref mut right) => { + skew(right); + match right.right { + Some(ref mut x) => { skew(x) }, + None => () + } + } + None => () + } - match save.right { - Some(ref mut right) => { - skew(right); - match right.right { - Some(ref mut x) => { skew(x) }, - None => () + split(save); + match save.right { + Some(ref mut x) => { split(x) }, + None => () } - } - None => () } - split(save); - match save.right { - Some(ref mut x) => { split(x) }, - None => () - } + return removed; } - - removed } } + + *node = None; + return true; } #[cfg(test)] diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs new file mode 100644 index 0000000000000..47b6b4de64281 --- /dev/null +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -0,0 +1,124 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn make_foo() -> ~Foo { die!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &*foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs new file mode 100644 index 0000000000000..30757cc6e7798 --- /dev/null +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -0,0 +1,124 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn make_foo() -> Foo { die!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + match foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &foo; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/compile-fail/borrowck-confuse-region.rs b/src/test/compile-fail/borrowck-confuse-region.rs deleted file mode 100644 index 7b5d9829f5f56..0000000000000 --- a/src/test/compile-fail/borrowck-confuse-region.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Here we are checking that a reasonable error msg is provided. -// -// The current message is not ideal, but we used to say "borrowed -// pointer has lifetime &, but the borrowed value only has lifetime &" -// which is definitely no good. - - -fn get() -> &int { - //~^ NOTE borrowed pointer must be valid for the anonymous lifetime #1 defined on - //~^^ NOTE ...but borrowed value is only valid for the block at - let x = 3; - return &x; - //~^ ERROR illegal borrow -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck-imm-field-mut-base.rs b/src/test/compile-fail/borrowck-imm-field-mut-base.rs deleted file mode 100644 index 5c3fe22960254..0000000000000 --- a/src/test/compile-fail/borrowck-imm-field-mut-base.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - mut x: uint -} - -struct Bar { - foo: Foo -} - -fn main() { - let mut b = Bar { foo: Foo { x: 3 } }; - let p = &b.foo.x; - let q = &mut b.foo; //~ ERROR loan of mutable field as mutable conflicts with prior loan - //~^ ERROR loan of mutable local variable as mutable conflicts with prior loan - let r = &mut b; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan - //~^ ERROR loan of mutable local variable as mutable conflicts with prior loan - io::println(fmt!("*p = %u", *p)); - q.x += 1; - r.foo.x += 1; - io::println(fmt!("*p = %u", *p)); -} diff --git a/src/test/compile-fail/borrowck-imm-field-imm-base.rs b/src/test/compile-fail/borrowck-insert-during-each.rs similarity index 57% rename from src/test/compile-fail/borrowck-imm-field-imm-base.rs rename to src/test/compile-fail/borrowck-insert-during-each.rs index 0d850fd5cee0f..1dcf8268440eb 100644 --- a/src/test/compile-fail/borrowck-imm-field-imm-base.rs +++ b/src/test/compile-fail/borrowck-insert-during-each.rs @@ -8,20 +8,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::hashmap::linear::LinearSet; + struct Foo { - x: uint + n: LinearSet, +} + +impl Foo { + fn foo(&mut self, fun: fn(&int)) { + for self.n.each |f| { + fun(f); + } + } } -struct Bar { - foo: Foo +fn bar(f: &mut Foo) { + do f.foo |a| { //~ NOTE prior loan as mutable granted here + f.n.insert(*a); //~ ERROR conflicts with prior loan + } } fn main() { - let mut b = Bar { foo: Foo { x: 3 } }; - let p = &b; //~ NOTE prior loan as immutable granted here - let q = &mut b.foo.x; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan - let r = &p.foo.x; - io::println(fmt!("*r = %u", *r)); - *q += 1; - io::println(fmt!("*r = %u", *r)); + let mut f = Foo { n: LinearSet::new() }; + bar(&mut f); } \ No newline at end of file diff --git a/src/test/compile-fail/borrowck-reborrow-from-mut.rs b/src/test/compile-fail/borrowck-reborrow-from-mut.rs new file mode 100644 index 0000000000000..60f817dee0c54 --- /dev/null +++ b/src/test/compile-fail/borrowck-reborrow-from-mut.rs @@ -0,0 +1,106 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn borrow_same_field_twice_mut_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern(foo: &mut Foo) { + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &*foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; +} + +fn borrow_mut_and_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm(foo: &Foo) { + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} From e07623d70b5f1841a3e958195a0f8df4606d264c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 11 Feb 2013 16:28:39 -0800 Subject: [PATCH 62/92] librustc: Make monomorphic newtype structs work cross-crate --- src/librustc/metadata/common.rs | 3 + src/librustc/metadata/csearch.rs | 5 +- src/librustc/metadata/decoder.rs | 24 +++++-- src/librustc/metadata/encoder.rs | 90 ++++++++++++++++++------ src/librustc/middle/resolve.rs | 9 ++- src/librustc/middle/trans/base.rs | 9 ++- src/librustc/middle/trans/reachable.rs | 3 + src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/test/auxiliary/newtype_struct_xc.rs | 4 ++ src/test/run-pass/newtype-struct-xc-2.rs | 14 ++++ src/test/run-pass/newtype-struct-xc.rs | 9 +++ 12 files changed, 138 insertions(+), 36 deletions(-) create mode 100644 src/test/auxiliary/newtype_struct_xc.rs create mode 100644 src/test/run-pass/newtype-struct-xc-2.rs create mode 100644 src/test/run-pass/newtype-struct-xc.rs diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 37c19e80600b7..27c9435bcbcca 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -153,5 +153,8 @@ pub const tag_lang_items_item: uint = 0x73; pub const tag_lang_items_item_id: uint = 0x74; pub const tag_lang_items_item_node_id: uint = 0x75; +pub const tag_item_unnamed_field: uint = 0x76; +pub const tag_items_data_item_struct_ctor: uint = 0x77; + pub type link_meta = {name: @str, vers: @str, extras_hash: @str}; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 2cb5cfbddd730..fa82e6c92c098 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -166,8 +166,9 @@ pub fn get_item_attrs(cstore: @mut cstore::CStore, decoder::get_item_attrs(cdata, def_id.node, f) } -pub fn get_struct_fields(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::field_ty] { - let cstore = tcx.cstore; +pub fn get_struct_fields(cstore: @mut cstore::CStore, + def: ast::def_id) + -> ~[ty::field_ty] { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_struct_fields(cstore.intr, cdata, def.node) } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 67498ad5aafe6..14dda96228206 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -42,7 +42,7 @@ use std::serialize::Decodable; use syntax::ast_map; use syntax::attr; use syntax::diagnostic::span_handler; -use syntax::parse::token::ident_interner; +use syntax::parse::token::{ident_interner, special_idents}; use syntax::print::pprust; use syntax::{ast, ast_util}; use syntax::codemap; @@ -231,7 +231,9 @@ pub fn item_type(item_id: ast::def_id, item: ebml::Doc, let t = doc_type(item, tcx, cdata); if family_names_type(item_family(item)) { ty::mk_with_id(tcx, t, item_id) - } else { t } + } else { + t + } } fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { @@ -661,11 +663,12 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, rslt } -pub fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, - m_id: ast::node_id, name: Option, - get_cdata: fn(ast::crate_num) -> cmd) +pub fn get_impls_for_mod(intr: @ident_interner, + cdata: cmd, + m_id: ast::node_id, + name: Option, + get_cdata: &fn(ast::crate_num) -> cmd) -> @~[@_impl] { - let data = cdata.data; let mod_item = lookup_item(m_id, data); let mut result = ~[]; @@ -887,6 +890,15 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) }); } } + for reader::tagged_docs(item, tag_item_unnamed_field) |an_item| { + let did = item_def_id(an_item, cdata); + result.push(ty::field_ty { + ident: special_idents::unnamed_field, + id: did, + vis: ast::inherited, + mutability: ast::struct_immutable, + }); + } result } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index fcc1a4e806dff..3c39a4032f539 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -46,6 +46,7 @@ use syntax::ast_map; use syntax::ast_util::*; use syntax::attr; use syntax::diagnostic::span_handler; +use syntax::parse::token::special_idents; use syntax::print::pprust; use syntax::{ast_util, visit}; use syntax; @@ -328,7 +329,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder, // Encode info about all the module children. for md.items.each |item| { match item.node { - item_impl(*) | item_struct(*) => { + item_impl(*) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl %s \ (%?/%?)", @@ -432,25 +433,28 @@ fn encode_info_for_struct(ecx: @encode_ctxt, ebml_w: writer::Encoder, /* We encode both private and public fields -- need to include private fields to get the offsets right */ for fields.each |field| { - match field.node.kind { - named_field(nm, mt, vis) => { - let id = field.node.id; - index.push({val: id, pos: ebml_w.writer.tell()}); - global_index.push({val: id, - pos: ebml_w.writer.tell()}); - ebml_w.start_tag(tag_items_data_item); - debug!("encode_info_for_struct: doing %s %d", - tcx.sess.str_of(nm), id); - encode_visibility(ebml_w, vis); - encode_name(ecx, ebml_w, nm); - encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); - encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); - encode_mutability(ebml_w, mt); - encode_def_id(ebml_w, local_def(id)); - ebml_w.end_tag(); - } - unnamed_field => {} - } + let (nm, mt, vis) = match field.node.kind { + named_field(nm, mt, vis) => (nm, mt, vis), + unnamed_field => ( + special_idents::unnamed_field, + struct_immutable, + inherited + ) + }; + + let id = field.node.id; + index.push({val: id, pos: ebml_w.writer.tell()}); + global_index.push({val: id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + debug!("encode_info_for_struct: doing %s %d", + tcx.sess.str_of(nm), id); + encode_visibility(ebml_w, vis); + encode_name(ecx, ebml_w, nm); + encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); + encode_mutability(ebml_w, mt); + encode_def_id(ebml_w, local_def(id)); + ebml_w.end_tag(); } /*bad*/copy *index } @@ -481,6 +485,28 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: writer::Encoder, ebml_w.end_tag(); } +fn encode_info_for_struct_ctor(ecx: @encode_ctxt, + ebml_w: writer::Encoder, + path: &[ast_map::path_elt], + name: ast::ident, + ctor_id: node_id, + index: @mut ~[entry]) { + index.push({ val: ctor_id, pos: ebml_w.writer.tell() }); + + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(ctor_id)); + encode_family(ebml_w, 'f'); + encode_name(ecx, ebml_w, name); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(name)); + + if ecx.item_symbols.contains_key(&ctor_id) { + encode_symbol(ecx, ebml_w, ctor_id); + } + + ebml_w.end_tag(); +} + fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: writer::Encoder, impl_path: &[ast_map::path_elt], @@ -674,6 +700,24 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_family(ebml_w, 'S'); encode_type_param_bounds(ebml_w, ecx, tps); encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + + // If this is a tuple- or enum-like struct, encode the type of the + // constructor. + if struct_def.fields.len() > 0 && + struct_def.fields[0].node.kind == ast::unnamed_field { + let ctor_id = match struct_def.ctor_id { + Some(ctor_id) => ctor_id, + None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), + }; + + encode_info_for_struct_ctor(ecx, + ebml_w, + path, + item.ident, + ctor_id, + index); + } + encode_name(ecx, ebml_w, item.ident); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_region_param(ecx, ebml_w, item); @@ -697,7 +741,11 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); } - unnamed_field => {} + unnamed_field => { + ebml_w.start_tag(tag_item_unnamed_field); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index ba550dbbde8ed..ea840da73cd98 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -13,7 +13,8 @@ use core::prelude::*; use driver::session; use driver::session::Session; use metadata::csearch::{each_path, get_method_names_if_trait}; -use metadata::csearch::{get_static_methods_if_impl, get_type_name_if_impl}; +use metadata::csearch::{get_static_methods_if_impl, get_struct_fields}; +use metadata::csearch::{get_type_name_if_impl}; use metadata::cstore::find_use_stmt_cnum; use metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; use middle::lang_items::LanguageItems; @@ -1745,10 +1746,12 @@ pub impl Resolver { OverwriteDuplicates, dummy_sp()); - self.handle_external_def(def, modules, + self.handle_external_def(def, + modules, child_name_bindings, self.session.str_of(final_ident), - final_ident, new_parent); + final_ident, + new_parent); } dl_impl(def) => { // We only process static methods of impls here. diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index ced47bb5681b1..c61ff7d5e0267 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1905,8 +1905,13 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt, } }; - let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, ctor_id, None, - param_substs, None); + let fcx = new_fn_ctxt_w_id(ccx, + ~[], + llfndecl, + ctor_id, + None, + param_substs, + None); // XXX: Bad copy. let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index f77aa33407d10..bf417e9a5f4f9 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -122,6 +122,9 @@ fn traverse_public_item(cx: ctx, item: @item) { } } item_struct(struct_def, tps) => { + for struct_def.ctor_id.each |&ctor_id| { + cx.rmap.insert(ctor_id, ()); + } do option::iter(&struct_def.dtor) |dtor| { cx.rmap.insert(dtor.node.id, ()); if tps.len() > 0u || attr::find_inline_attr(dtor.node.attrs) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index cef4f9ff1b4b0..d38eef0fcf9f6 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4012,7 +4012,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } } else { - return csearch::get_struct_fields(cx, did); + return csearch::get_struct_fields(cx.sess.cstore, did); } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 5e51c21609300..fdf936f7aec62 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -828,7 +828,7 @@ pub impl CoherenceChecker { let implementations = get_impls_for_mod(crate_store, module_def_id, None); - for (*implementations).each |implementation| { + for implementations.each |implementation| { debug!("coherence: adding impl from external crate: %s", ty::item_path_str(self.crate_context.tcx, implementation.did)); diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs new file mode 100644 index 0000000000000..90036e0f96cd8 --- /dev/null +++ b/src/test/auxiliary/newtype_struct_xc.rs @@ -0,0 +1,4 @@ +#[crate_type="lib"]; + +pub struct Au(int); + diff --git a/src/test/run-pass/newtype-struct-xc-2.rs b/src/test/run-pass/newtype-struct-xc-2.rs new file mode 100644 index 0000000000000..a7c686daa7f35 --- /dev/null +++ b/src/test/run-pass/newtype-struct-xc-2.rs @@ -0,0 +1,14 @@ +// xfail-fast +// aux-build:newtype_struct_xc.rs + +extern mod newtype_struct_xc; +use newtype_struct_xc::Au; + +fn f() -> Au { + Au(2) +} + +fn main() { + let _ = f(); +} + diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs new file mode 100644 index 0000000000000..8b15d73dc933d --- /dev/null +++ b/src/test/run-pass/newtype-struct-xc.rs @@ -0,0 +1,9 @@ +// xfail-fast +// aux-build:newtype_struct_xc.rs + +extern mod newtype_struct_xc; + +fn main() { + let _ = newtype_struct_xc::Au(2); +} + From e58c812f7761228281aaf3140e53cc2e9945760a Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Thu, 7 Feb 2013 23:23:43 -0500 Subject: [PATCH 63/92] Partially de-vec-mut librustc --- src/librustc/middle/trans/cabi_x86_64.rs | 10 +++++----- src/librustc/middle/typeck/check/method.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index d3eb2157ee340..043ee4115270a 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -127,13 +127,13 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } } - fn all_mem(cls: &[mut x86_64_reg_class]) { + fn all_mem(cls: &mut [x86_64_reg_class]) { for uint::range(0, cls.len()) |i| { cls[i] = memory_class; } } - fn unify(cls: &[mut x86_64_reg_class], + fn unify(cls: &mut [x86_64_reg_class], i: uint, newv: x86_64_reg_class) { if cls[i] == newv { @@ -159,7 +159,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn classify_struct(tys: &[TypeRef], - cls: &[mut x86_64_reg_class], i: uint, + cls: &mut [x86_64_reg_class], i: uint, off: uint) { let mut field_off = off; for vec::each(tys) |ty| { @@ -170,7 +170,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn classify(ty: TypeRef, - cls: &[mut x86_64_reg_class], ix: uint, + cls: &mut [x86_64_reg_class], ix: uint, off: uint) { unsafe { let t_align = ty_align(ty); @@ -220,7 +220,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } } - fn fixup(ty: TypeRef, cls: &[mut x86_64_reg_class]) { + fn fixup(ty: TypeRef, cls: &mut [x86_64_reg_class]) { unsafe { let mut i = 0u; let llty = llvm::LLVMGetTypeKind(ty) as int; diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 463ae3201a447..45b0fa962ad91 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -779,7 +779,7 @@ pub impl LookupContext { /*! * * In the event that we are invoking a method with a receiver - * of a linear borrowed type like `&mut T` or `&[mut T]`, + * of a linear borrowed type like `&mut T` or `&mut [T]`, * we will "reborrow" the receiver implicitly. For example, if * you have a call `r.inc()` and where `r` has type `&mut T`, * then we treat that like `(&mut *r).inc()`. This avoids From 2d2ed075e3c549e8bb1980de26a106de965e51c8 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Mon, 11 Feb 2013 22:50:35 -0500 Subject: [PATCH 64/92] RIMOV core::run --- src/libcore/run.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/run.rs b/src/libcore/run.rs index ae5c4d19b1c05..0ef22cfc5ec69 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -290,7 +290,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { fn read_all(rd: io::Reader) -> ~str { let buf = io::with_bytes_writer(|wr| { - let mut bytes = [mut 0, ..4096]; + let mut bytes = [0, ..4096]; while !rd.eof() { let nread = rd.read(bytes, bytes.len()); wr.write(bytes.view(0, nread)); @@ -391,7 +391,7 @@ pub fn readclose(fd: c_int) -> ~str { let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); let buf = io::with_bytes_writer(|writer| { - let mut bytes = [mut 0, ..4096]; + let mut bytes = [0, ..4096]; while !reader.eof() { let nread = reader.read(bytes, bytes.len()); writer.write(bytes.view(0, nread)); From 3a3f7b8e557aa9ff8e99a11c826ffc6e1147e414 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Mon, 11 Feb 2013 23:04:10 -0500 Subject: [PATCH 65/92] RIMOV core::rand --- src/libcore/rand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 452ab9452510b..1881bd784c4cb 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -350,7 +350,7 @@ impl Rng { } /// Shuffle a mutable vec in place - fn shuffle_mut(values: &[mut T]) { + fn shuffle_mut(values: &mut [T]) { let mut i = values.len(); while i >= 2u { // invariant: elements with index >= i have been locked in place. From 808ccd33495452e6fce56cbd7e889c88e39fccff Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Mon, 11 Feb 2013 23:18:34 -0500 Subject: [PATCH 66/92] RIMOV core::io --- src/libcore/io.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 721a6584c6506..c1e47439e9280 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -56,7 +56,7 @@ pub trait Reader { /// Read up to len bytes (or EOF) and put them into bytes (which /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. - fn read(&self, bytes: &[mut u8], len: uint) -> uint; + fn read(&self, bytes: &mut [u8], len: uint) -> uint; /// Read a single byte, returning a negative value for EOF or read error. fn read_byte(&self) -> int; @@ -416,7 +416,7 @@ fn convert_whence(whence: SeekStyle) -> i32 { } impl *libc::FILE: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { unsafe { do vec::as_mut_buf(bytes) |buf_p, buf_len| { assert buf_len >= len; @@ -461,7 +461,7 @@ struct Wrapper { // duration of its lifetime. // FIXME there really should be a better way to do this // #2004 impl Wrapper: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { self.base.read(bytes, len) } fn read_byte(&self) -> int { self.base.read_byte() } @@ -528,7 +528,7 @@ pub struct BytesReader { } impl BytesReader: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { let count = uint::min(len, self.bytes.len() - self.pos); let view = vec::view(self.bytes, self.pos, self.bytes.len()); From 4de76aeb1499d9c9df4e7b8d77ca4f9f17fab4f6 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Mon, 11 Feb 2013 23:32:45 -0500 Subject: [PATCH 67/92] RIMOV core::hash --- src/libcore/hash.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 692cfee536581..e53b7d29ebe7f 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -165,7 +165,7 @@ struct SipState { mut v1: u64, mut v2: u64, mut v3: u64, - tail: [mut u8 * 8], // unprocessed bytes + mut tail: [u8 * 8], // unprocessed bytes mut ntail: uint, // how many bytes in tail are valid } @@ -179,7 +179,7 @@ fn SipState(key0: u64, key1: u64) -> SipState { mut v1 : 0u64, mut v2 : 0u64, mut v3 : 0u64, - tail : [mut 0u8,0,0,0,0,0,0,0], + mut tail : [0u8,0,0,0,0,0,0,0], mut ntail : 0u, }; (&state).reset(); From e6c82c0375e042e062079c056e5e3ac31eb86005 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Tue, 12 Feb 2013 18:34:48 -0500 Subject: [PATCH 68/92] RIMOV core::vec Also remove as many uses as possible of vec::cast_to_mut and cast_from_mut --- src/compiletest/runtest.rs | 4 +- src/libcore/os.rs | 6 +- src/libcore/vec.rs | 60 ++++------------ src/librustc/middle/trans/_match.rs | 2 +- src/librustc/middle/trans/cabi_x86_64.rs | 7 +- src/librustc/middle/typeck/check/mod.rs | 2 +- src/libstd/getopts.rs | 4 +- src/libstd/md4.rs | 2 +- src/libstd/rope.rs | 6 +- src/libstd/sha1.rs | 68 +++++++++---------- src/libstd/sort.rs | 4 +- src/libstd/workcache.rs | 4 +- src/test/bench/shootout-fannkuchredux.rs | 6 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 2 +- src/test/bench/shootout-spectralnorm.rs | 6 +- src/test/compile-fail/issue-2548.rs | 4 +- src/test/run-pass/import-in-block.rs | 2 + 17 files changed, 81 insertions(+), 108 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 0f8c8761c427c..83ab56309c13f 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -322,8 +322,8 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError], ProcRes: ProcRes) { // true if we found the error in question - let found_flags = vec::cast_to_mut(vec::from_elem( - vec::len(expected_errors), false)); + let mut found_flags = vec::from_elem( + vec::len(expected_errors), false); if ProcRes.status == 0 { fatal(~"process did not return an error status"); diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 0efc17354dd58..ce590092db8fc 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -79,7 +79,7 @@ pub fn as_c_charp(s: &str, f: fn(*c_char) -> T) -> T { pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) -> Option<~str> { - let buf = vec::cast_to_mut(vec::from_elem(TMPBUF_SZ, 0u8 as c_char)); + let mut buf = vec::from_elem(TMPBUF_SZ, 0u8 as c_char); do vec::as_mut_buf(buf) |b, sz| { if f(b, sz as size_t) { unsafe { @@ -108,7 +108,7 @@ pub mod win32 { let mut res = None; let mut done = false; while !done { - let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16)); + let mut buf = vec::from_elem(n as uint, 0u16); do vec::as_mut_buf(buf) |b, _sz| { let k : DWORD = f(b, TMPBUF_SZ as DWORD); if k == (0 as DWORD) { @@ -1325,7 +1325,7 @@ mod tests { }; assert (ostream as uint != 0u); let s = ~"hello"; - let mut buf = vec::cast_to_mut(str::to_bytes(s) + ~[0 as u8]); + let mut buf = str::to_bytes(s) + ~[0 as u8]; do vec::as_mut_buf(buf) |b, _len| { assert (libc::fwrite(b as *c_void, 1u as size_t, (str::len(s) + 1u) as size_t, ostream) diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 16cad87c0603a..7f02ad79583e3 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -558,10 +558,6 @@ pub fn consume(mut v: ~[T], f: fn(uint, v: T)) { } } -pub fn consume_mut(v: ~[mut T], f: fn(uint, v: T)) { - consume(vec::cast_from_mut(v), f) -} - /// Remove the last element from a vector and return it pub fn pop(v: &mut ~[T]) -> T { let ln = v.len(); @@ -728,11 +724,6 @@ pub pure fn append_one(lhs: ~[T], x: T) -> ~[T] { v } -#[inline(always)] -pub pure fn append_mut(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { - cast_to_mut(append(cast_from_mut(lhs), rhs)) -} - /** * Expands a vector in place, initializing the new elements to a given value * @@ -1285,12 +1276,12 @@ pub pure fn zip(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] { * * a - The index of the first element * * b - The index of the second element */ -pub fn swap(v: &[mut T], a: uint, b: uint) { +pub fn swap(v: &mut [T], a: uint, b: uint) { v[a] <-> v[b]; } /// Reverse the order of elements in a vector, in place -pub fn reverse(v: &[mut T]) { +pub fn reverse(v: &mut [T]) { let mut i: uint = 0; let ln = len::(v); while i < ln / 2 { v[i] <-> v[ln - i - 1]; i += 1; } @@ -1371,7 +1362,7 @@ pub pure fn each(v: &r/[T], f: fn(&r/T) -> bool) { /// a vector with mutable contents and you would like /// to mutate the contents as you iterate. #[inline(always)] -pub fn each_mut(v: &[mut T], f: fn(elem: &mut T) -> bool) { +pub fn each_mut(v: &mut [T], f: fn(elem: &mut T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1541,7 +1532,7 @@ pub pure fn as_const_buf(s: &[const T], /// Similar to `as_imm_buf` but passing a `*mut T` #[inline(always)] -pub pure fn as_mut_buf(s: &[mut T], +pub pure fn as_mut_buf(s: &mut [T], f: fn(*mut T, uint) -> U) -> U { unsafe { @@ -1653,7 +1644,7 @@ impl @[T] : Ord { pub mod traits { use kinds::Copy; use ops::Add; - use vec::{append, append_mut}; + use vec::append; impl ~[T] : Add<&[const T],~[T]> { #[inline(always)] @@ -1661,13 +1652,6 @@ pub mod traits { append(copy *self, (*rhs)) } } - - impl ~[mut T] : Add<&[const T],~[mut T]> { - #[inline(always)] - pure fn add(&self, rhs: & &self/[const T]) -> ~[mut T] { - append_mut(copy *self, (*rhs)) - } - } } impl &[const T]: Container { @@ -2088,7 +2072,7 @@ pub mod raw { /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_mut_ptr(v: &[mut T]) -> *mut T { + pub unsafe fn to_mut_ptr(v: &mut [T]) -> *mut T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } @@ -2121,7 +2105,7 @@ pub mod raw { * is newly allocated. */ #[inline(always)] - pub unsafe fn init_elem(v: &[mut T], i: uint, val: T) { + pub unsafe fn init_elem(v: &mut [T], i: uint, val: T) { let mut box = Some(val); do as_mut_buf(v) |p, _len| { let mut box2 = None; @@ -2155,7 +2139,7 @@ pub mod raw { * may overlap. */ #[inline(always)] - pub unsafe fn copy_memory(dst: &[mut T], src: &[const T], + pub unsafe fn copy_memory(dst: &mut [T], src: &[const T], count: uint) { assert dst.len() >= count; assert src.len() >= count; @@ -2222,7 +2206,7 @@ pub mod bytes { * may overlap. */ #[inline(always)] - pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) { + pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) { // Bound checks are done at vec::raw::copy_memory. unsafe { vec::raw::copy_memory(dst, src, count) } } @@ -3220,7 +3204,7 @@ mod tests { #[test] fn reverse_and_reversed() { - let v: ~[mut int] = ~[mut 10, 20]; + let mut v: ~[int] = ~[10, 20]; assert (v[0] == 10); assert (v[1] == 20); reverse(v); @@ -3235,13 +3219,13 @@ mod tests { let v4 = reversed::(~[]); assert (v4 == ~[]); - let v3: ~[mut int] = ~[mut]; + let mut v3: ~[int] = ~[]; reverse::(v3); } #[test] fn reversed_mut() { - let v2 = reversed::(~[mut 10, 20]); + let mut v2 = reversed::(~[10, 20]); assert (v2[0] == 20); assert (v2[1] == 10); } @@ -3625,20 +3609,6 @@ mod tests { }; } - #[test] - #[ignore(windows)] - #[should_fail] - fn test_consume_mut_fail() { - let v = ~[mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)]; - let mut i = 0; - do consume_mut(v) |_i, _elt| { - if i == 2 { - die!() - } - i += 1; - }; - } - #[test] #[ignore(windows)] #[should_fail] @@ -3657,7 +3627,7 @@ mod tests { #[ignore(windows)] #[should_fail] fn test_map_fail() { - let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)]; + let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; let mut i = 0; do map(v) |_elt| { if i == 2 { @@ -3983,7 +3953,7 @@ mod tests { #[ignore(cfg(windows))] #[should_fail] fn test_as_mut_buf_fail() { - let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)]; + let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_mut_buf(v) |_buf, _i| { die!() } @@ -3994,7 +3964,7 @@ mod tests { #[ignore(cfg(windows))] fn test_copy_memory_oob() { unsafe { - let a = [mut 1, 2, 3, 4]; + let mut a = [1, 2, 3, 4]; let b = [1, 2, 3, 4, 5]; raw::copy_memory(a, b, 5); } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 2369a63e54489..d9d3b63b6c9a5 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1002,7 +1002,7 @@ pub fn pick_col(m: &[@Match]) -> uint { _ => 0u } } - let scores = vec::cast_to_mut(vec::from_elem(m[0].pats.len(), 0u)); + let mut scores = vec::from_elem(m[0].pats.len(), 0u); for vec::each(m) |br| { let mut i = 0u; for vec::each(br.pats) |p| { scores[i] += score(*p); i += 1u; } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 043ee4115270a..00235c32d3c3d 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -270,14 +270,15 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } let words = (ty_size(ty) + 7) / 8; - let cls = vec::cast_to_mut(vec::from_elem(words, no_class)); + let mut cls = vec::from_elem(words, no_class); if words > 4 { all_mem(cls); - return vec::cast_from_mut(move cls); + let cls = cls; + return move cls; } classify(ty, cls, 0, 0); fixup(ty, cls); - return vec::cast_from_mut(move cls); + return move cls; } fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index fda9702d58284..d6bd9aa96dd56 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3131,7 +3131,7 @@ pub fn check_bounds_are_used(ccx: @mut CrateCtxt, // make a vector of booleans initially false, set to true when used if tps.len() == 0u { return; } - let tps_used = vec::cast_to_mut(vec::from_elem(tps.len(), false)); + let mut tps_used = vec::from_elem(tps.len(), false); ty::walk_regions_and_ty( ccx.tcx, ty, diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index a778649f6f4b0..e3f8ef1b2b53b 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -224,7 +224,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result { unsafe { let n_opts = opts.len(); fn f(_x: uint) -> ~[Optval] { return ~[]; } - let vals = vec::cast_to_mut(vec::from_fn(n_opts, f)); + let mut vals = vec::from_fn(n_opts, f); let mut free: ~[~str] = ~[]; let l = args.len(); let mut i = 0; @@ -339,7 +339,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result { i += 1; } return Ok(Matches {opts: vec::from_slice(opts), - vals: vec::cast_from_mut(move vals), + vals: move vals, free: free}); } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 1d831af0e292a..6fe82d554de75 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -52,7 +52,7 @@ pub pure fn md4(msg: &[u8]) -> Quad { let mut i = 0u; let e = vec::len(msg); - let x = vec::cast_to_mut(vec::from_elem(16u, 0u32)); + let mut x = vec::from_elem(16u, 0u32); while i < e { let aa = a, bb = b, cc = c, dd = d; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index f8aef2c5f1e99..dbfa771e0a256 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -174,7 +174,7 @@ pub fn concat(v: ~[Rope]) -> Rope { //Copy `v` into a mut vector let mut len = vec::len(v); if len == 0u { return node::Empty; } - let ropes = vec::cast_to_mut(vec::from_elem(len, v[0])); + let mut ropes = vec::from_elem(len, v[0]); for uint::range(1u, len) |i| { ropes[i] = v[i]; } @@ -719,7 +719,7 @@ pub mod node { //Firstly, split `str` in slices of hint_max_leaf_char_len let mut leaves = uint::div_ceil(char_len, hint_max_leaf_char_len); //Number of leaves - let nodes = vec::cast_to_mut(vec::from_elem(leaves, candidate)); + let mut nodes = vec::from_elem(leaves, candidate); let mut i = 0u; let mut offset = byte_start; @@ -832,7 +832,7 @@ pub mod node { pub fn serialize_node(node: @Node) -> ~str { unsafe { - let mut buf = vec::cast_to_mut(vec::from_elem(byte_len(node), 0)); + let mut buf = vec::from_elem(byte_len(node), 0); let mut offset = 0u;//Current position in the buffer let it = leaf_iterator::start(node); loop { diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 6209170ac3d1f..788d1d1012d2a 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -35,21 +35,21 @@ use core::vec; /// The SHA-1 interface trait Sha1 { /// Provide message input as bytes - fn input(&[const u8]); + fn input(&mut self, &[const u8]); /// Provide message input as string - fn input_str(&str); + fn input_str(&mut self, &str); /** * Read the digest as a vector of 20 bytes. After calling this no further * input may be provided until reset is called. */ - fn result() -> ~[u8]; + fn result(&mut self) -> ~[u8]; /** * Read the digest as a hex string. After calling this no further * input may be provided until reset is called. */ - fn result_str() -> ~str; + fn result_str(&mut self) -> ~str; /// Reset the SHA-1 state for reuse - fn reset(); + fn reset(&mut self); } // Some unexported constants @@ -65,15 +65,15 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object pub fn sha1() -> Sha1 { struct Sha1State - {h: ~[mut u32], - mut len_low: u32, - mut len_high: u32, - msg_block: ~[mut u8], - mut msg_block_idx: uint, - mut computed: bool, - work_buf: @~[mut u32]}; + { h: ~[u32], + len_low: u32, + len_high: u32, + msg_block: ~[u8], + msg_block_idx: uint, + computed: bool, + work_buf: @mut ~[u32]}; - fn add_input(st: &Sha1State, msg: &[const u8]) { + fn add_input(st: &mut Sha1State, msg: &[const u8]) { assert (!st.computed); for vec::each_const(msg) |element| { st.msg_block[st.msg_block_idx] = *element; @@ -89,11 +89,11 @@ pub fn sha1() -> Sha1 { if st.msg_block_idx == msg_block_len { process_msg_block(st); } } } - fn process_msg_block(st: &Sha1State) { + fn process_msg_block(st: &mut Sha1State) { assert (vec::len(st.h) == digest_buf_len); assert (vec::len(*st.work_buf) == work_buf_len); let mut t: int; // Loop counter - let w = st.work_buf; + let mut w = st.work_buf; // Initialize the first 16 words of the vector w t = 0; @@ -168,7 +168,7 @@ pub fn sha1() -> Sha1 { fn circular_shift(bits: u32, word: u32) -> u32 { return word << bits | word >> 32u32 - bits; } - fn mk_result(st: &Sha1State) -> ~[u8] { + fn mk_result(st: &mut Sha1State) -> ~[u8] { if !(*st).computed { pad_msg(st); (*st).computed = true; } let mut rs: ~[u8] = ~[]; for vec::each_mut((*st).h) |ptr_hpart| { @@ -191,7 +191,7 @@ pub fn sha1() -> Sha1 { * call process_msg_block() appropriately. When it returns, it * can be assumed that the message digest has been computed. */ - fn pad_msg(st: &Sha1State) { + fn pad_msg(st: &mut Sha1State) { assert (vec::len((*st).msg_block) == msg_block_len); /* @@ -229,7 +229,7 @@ pub fn sha1() -> Sha1 { } impl Sha1State: Sha1 { - fn reset() { + fn reset(&mut self) { assert (vec::len(self.h) == digest_buf_len); self.len_low = 0u32; self.len_high = 0u32; @@ -241,14 +241,14 @@ pub fn sha1() -> Sha1 { self.h[4] = 0xC3D2E1F0u32; self.computed = false; } - fn input(msg: &[const u8]) { add_input(&self, msg); } - fn input_str(msg: &str) { + fn input(&mut self, msg: &[const u8]) { add_input(self, msg); } + fn input_str(&mut self, msg: &str) { let bs = str::to_bytes(msg); - add_input(&self, bs); + add_input(self, bs); } - fn result() -> ~[u8] { return mk_result(&self); } - fn result_str() -> ~str { - let rr = mk_result(&self); + fn result(&mut self) -> ~[u8] { return mk_result(self); } + fn result_str(&mut self) -> ~str { + let rr = mk_result(self); let mut s = ~""; for vec::each(rr) |b| { s += uint::to_str_radix(*b as uint, 16u); @@ -256,16 +256,16 @@ pub fn sha1() -> Sha1 { return s; } } - let st = Sha1State { - h: vec::cast_to_mut(vec::from_elem(digest_buf_len, 0u32)), - mut len_low: 0u32, - mut len_high: 0u32, - msg_block: vec::cast_to_mut(vec::from_elem(msg_block_len, 0u8)), - mut msg_block_idx: 0u, - mut computed: false, - work_buf: @vec::cast_to_mut(vec::from_elem(work_buf_len, 0u32)) + let mut st = Sha1State { + h: vec::from_elem(digest_buf_len, 0u32), + len_low: 0u32, + len_high: 0u32, + msg_block: vec::from_elem(msg_block_len, 0u8), + msg_block_idx: 0u, + computed: false, + work_buf: @mut vec::from_elem(work_buf_len, 0u32) }; - let sh = (move st) as Sha1; + let mut sh = (move st) as Sha1; sh.reset(); return sh; } @@ -368,7 +368,7 @@ mod tests { } // Test that it works when accepting the message all at once - let sh = sha1::sha1(); + let mut sh = sha1::sha1(); for vec::each(tests) |t| { sh.input_str(t.input); let out = sh.result(); diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 680a2b99c4a2e..9c7d31e15f3fd 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -455,7 +455,7 @@ impl MergeState { base2: uint, len2: uint) { assert len1 != 0 && len2 != 0 && base1+len1 == base2; - let tmp = vec::cast_to_mut(vec::slice(array, base1, base1+len1)); + let mut tmp = vec::slice(array, base1, base1+len1); let mut c1 = 0; let mut c2 = base2; @@ -558,7 +558,7 @@ impl MergeState { base2: uint, len2: uint) { assert len1 != 1 && len2 != 0 && base1 + len1 == base2; - let tmp = vec::cast_to_mut(vec::slice(array, base2, base2+len2)); + let mut tmp = vec::slice(array, base2, base2+len2); let mut c1 = base1 + len1 - 1; let mut c2 = len2 - 1; diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 593d26d012404..69116ace9e860 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -242,13 +242,13 @@ fn json_decode>(s: &str) -> T { } fn digest>(t: &T) -> ~str { - let sha = sha1::sha1(); + let mut sha = sha1::sha1(); sha.input_str(json_encode(t)); sha.result_str() } fn digest_file(path: &Path) -> ~str { - let sha = sha1::sha1(); + let mut sha = sha1::sha1(); let s = io::read_whole_file_str(path); sha.input_str(*s.get_ref()); sha.result_str() diff --git a/src/test/bench/shootout-fannkuchredux.rs b/src/test/bench/shootout-fannkuchredux.rs index bb790a94ae47b..675151cf6c9da 100644 --- a/src/test/bench/shootout-fannkuchredux.rs +++ b/src/test/bench/shootout-fannkuchredux.rs @@ -14,9 +14,9 @@ extern mod std; fn fannkuch(n: int) -> int { fn perm1init(i: uint) -> int { return i as int; } - let perm = vec::cast_to_mut(vec::from_elem(n as uint, 0)); - let perm1 = vec::cast_to_mut(vec::from_fn(n as uint, |i| perm1init(i))); - let count = vec::cast_to_mut(vec::from_elem(n as uint, 0)); + let mut perm = vec::from_elem(n as uint, 0); + let mut perm1 = vec::from_fn(n as uint, |i| perm1init(i)); + let mut count = vec::from_elem(n as uint, 0); let mut f = 0; let mut i = 0; let mut k = 0; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 62341f08ce3be..3afb86210e1b8 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -149,7 +149,7 @@ fn main() { // initialize each sequence sorter let sizes = ~[1,2,3,4,6,12,18]; let streams = vec::map(sizes, |_sz| Some(stream())); - let streams = vec::cast_to_mut(move streams); + let mut streams = move streams; let mut from_child = ~[]; let to_child = vec::mapi(sizes, |ii, sz| { let sz = *sz; diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index b679b83228589..2b9a030fdf4ce 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -45,7 +45,7 @@ fn eval_At_times_u(u: &[const float], Au: &mut [float]) { } fn eval_AtA_times_u(u: &[const float], AtAu: &mut [float]) { - let v = vec::cast_to_mut(vec::from_elem(vec::len(u), 0.0)); + let mut v = vec::from_elem(vec::len(u), 0.0); eval_A_times_u(u, v); eval_At_times_u(v, AtAu); } @@ -62,8 +62,8 @@ fn main() { let N = uint::from_str(args[1]).get(); - let u = vec::cast_to_mut(vec::from_elem(N, 1.0)); - let v = vec::cast_to_mut(vec::from_elem(N, 0.0)); + let mut u = vec::from_elem(N, 1.0); + let mut v = vec::from_elem(N, 0.0); let mut i = 0u; while i < 10u { eval_AtA_times_u(u, v); diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 402e8ee831f90..1b85bd9646e75 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -33,8 +33,8 @@ fn main() { { let mut res = foo(x); - let mut v = ~[mut]; - v = move ~[mut (move res)] + v; //~ ERROR does not fulfill `Copy` + let mut v = ~[]; + v = move ~[(move res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy` assert (v.len() == 2); } diff --git a/src/test/run-pass/import-in-block.rs b/src/test/run-pass/import-in-block.rs index a41633c0b8240..6ad3344599734 100644 --- a/src/test/run-pass/import-in-block.rs +++ b/src/test/run-pass/import-in-block.rs @@ -9,6 +9,8 @@ // except according to those terms. pub fn main() { + // Once cast_to_mut is removed, pick a better function to import + // for this test! use vec::cast_to_mut; log(debug, vec::len(cast_to_mut(~[1, 2]))); { From c42a36776fa9a6a311c5ae54f7ac61dfef0fb981 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 13 Feb 2013 09:53:10 -0800 Subject: [PATCH 69/92] Add Brendan Zabarauskas to AUTHORS --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 3c62ba0843765..22877f12a935d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -29,6 +29,7 @@ Benjamin Peterson Bilal Husain Bill Fallon Brendan Eich +Brendan Zabarauskas Brian Anderson Brian J. Burg Brian Leibig From e92e3e4578c051a426e364eb4875cf81adbae25b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 13 Feb 2013 09:59:57 -0800 Subject: [PATCH 70/92] Add forgotten authors Jesse Jones, Mark Vian, and Trinick --- AUTHORS.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 22877f12a935d..628fa4c86da00 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -81,6 +81,7 @@ Jeff Muizelaar Jeff Olson Jeffrey Yasskin Jens Nockert +Jesse Jones Jesse Ruderman Jim Blandy Jimmy Lu @@ -106,6 +107,7 @@ Mahmut Bulut Margaret Meyerhofer Marijn Haverbeke Mark Lacey <641@rudkx.com> +Mark Vian Martin DeMello Marvin Löbel Matt Brubeck @@ -150,6 +152,7 @@ Tim Taubert Tom Lee Tomoki Aonuma Tony Young +Trinick Tycho Sci Tyler Bindon Viktor Dahl From 9df11ae83f8bfc06bc9bd1dc2132e344bc1ed0c7 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 13 Feb 2013 10:45:30 -0800 Subject: [PATCH 71/92] retabbing --- src/libsyntax/ext/auto_encode.rs | 119 ++++++++++++++++--------------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index d8c8629410c63..acbe4d7fa23ef 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -1189,87 +1189,88 @@ mod test { self.add_to_log (CallToOther) } } - + pub impl Encoder for TestEncoder { fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } - + fn emit_uint(&self, +v: uint) {self.add_to_log(CallToEmitUint(v)); } fn emit_u64(&self, +_v: u64) { self.add_unknown_to_log(); } - fn emit_u32(&self, +_v: u32) { self.add_unknown_to_log(); } - fn emit_u16(&self, +_v: u16) { self.add_unknown_to_log(); } - fn emit_u8(&self, +_v: u8) { self.add_unknown_to_log(); } + fn emit_u32(&self, +_v: u32) { self.add_unknown_to_log(); } + fn emit_u16(&self, +_v: u16) { self.add_unknown_to_log(); } + fn emit_u8(&self, +_v: u8) { self.add_unknown_to_log(); } - fn emit_int(&self, +_v: int) { self.add_unknown_to_log(); } - fn emit_i64(&self, +_v: i64) { self.add_unknown_to_log(); } - fn emit_i32(&self, +_v: i32) { self.add_unknown_to_log(); } - fn emit_i16(&self, +_v: i16) { self.add_unknown_to_log(); } - fn emit_i8(&self, +_v: i8) { self.add_unknown_to_log(); } + fn emit_int(&self, +_v: int) { self.add_unknown_to_log(); } + fn emit_i64(&self, +_v: i64) { self.add_unknown_to_log(); } + fn emit_i32(&self, +_v: i32) { self.add_unknown_to_log(); } + fn emit_i16(&self, +_v: i16) { self.add_unknown_to_log(); } + fn emit_i8(&self, +_v: i8) { self.add_unknown_to_log(); } - fn emit_bool(&self, +_v: bool) { self.add_unknown_to_log(); } + fn emit_bool(&self, +_v: bool) { self.add_unknown_to_log(); } - fn emit_f64(&self, +_v: f64) { self.add_unknown_to_log(); } - fn emit_f32(&self, +_v: f32) { self.add_unknown_to_log(); } - fn emit_float(&self, +_v: float) { self.add_unknown_to_log(); } + fn emit_f64(&self, +_v: f64) { self.add_unknown_to_log(); } + fn emit_f32(&self, +_v: f32) { self.add_unknown_to_log(); } + fn emit_float(&self, +_v: float) { self.add_unknown_to_log(); } - fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); } + fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); } - fn emit_borrowed_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_owned_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_managed_str(&self, +_v: &str) { self.add_unknown_to_log(); } + fn emit_borrowed_str(&self, +_v: &str) { self.add_unknown_to_log(); } + fn emit_owned_str(&self, +_v: &str) { self.add_unknown_to_log(); } + fn emit_managed_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_borrowed(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_owned(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_managed(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_borrowed(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_owned(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_managed(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_enum(&self, name: &str, f: fn()) { - self.add_to_log(CallToEmitEnum(name.to_str())); f(); } + fn emit_enum(&self, name: &str, f: fn()) { + self.add_to_log(CallToEmitEnum(name.to_str())); f(); } - fn emit_enum_variant(&self, name: &str, +id: uint, +cnt: uint, f: fn()) { - self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); f(); - } + fn emit_enum_variant(&self, name: &str, +id: uint, + +cnt: uint, f: fn()) { + self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); + f(); + } - fn emit_enum_variant_arg(&self, +idx: uint, f: fn()) { - self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); - } + fn emit_enum_variant_arg(&self, +idx: uint, f: fn()) { + self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); + } - fn emit_borrowed_vec(&self, +_len: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } + fn emit_borrowed_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } - fn emit_owned_vec(&self, +_len: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } - fn emit_managed_vec(&self, +_len: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } - fn emit_vec_elt(&self, +_idx: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } + fn emit_owned_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_managed_vec(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_vec_elt(&self, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } - fn emit_rec(&self, f: fn()) { - self.add_unknown_to_log(); f(); - } - fn emit_struct(&self, _name: &str, +_len: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } - fn emit_field(&self, _name: &str, +_idx: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } - - fn emit_tup(&self, +_len: uint, f: fn()) { - self.add_unknown_to_log(); f(); - } - fn emit_tup_elt(&self, +_idx: uint, f: fn()) { - self.add_unknown_to_log(); f(); + fn emit_rec(&self, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_struct(&self, _name: &str, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_field(&self, _name: &str, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + + fn emit_tup(&self, +_len: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } + fn emit_tup_elt(&self, +_idx: uint, f: fn()) { + self.add_unknown_to_log(); f(); + } } -} - + #[auto_decode] #[auto_encode] struct Node {id: uint} - fn to_call_log (val: Encodable) -> ~[call] { let mut te = TestEncoder {call_log: ~[]}; val.encode(&te); From 389125aeb83eb1571ff1ec4e5e140b1ac2109341 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 15 Jan 2013 17:30:01 -0800 Subject: [PATCH 72/92] core: add min and max to cmp, re-export various places. --- src/libcore/cmp.rs | 9 +++++++++ src/libcore/num/f64.rs | 1 + src/libcore/num/int-template.rs | 6 +----- src/libcore/num/uint-template.rs | 7 ++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index e1ec8c7737c7d..7cd4d4c9bc3b2 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -85,3 +85,12 @@ pub pure fn gt(v1: &T, v2: &T) -> bool { (*v1).gt(v2) } +#[inline(always)] +pub pure fn min(v1: T, v2: T) -> T { + if v1 < v2 { v1 } else { v2 } +} + +#[inline(always)] +pub pure fn max(v1: T, v2: T) -> T { + if v1 > v2 { v1 } else { v2 } +} diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 7cde210265324..75f68fdafc72c 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -21,6 +21,7 @@ use to_str; use from_str; pub use cmath::c_double_targ_consts::*; +pub use cmp::{min, max}; macro_rules! delegate( ( diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index b616a08246b67..4c22a8001e9b8 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -24,6 +24,7 @@ use vec; use i8; use i16; use i32; +pub use cmp::{min, max}; pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); @@ -31,11 +32,6 @@ pub const bytes : uint = (inst::bits / 8); pub const min_value: T = (-1 as T) << (bits - 1); pub const max_value: T = min_value - 1 as T; -#[inline(always)] -pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } -#[inline(always)] -pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } - #[inline(always)] pub pure fn add(x: T, y: T) -> T { x + y } #[inline(always)] diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 0a219660fb946..4a3c571520195 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -27,17 +27,14 @@ use u8; use u16; use u32; +pub use cmp::{min, max}; + pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); pub const min_value: T = 0 as T; pub const max_value: T = 0 as T - 1 as T; -#[inline(always)] -pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } -#[inline(always)] -pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } - #[inline(always)] pub pure fn add(x: T, y: T) -> T { x + y } #[inline(always)] From 73280b0472afdcf4df7eb1a80a7ac0b74a791ca9 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 15 Jan 2013 17:30:16 -0800 Subject: [PATCH 73/92] core: add abs to num. --- src/libcore/num/num.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index eb722b441c7a6..9ba53defd6ea7 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -39,6 +39,10 @@ pub trait One { static pure fn one() -> Self; } +pub pure fn abs(v: T) -> T { + if v < Zero::zero() { v.neg() } else { v } +} + pub trait Round { pure fn round(&self, mode: RoundMode) -> Self; From ebe99637fda18617684a7ae720247315701f19d3 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 15 Jan 2013 17:30:35 -0800 Subject: [PATCH 74/92] std: add stats. --- src/libstd/stats.rs | 96 +++++++++++++++++++++++++++++++++++++++++++++ src/libstd/std.rc | 1 + 2 files changed, 97 insertions(+) create mode 100644 src/libstd/stats.rs diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs new file mode 100644 index 0000000000000..f0043803c4b94 --- /dev/null +++ b/src/libstd/stats.rs @@ -0,0 +1,96 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core::vec; +use core::f64; +use core::cmp; +use core::num; +use sort; + +// NB: this can probably be rewritten in terms of num::Num +// to be less f64-specific. + +pub trait Stats { + fn sum(self) -> f64; + fn min(self) -> f64; + fn max(self) -> f64; + fn mean(self) -> f64; + fn median(self) -> f64; + fn var(self) -> f64; + fn std_dev(self) -> f64; + fn std_dev_pct(self) -> f64; + fn median_abs_dev(self) -> f64; + fn median_abs_dev_pct(self) -> f64; +} + +impl &[f64] : Stats { + fn sum(self) -> f64 { + vec::foldl(0.0, self, |p,q| p + *q) + } + + fn min(self) -> f64 { + assert self.len() != 0; + vec::foldl(self[0], self, |p,q| cmp::min(p, *q)) + } + + fn max(self) -> f64 { + assert self.len() != 0; + vec::foldl(self[0], self, |p,q| cmp::max(p, *q)) + } + + fn mean(self) -> f64 { + assert self.len() != 0; + self.sum() / (self.len() as f64) + } + + fn median(self) -> f64 { + assert self.len() != 0; + let tmp = vec::to_mut(vec::from_slice(self)); + sort::tim_sort(tmp); + if tmp.len() & 1 == 0 { + let m = tmp.len() / 2; + (tmp[m] + tmp[m-1]) / 2.0 + } else { + tmp[tmp.len() / 2] + } + } + + fn var(self) -> f64 { + if self.len() == 0 { + 0.0 + } else { + let mean = self.mean(); + let mut v = 0.0; + for self.each |s| { + let x = *s - mean; + v += x*x; + } + v/(self.len() as f64) + } + } + + fn std_dev(self) -> f64 { + f64::sqrt(self.var()) + } + + fn std_dev_pct(self) -> f64 { + (self.std_dev() / self.mean()) * 100.0 + } + + fn median_abs_dev(self) -> f64 { + let med = self.median(); + let abs_devs = self.map(|v| num::abs(med - *v)); + abs_devs.median() + } + + fn median_abs_dev_pct(self) -> f64 { + (self.median_abs_dev() / self.median()) * 100.0 + } +} diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 8c142908d106f..3b855b3453d3a 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -98,6 +98,7 @@ pub mod base64; pub mod rl; pub mod workcache; pub mod bigint; +pub mod stats; #[cfg(unicode)] mod unicode; From e5aa399e0d98b81b6454ec30f70aac8604fb7b11 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 13 Feb 2013 11:46:14 -0800 Subject: [PATCH 75/92] rustc and std: teach about #[bench], modernize to use quote_expr! some. --- src/compiletest/compiletest.rc | 16 +- src/libcore/either.rs | 2 +- src/libcore/num/num.rs | 2 +- src/librustc/front/test.rs | 458 ++++++++---------------- src/librustc/middle/check_const.rs | 12 +- src/libstd/stats.rs | 2 +- src/libstd/std.rc | 1 + src/libstd/test.rs | 513 +++++++++++++++++++++++---- src/test/run-pass/test-ignore-cfg.rs | 6 +- 9 files changed, 610 insertions(+), 402 deletions(-) diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 6d3bfde037216..ccd1b899ce34f 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -33,7 +33,7 @@ mod errors; use std::getopts; use std::test; -use core::result; +use core::{result, either}; use result::{Ok, Err}; use common::config; @@ -158,7 +158,11 @@ pub fn test_opts(config: config) -> test::TestOpts { test::TestOpts { filter: config.filter, run_ignored: config.run_ignored, - logfile: config.logfile.map(|s| s.to_str()), + logfile: copy config.logfile, + run_tests: true, + run_benchmarks: false, + save_results: option::None, + compare_results: option::None } } @@ -210,13 +214,15 @@ pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn { } } -pub fn make_test_name(config: config, testfile: &Path) -> ~str { - fmt!("[%s] %s", mode_str(config.mode), testfile.to_str()) +pub fn make_test_name(config: config, testfile: &Path) -> test::TestName { + test::DynTestName(fmt!("[%s] %s", + mode_str(config.mode), + testfile.to_str())) } pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); - fn~() { runtest::run(config, testfile) } + test::DynTestFn(fn~() { runtest::run(config, testfile) }) } // Local Variables: diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 7efde62c4ca6b..b8f60c1a2d906 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -145,7 +145,7 @@ pub pure fn unwrap_right(eith: Either) -> U { } } -impl Either { +pub impl Either { #[inline(always)] fn either(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V { either(f_left, f_right, self) diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 9ba53defd6ea7..bc5a42262ca9c 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -39,7 +39,7 @@ pub trait One { static pure fn one() -> Self; } -pub pure fn abs(v: T) -> T { +pub pure fn abs(v: T) -> T { if v < Zero::zero() { v.neg() } else { v } } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 34f0045f3fd4b..caa2035389d63 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -21,18 +21,21 @@ use core::option; use core::vec; use syntax::ast_util::*; use syntax::attr; -use syntax::codemap::{dummy_sp, span}; +use syntax::codemap::{dummy_sp, span, ExpandedFrom}; use syntax::codemap; use syntax::fold; use syntax::print::pprust; use syntax::{ast, ast_util}; use syntax::attr::attrs_contains_name; +use syntax::ext::base::{mk_ctxt, ext_ctxt}; + type node_id_gen = fn@() -> ast::node_id; type test = { span: span, path: ~[ast::ident], + bench: bool, ignore: bool, should_fail: bool }; @@ -41,6 +44,7 @@ struct TestCtxt { sess: session::Session, crate: @ast::crate, path: ~[ast::ident], + ext_cx: ext_ctxt, testfns: ~[test] } @@ -68,10 +72,15 @@ fn generate_test_harness(sess: session::Session, let cx: @mut TestCtxt = @mut TestCtxt { sess: sess, crate: crate, + ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg), path: ~[], testfns: ~[] }; + cx.ext_cx.bt_push(ExpandedFrom({call_site: dummy_sp(), + callie: {name: ~"test", + span: None}})); + let precursor = @fold::AstFoldFns { fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ), fold_item: |a,b| fold_item(cx, a, b), @@ -79,6 +88,7 @@ fn generate_test_harness(sess: session::Session, let fold = fold::make_fold(precursor); let res = @fold.fold_crate(*crate); + cx.ext_cx.bt_pop(); return res; } @@ -86,7 +96,8 @@ 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| { - !attr::contains_name(attr::attr_metas(attrs), ~"test") + !attr::contains_name(attr::attr_metas(attrs), ~"test") && + !attr::contains_name(attr::attr_metas(attrs), ~"bench") } } @@ -132,7 +143,7 @@ fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: fold::ast_fold) debug!("current path: %s", ast_util::path_name_i(cx.path, cx.sess.parse_sess.interner)); - if is_test_fn(i) { + if is_test_fn(i) || is_bench_fn(i) { match i.node { ast::item_fn(_, purity, _, _) if purity == ast::unsafe_fn => { let sess = cx.sess; @@ -143,10 +154,12 @@ fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: fold::ast_fold) _ => { debug!("this is a test function"); let test = {span: i.span, - path: /*bad*/copy cx.path, ignore: is_ignored(cx, i), + path: /*bad*/copy cx.path, + bench: is_bench_fn(i), + ignore: is_ignored(cx, i), should_fail: should_fail(i)}; cx.testfns.push(test); - debug!("have %u test functions", cx.testfns.len()); + debug!("have %u test/bench functions", cx.testfns.len()); } } } @@ -176,6 +189,31 @@ fn is_test_fn(i: @ast::item) -> bool { return has_test_attr && has_test_signature(i); } +fn is_bench_fn(i: @ast::item) -> bool { + let has_bench_attr = + vec::len(attr::find_attrs_by_name(i.attrs, ~"bench")) > 0u; + + fn has_test_signature(i: @ast::item) -> bool { + match /*bad*/copy i.node { + ast::item_fn(decl, _, tps, _) => { + let input_cnt = vec::len(decl.inputs); + let no_output = match decl.output.node { + ast::ty_nil => true, + _ => false + }; + let tparm_cnt = vec::len(tps); + // NB: inadequate check, but we're running + // well before resolve, can't get too deep. + input_cnt == 1u + && no_output && tparm_cnt == 0u + } + _ => false + } + } + + return has_bench_attr && has_test_signature(i); +} + fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool { let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore"); let ignoreitems = attr::attr_metas(ignoreattrs); @@ -194,7 +232,7 @@ fn should_fail(i: @ast::item) -> bool { vec::len(attr::find_attrs_by_name(i.attrs, ~"should_fail")) > 0u } -fn add_test_module(cx: @mut TestCtxt, +m: ast::_mod) -> ast::_mod { +fn add_test_module(cx: &TestCtxt, +m: ast::_mod) -> ast::_mod { let testmod = mk_test_module(cx); ast::_mod { items: vec::append_one(/*bad*/copy m.items, testmod), @@ -207,47 +245,84 @@ fn add_test_module(cx: @mut TestCtxt, +m: ast::_mod) -> ast::_mod { We're going to be building a module that looks more or less like: mod __test { - fn main(args: ~[str]) -> int { - std::test::test_main(args, tests()) + #[!resolve_unexported] + extern mod std (name = "std", vers = "..."); + fn main() { + #[main]; + std::test::test_main_static(::os::args(), tests) } - fn tests() -> ~[std::test::test_desc] { + const tests : &static/[std::test::TestDescAndFn] = &[ ... the list of tests in the crate ... - } + ]; } */ -fn mk_test_module(cx: @mut TestCtxt) -> @ast::item { +fn mk_std(cx: &TestCtxt) -> @ast::view_item { + let vers = ast::lit_str(@~"0.6"); + let vers = nospan(vers); + let mi = ast::meta_name_value(~"vers", vers); + let mi = nospan(mi); + let id_std = cx.sess.ident_of(~"std"); + let vi = if is_std(cx) { + ast::view_item_import( + ~[@nospan(ast::view_path_simple(id_std, + path_node(~[id_std]), + ast::type_value_ns, + cx.sess.next_node_id()))]) + } else { + ast::view_item_use(id_std, ~[@mi], + cx.sess.next_node_id()) + }; + let vi = ast::view_item { + node: vi, + attrs: ~[], + vis: ast::private, + span: dummy_sp() + }; + return @vi; +} + +fn mk_test_module(cx: &TestCtxt) -> @ast::item { + // Link to std - let std = mk_std(cx); - let view_items = if is_std(cx) { ~[] } else { ~[std] }; - // A function that generates a vector of test descriptors to feed to the - // test runner - let testsfn = mk_tests(cx); + let view_items = ~[mk_std(cx)]; + + // A constant vector of test descriptors. + let tests = mk_tests(cx); + // The synthesized main function which will call the console test runner // with our list of tests - let mainfn = mk_main(cx); + let ext_cx = cx.ext_cx; + let mainfn = (quote_item!( + pub fn main() { + #[main]; + std::test::test_main_static(::os::args(), tests); + } + )).get(); + let testmod = ast::_mod { view_items: view_items, - items: ~[mainfn, testsfn], + items: ~[mainfn, tests], }; let item_ = ast::item_mod(testmod); + // This attribute tells resolve to let us call unexported functions let resolve_unexported_attr = attr::mk_attr(attr::mk_word_item(~"!resolve_unexported")); - let sess = cx.sess; + let item = ast::item { - ident: sess.ident_of(~"__test"), + ident: cx.sess.ident_of(~"__test"), attrs: ~[resolve_unexported_attr], - id: sess.next_node_id(), + id: cx.sess.next_node_id(), node: item_, vis: ast::public, span: dummy_sp(), - }; + }; debug!("Synthetic test module:\n%s\n", - pprust::item_to_str(@copy item, sess.intr())); + pprust::item_to_str(@copy item, cx.sess.intr())); return @item; } @@ -258,10 +333,10 @@ fn nospan(t: T) -> codemap::spanned { fn path_node(+ids: ~[ast::ident]) -> @ast::path { @ast::path { span: dummy_sp(), - global: false, - idents: ids, - rp: None, - types: ~[] } + global: false, + idents: ids, + rp: None, + types: ~[] } } fn path_node_global(+ids: ~[ast::ident]) -> @ast::path { @@ -272,56 +347,22 @@ fn path_node_global(+ids: ~[ast::ident]) -> @ast::path { types: ~[] } } -fn mk_std(cx: @mut TestCtxt) -> @ast::view_item { - let vers = ast::lit_str(@~"0.6"); - let vers = nospan(vers); - let mi = ast::meta_name_value(~"vers", vers); - let mi = nospan(mi); - let sess = cx.sess; - let vi = ast::view_item_use(sess.ident_of(~"std"), - ~[@mi], - sess.next_node_id()); - let vi = ast::view_item { - node: vi, - attrs: ~[], - vis: ast::private, - span: dummy_sp() - }; - - return @vi; -} -fn mk_tests(cx: @mut TestCtxt) -> @ast::item { - let ret_ty = mk_test_desc_and_fn_vec_ty(cx); +fn mk_tests(cx: &TestCtxt) -> @ast::item { - let decl = ast::fn_decl { - inputs: ~[], - output: ret_ty, - cf: ast::return_val, - }; + let ext_cx = cx.ext_cx; // The vector of test_descs for this crate - let test_descs = mk_test_desc_and_fn_vec(cx); - - let sess = cx.sess; - let body_: ast::blk_ = default_block(~[], - option::Some(test_descs), - sess.next_node_id()); - let body = nospan(body_); + let test_descs = mk_test_descs(cx); - let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body); - let item = ast::item { - ident: sess.ident_of(~"tests"), - attrs: ~[], - id: sess.next_node_id(), - node: item_, - vis: ast::public, - span: dummy_sp(), - }; - return @item; + (quote_item!( + pub const tests : &static/[self::std::test::TestDescAndFn] = + $test_descs + ; + )).get() } -fn is_std(cx: @mut TestCtxt) -> bool { +fn is_std(cx: &TestCtxt) -> bool { let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); match attr::last_meta_item_value_str_by_name(items, ~"name") { @@ -332,55 +373,11 @@ fn is_std(cx: @mut TestCtxt) -> bool { return is_std; } -fn mk_path(cx: @mut TestCtxt, +path: ~[ast::ident]) -> @ast::path { - // For tests that are inside of std we don't want to prefix - // the paths with std:: - let sess = cx.sess; - if is_std(cx) { - path_node_global(path) - } else { - path_node(~[ sess.ident_of(~"self"), sess.ident_of(~"std") ] + path) - } -} - -// The ast::Ty of ~[std::test::test_desc] -fn mk_test_desc_and_fn_vec_ty(cx: @mut TestCtxt) -> @ast::Ty { - let sess = cx.sess; - let test_desc_and_fn_ty_path = mk_path(cx, ~[ - sess.ident_of(~"test"), - sess.ident_of(~"TestDescAndFn") - ]); - - let test_desc_and_fn_ty = ast::Ty { - id: sess.next_node_id(), - node: ast::ty_path(test_desc_and_fn_ty_path, sess.next_node_id()), - span: dummy_sp(), - }; - - let vec_mt = ast::mt {ty: @test_desc_and_fn_ty, - mutbl: ast::m_imm}; - - let inner_ty = @ast::Ty { - id: sess.next_node_id(), - node: ast::ty_vec(vec_mt), - span: dummy_sp(), - }; - - @ast::Ty { - id: sess.next_node_id(), - node: ast::ty_uniq(ast::mt { ty: inner_ty, mutbl: ast::m_imm }), - span: dummy_sp(), - } -} - -fn mk_test_desc_and_fn_vec(cx: @mut TestCtxt) -> @ast::expr { +fn mk_test_descs(cx: &TestCtxt) -> @ast::expr { debug!("building test vector from %u tests", cx.testfns.len()); let mut descs = ~[]; - { - let testfns = &mut cx.testfns; - for testfns.each |test| { - descs.push(mk_test_desc_and_fn_rec(cx, *test)); - } + for cx.testfns.each |test| { + descs.push(mk_test_desc_and_fn_rec(cx, *test)); } let sess = cx.sess; @@ -394,223 +391,70 @@ fn mk_test_desc_and_fn_vec(cx: @mut TestCtxt) -> @ast::expr { @ast::expr { id: sess.next_node_id(), callee_id: sess.next_node_id(), - node: ast::expr_vstore(inner_expr, ast::expr_vstore_uniq), + node: ast::expr_vstore(inner_expr, ast::expr_vstore_slice), span: dummy_sp(), } } -fn mk_test_desc_and_fn_rec(cx: @mut TestCtxt, test: test) -> @ast::expr { +fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: test) -> @ast::expr { let span = test.span; let path = /*bad*/copy test.path; - let sess = cx.sess; - debug!("encoding %s", - ast_util::path_name_i(path, sess.parse_sess.interner)); + let ext_cx = cx.ext_cx; + + debug!("encoding %s", ast_util::path_name_i(path, + cx.sess.parse_sess.interner)); let name_lit: ast::lit = nospan(ast::lit_str(@ast_util::path_name_i( path, - sess.parse_sess.interner))); - - let name_expr_inner = @ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_lit(@name_lit), - span: span, - }; - - let name_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_vstore(name_expr_inner, ast::expr_vstore_uniq), - span: dummy_sp(), - }; - - let name_field = nospan(ast::field_ { - mutbl: ast::m_imm, - ident: sess.ident_of(~"name"), - expr: @name_expr, - }); - - let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore)); - - let ignore_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_lit(@ignore_lit), - span: span, - }; - - let ignore_field = nospan(ast::field_ { - mutbl: ast::m_imm, - ident: sess.ident_of(~"ignore"), - expr: @ignore_expr, - }); - - let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail)); - - let fail_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_lit(@fail_lit), - span: span, - }; - - let fail_field = nospan(ast::field_ { - mutbl: ast::m_imm, - ident: sess.ident_of(~"should_fail"), - expr: @fail_expr, - }); - - let test_desc_path = - mk_path(cx, ~[ sess.ident_of(~"test"), sess.ident_of(~"TestDesc") ]); + cx.sess.parse_sess.interner))); - let desc_rec_ = ast::expr_struct( - test_desc_path, - ~[name_field, ignore_field, fail_field], - option::None - ); - - let desc_rec = @ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: desc_rec_, - span: span, + let name_expr = @ast::expr { + id: cx.sess.next_node_id(), + callee_id: cx.sess.next_node_id(), + node: ast::expr_lit(@name_lit), + span: span }; - let desc_field = nospan(ast::field_ { - mutbl: ast::m_imm, - ident: sess.ident_of(~"desc"), - expr: desc_rec - }); - let fn_path = path_node_global(path); let fn_expr = @ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), + id: cx.sess.next_node_id(), + callee_id: cx.sess.next_node_id(), node: ast::expr_path(fn_path), span: span, }; - let fn_field = nospan(ast::field_ { - mutbl: ast::m_imm, - ident: sess.ident_of(~"testfn"), - expr: fn_expr, - }); - - let test_desc_and_fn_path = - mk_path(cx, ~[sess.ident_of(~"test"), - sess.ident_of(~"TestDescAndFn")]); - - let desc_and_fn_rec = @ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_struct(test_desc_and_fn_path, - ~[fn_field, desc_field], - option::None), - span: span, - }; - - return desc_and_fn_rec; -} - -fn mk_main(cx: @mut TestCtxt) -> @ast::item { - let sess = cx.sess; - let ret_ty = ast::Ty { - id: sess.next_node_id(), - node: ast::ty_nil, - span: dummy_sp(), - }; - - let decl = ast::fn_decl { - inputs: ~[], - output: @ret_ty, - cf: ast::return_val, - }; - - let test_main_call_expr = mk_test_main_call(cx); - - let body_: ast::blk_ = - default_block(~[], - option::Some(test_main_call_expr), - sess.next_node_id()); - let body = codemap::spanned { node: body_, span: dummy_sp() }; - - let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body); - let item = ast::item { - ident: sess.ident_of(~"main"), - attrs: ~[attr::mk_attr(attr::mk_word_item(~"main"))], - id: sess.next_node_id(), - node: item_, - vis: ast::public, - span: dummy_sp(), - }; - return @item; -} - -fn mk_test_main_call(cx: @mut TestCtxt) -> @ast::expr { - // Call os::args to generate the vector of test_descs - let sess = cx.sess; - let args_path = path_node_global(~[ - sess.ident_of(~"os"), - sess.ident_of(~"args") - ]); - - let args_path_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_path(args_path), - span: dummy_sp(), - }; - - let args_call_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_call(@args_path_expr, ~[], ast::NoSugar), - span: dummy_sp(), - }; - - // Call __test::test to generate the vector of test_descs - let test_path = path_node(~[ sess.ident_of(~"tests") ]); - - let test_path_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_path(test_path), - span: dummy_sp(), - }; - - let test_call_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_call(@test_path_expr, ~[], ast::NoSugar), - span: dummy_sp(), + let t_expr = if test.bench { + quote_expr!( self::std::test::StaticBenchFn($fn_expr) ) + } else { + quote_expr!( self::std::test::StaticTestFn($fn_expr) ) }; - // Call std::test::test_main - let test_main_path = mk_path(cx, ~[ - sess.ident_of(~"test"), - sess.ident_of(~"test_main") - ]); - - let test_main_path_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_path(test_main_path), - span: dummy_sp(), + let ignore_expr = if test.ignore { + quote_expr!( true ) + } else { + quote_expr!( false ) }; - let test_main_call_expr = ast::expr { - id: sess.next_node_id(), - callee_id: sess.next_node_id(), - node: ast::expr_call(@test_main_path_expr, - ~[@args_call_expr, @test_call_expr], - ast::NoSugar), - span: dummy_sp(), + let fail_expr = if test.should_fail { + quote_expr!( true ) + } else { + quote_expr!( false ) }; - return @test_main_call_expr; + let e = quote_expr!( + self::std::test::TestDescAndFn { + desc: self::std::test::TestDesc { + name: self::std::test::StaticTestName($name_expr), + ignore: $ignore_expr, + should_fail: $fail_expr + }, + testfn: $t_expr, + } + ); + e } // Local Variables: diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 6cca576fa130b..8890da1587d9c 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -127,15 +127,15 @@ pub fn check_expr(sess: Session, items without type parameters"); } match def_map.find(&e.id) { - Some(def_const(def_id)) | - Some(def_fn(def_id, _)) | - Some(def_variant(_, def_id)) | - Some(def_struct(def_id)) => { + Some(def_variant(_, _)) | + Some(def_struct(_)) => { } + + Some(def_const(def_id)) | + Some(def_fn(def_id, _)) => { if !ast_util::is_local(def_id) { sess.span_err( e.span, ~"paths in constants may only refer to \ - crate-local constants, functions, or \ - structs"); + crate-local constants or functions"); } } Some(def) => { diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs index f0043803c4b94..2048cb6c59f0d 100644 --- a/src/libstd/stats.rs +++ b/src/libstd/stats.rs @@ -52,7 +52,7 @@ impl &[f64] : Stats { fn median(self) -> f64 { assert self.len() != 0; - let tmp = vec::to_mut(vec::from_slice(self)); + let tmp = vec::cast_to_mut(vec::from_slice(self)); sort::tim_sort(tmp); if tmp.len() & 1 == 0 { let m = tmp.len() / 2; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 3b855b3453d3a..3c2baae6d57c1 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -115,6 +115,7 @@ pub mod serialize; #[doc(hidden)] // FIXME #3538 mod std { pub use serialize; + pub use test; } // Local Variables: diff --git a/src/libstd/test.rs b/src/libstd/test.rs index e83b759f90144..f3e96826a8e59 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -20,6 +20,8 @@ use sort; use term; use core::cmp::Eq; + +use core::to_str::ToStr; use core::either::Either; use core::either; use core::io::WriterUtil; @@ -43,13 +45,62 @@ extern mod rustrt { // paths; i.e. it should be a series of identifiers seperated by double // colons. This way if some test runner wants to arrange the tests // hierarchically it may. -pub type TestName = ~str; + +#[cfg(stage0)] +pub enum TestName { + // Stage0 doesn't understand sendable &static/str yet + StaticTestName(&static/[u8]), + DynTestName(~str) +} + +#[cfg(stage0)] +impl ToStr for TestName { + pure fn to_str(&self) -> ~str { + match self { + &StaticTestName(s) => str::from_bytes(s), + &DynTestName(s) => s.to_str() + } + } +} + +#[cfg(stage1)] +#[cfg(stage2)] +#[cfg(stage3)] +pub enum TestName { + StaticTestName(&static/str), + DynTestName(~str) +} + +#[cfg(stage1)] +#[cfg(stage2)] +#[cfg(stage3)] +impl ToStr for TestName { + pure fn to_str(&self) -> ~str { + match self { + &StaticTestName(s) => s.to_str(), + &DynTestName(s) => s.to_str() + } + } +} // A function that runs a test. If the function returns successfully, // the test succeeds; if the function fails then the test fails. We // may need to come up with a more clever definition of test in order // to support isolation of tests into tasks. -pub type TestFn = ~fn(); +pub enum TestFn { + StaticTestFn(extern fn()), + StaticBenchFn(extern fn(&mut BenchHarness)), + DynTestFn(~fn()), + DynBenchFn(~fn(&mut BenchHarness)) +} + +// Structure passed to BenchFns +pub struct BenchHarness { + iterations: u64, + ns_start: u64, + ns_end: u64, + bytes: u64 +} // The definition of a single test. A test runner will run a list of // these. @@ -65,7 +116,7 @@ pub struct TestDescAndFn { } // The default console test runner. It accepts the command line -// arguments and a vector of test_descs (generated at compile time). +// arguments and a vector of test_descs. pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) { let opts = match parse_opts(args) { @@ -75,10 +126,38 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) { if !run_tests_console(&opts, tests) { die!(~"Some tests failed"); } } +// A variant optimized for invocation with a static test vector. +// This will fail (intentionally) when fed any dynamic tests, because +// it is copying the static values out into a dynamic vector and cannot +// copy dynamic values. It is doing this because from this point on +// a ~[TestDescAndFn] is used in order to effect ownership-transfer +// semantics into parallel test runners, which in turn requires a ~[] +// rather than a &[]. +pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) { + let owned_tests = do tests.map |t| { + match t.testfn { + StaticTestFn(f) => + TestDescAndFn { testfn: StaticTestFn(f), desc: copy t.desc }, + + StaticBenchFn(f) => + TestDescAndFn { testfn: StaticBenchFn(f), desc: copy t.desc }, + + _ => { + die! (~"non-static tests passed to test::test_main_static"); + } + } + }; + test_main(args, owned_tests) +} + pub struct TestOpts { filter: Option<~str>, run_ignored: bool, - logfile: Option<~str>, + run_tests: bool, + run_benchmarks: bool, + save_results: Option, + compare_results: Option, + logfile: Option } type OptRes = Either; @@ -86,7 +165,12 @@ type OptRes = Either; // Parses command line arguments into test options pub fn parse_opts(args: &[~str]) -> OptRes { let args_ = vec::tail(args); - let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")]; + let opts = ~[getopts::optflag(~"ignored"), + getopts::optflag(~"test"), + getopts::optflag(~"bench"), + getopts::optopt(~"save"), + getopts::optopt(~"diff"), + getopts::optopt(~"logfile")]; let matches = match getopts::getopts(args_, opts) { Ok(move m) => m, @@ -99,19 +183,41 @@ pub fn parse_opts(args: &[~str]) -> OptRes { } else { option::None }; let run_ignored = getopts::opt_present(&matches, ~"ignored"); + let logfile = getopts::opt_maybe_str(&matches, ~"logfile"); + let logfile = logfile.map(|s| Path(*s)); + + let run_benchmarks = getopts::opt_present(&matches, ~"bench"); + let run_tests = ! run_benchmarks || + getopts::opt_present(&matches, ~"test"); + + let save_results = getopts::opt_maybe_str(&matches, ~"save"); + let save_results = save_results.map(|s| Path(*s)); + + let compare_results = getopts::opt_maybe_str(&matches, ~"diff"); + let compare_results = compare_results.map(|s| Path(*s)); let test_opts = TestOpts { filter: filter, run_ignored: run_ignored, - logfile: logfile, + run_tests: run_tests, + run_benchmarks: run_benchmarks, + save_results: save_results, + compare_results: compare_results, + logfile: logfile }; either::Left(test_opts) } #[deriving_eq] -pub enum TestResult { TrOk, TrFailed, TrIgnored, } +pub struct BenchSamples { + ns_iter_samples: ~[f64], + mb_s: uint +} + +#[deriving_eq] +pub enum TestResult { TrOk, TrFailed, TrIgnored, TrBench(BenchSamples) } struct ConsoleTestState { out: io::Writer, @@ -121,6 +227,7 @@ struct ConsoleTestState { mut passed: uint, mut failed: uint, mut ignored: uint, + mut benchmarked: uint, mut failures: ~[TestDesc] } @@ -137,7 +244,7 @@ pub fn run_tests_console(opts: &TestOpts, st.out.write_line(fmt!("\nrunning %u %s", st.total, noun)); } TeWait(ref test) => st.out.write_str( - fmt!("test %s ... ", test.name)), + fmt!("test %s ... ", test.name.to_str())), TeResult(copy test, result) => { match st.log_out { Some(f) => write_log(f, result, &test), @@ -160,14 +267,21 @@ pub fn run_tests_console(opts: &TestOpts, write_ignored(st.out, st.use_color); st.out.write_line(~""); } + TrBench(bs) => { + st.benchmarked += 1u; + write_bench(st.out, st.use_color); + st.out.write_line(fmt!(": %s", + fmt_bench_samples(&bs))); + } } } } } let log_out = match opts.logfile { - Some(ref path) => match io::file_writer(&Path(*path), - ~[io::Create, io::Truncate]) { + Some(ref path) => match io::file_writer(path, + ~[io::Create, + io::Truncate]) { result::Ok(w) => Some(w), result::Err(ref s) => { die!(fmt!("can't open output file: %s", *s)) @@ -176,20 +290,23 @@ pub fn run_tests_console(opts: &TestOpts, None => None }; - let st = - @ConsoleTestState{out: io::stdout(), - log_out: log_out, - use_color: use_color(), - mut total: 0, - mut passed: 0, - mut failed: 0, - mut ignored: 0, - mut failures: ~[]}; + let st = @ConsoleTestState { + out: io::stdout(), + log_out: log_out, + use_color: use_color(), + mut total: 0u, + mut passed: 0u, + mut failed: 0u, + mut ignored: 0u, + mut benchmarked: 0u, + mut failures: ~[] + }; run_tests(opts, tests, |x| callback(&x, st)); - assert (st.passed + st.failed + st.ignored == st.total); - let success = st.failed == 0; + assert (st.passed + st.failed + + st.ignored + st.benchmarked == st.total); + let success = st.failed == 0u; if !success { print_failures(st); @@ -199,19 +316,36 @@ pub fn run_tests_console(opts: &TestOpts, if success { // There's no parallelism at this point so it's safe to use color write_ok(st.out, true); - } else { write_failed(st.out, true); } - st.out.write_str(fmt!(". %u passed; %u failed; %u ignored\n\n", st.passed, - st.failed, st.ignored)); + } else { + write_failed(st.out, true); + } + st.out.write_str(fmt!(". %u passed; %u failed; %u ignored\n\n", + st.passed, st.failed, st.ignored)); return success; + fn fmt_bench_samples(bs: &BenchSamples) -> ~str { + use stats::Stats; + if bs.mb_s != 0 { + fmt!("%u ns/iter (+/- %u) = %u MB/s", + bs.ns_iter_samples.median() as uint, + 3 * (bs.ns_iter_samples.median_abs_dev() as uint), + bs.mb_s) + } else { + fmt!("%u ns/iter (+/- %u)", + bs.ns_iter_samples.median() as uint, + 3 * (bs.ns_iter_samples.median_abs_dev() as uint)) + } + } + fn write_log(out: io::Writer, result: TestResult, test: &TestDesc) { out.write_line(fmt!("%s %s", match result { TrOk => ~"ok", TrFailed => ~"failed", - TrIgnored => ~"ignored" - }, test.name)); + TrIgnored => ~"ignored", + TrBench(ref bs) => fmt_bench_samples(bs) + }, test.name.to_str())); } fn write_ok(out: io::Writer, use_color: bool) { @@ -226,6 +360,10 @@ pub fn run_tests_console(opts: &TestOpts, write_pretty(out, ~"ignored", term::color_yellow, use_color); } + fn write_bench(out: io::Writer, use_color: bool) { + write_pretty(out, ~"bench", term::color_cyan, use_color); + } + fn write_pretty(out: io::Writer, word: &str, color: u8, use_color: bool) { if use_color && term::color_supported() { term::fg(out, color); @@ -239,11 +377,10 @@ pub fn run_tests_console(opts: &TestOpts, fn print_failures(st: @ConsoleTestState) { st.out.write_line(~"\nfailures:"); - let failures = copy st.failures; - let failures = vec::map(failures, |test| test.name); - let failures = do sort::merge_sort(failures) |x, y| { str::le(*x, *y) }; + let failures = vec::cast_to_mut(st.failures.map(|t| t.name.to_str())); + sort::tim_sort(failures); for vec::each(failures) |name| { - st.out.write_line(fmt!(" %s", *name)); + st.out.write_line(fmt!(" %s", name.to_str())); } } @@ -253,26 +390,28 @@ fn should_sort_failures_before_printing_them() { let s = do io::with_str_writer |wr| { let test_a = TestDesc { - name: ~"a", + name: StaticTestName("a"), ignore: false, should_fail: false }; let test_b = TestDesc { - name: ~"b", + name: StaticTestName("b"), ignore: false, should_fail: false }; - let st = - @ConsoleTestState{out: wr, - log_out: option::None, - use_color: false, - mut total: 0, - mut passed: 0, - mut failed: 0, - mut ignored: 0, - mut failures: ~[move test_b, move test_a]}; + let st = @ConsoleTestState { + out: wr, + log_out: option::None, + use_color: false, + mut total: 0u, + mut passed: 0u, + mut failed: 0u, + mut ignored: 0u, + mut benchmarked: 0u, + mut failures: ~[move test_b, move test_a] + }; print_failures(st); }; @@ -300,6 +439,15 @@ fn run_tests(opts: &TestOpts, let filtered_descs = filtered_tests.map(|t| t.desc); callback(TeFiltered(filtered_descs)); + let mut (filtered_tests, + filtered_benchs) = + do vec::partition(filtered_tests) |e| { + match e.testfn { + StaticTestFn(_) | DynTestFn(_) => true, + StaticBenchFn(_) | DynBenchFn(_) => false + } + }; + // It's tempting to just spawn all the tests at once, but since we have // many tests that run in other processes we would be making a big mess. let concurrency = get_concurrency(); @@ -321,7 +469,7 @@ fn run_tests(opts: &TestOpts, // that hang forever. callback(TeWait(test.desc)); } - run_test(test, ch.clone()); + run_test(!opts.run_tests, test, ch.clone()); pending += 1; } @@ -332,6 +480,14 @@ fn run_tests(opts: &TestOpts, callback(TeResult(desc, result)); pending -= 1; } + + // All benchmarks run at the end, in serial. + do vec::consume(filtered_benchs) |_, b| { + callback(TeWait(copy b.desc)); + run_test(!opts.run_benchmarks, b, ch.clone()); + let (test, result) = p.recv(); + callback(TeResult(move test, result)); + } } // Windows tends to dislike being overloaded with threads. @@ -368,7 +524,7 @@ pub fn filter_tests( fn filter_fn(test: TestDescAndFn, filter_str: &str) -> Option { - if str::contains(test.desc.name, filter_str) { + if str::contains(test.desc.name.to_str(), filter_str) { return option::Some(test); } else { return option::None; } } @@ -391,13 +547,12 @@ pub fn filter_tests( None } }; - vec::filter_map(filtered, |x| filter(x)) }; // Sort the tests alphabetically pure fn lteq(t1: &TestDescAndFn, t2: &TestDescAndFn) -> bool { - str::le(t1.desc.name, t2.desc.name) + str::le(t1.desc.name.to_str(), t2.desc.name.to_str()) } sort::quick_sort(filtered, lteq); @@ -409,24 +564,47 @@ struct TestFuture { wait: fn@() -> TestResult, } -pub fn run_test(test: TestDescAndFn, monitor_ch: SharedChan) { +pub fn run_test(force_ignore: bool, + test: TestDescAndFn, + monitor_ch: SharedChan) { + let TestDescAndFn {desc, testfn} = test; - if desc.ignore { + if force_ignore || desc.ignore { monitor_ch.send((desc, TrIgnored)); return; } - let testfn_cell = ::cell::Cell(testfn); - do task::spawn { - let mut result_future = None; // task::future_result(builder); - task::task().unlinked().future_result(|+r| { - result_future = Some(move r); - }).spawn(testfn_cell.take()); - let task_result = option::unwrap(move result_future).recv(); - let test_result = calc_result(&desc, task_result == task::Success); - monitor_ch.send((desc, test_result)); - }; + fn run_test_inner(desc: TestDesc, + monitor_ch: SharedChan, + testfn: ~fn()) { + let testfn_cell = ::cell::Cell(testfn); + do task::spawn { + let mut result_future = None; // task::future_result(builder); + task::task().unlinked().future_result(|+r| { + result_future = Some(move r); + }).spawn(testfn_cell.take()); + let task_result = option::unwrap(move result_future).recv(); + let test_result = calc_result(&desc, + task_result == task::Success); + monitor_ch.send((desc, test_result)); + } + } + + match testfn { + DynBenchFn(benchfn) => { + let bs = ::test::bench::benchmark(benchfn); + monitor_ch.send((desc, TrBench(bs))); + return; + } + StaticBenchFn(benchfn) => { + let bs = ::test::bench::benchmark(benchfn); + monitor_ch.send((desc, TrBench(bs))); + return; + } + DynTestFn(f) => run_test_inner(desc, monitor_ch, f), + StaticTestFn(f) => run_test_inner(desc, monitor_ch, || f()) + } } fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { @@ -439,10 +617,180 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { } } +pub mod bench { + + use rand; + use u64; + use vec; + use time::precise_time_ns; + use test::{BenchHarness, BenchSamples}; + use stats::Stats; + use num; + use rand; + + pub impl BenchHarness { + + /// Callback for benchmark functions to run in their body. + pub fn iter(&mut self, inner:&fn()) { + self.ns_start = precise_time_ns(); + let k = self.iterations; + for u64::range(0, k) |_| { + inner(); + } + self.ns_end = precise_time_ns(); + } + + fn ns_elapsed(&mut self) -> u64 { + if self.ns_start == 0 || self.ns_end == 0 { + 0 + } else { + self.ns_end - self.ns_start + } + } + + fn ns_per_iter(&mut self) -> u64 { + if self.iterations == 0 { + 0 + } else { + self.ns_elapsed() / self.iterations + } + } + + fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) { + self.iterations = n; + debug!("running benchmark for %u iterations", + n as uint); + f(self); + } + + // This is the Go benchmark algorithm. It produces a single + // datapoint and always tries to run for 1s. + pub fn go_bench(&mut self, f: &fn(&mut BenchHarness)) { + + // Rounds a number down to the nearest power of 10. + fn round_down_10(n: u64) -> u64 { + let mut n = n; + let mut res = 1; + while n > 10 { + n = n / 10; + res *= 10; + } + res + } + + // Rounds x up to a number of the form [1eX, 2eX, 5eX]. + fn round_up(n: u64) -> u64 { + let base = round_down_10(n); + if n < (2 * base) { + 2 * base + } else if n < (5 * base) { + 5 * base + } else { + 10 * base + } + } + + // Initial bench run to get ballpark figure. + let mut n = 1_u64; + self.bench_n(n, f); + + while n < 1_000_000_000 && + self.ns_elapsed() < 1_000_000_000 { + let last = n; + + // Try to estimate iter count for 1s falling back to 1bn + // iterations if first run took < 1ns. + if self.ns_per_iter() == 0 { + n = 1_000_000_000; + } else { + n = 1_000_000_000 / self.ns_per_iter(); + } + + n = u64::max(u64::min(n+n/2, 100*last), last+1); + n = round_up(n); + self.bench_n(n, f); + } + } + + // This is a more statistics-driven benchmark algorithm. + // It stops as quickly as 50ms, so long as the statistical + // properties are satisfactory. If those properties are + // not met, it may run as long as the Go algorithm. + pub fn auto_bench(&mut self, f: &fn(&mut BenchHarness)) -> ~[f64] { + + let rng = rand::Rng(); + let mut magnitude = 10; + let mut prev_madp = 0.0; + + loop { + + let n_samples = rng.gen_uint_range(50, 60); + let n_iter = rng.gen_uint_range(magnitude, + magnitude * 2); + + let samples = do vec::from_fn(n_samples) |_| { + self.bench_n(n_iter as u64, f); + self.ns_per_iter() as f64 + }; + + // Eliminate outliers + let med = samples.median(); + let mad = samples.median_abs_dev(); + let samples = do vec::filter(samples) |f| { + num::abs(*f - med) <= 3.0 * mad + }; + + debug!("%u samples, median %f, MAD=%f, %u survived filter", + n_samples, med as float, mad as float, + samples.len()); + + if samples.len() != 0 { + // If we have _any_ cluster of signal... + let curr_madp = samples.median_abs_dev_pct(); + if self.ns_elapsed() > 1_000_000 && + (curr_madp < 1.0 || + num::abs(curr_madp - prev_madp) < 0.1) { + return samples; + } + prev_madp = curr_madp; + + if n_iter > 20_000_000 || + self.ns_elapsed() > 20_000_000 { + return samples; + } + } + + magnitude *= 2; + } + } + } + + pub fn benchmark(f: &fn(&mut BenchHarness)) -> BenchSamples { + + let mut bs = BenchHarness { + iterations: 0, + ns_start: 0, + ns_end: 0, + bytes: 0 + }; + + let ns_iter_samples = bs.auto_bench(f); + + let iter_s = 1_000_000_000 / (ns_iter_samples.median() as u64); + let mb_s = (bs.bytes * iter_s) / 1_000_000; + + BenchSamples { + ns_iter_samples: ns_iter_samples, + mb_s: mb_s as uint + } + } +} + #[cfg(test)] mod tests { use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, - TestDesc, TestDescAndFn}; + TestDesc, TestDescAndFn, + StaticTestName, DynTestName, DynTestFn}; use test::{TestOpts, run_test}; use core::either; @@ -455,15 +803,15 @@ mod tests { fn f() { die!(); } let desc = TestDescAndFn { desc: TestDesc { - name: ~"whatever", + name: StaticTestName("whatever"), ignore: true, should_fail: false }, - testfn: f, + testfn: DynTestFn(fn~() { f()}), }; let (p, ch) = stream(); let ch = SharedChan(ch); - run_test(desc, ch); + run_test(false, desc, ch); let (_, res) = p.recv(); assert res != TrOk; } @@ -473,15 +821,15 @@ mod tests { fn f() { } let desc = TestDescAndFn { desc: TestDesc { - name: ~"whatever", + name: StaticTestName("whatever"), ignore: true, should_fail: false }, - testfn: f, + testfn: DynTestFn(fn~() { f()}), }; let (p, ch) = stream(); let ch = SharedChan(ch); - run_test(desc, ch); + run_test(false, desc, ch); let (_, res) = p.recv(); assert res == TrIgnored; } @@ -492,15 +840,15 @@ mod tests { fn f() { die!(); } let desc = TestDescAndFn { desc: TestDesc { - name: ~"whatever", + name: StaticTestName("whatever"), ignore: false, should_fail: true }, - testfn: f, + testfn: DynTestFn(fn~() { f() }), }; let (p, ch) = stream(); let ch = SharedChan(ch); - run_test(desc, ch); + run_test(false, desc, ch); let (_, res) = p.recv(); assert res == TrOk; } @@ -510,15 +858,15 @@ mod tests { fn f() { } let desc = TestDescAndFn { desc: TestDesc { - name: ~"whatever", + name: StaticTestName("whatever"), ignore: false, should_fail: true }, - testfn: f, + testfn: DynTestFn(fn~() { f() }), }; let (p, ch) = stream(); let ch = SharedChan(ch); - run_test(desc, ch); + run_test(false, desc, ch); let (_, res) = p.recv(); assert res == TrFailed; } @@ -554,30 +902,34 @@ mod tests { filter: option::None, run_ignored: true, logfile: option::None, + run_tests: true, + run_benchmarks: false, + save_results: option::None, + compare_results: option::None }; let tests = ~[ TestDescAndFn { desc: TestDesc { - name: ~"1", + name: StaticTestName("1"), ignore: true, should_fail: false, }, - testfn: dummy, + testfn: DynTestFn(fn~() { }), }, TestDescAndFn { desc: TestDesc { - name: ~"2", + name: StaticTestName("2"), ignore: false, should_fail: false }, - testfn: dummy, + testfn: DynTestFn(fn~() { }), }, ]; let filtered = filter_tests(&opts, tests); assert (vec::len(filtered) == 1); - assert (filtered[0].desc.name == ~"1"); + assert (filtered[0].desc.name.to_str() == ~"1"); assert (filtered[0].desc.ignore == false); } @@ -587,6 +939,10 @@ mod tests { filter: option::None, run_ignored: false, logfile: option::None, + run_tests: true, + run_benchmarks: false, + save_results: option::None, + compare_results: option::None }; let names = @@ -603,10 +959,11 @@ mod tests { for vec::each(names) |name| { let test = TestDescAndFn { desc: TestDesc { - name: *name, ignore: false, + name: DynTestName(*name), + ignore: false, should_fail: false }, - testfn: testfn, + testfn: DynTestFn(copy testfn), }; tests.push(move test); } @@ -627,7 +984,7 @@ mod tests { for vec::each(pairs) |p| { match *p { - (ref a, ref b) => { assert (*a == b.desc.name); } + (ref a, ref b) => { assert (*a == b.desc.name.to_str()); } } } } diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index 1f4df7be1f352..6028d8c71d31b 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -26,13 +26,13 @@ fn shouldnotignore() { #[test] fn checktests() { // Pull the tests out of the secreturn test module - let tests = __test::tests(); + let tests = __test::tests; assert vec::any( tests, - |t| t.desc.name == ~"shouldignore" && t.desc.ignore); + |t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore); assert vec::any( tests, - |t| t.desc.name == ~"shouldnotignore" && !t.desc.ignore); + |t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore); } \ No newline at end of file From d67e144f685783503c1406cb4f28ea19d91d1fec Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Wed, 13 Feb 2013 04:42:39 -0500 Subject: [PATCH 76/92] rt: get rid of rust_fn and replace with fn_env_pair plus a little cleanup. --- src/rt/rust_builtin.cpp | 34 ++++++++-------------------------- src/rt/rust_refcount.h | 8 -------- src/rt/rust_task.h | 2 -- src/rt/rustrt.def.in | 1 - 4 files changed, 8 insertions(+), 37 deletions(-) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 86f371a30f3ac..22ebc52edf090 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -249,24 +249,16 @@ debug_opaque(type_desc *t, uint8_t *front) { } } -// FIXME (#2667) this no longer reflects the actual structure of boxes! -struct rust_box { - RUST_REFCOUNTED(rust_box) - - // FIXME (#2667) `data` could be aligned differently from the actual - // box body data - uint8_t data[]; -}; - extern "C" CDECL void -debug_box(type_desc *t, rust_box *box) { +debug_box(type_desc *t, rust_opaque_box *box) { rust_task *task = rust_get_current_task(); LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box); debug_tydesc_helper(t); LOG(task, stdlib, " refcount %" PRIdPTR, box->ref_count - 1); // -1 because we ref'ed for this call + uint8_t *data = (uint8_t *)box_body(box); for (uintptr_t i = 0; i < t->size; ++i) { - LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]); + LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, data[i]); } } @@ -288,20 +280,15 @@ debug_tag(type_desc *t, rust_tag *tag) { tag->variant[i]); } -struct rust_fn { - uintptr_t *thunk; - rust_box *closure; -}; - extern "C" CDECL void -debug_fn(type_desc *t, rust_fn *fn) { +debug_fn(type_desc *t, fn_env_pair *fn) { rust_task *task = rust_get_current_task(); LOG(task, stdlib, "debug_fn"); debug_tydesc_helper(t); - LOG(task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk); - LOG(task, stdlib, " closure at 0x%" PRIxPTR, fn->closure); - if (fn->closure) { - LOG(task, stdlib, " refcount %" PRIdPTR, fn->closure->ref_count); + LOG(task, stdlib, " fn at 0x%" PRIxPTR, fn->f); + LOG(task, stdlib, " env at 0x%" PRIxPTR, fn->env); + if (fn->env) { + LOG(task, stdlib, " refcount %" PRIdPTR, fn->env->ref_count); } } @@ -389,11 +376,6 @@ extern "C" CDECL FILE* rust_get_stdin() {return stdin;} extern "C" CDECL FILE* rust_get_stdout() {return stdout;} extern "C" CDECL FILE* rust_get_stderr() {return stderr;} -extern "C" CDECL int -rust_ptr_eq(type_desc *t, rust_box *a, rust_box *b) { - return a == b; -} - #if defined(__WIN32__) extern "C" CDECL void get_time(int64_t *sec, int32_t *nsec) { diff --git a/src/rt/rust_refcount.h b/src/rt/rust_refcount.h index ef7ae1f35e332..1ed05ec833959 100644 --- a/src/rt/rust_refcount.h +++ b/src/rt/rust_refcount.h @@ -17,14 +17,6 @@ // Refcounting defines typedef unsigned long ref_cnt_t; -#define RUST_REFCOUNTED(T) \ - RUST_REFCOUNTED_WITH_DTOR(T, delete (T*)this) - -#define RUST_REFCOUNTED_WITH_DTOR(T, dtor) \ - intptr_t ref_count; \ - void ref() { ++ref_count; } \ - void deref() { if (--ref_count == 0) { dtor; } } - #define RUST_ATOMIC_REFCOUNT() \ private: \ intptr_t ref_count; \ diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index cbde863fa2319..23354918c5046 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -168,8 +168,6 @@ #define RED_ZONE_SIZE RZ_MAC_32 #endif -struct rust_box; - struct frame_glue_fns { uintptr_t mark_glue_off; uintptr_t drop_glue_off; diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index c554489c4b35b..a19f9053cbeaa 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -39,7 +39,6 @@ rust_list_files2 rust_log_console_on rust_log_console_off rust_process_wait -rust_ptr_eq rust_run_program rust_sched_current_nonlazy_threads rust_sched_threads From c22d0af14c621a847e71dac7fe0e7fe19bf851a1 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Wed, 13 Feb 2013 05:28:24 -0500 Subject: [PATCH 77/92] rt: take into account alignment for debug_opaque. Closes #2667 --- src/rt/rust_builtin.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 22ebc52edf090..a8e1e7a0be4ba 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -241,10 +241,13 @@ debug_opaque(type_desc *t, uint8_t *front) { rust_task *task = rust_get_current_task(); LOG(task, stdlib, "debug_opaque"); debug_tydesc_helper(t); - // FIXME (#2667) may want to actually account for alignment. - // `front` may not indeed be the front byte of the passed-in - // argument. for (uintptr_t i = 0; i < t->size; ++front, ++i) { + + // Account for alignment. `front` may not indeed be the + // front byte of the passed-in argument + if (((uintptr_t)front % t->align) != 0) + front = (uint8_t *)align_to((uintptr_t)front, (size_t)t->align); + LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, *front); } } From 2c198561dd878dcfa4fca3b7785215fd3490ca84 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Wed, 13 Feb 2013 15:41:04 -0500 Subject: [PATCH 78/92] rt: Fix alignment in debug_opaque --- src/rt/rust_builtin.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index a8e1e7a0be4ba..3f6545caaa8e4 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -241,13 +241,12 @@ debug_opaque(type_desc *t, uint8_t *front) { rust_task *task = rust_get_current_task(); LOG(task, stdlib, "debug_opaque"); debug_tydesc_helper(t); + // Account for alignment. `front` may not indeed be the + // front byte of the passed-in argument + if (((uintptr_t)front % t->align) != 0) { + front = (uint8_t *)align_to((uintptr_t)front, (size_t)t->align); + } for (uintptr_t i = 0; i < t->size; ++front, ++i) { - - // Account for alignment. `front` may not indeed be the - // front byte of the passed-in argument - if (((uintptr_t)front % t->align) != 0) - front = (uint8_t *)align_to((uintptr_t)front, (size_t)t->align); - LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, *front); } } From 6d09fc2cd80231aab527a27e8112e6167a15f042 Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 7 Feb 2013 17:58:50 -0800 Subject: [PATCH 79/92] removed reference to crate file keywords --- doc/rust.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index fc8ce9f9c38fc..3013fe0e0eb8e 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -202,13 +202,7 @@ grammar as double-quoted strings. Other tokens have exact rules given. ### Keywords -The keywords in [crate files](#crate-files) are the following strings: - -~~~~~~~~ {.keyword} -mod priv pub use -~~~~~~~~ - -The keywords in [source files](#source-files) are the following strings: +The keywords are the following strings: ~~~~~~~~ {.keyword} as assert From 25c4676dfa805e027564116b9c37fee7aeaf1cc4 Mon Sep 17 00:00:00 2001 From: John Clements Date: Mon, 4 Feb 2013 13:15:17 -0800 Subject: [PATCH 80/92] Commenting, test cases, cleanup --- src/libcore/dvec.rs | 2 +- src/libsyntax/ast.rs | 11 ++++++- src/libsyntax/ext/base.rs | 12 ++++---- src/libsyntax/ext/tt/transcribe.rs | 6 ++-- src/libsyntax/parse/common.rs | 26 +++++++++++++++-- src/libsyntax/parse/mod.rs | 47 +++++++++++++++++++++++++++++- src/libsyntax/parse/parser.rs | 43 +++++++++++++++++---------- src/libsyntax/parse/token.rs | 1 + 8 files changed, 119 insertions(+), 29 deletions(-) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index fe36ed159603c..c7a0300a97892 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -229,7 +229,7 @@ impl DVec { impl DVec { /** - * Append all elements of a vector to the end of the list + * Append all elements of a vector to the end of the list. * * Equivalent to `append_iter()` but potentially more efficient. */ diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b109333c3b590..b26cab7694c91 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -779,10 +779,19 @@ pub enum expr_ { #[auto_decode] #[doc="For macro invocations; parsing is delegated to the macro"] pub enum token_tree { + // a single token tt_tok(span, ::parse::token::Token), + // a delimited sequence (the delimiters appear as the first + // and last elements of the vector) tt_delim(~[token_tree]), - // These only make sense for right-hand-sides of MBE macros + // These only make sense for right-hand-sides of MBE macros: + + // a kleene-style repetition sequence with a span, a tt_forest, + // an optional separator (?), and a boolean where true indicates + // zero or more (*), and false indicates one or more (+). tt_seq(span, ~[token_tree], Option<::parse::token::Token>, bool), + + // a syntactic variable that will be filled in by macro expansion. tt_nonterminal(span, ident) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 8c3db21f4ea47..a85a7990ace98 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -44,8 +44,8 @@ pub struct SyntaxExpanderTT { span: Option } -pub type SyntaxExpanderTTFun = fn@(ext_ctxt, span, ~[ast::token_tree]) - -> MacResult; +pub type SyntaxExpanderTTFun + = fn@(ext_ctxt, span, ~[ast::token_tree]) -> MacResult; pub struct SyntaxExpanderTTItem { expander: SyntaxExpanderTTItemFun, @@ -59,7 +59,7 @@ pub enum MacResult { MRExpr(@ast::expr), MRItem(@ast::item), MRAny(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt), - MRDef(MacroDef) + MRDef(MacroDef), } pub enum SyntaxExtension { @@ -78,9 +78,11 @@ pub enum SyntaxExtension { // A temporary hard-coded map of methods for expanding syntax extension // AST nodes into full ASTs pub fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> { + // utility function to simplify creating NormalTT syntax extensions fn builtin_normal_tt(f: SyntaxExpanderTTFun) -> SyntaxExtension { NormalTT(SyntaxExpanderTT{expander: f, span: None}) } + // utility function to simplify creating ItemTT syntax extensions fn builtin_item_tt(f: SyntaxExpanderTTItemFun) -> SyntaxExtension { ItemTT(SyntaxExpanderTTItem{expander: f, span: None}) } @@ -112,8 +114,8 @@ pub fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> { ext::deriving::expand_deriving_iter_bytes)); // Quasi-quoting expanders - syntax_expanders.insert( - ~"quote_tokens", builtin_normal_tt(ext::quote::expand_quote_tokens)); + syntax_expanders.insert(~"quote_tokens", + builtin_normal_tt(ext::quote::expand_quote_tokens)); syntax_expanders.insert(~"quote_expr", builtin_normal_tt(ext::quote::expand_quote_expr)); syntax_expanders.insert(~"quote_ty", diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index aa9036d295e53..75120e9c0bc8c 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -121,15 +121,15 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader, vec::foldl(start, r.repeat_idx, red) } -fn lookup_cur_matched(r: @mut TtReader, name: ident) -> @named_match { +fn lookup_cur_matched(r: &TtReader, name: ident) -> @named_match { lookup_cur_matched_by_matched(r, r.interpolations.get(&name)) } enum lis { lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } -fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { - fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis { +fn lockstep_iter_size(t: token_tree, r: &TtReader) -> lis { + fn lis_merge(lhs: lis, rhs: lis, r: &TtReader) -> lis { match lhs { lis_unconstrained => rhs, lis_contradiction(_) => lhs, diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index e0d53fadfa0b8..7e74163b6bf36 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -20,6 +20,8 @@ use core::option::{None, Option, Some}; use core::option; use std::oldmap::HashMap; +// seq_sep : a sequence separator (token) +// and whether a trailing separator is allowed. pub type seq_sep = { sep: Option, trailing_sep_allowed: bool @@ -51,6 +53,8 @@ pub impl Parser { + token_to_str(self.reader, self.token) + ~"`"); } + // expect and consume the token t. Signal an error if + // the next token is not t. fn expect(t: token::Token) { if self.token == t { self.bump(); @@ -88,6 +92,8 @@ pub impl Parser { return self.parse_ident(); } + // consume token 'tok' if it exists. Returns true if the given + // token was present, false otherwise. fn eat(tok: token::Token) -> bool { return if self.token == tok { self.bump(); true } else { false }; } @@ -185,6 +191,8 @@ pub impl Parser { } } + // expect and consume a GT. if a >> is seen, replace it + // with a single > and continue. fn expect_gt() { if self.token == token::GT { self.bump(); @@ -202,16 +210,19 @@ pub impl Parser { } } + // parse a sequence bracketed by '<' and '>', stopping + // before the '>'. fn parse_seq_to_before_gt(sep: Option, f: fn(Parser) -> T) -> ~[T] { let mut first = true; let mut v = ~[]; while self.token != token::GT + // wait... isn't this going to eat a whole '>>' ? && self.token != token::BINOP(token::SHR) { match sep { Some(ref t) => { if first { first = false; } - else { self.expect((*t)); } + else { self.expect(*t); } } _ => () } @@ -229,6 +240,7 @@ pub impl Parser { return v; } + // parse a sequence bracketed by '<' and '>' fn parse_seq_lt_gt(sep: Option, f: fn(Parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; @@ -239,6 +251,9 @@ pub impl Parser { return spanned(lo, hi, result); } + // parse a sequence, including the closing delimiter. The function + // f must consume tokens until reaching the next separator or + // closing bracket. fn parse_seq_to_end(ket: token::Token, sep: seq_sep, f: fn(Parser) -> T) -> ~[T] { let val = self.parse_seq_to_before_end(ket, sep, f); @@ -246,7 +261,9 @@ pub impl Parser { return val; } - + // parse a sequence, not including the closing delimiter. The function + // f must consume tokens until reaching the next separator or + // closing bracket. fn parse_seq_to_before_end(ket: token::Token, sep: seq_sep, f: fn(Parser) -> T) -> ~[T] { let mut first: bool = true; @@ -255,7 +272,7 @@ pub impl Parser { match sep.sep { Some(ref t) => { if first { first = false; } - else { self.expect((*t)); } + else { self.expect(*t); } } _ => () } @@ -265,6 +282,9 @@ pub impl Parser { return v; } + // parse a sequence, including the closing delimiter. The function + // f must consume tokens until reaching the next separator or + // closing bracket. fn parse_unspanned_seq(bra: token::Token, ket: token::Token, sep: seq_sep, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index b8e671b32659e..b863e2bd0e494 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -183,7 +183,6 @@ pub fn new_parser_from_file(sess: parse_sess, let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap, sess.interner); - Ok(Parser(sess, cfg, srdr as reader)) } @@ -222,3 +221,49 @@ pub fn new_parser_from_tts(sess: parse_sess, cfg: ast::crate_cfg, return Parser(sess, cfg, trdr as reader) } + +#[cfg(test)] +mod test { + use super::*; + use std::serialize::Encodable; + use std; + use core::dvec; + use core::str; + use util::testing::*; + + #[test] fn to_json_str (val: Encodable) -> ~str { + let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; + val.encode(~std::json::Encoder(bw as io::Writer)); + str::from_bytes(bw.bytes.data) + } + + #[test] fn alltts () { + let tts = parse_tts_from_source_str( + ~"bogofile", + @~"fn foo (x : int) { x; }", + ~[], + new_parse_sess(None)); + check_equal(to_json_str(tts as Encodable::), + //[["tt_tok",["IDENT","fn"]]] + ~"abc" + ); + let ast1 = new_parser_from_tts(new_parse_sess(None),~[],tts) + .parse_item(~[]); + let ast2 = parse_item_from_source_str( + ~"bogofile", + @~"fn foo (x : int) { x; }", + ~[],~[], + new_parse_sess(None)); + check_equal(ast1,ast2); + } +} + +// +// Local Variables: +// mode: rust +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// End: +// diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6382413b08169..3c1f306ff079e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -182,7 +182,8 @@ pure fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>) /* ident is handled by common.rs */ -pub fn Parser(sess: parse_sess, +pub fn Parser(sess: parse_sess + , cfg: ast::crate_cfg, +rdr: reader) -> Parser { @@ -1238,6 +1239,8 @@ pub impl Parser { return e; } + // parse an optional separator followed by a kleene-style + // repetition token (+ or *). fn parse_sep_and_zerok() -> (Option, bool) { if self.token == token::BINOP(token::STAR) || self.token == token::BINOP(token::PLUS) { @@ -1258,20 +1261,18 @@ pub impl Parser { } } + // parse a single token tree from the input. fn parse_token_tree() -> token_tree { maybe_whole!(deref self, nt_tt); - fn parse_tt_tok(p: Parser, delim_ok: bool) -> token_tree { + fn parse_non_delim_tt_tok(p: Parser) -> token_tree { maybe_whole!(deref p, nt_tt); match p.token { token::RPAREN | token::RBRACE | token::RBRACKET - if !delim_ok => { + => { p.fatal(~"incorrect close delimiter: `" + token_to_str(p.reader, p.token) + ~"`"); } - token::EOF => { - p.fatal(~"file ended in the middle of a macro invocation"); - } /* we ought to allow different depths of unquotation */ token::DOLLAR if p.quote_depth > 0u => { p.bump(); @@ -1282,32 +1283,43 @@ pub impl Parser { seq_sep_none(), |p| p.parse_token_tree()); let (s, z) = p.parse_sep_and_zerok(); - return tt_seq(mk_sp(sp.lo ,p.span.hi), seq.node, s, z); + tt_seq(mk_sp(sp.lo ,p.span.hi), seq.node, s, z) } else { - return tt_nonterminal(sp, p.parse_ident()); + tt_nonterminal(sp, p.parse_ident()) } } - _ => { /* ok */ } + _ => { + parse_any_tt_tok(p) + } } + } + + // turn the next token into a tt_tok: + fn parse_any_tt_tok(p: Parser) -> token_tree{ let res = tt_tok(p.span, p.token); p.bump(); - return res; + res } - return match self.token { + match self.token { + token::EOF => { + self.fatal(~"file ended in the middle of a macro invocation"); + } token::LPAREN | token::LBRACE | token::LBRACKET => { // tjc: ?????? let ket = token::flip_delimiter(copy self.token); tt_delim(vec::append( - ~[parse_tt_tok(self, true)], + // the open delimiter: + ~[parse_any_tt_tok(self)], vec::append( self.parse_seq_to_before_end( ket, seq_sep_none(), |p| p.parse_token_tree()), - ~[parse_tt_tok(self, true)]))) + // the close delimiter: + ~[parse_any_tt_tok(self)]))) } - _ => parse_tt_tok(self, false) - }; + _ => parse_non_delim_tt_tok(self) + } } fn parse_all_token_trees() -> ~[token_tree] { @@ -3999,6 +4011,7 @@ pub impl Parser { } } + // // Local Variables: // mode: rust diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b8d756d893adf..1f8b04630e265 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -86,6 +86,7 @@ pub enum Token { LIT_STR(ast::ident), /* Name components */ + // an identifier contains an "is_mod_name" boolean. IDENT(ast::ident, bool), UNDERSCORE, LIFETIME(ast::ident), From 17d3a55362eb6a0b900d1d828e90d583897fa3b1 Mon Sep 17 00:00:00 2001 From: John Clements Date: Sat, 9 Feb 2013 13:25:47 -0800 Subject: [PATCH 81/92] @mut fix --- src/libsyntax/ext/tt/transcribe.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 75120e9c0bc8c..aa9036d295e53 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -121,15 +121,15 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader, vec::foldl(start, r.repeat_idx, red) } -fn lookup_cur_matched(r: &TtReader, name: ident) -> @named_match { +fn lookup_cur_matched(r: @mut TtReader, name: ident) -> @named_match { lookup_cur_matched_by_matched(r, r.interpolations.get(&name)) } enum lis { lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } -fn lockstep_iter_size(t: token_tree, r: &TtReader) -> lis { - fn lis_merge(lhs: lis, rhs: lis, r: &TtReader) -> lis { +fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { + fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis { match lhs { lis_unconstrained => rhs, lis_contradiction(_) => lhs, From 819c6d1c048c909fe6bbdde4937dc832cf485849 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 6 Feb 2013 18:35:01 -0800 Subject: [PATCH 82/92] deriving-eq all over ast --- src/libsyntax/ast.rs | 582 ++++++--------------------------------- src/libsyntax/codemap.rs | 1 + 2 files changed, 81 insertions(+), 502 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b26cab7694c91..02f7029fac2fe 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -69,6 +69,7 @@ pub type fn_ident = Option; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct path { span: span, global: bool, @@ -83,23 +84,18 @@ pub type node_id = int; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct def_id { crate: crate_num, node: node_id, } -pub impl def_id : cmp::Eq { - pure fn eq(&self, other: &def_id) -> bool { - (*self).crate == (*other).crate && (*self).node == (*other).node - } - pure fn ne(&self, other: &def_id) -> bool { !(*self).eq(other) } -} - pub const local_crate: crate_num = 0; pub const crate_node_id: node_id = 0; #[auto_encode] #[auto_decode] +#[deriving_eq] // The AST represents all type param bounds as types. // typeck::collect::compute_bounds matches these against // the "special" built-in traits (see middle::lang_items) and @@ -111,6 +107,7 @@ pub enum ty_param_bound { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct ty_param { ident: ident, id: node_id, @@ -119,6 +116,7 @@ pub struct ty_param { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum def { def_fn(def_id, purity), def_static_method(/* method */ def_id, @@ -147,136 +145,6 @@ pub enum def { def_label(node_id) } -pub impl def : cmp::Eq { - pure fn eq(&self, other: &def) -> bool { - match (*self) { - def_fn(e0a, e1a) => { - match (*other) { - def_fn(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_static_method(e0a, e1a, e2a) => { - match (*other) { - def_static_method(e0b, e1b, e2b) => - e0a == e0b && e1a == e1b && e2a == e2b, - _ => false - } - } - def_self(e0a, e1a) => { - match (*other) { - def_self(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_self_ty(e0a) => { - match (*other) { - def_self_ty(e0b) => e0a == e0b, - _ => false - } - } - def_mod(e0a) => { - match (*other) { - def_mod(e0b) => e0a == e0b, - _ => false - } - } - def_foreign_mod(e0a) => { - match (*other) { - def_foreign_mod(e0b) => e0a == e0b, - _ => false - } - } - def_const(e0a) => { - match (*other) { - def_const(e0b) => e0a == e0b, - _ => false - } - } - def_arg(e0a, e1a, e2a) => { - match (*other) { - def_arg(e0b, e1b, e2b) => - e0a == e0b && e1a == e1b && e2a == e2b, - _ => false - } - } - def_local(e0a, e1a) => { - match (*other) { - def_local(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_variant(e0a, e1a) => { - match (*other) { - def_variant(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_ty(e0a) => { - match (*other) { - def_ty(e0b) => e0a == e0b, - _ => false - } - } - def_prim_ty(e0a) => { - match (*other) { - def_prim_ty(e0b) => e0a == e0b, - _ => false - } - } - def_ty_param(e0a, e1a) => { - match (*other) { - def_ty_param(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_binding(e0a, e1a) => { - match (*other) { - def_binding(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - def_use(e0a) => { - match (*other) { - def_use(e0b) => e0a == e0b, - _ => false - } - } - def_upvar(e0a, e1a, e2a, e3a) => { - match (*other) { - def_upvar(e0b, e1b, e2b, e3b) => - e0a == e0b && e1a == e1b && e2a == e2b && e3a == e3b, - _ => false - } - } - def_struct(e0a) => { - match (*other) { - def_struct(e0b) => e0a == e0b, - _ => false - } - } - def_typaram_binder(e0a) => { - match (*other) { - def_typaram_binder(e1a) => e0a == e1a, - _ => false - } - } - def_region(e0a) => { - match (*other) { - def_region(e0b) => e0a == e0b, - _ => false - } - } - def_label(e0a) => { - match (*other) { - def_label(e0b) => e0a == e0b, - _ => false - } - } - } - } - pure fn ne(&self, other: &def) -> bool { !(*self).eq(other) } -} // The set of meta_items that define the compilation environment of the crate, // used to drive conditional compilation @@ -284,6 +152,7 @@ pub type crate_cfg = ~[@meta_item]; pub type crate = spanned; +#[deriving_eq] pub struct crate_ { module: _mod, attrs: ~[attribute], @@ -294,6 +163,7 @@ pub type meta_item = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum meta_item_ { meta_word(~str), meta_list(~str, ~[@meta_item]), @@ -304,6 +174,7 @@ pub type blk = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct blk_ { view_items: ~[@view_item], stmts: ~[@stmt], @@ -314,6 +185,7 @@ pub struct blk_ { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct pat { id: node_id, node: pat_, @@ -322,6 +194,7 @@ pub struct pat { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct field_pat { ident: ident, pat: @pat, @@ -352,6 +225,7 @@ pub impl binding_mode : to_bytes::IterBytes { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum pat_ { pat_wild, // A pat_ident may either be a new bound variable, @@ -377,6 +251,7 @@ pub enum pat_ { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum mutability { m_mutbl, m_imm, m_const, } pub impl mutability : to_bytes::IterBytes { @@ -385,13 +260,6 @@ pub impl mutability : to_bytes::IterBytes { } } -pub impl mutability : cmp::Eq { - pure fn eq(&self, other: &mutability) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &mutability) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] #[deriving_eq] @@ -440,6 +308,7 @@ pub impl Sigil : ToStr { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum vstore { // FIXME (#3469): Change uint to @expr (actually only constant exprs) vstore_fixed(Option), // [1,2,3,4] @@ -450,6 +319,7 @@ pub enum vstore { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum expr_vstore { // FIXME (#3469): Change uint to @expr (actually only constant exprs) expr_vstore_fixed(Option), // [1,2,3,4] @@ -462,6 +332,7 @@ pub enum expr_vstore { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum binop { add, subtract, @@ -483,15 +354,9 @@ pub enum binop { gt, } -pub impl binop : cmp::Eq { - pure fn eq(&self, other: &binop) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum unop { box(mutability), uniq(mutability), @@ -500,50 +365,11 @@ pub enum unop { neg } -pub impl unop : cmp::Eq { - pure fn eq(&self, other: &unop) -> bool { - match (*self) { - box(e0a) => { - match (*other) { - box(e0b) => e0a == e0b, - _ => false - } - } - uniq(e0a) => { - match (*other) { - uniq(e0b) => e0a == e0b, - _ => false - } - } - deref => { - match (*other) { - deref => true, - _ => false - } - } - not => { - match (*other) { - not => true, - _ => false - } - } - neg => { - match (*other) { - neg => true, - _ => false - } - } - } - } - pure fn ne(&self, other: &unop) -> bool { - !(*self).eq(other) - } -} - // Generally, after typeck you can get the inferred value // using ty::resolved_T(...). #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum inferable { expl(T), infer(node_id) @@ -561,29 +387,10 @@ pub impl inferable : to_bytes::IterBytes { } } -pub impl inferable : cmp::Eq { - pure fn eq(&self, other: &inferable) -> bool { - match (*self) { - expl(ref e0a) => { - match (*other) { - expl(ref e0b) => (*e0a) == (*e0b), - _ => false - } - } - infer(e0a) => { - match (*other) { - infer(e0b) => e0a == e0b, - _ => false - } - } - } - } - pure fn ne(&self, other: &inferable) -> bool { !(*self).eq(other) } -} - // "resolved" mode: the real modes. #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum rmode { by_ref, by_val, by_copy } pub impl rmode : to_bytes::IterBytes { @@ -592,14 +399,6 @@ pub impl rmode : to_bytes::IterBytes { } } - -pub impl rmode : cmp::Eq { - pure fn eq(&self, other: &rmode) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &rmode) -> bool { !(*self).eq(other) } -} - // inferable mode. pub type mode = inferable; @@ -607,6 +406,7 @@ pub type stmt = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum stmt_ { stmt_decl(@decl, node_id), @@ -624,6 +424,7 @@ pub enum stmt_ { // a refinement on pat. #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct local_ { is_mutbl: bool, ty: @Ty, @@ -638,10 +439,12 @@ pub type decl = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum decl_ { decl_local(~[@local]), decl_item(@item), } #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct arm { pats: ~[@pat], guard: Option<@expr>, @@ -650,6 +453,7 @@ pub struct arm { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct field_ { mutbl: mutability, ident: ident, @@ -660,22 +464,12 @@ pub type field = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum blk_check_mode { default_blk, unsafe_blk, } -pub impl blk_check_mode : cmp::Eq { - pure fn eq(&self, other: &blk_check_mode) -> bool { - match ((*self), (*other)) { - (default_blk, default_blk) => true, - (unsafe_blk, unsafe_blk) => true, - (default_blk, _) => false, - (unsafe_blk, _) => false, - } - } - pure fn ne(&self, other: &blk_check_mode) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct expr { id: node_id, // Extra node ID is only used for index, assign_op, unary, binary, method @@ -687,6 +481,7 @@ pub struct expr { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum log_level { error, debug, log_other } // 0 = error, 1 = debug, 2 = log_other @@ -701,6 +496,7 @@ pub enum CallSugar { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum expr_ { expr_vstore(@expr, expr_vstore), expr_vec(~[@expr], mutability), @@ -777,6 +573,7 @@ pub enum expr_ { // #[auto_encode] #[auto_decode] +#[deriving_eq] #[doc="For macro invocations; parsing is delegated to the macro"] pub enum token_tree { // a single token @@ -851,6 +648,7 @@ pub type matcher = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum matcher_ { // match one token match_tok(::parse::token::Token), @@ -865,6 +663,7 @@ pub type mac = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum mac_ { mac_invoc_tt(@path,~[token_tree]), // new macro-invocation } @@ -873,6 +672,7 @@ pub type lit = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum lit_ { lit_str(@~str), lit_int(i64, int_ty), @@ -884,40 +684,11 @@ pub enum lit_ { lit_bool(bool), } -pub impl lit_: cmp::Eq { - pure fn eq(&self, other: &lit_) -> bool { - match ((*self), *other) { - (lit_str(a), lit_str(b)) => a == b, - (lit_int(val_a, ty_a), lit_int(val_b, ty_b)) => { - val_a == val_b && ty_a == ty_b - } - (lit_uint(val_a, ty_a), lit_uint(val_b, ty_b)) => { - val_a == val_b && ty_a == ty_b - } - (lit_int_unsuffixed(a), lit_int_unsuffixed(b)) => a == b, - (lit_float(val_a, ty_a), lit_float(val_b, ty_b)) => { - val_a == val_b && ty_a == ty_b - } - (lit_float_unsuffixed(a), lit_float_unsuffixed(b)) => a == b, - (lit_nil, lit_nil) => true, - (lit_bool(a), lit_bool(b)) => a == b, - (lit_str(_), _) => false, - (lit_int(*), _) => false, - (lit_uint(*), _) => false, - (lit_int_unsuffixed(*), _) => false, - (lit_float(*), _) => false, - (lit_float_unsuffixed(*), _) => false, - (lit_nil, _) => false, - (lit_bool(_), _) => false - } - } - pure fn ne(&self, other: &lit_) -> bool { !(*self).eq(other) } -} - // NB: If you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct mt { ty: @Ty, mutbl: mutability, @@ -925,6 +696,7 @@ pub struct mt { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct ty_field_ { ident: ident, mt: mt, @@ -934,6 +706,7 @@ pub type ty_field = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct ty_method { ident: ident, attrs: ~[attribute], @@ -947,6 +720,7 @@ pub struct ty_method { #[auto_encode] #[auto_decode] +#[deriving_eq] // A trait method is either required (meaning it doesn't have an // implementation, just a signature) or provided (meaning it has a default // implementation). @@ -957,6 +731,7 @@ pub enum trait_method { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } pub impl int_ty : ToStr { @@ -971,28 +746,9 @@ pub impl int_ty : to_bytes::IterBytes { } } -pub impl int_ty : cmp::Eq { - pure fn eq(&self, other: &int_ty) -> bool { - match ((*self), (*other)) { - (ty_i, ty_i) => true, - (ty_char, ty_char) => true, - (ty_i8, ty_i8) => true, - (ty_i16, ty_i16) => true, - (ty_i32, ty_i32) => true, - (ty_i64, ty_i64) => true, - (ty_i, _) => false, - (ty_char, _) => false, - (ty_i8, _) => false, - (ty_i16, _) => false, - (ty_i32, _) => false, - (ty_i64, _) => false, - } - } - pure fn ne(&self, other: &int_ty) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } pub impl uint_ty : ToStr { @@ -1007,26 +763,9 @@ pub impl uint_ty : to_bytes::IterBytes { } } -pub impl uint_ty : cmp::Eq { - pure fn eq(&self, other: &uint_ty) -> bool { - match ((*self), (*other)) { - (ty_u, ty_u) => true, - (ty_u8, ty_u8) => true, - (ty_u16, ty_u16) => true, - (ty_u32, ty_u32) => true, - (ty_u64, ty_u64) => true, - (ty_u, _) => false, - (ty_u8, _) => false, - (ty_u16, _) => false, - (ty_u32, _) => false, - (ty_u64, _) => false - } - } - pure fn ne(&self, other: &uint_ty) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum float_ty { ty_f, ty_f32, ty_f64, } pub impl float_ty : ToStr { @@ -1041,16 +780,7 @@ pub impl float_ty : to_bytes::IterBytes { } } -pub impl float_ty : cmp::Eq { - pure fn eq(&self, other: &float_ty) -> bool { - match ((*self), (*other)) { - (ty_f, ty_f) | (ty_f32, ty_f32) | (ty_f64, ty_f64) => true, - (ty_f, _) | (ty_f32, _) | (ty_f64, _) => false - } - } - pure fn ne(&self, other: &float_ty) -> bool { !(*self).eq(other) } -} - +// NB Eq method appears below. #[auto_encode] #[auto_decode] pub struct Ty { @@ -1062,6 +792,7 @@ pub struct Ty { // Not represented directly in the AST, referred to by name through a ty_path. #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum prim_ty { ty_int(int_ty), ty_uint(uint_ty), @@ -1070,46 +801,9 @@ pub enum prim_ty { ty_bool, } -pub impl prim_ty : cmp::Eq { - pure fn eq(&self, other: &prim_ty) -> bool { - match (*self) { - ty_int(e0a) => { - match (*other) { - ty_int(e0b) => e0a == e0b, - _ => false - } - } - ty_uint(e0a) => { - match (*other) { - ty_uint(e0b) => e0a == e0b, - _ => false - } - } - ty_float(e0a) => { - match (*other) { - ty_float(e0b) => e0a == e0b, - _ => false - } - } - ty_str => { - match (*other) { - ty_str => true, - _ => false - } - } - ty_bool => { - match (*other) { - ty_bool => true, - _ => false - } - } - } - } - pure fn ne(&self, other: &prim_ty) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct region { id: node_id, node: region_, @@ -1117,6 +811,7 @@ pub struct region { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum region_ { re_anon, re_static, @@ -1149,6 +844,7 @@ pub impl Onceness : to_bytes::IterBytes { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct TyClosure { sigil: Sigil, region: Option<@region>, @@ -1167,6 +863,7 @@ pub struct TyBareFn { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum ty_ { ty_nil, ty_bot, /* bottom type */ @@ -1207,6 +904,7 @@ pub impl Ty : to_bytes::IterBytes { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct arg { mode: mode, is_mutbl: bool, @@ -1217,6 +915,7 @@ pub struct arg { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct fn_decl { inputs: ~[arg], output: @Ty, @@ -1225,6 +924,7 @@ pub struct fn_decl { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum purity { pure_fn, // declared with "pure fn" unsafe_fn, // declared with "unsafe fn" @@ -1249,15 +949,9 @@ pub impl purity : to_bytes::IterBytes { } } -pub impl purity : cmp::Eq { - pure fn eq(&self, other: &purity) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &purity) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum ret_style { noreturn, // functions with return type _|_ that always // raise an error or exit (i.e. never return to the caller) @@ -1270,20 +964,9 @@ pub impl ret_style : to_bytes::IterBytes { } } -pub impl ret_style : cmp::Eq { - pure fn eq(&self, other: &ret_style) -> bool { - match ((*self), (*other)) { - (noreturn, noreturn) => true, - (return_val, return_val) => true, - (noreturn, _) => false, - (return_val, _) => false, - } - } - pure fn ne(&self, other: &ret_style) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum self_ty_ { sty_static, // no self: static method sty_by_ref, // old by-reference self: `` @@ -1293,54 +976,11 @@ pub enum self_ty_ { sty_uniq(mutability) // by-unique-pointer self: `~self` } -pub impl self_ty_ : cmp::Eq { - pure fn eq(&self, other: &self_ty_) -> bool { - match (*self) { - sty_static => { - match (*other) { - sty_static => true, - _ => false - } - } - sty_by_ref => { - match (*other) { - sty_by_ref => true, - _ => false - } - } - sty_value => { - match (*other) { - sty_value => true, - _ => false - } - } - sty_region(e0a) => { - match (*other) { - sty_region(e0b) => e0a == e0b, - _ => false - } - } - sty_box(e0a) => { - match (*other) { - sty_box(e0b) => e0a == e0b, - _ => false - } - } - sty_uniq(e0a) => { - match (*other) { - sty_uniq(e0b) => e0a == e0b, - _ => false - } - } - } - } - pure fn ne(&self, other: &self_ty_) -> bool { !(*self).eq(other) } -} - pub type self_ty = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct method { ident: ident, attrs: ~[attribute], @@ -1357,6 +997,7 @@ pub struct method { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct _mod { view_items: ~[@view_item], items: ~[@item], @@ -1364,6 +1005,7 @@ pub struct _mod { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum foreign_abi { foreign_abi_rust_intrinsic, foreign_abi_cdecl, @@ -1373,31 +1015,12 @@ pub enum foreign_abi { // Foreign mods can be named or anonymous #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum foreign_mod_sort { named, anonymous } -pub impl foreign_mod_sort : cmp::Eq { - pure fn eq(&self, other: &foreign_mod_sort) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &foreign_mod_sort) -> bool { !(*self).eq(other) } -} - -pub impl foreign_abi : cmp::Eq { - pure fn eq(&self, other: &foreign_abi) -> bool { - match ((*self), (*other)) { - (foreign_abi_rust_intrinsic, foreign_abi_rust_intrinsic) => true, - (foreign_abi_cdecl, foreign_abi_cdecl) => true, - (foreign_abi_stdcall, foreign_abi_stdcall) => true, - (foreign_abi_rust_intrinsic, _) => false, - (foreign_abi_cdecl, _) => false, - (foreign_abi_stdcall, _) => false, - } - } - pure fn ne(&self, other: &foreign_abi) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct foreign_mod { sort: foreign_mod_sort, abi: ident, @@ -1407,6 +1030,7 @@ pub struct foreign_mod { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct variant_arg { ty: @Ty, id: node_id, @@ -1414,6 +1038,7 @@ pub struct variant_arg { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum variant_kind { tuple_variant_kind(~[variant_arg]), struct_variant_kind(@struct_def), @@ -1422,6 +1047,7 @@ pub enum variant_kind { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct enum_def_ { variants: ~[variant], common: Option<@struct_def>, @@ -1429,10 +1055,12 @@ pub struct enum_def_ { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum enum_def = enum_def_; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct variant_ { name: ident, attrs: ~[attribute], @@ -1446,6 +1074,7 @@ pub type variant = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct path_list_ident_ { name: ident, id: node_id, @@ -1455,19 +1084,14 @@ pub type path_list_ident = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum namespace { module_ns, type_value_ns } -pub impl namespace : cmp::Eq { - pure fn eq(&self, other: &namespace) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &namespace) -> bool { !(*self).eq(other) } -} - pub type view_path = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum view_path_ { // quux = foo::bar::baz @@ -1486,6 +1110,7 @@ pub enum view_path_ { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct view_item { node: view_item_, attrs: ~[attribute], @@ -1495,6 +1120,7 @@ pub struct view_item { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum view_item_ { view_item_use(ident, ~[@meta_item], node_id), view_item_import(~[@view_path]), @@ -1508,18 +1134,13 @@ pub type attribute = spanned; // distinguished for pretty-printing. #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum attr_style { attr_outer, attr_inner, } -pub impl attr_style : cmp::Eq { - pure fn eq(&self, other: &attr_style) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &attr_style) -> bool { !(*self).eq(other) } -} - // doc-comments are promoted to attributes that have is_sugared_doc = true #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct attribute_ { style: attr_style, value: meta_item, @@ -1535,6 +1156,7 @@ pub struct attribute_ { */ #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct trait_ref { path: @path, ref_id: node_id, @@ -1542,24 +1164,12 @@ pub struct trait_ref { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum visibility { public, private, inherited } -pub impl visibility : cmp::Eq { - pure fn eq(&self, other: &visibility) -> bool { - match ((*self), (*other)) { - (public, public) => true, - (private, private) => true, - (inherited, inherited) => true, - (public, _) => false, - (private, _) => false, - (inherited, _) => false, - } - } - pure fn ne(&self, other: &visibility) -> bool { !(*self).eq(other) } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct struct_field_ { kind: struct_field_kind, id: node_id, @@ -1570,40 +1180,15 @@ pub type struct_field = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum struct_field_kind { named_field(ident, struct_mutability, visibility), unnamed_field // element of a tuple-like struct } -pub impl struct_field_kind : cmp::Eq { - pure fn eq(&self, other: &struct_field_kind) -> bool { - match (*self) { - named_field(ident_a, struct_mutability_a, visibility_a) => { - match *other { - named_field(ident_b, struct_mutability_b, visibility_b) - => { - ident_a == ident_b && - struct_mutability_a == struct_mutability_b && - visibility_a == visibility_b - } - unnamed_field => false - } - } - unnamed_field => { - match *other { - named_field(*) => false, - unnamed_field => true - } - } - } - } - pure fn ne(&self, other: &struct_field_kind) -> bool { - !(*self).eq(other) - } -} - #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct struct_def { fields: ~[@struct_field], /* fields */ /* (not including ctor or dtor) */ @@ -1620,6 +1205,7 @@ pub struct struct_def { */ #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct item { ident: ident, attrs: ~[attribute], @@ -1631,6 +1217,7 @@ pub struct item { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum item_ { item_const(@Ty, @expr), item_fn(fn_decl, purity, ~[ty_param], blk), @@ -1641,14 +1228,15 @@ pub enum item_ { item_struct(@struct_def, ~[ty_param]), item_trait(~[ty_param], ~[@trait_ref], ~[trait_method]), item_impl(~[ty_param], - Option<@trait_ref>, /* (optional) trait this impl implements */ - @Ty, /* self */ + Option<@trait_ref>, // (optional) trait this impl implements + @Ty, // self ~[@method]), item_mac(mac), } #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum struct_mutability { struct_mutable, struct_immutable } pub impl struct_mutability : to_bytes::IterBytes { @@ -1657,24 +1245,11 @@ pub impl struct_mutability : to_bytes::IterBytes { } } -pub impl struct_mutability : cmp::Eq { - pure fn eq(&self, other: &struct_mutability) -> bool { - match ((*self), (*other)) { - (struct_mutable, struct_mutable) => true, - (struct_immutable, struct_immutable) => true, - (struct_mutable, _) => false, - (struct_immutable, _) => false, - } - } - pure fn ne(&self, other: &struct_mutability) -> bool { - !(*self).eq(other) - } -} - pub type struct_dtor = spanned; #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct struct_dtor_ { id: node_id, attrs: ~[attribute], @@ -1684,6 +1259,7 @@ pub struct struct_dtor_ { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct foreign_item { ident: ident, attrs: ~[attribute], @@ -1695,6 +1271,7 @@ pub struct foreign_item { #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum foreign_item_ { foreign_item_fn(fn_decl, purity, ~[ty_param]), foreign_item_const(@Ty) @@ -1705,6 +1282,7 @@ pub enum foreign_item_ { // that we trans. #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum inlined_item { ii_item(@item), ii_method(def_id /* impl id */, @method), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index a509325faceca..3fbf732c14376 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -130,6 +130,7 @@ pub struct span { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct spanned { node: T, span: span } pub impl span : cmp::Eq { From 0419e36b76a3d00dd313dcb3b079604d3440d2ff Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 7 Feb 2013 14:39:49 -0800 Subject: [PATCH 83/92] finish deriving_eq in ast --- src/libsyntax/ast.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 02f7029fac2fe..19de5cc62f3d8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -783,6 +783,7 @@ pub impl float_ty : to_bytes::IterBytes { // NB Eq method appears below. #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct Ty { id: node_id, node: ty_, @@ -855,6 +856,7 @@ pub struct TyClosure { #[auto_encode] #[auto_decode] +#[deriving_eq] pub struct TyBareFn { purity: purity, abi: Abi, @@ -885,17 +887,6 @@ pub enum ty_ { ty_infer, } -// Equality and byte-iter (hashing) can be quite approximate for AST types. -// since we only care about this for normalizing them to "real" types. -pub impl Ty : cmp::Eq { - pure fn eq(&self, other: &Ty) -> bool { - ptr::addr_of(&(*self)) == ptr::addr_of(&(*other)) - } - pure fn ne(&self, other: &Ty) -> bool { - ptr::addr_of(&(*self)) != ptr::addr_of(&(*other)) - } -} - pub impl Ty : to_bytes::IterBytes { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f); From 16da4e15af02f92d4c7e7cfe36344a276096585d Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 7 Feb 2013 11:48:12 -0800 Subject: [PATCH 84/92] use node_id for indexing in ast_to_ty_cache --- src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/astconv.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index d38eef0fcf9f6..d0e6025c3eff8 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -262,7 +262,7 @@ struct ctxt_ { needs_drop_cache: HashMap, needs_unwind_cleanup_cache: HashMap, mut tc_cache: LinearMap, - ast_ty_to_ty_cache: HashMap<@ast::Ty, ast_ty_to_ty_cache_entry>, + ast_ty_to_ty_cache: HashMap, enum_var_cache: HashMap, trait_method_cache: HashMap, ty_param_bounds: HashMap, diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 8cd5be85a1a4a..3ee604426c9f7 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -277,7 +277,7 @@ pub fn ast_ty_to_ty( let tcx = self.tcx(); - match tcx.ast_ty_to_ty_cache.find(&ast_ty) { + match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) { Some(ty::atttce_resolved(ty)) => return ty, Some(ty::atttce_unresolved) => { tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ @@ -287,7 +287,7 @@ pub fn ast_ty_to_ty( None => { /* go on */ } } - tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved); + tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved); let typ = match /*bad*/copy ast_ty.node { ast::ty_nil => ty::mk_nil(tcx), ast::ty_bot => ty::mk_bot(tcx), @@ -409,7 +409,7 @@ pub fn ast_ty_to_ty( } }; - tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_resolved(typ)); + tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_resolved(typ)); return typ; } From ded95d2c2891d7ffec1277cb4969ed956ff0bd25 Mon Sep 17 00:00:00 2001 From: John Clements Date: Fri, 8 Feb 2013 18:50:12 -0800 Subject: [PATCH 85/92] deriving_eq for tokens and binops Note that the replaced definition of equality on tokens contains a *huge* shortcut on INTERPOLATED tokens (those that contain ASTs), whereby any two INTERPOLATED tokens are considered equal. This seems like a really broken notion of equality, but it appears that the existing test cases and the compiler don't depend on it. Niko noticed this, BTW. Replace long definition of Eq on tokens and binops w --- src/libsyntax/parse/token.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 1f8b04630e265..391e8b04336b1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -25,6 +25,7 @@ use std::oldmap::HashMap; #[auto_encode] #[auto_decode] +#[deriving_eq] pub enum binop { PLUS, MINUS, @@ -518,12 +519,6 @@ pub fn reserved_keyword_table() -> HashMap<~str, ()> { words } -impl binop : cmp::Eq { - pure fn eq(&self, other: &binop) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) } -} impl Token : cmp::Eq { pure fn eq(&self, other: &Token) -> bool { From 9d962d84669a02805571683707cec712415af4c6 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 13 Feb 2013 12:49:45 -0800 Subject: [PATCH 86/92] add test case --- src/libsyntax/ast.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 19de5cc62f3d8..36c8c29ded816 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -152,6 +152,8 @@ pub type crate_cfg = ~[@meta_item]; pub type crate = spanned; +#[auto_encode] +#[auto_decode] #[deriving_eq] pub struct crate_ { module: _mod, @@ -1281,7 +1283,34 @@ pub enum inlined_item { ii_dtor(struct_dtor, ident, ~[ty_param], def_id /* parent id */) } - +#[cfg(test)] +mod test { + use std; + use codemap::*; + use super::*; + + //are asts encodable? + + // it looks like this *will* be a compiler bug, after + // I get deriving_eq for crates into incoming :) + /* + #[test] fn check_asts_encodable() { + let bogus_span = span {lo:BytePos(10), + hi:BytePos(20), + expn_info:None}; + let _e : crate = + spanned{ + node: crate_{ + module: _mod {view_items: ~[], items: ~[]}, + attrs: ~[], + config: ~[] + }, + span: bogus_span}; + // doesn't matter which encoder we use.... + let _f = (_e as std::serialize::Encodable::); + } + */ +} // // Local Variables: // mode: rust From 754718c91018ec1623425521f86f105360739444 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sun, 10 Feb 2013 23:15:45 -0800 Subject: [PATCH 87/92] libsyntax: Pretty print using the new impl syntax. r=brson --- src/libsyntax/print/pprust.rs | 6 ++++-- src/test/run-pass/class-attributes-1.rs | 2 +- src/test/run-pass/method-attributes.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index dec9f5abd6ab3..7a60696c0a2d0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -554,15 +554,17 @@ pub fn print_item(s: @ps, &&item: @ast::item) { print_type_params(s, tps); space(s.s); } - print_type(s, ty); match opt_trait { Some(t) => { - word_space(s, ~":"); print_path(s, t.path, false); + space(s.s); + word_space(s, ~"for"); } None => () }; + + print_type(s, ty); space(s.s); if methods.len() == 0 { diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs index 9382cc8ac3401..b7ecb622e7fe6 100644 --- a/src/test/run-pass/class-attributes-1.rs +++ b/src/test/run-pass/class-attributes-1.rs @@ -14,7 +14,7 @@ struct cat { name: ~str, } -impl cat: Drop { +impl Drop for cat { #[cat_dropper] fn finalize(&self) { error!("%s landed on hir feet" , self . name); } } diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index e3d4a2aff9f3f..20cd9643b083f 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -19,7 +19,7 @@ trait frobable { } #[int_frobable] -impl int: frobable { +impl frobable for int { #[frob_attr1] fn frob() { #[frob_attr2]; From f9d789fa083220cc9d84cbea94868606600c64a9 Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 13 Feb 2013 15:38:42 -0800 Subject: [PATCH 88/92] cleanup, fix test case --- src/libcore/dvec.rs | 2 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/parse/common.rs | 1 - src/libsyntax/parse/mod.rs | 13 +++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index c7a0300a97892..fe36ed159603c 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -229,7 +229,7 @@ impl DVec { impl DVec { /** - * Append all elements of a vector to the end of the list. + * Append all elements of a vector to the end of the list * * Equivalent to `append_iter()` but potentially more efficient. */ diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a85a7990ace98..c924acd577d32 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -59,7 +59,7 @@ pub enum MacResult { MRExpr(@ast::expr), MRItem(@ast::item), MRAny(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt), - MRDef(MacroDef), + MRDef(MacroDef) } pub enum SyntaxExtension { diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 7e74163b6bf36..e7b5005d8dbf4 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -217,7 +217,6 @@ pub impl Parser { let mut first = true; let mut v = ~[]; while self.token != token::GT - // wait... isn't this going to eat a whole '>>' ? && self.token != token::BINOP(token::SHR) { match sep { Some(ref t) => { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index b863e2bd0e494..12038898a9d1c 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -244,8 +244,17 @@ mod test { ~[], new_parse_sess(None)); check_equal(to_json_str(tts as Encodable::), - //[["tt_tok",["IDENT","fn"]]] - ~"abc" + ~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\ + [\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\ + [\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\ + [\"tt_tok\",[,[\"IDENT\",[\"x\",false]]]],\ + [\"tt_tok\",[,[\"COLON\",[]]]],\ + [\"tt_tok\",[,[\"IDENT\",[\"int\",false]]]],\ + [\"tt_tok\",[,[\"RPAREN\",[]]]]]]],\ + [\"tt_delim\",[[[\"tt_tok\",[,[\"LBRACE\",[]]]],\ + [\"tt_tok\",[,[\"IDENT\",[\"x\",false]]]],\ + [\"tt_tok\",[,[\"SEMI\",[]]]],\ + [\"tt_tok\",[,[\"RBRACE\",[]]]]]]]]" ); let ast1 = new_parser_from_tts(new_parse_sess(None),~[],tts) .parse_item(~[]); From 4445b38df27777b043cad9ecc2452daad3469949 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 11 Feb 2013 19:26:38 -0800 Subject: [PATCH 89/92] Remove die!, raplace invocations with fail! Issue #4524 pt 3 --- src/compiletest/compiletest.rc | 6 +- src/compiletest/header.rs | 2 +- src/compiletest/procsrv.rs | 4 +- src/compiletest/runtest.rs | 8 +- src/libcargo/cargo.rc | 30 +++--- src/libcargo/pgp.rs | 4 +- src/libcore/char.rs | 4 +- src/libcore/condition.rs | 2 +- src/libcore/dlist.rs | 28 +++--- src/libcore/dvec.rs | 8 +- src/libcore/either.rs | 6 +- src/libcore/extfmt.rs | 2 +- src/libcore/hash.rs | 2 +- src/libcore/hashmap.rs | 6 +- src/libcore/io.rs | 14 +-- src/libcore/iter-trait/dlist.rs | 4 +- src/libcore/iter.rs | 4 +- src/libcore/mutable.rs | 4 +- src/libcore/num/f32.rs | 2 +- src/libcore/num/f64.rs | 2 +- src/libcore/num/float.rs | 14 +-- src/libcore/num/int-template.rs | 10 +- src/libcore/num/num.rs | 14 +-- src/libcore/num/uint-template.rs | 10 +- src/libcore/option.rs | 10 +- src/libcore/os.rs | 2 +- src/libcore/pipes.rs | 26 ++--- src/libcore/private.rs | 7 +- src/libcore/private/finally.rs | 2 +- src/libcore/private/global.rs | 6 +- src/libcore/private/weak_task.rs | 4 +- src/libcore/repr.rs | 8 +- src/libcore/result.rs | 10 +- src/libcore/run.rs | 10 +- src/libcore/str.rs | 10 +- src/libcore/task/local_data.rs | 10 +- src/libcore/task/mod.rs | 44 ++++----- src/libcore/task/spawn.rs | 10 +- src/libcore/util.rs | 2 +- src/libcore/vec.rs | 82 ++++++++-------- src/libfuzzer/fuzzer.rc | 2 +- src/libfuzzer/rand_util.rs | 2 +- src/librustc/back/link.rs | 2 +- src/librustc/back/rpath.rs | 2 +- src/librustc/driver/driver.rs | 8 +- src/librustc/lib/llvm.rs | 2 +- src/librustc/metadata/decoder.rs | 22 ++--- src/librustc/metadata/encoder.rs | 8 +- src/librustc/metadata/filesearch.rs | 4 +- src/librustc/metadata/loader.rs | 4 +- src/librustc/metadata/tydecode.rs | 26 ++--- src/librustc/metadata/tyencode.rs | 2 +- src/librustc/middle/astencode.rs | 6 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 20 ++-- src/librustc/middle/const_eval.rs | 4 +- src/librustc/middle/freevars.rs | 4 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/lint.rs | 8 +- src/librustc/middle/resolve.rs | 34 +++---- src/librustc/middle/trans/_match.rs | 4 +- src/librustc/middle/trans/base.rs | 14 +-- src/librustc/middle/trans/build.rs | 2 +- src/librustc/middle/trans/cabi_x86_64.rs | 8 +- src/librustc/middle/trans/callee.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 6 +- src/librustc/middle/trans/foreign.rs | 4 +- src/librustc/middle/trans/meth.rs | 28 +++--- src/librustc/middle/trans/reachable.rs | 2 +- src/librustc/middle/trans/type_use.rs | 2 +- src/librustc/middle/ty.rs | 25 ++--- src/librustc/middle/typeck/check/method.rs | 2 +- src/librustc/middle/typeck/check/mod.rs | 4 +- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/librustc/middle/typeck/collect.rs | 4 +- src/librustc/middle/typeck/infer/test.rs | 14 +-- src/librustc/rustc.rc | 2 +- src/librustdoc/attr_pass.rs | 6 +- src/librustdoc/demo.rs | 4 +- src/librustdoc/extract.rs | 2 +- src/librustdoc/markdown_pass.rs | 2 +- src/librustdoc/markdown_writer.rs | 4 +- src/librustdoc/tystr_pass.rs | 22 ++--- src/librusti/rusti.rc | 6 +- src/libstd/arc.rs | 8 +- src/libstd/arena.rs | 2 +- src/libstd/base64.rs | 8 +- src/libstd/bigint.rs | 18 ++-- src/libstd/bitv.rs | 6 +- src/libstd/cell.rs | 4 +- src/libstd/deque.rs | 2 +- src/libstd/ebml.rs | 38 ++++---- src/libstd/flatpipes.rs | 6 +- src/libstd/future.rs | 6 +- src/libstd/getopts.rs | 96 +++++++++---------- src/libstd/json.rs | 40 ++++---- src/libstd/list.rs | 4 +- src/libstd/net_ip.rs | 14 +-- src/libstd/net_tcp.rs | 20 ++-- src/libstd/oldmap.rs | 2 +- src/libstd/oldsmallintmap.rs | 2 +- src/libstd/rope.rs | 12 +-- src/libstd/serialize.rs | 2 +- src/libstd/sha1.rs | 2 +- src/libstd/sort.rs | 14 +-- src/libstd/sync.rs | 16 ++-- src/libstd/test.rs | 14 +-- src/libstd/time.rs | 4 +- src/libstd/timer.rs | 6 +- src/libstd/uv_global_loop.rs | 4 +- src/libstd/workcache.rs | 2 +- src/libsyntax/ast.rs | 4 +- src/libsyntax/ast_map.rs | 4 +- src/libsyntax/ast_util.rs | 6 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/codemap.rs | 4 +- src/libsyntax/diagnostic.rs | 4 +- src/libsyntax/ext/auto_encode.rs | 10 +- src/libsyntax/ext/expand.rs | 6 +- src/libsyntax/ext/pipes/parse_proto.rs | 4 +- src/libsyntax/ext/quote.rs | 8 +- src/libsyntax/ext/tt/macro_parser.rs | 6 +- src/libsyntax/parse/comments.rs | 4 +- src/libsyntax/parse/lexer.rs | 2 +- src/libsyntax/parse/parser.rs | 4 +- src/libsyntax/parse/token.rs | 4 +- src/libsyntax/print/pp.rs | 2 +- src/libsyntax/print/pprust.rs | 16 ++-- src/libsyntax/util/testing.rs | 4 +- src/test/auxiliary/cci_nested_lib.rs | 2 +- src/test/auxiliary/issue2378a.rs | 2 +- src/test/auxiliary/issue_2723_a.rs | 2 +- src/test/auxiliary/static-methods-crate.rs | 2 +- src/test/bench/graph500-bfs.rs | 4 +- src/test/bench/pingpong.rs | 4 +- src/test/bench/shootout-chameneos-redux.rs | 2 +- src/test/bench/shootout-pfib.rs | 2 +- src/test/bench/sudoku.rs | 2 +- src/test/bench/task-perf-alloc-unwind.rs | 2 +- .../bench/task-perf-jargon-metal-smoke.rs | 2 +- src/test/bench/task-perf-linked-failure.rs | 2 +- src/test/compile-fail/alt-join.rs | 2 +- src/test/compile-fail/bad-bang-ann.rs | 2 +- ...her-can-live-while-the-other-survives-1.rs | 2 +- ...her-can-live-while-the-other-survives-2.rs | 2 +- ...her-can-live-while-the-other-survives-3.rs | 2 +- ...her-can-live-while-the-other-survives-4.rs | 2 +- .../compile-fail/bind-by-move-no-guards.rs | 4 +- .../compile-fail/bind-by-move-no-lvalues-1.rs | 2 +- .../compile-fail/bind-by-move-no-lvalues-2.rs | 2 +- .../bind-by-move-no-sub-bindings.rs | 2 +- .../compile-fail/borrowck-autoref-3261.rs | 2 +- ...borrowck-loan-local-as-both-mut-and-imm.rs | 2 +- .../compile-fail/borrowck-ref-into-rvalue.rs | 2 +- .../borrowck-vec-pattern-element-loan.rs | 2 +- .../borrowck-vec-pattern-nesting.rs | 2 +- .../borrowck-vec-pattern-tail-element-loan.rs | 2 +- src/test/compile-fail/closure-that-fails.rs | 2 +- src/test/compile-fail/deref-non-pointer.rs | 2 +- src/test/compile-fail/die-not-unique.rs | 2 +- src/test/compile-fail/fail-expr.rs | 2 +- src/test/compile-fail/fail-simple.rs | 2 +- src/test/compile-fail/fail-type-err.rs | 2 +- src/test/compile-fail/issue-2149.rs | 2 +- src/test/compile-fail/issue-2150.rs | 2 +- src/test/compile-fail/issue-2151.rs | 2 +- src/test/compile-fail/issue-2330.rs | 2 +- src/test/compile-fail/issue-2354.rs | 4 +- src/test/compile-fail/issue-2611-3.rs | 2 +- src/test/compile-fail/issue-2611-4.rs | 2 +- src/test/compile-fail/issue-2611-5.rs | 2 +- src/test/compile-fail/issue-2817.rs | 8 +- src/test/compile-fail/issue-3021.rs | 2 +- src/test/compile-fail/issue-3601.rs | 2 +- src/test/compile-fail/issue-3668.rs | 2 +- src/test/compile-fail/issue-897-2.rs | 2 +- src/test/compile-fail/issue-897.rs | 2 +- .../compile-fail/liveness-use-after-send.rs | 4 +- .../compile-fail/moves-based-on-type-exprs.rs | 2 +- .../non-exhaustive-match-nested.rs | 4 +- .../compile-fail/noncopyable-match-pattern.rs | 2 +- src/test/compile-fail/not-enough-arguments.rs | 2 +- src/test/compile-fail/pattern-tyvar-2.rs | 2 +- src/test/compile-fail/pattern-tyvar.rs | 2 +- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- src/test/compile-fail/regions-fn-bound.rs | 4 +- src/test/compile-fail/regions-fn-subtyping.rs | 4 +- .../tag-that-dare-not-speak-its-name.rs | 2 +- src/test/compile-fail/tag-type-args.rs | 2 +- .../compile-fail/warn-foreign-int-types.rs | 2 +- src/test/pretty/issue-929.rs | 2 +- src/test/run-fail/alt-bot-fail.rs | 2 +- src/test/run-fail/alt-disc-bot.rs | 2 +- src/test/run-fail/alt-wildcards.rs | 6 +- src/test/run-fail/args-fail.rs | 4 +- src/test/run-fail/binop-fail-2.rs | 2 +- src/test/run-fail/binop-fail.rs | 2 +- src/test/run-fail/bug-811.rs | 4 +- src/test/run-fail/die-macro-expr.rs | 2 +- src/test/run-fail/die-macro-pure.rs | 2 +- src/test/run-fail/die-macro.rs | 2 +- src/test/run-fail/doublefail.rs | 4 +- src/test/run-fail/explicit-fail-msg.rs | 2 +- src/test/run-fail/explicit-fail.rs | 2 +- src/test/run-fail/expr-alt-fail-fn.rs | 2 +- src/test/run-fail/expr-alt-fail.rs | 2 +- src/test/run-fail/expr-fn-fail.rs | 2 +- src/test/run-fail/expr-if-fail-fn.rs | 2 +- src/test/run-fail/expr-if-fail.rs | 2 +- src/test/run-fail/extern-fail.rs | 2 +- src/test/run-fail/fail-arg.rs | 2 +- src/test/run-fail/fail-main.rs | 2 +- src/test/run-fail/fail-parens.rs | 4 +- src/test/run-fail/fmt-fail.rs | 2 +- src/test/run-fail/for-each-loop-fail.rs | 2 +- src/test/run-fail/if-check-fail.rs | 2 +- src/test/run-fail/if-cond-bot.rs | 2 +- src/test/run-fail/issue-1459.rs | 2 +- src/test/run-fail/issue-2156.rs | 2 +- src/test/run-fail/issue-2272.rs | 2 +- src/test/run-fail/issue-2444.rs | 2 +- src/test/run-fail/issue-3029.rs | 2 +- src/test/run-fail/issue-948.rs | 2 +- src/test/run-fail/linked-failure2.rs | 2 +- src/test/run-fail/linked-failure3.rs | 2 +- src/test/run-fail/morestack1.rs | 2 +- src/test/run-fail/morestack2.rs | 2 +- src/test/run-fail/morestack3.rs | 2 +- src/test/run-fail/morestack4.rs | 2 +- src/test/run-fail/rhs-type.rs | 2 +- src/test/run-fail/rt-log-trunc.rs | 2 +- src/test/run-fail/rt-set-exit-status-fail.rs | 2 +- src/test/run-fail/rt-set-exit-status-fail2.rs | 2 +- src/test/run-fail/run-unexported-tests.rs | 2 +- src/test/run-fail/spawnfail.rs | 2 +- src/test/run-fail/task-comm-recv-block.rs | 4 +- src/test/run-fail/unique-fail.rs | 2 +- src/test/run-fail/unwind-alt.rs | 2 +- src/test/run-fail/unwind-box-fn-unique.rs | 2 +- src/test/run-fail/unwind-box-fn.rs | 2 +- src/test/run-fail/unwind-box-res.rs | 2 +- src/test/run-fail/unwind-box-str.rs | 2 +- src/test/run-fail/unwind-box-trait.rs | 2 +- src/test/run-fail/unwind-box-unique-unique.rs | 2 +- src/test/run-fail/unwind-box-unique.rs | 2 +- src/test/run-fail/unwind-box-vec.rs | 2 +- src/test/run-fail/unwind-box.rs | 2 +- src/test/run-fail/unwind-closure.rs | 2 +- src/test/run-fail/unwind-fail.rs | 2 +- .../run-fail/unwind-initializer-indirect.rs | 2 +- src/test/run-fail/unwind-initializer.rs | 2 +- src/test/run-fail/unwind-interleaved.rs | 2 +- src/test/run-fail/unwind-iter.rs | 2 +- src/test/run-fail/unwind-iter2.rs | 2 +- src/test/run-fail/unwind-lambda.rs | 2 +- src/test/run-fail/unwind-misc-1.rs | 2 +- src/test/run-fail/unwind-move.rs | 2 +- src/test/run-fail/unwind-nested.rs | 2 +- src/test/run-fail/unwind-partial-box.rs | 2 +- src/test/run-fail/unwind-partial-unique.rs | 2 +- src/test/run-fail/unwind-partial-vec.rs | 2 +- src/test/run-fail/unwind-rec.rs | 2 +- src/test/run-fail/unwind-rec2.rs | 2 +- src/test/run-fail/unwind-resource-fail.rs | 2 +- src/test/run-fail/unwind-resource-fail2.rs | 4 +- src/test/run-fail/unwind-resource-fail3.rs | 2 +- src/test/run-fail/unwind-stacked.rs | 2 +- src/test/run-fail/unwind-tup.rs | 2 +- src/test/run-fail/unwind-tup2.rs | 2 +- src/test/run-fail/unwind-uninitialized.rs | 2 +- src/test/run-fail/unwind-unique.rs | 2 +- src/test/run-fail/while-body-fails.rs | 2 +- src/test/run-fail/while-fail.rs | 2 +- src/test/run-fail/zip-different-lengths.rs | 2 +- src/test/run-pass/alt-bot-2.rs | 2 +- src/test/run-pass/alt-bot.rs | 2 +- src/test/run-pass/alt-pattern-drop.rs | 2 +- src/test/run-pass/alt-pattern-lit.rs | 2 +- src/test/run-pass/alt-range.rs | 16 ++-- .../run-pass/alt-ref-binding-in-guard-3256.rs | 2 +- src/test/run-pass/alt-str.rs | 12 +-- src/test/run-pass/attr-main-2.rs | 2 +- .../run-pass/binary-minus-without-space.rs | 2 +- src/test/run-pass/bind-by-move.rs | 2 +- src/test/run-pass/block-arg.rs | 4 +- .../run-pass/boxed-class-type-substitution.rs | 2 +- .../class-impl-very-parameterized-trait.rs | 2 +- src/test/run-pass/cleanup-copy-mode.rs | 2 +- src/test/run-pass/conditional-compile.rs | 4 +- src/test/run-pass/const-big-enum.rs | 6 +- src/test/run-pass/const-enum-byref-self.rs | 2 +- src/test/run-pass/const-enum-byref.rs | 2 +- src/test/run-pass/const-enum-ptr.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 4 +- src/test/run-pass/const-enum-vec-ptr.rs | 4 +- src/test/run-pass/const-enum-vector.rs | 4 +- src/test/run-pass/const-nullary-enum.rs | 4 +- src/test/run-pass/die-macro.rs | 6 +- src/test/run-pass/expr-alt-box.rs | 4 +- src/test/run-pass/expr-alt-fail-all.rs | 2 +- src/test/run-pass/expr-alt-fail.rs | 4 +- src/test/run-pass/expr-alt-generic-box1.rs | 2 +- src/test/run-pass/expr-alt-generic-box2.rs | 2 +- src/test/run-pass/expr-alt-generic-unique1.rs | 2 +- src/test/run-pass/expr-alt-generic-unique2.rs | 2 +- src/test/run-pass/expr-alt-generic.rs | 2 +- src/test/run-pass/expr-alt-struct.rs | 2 +- src/test/run-pass/expr-alt-unique.rs | 2 +- src/test/run-pass/expr-if-fail-all.rs | 2 +- src/test/run-pass/expr-if-fail.rs | 6 +- src/test/run-pass/for-loop-fail.rs | 2 +- src/test/run-pass/getopts_ref.rs | 2 +- src/test/run-pass/if-bot.rs | 2 +- src/test/run-pass/if-check.rs | 2 +- src/test/run-pass/issue-1516.rs | 2 +- src/test/run-pass/issue-2311-2.rs | 2 +- src/test/run-pass/issue-2312.rs | 2 +- src/test/run-pass/issue-2718.rs | 16 ++-- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-3168.rs | 2 +- src/test/run-pass/issue-3176.rs | 2 +- src/test/run-pass/issue-3895.rs | 2 +- src/test/run-pass/issue-4016.rs | 2 +- src/test/run-pass/iter-eachi.rs | 2 +- src/test/run-pass/last-use-in-block.rs | 2 +- src/test/run-pass/lots-a-fail.rs | 2 +- src/test/run-pass/macro-interpolation.rs | 2 +- src/test/run-pass/negative.rs | 2 +- src/test/run-pass/nested-alts.rs | 2 +- src/test/run-pass/nested-class.rs | 2 +- src/test/run-pass/nested-pattern.rs | 2 +- src/test/run-pass/nested-patterns.rs | 2 +- src/test/run-pass/option-unwrap.rs | 2 +- src/test/run-pass/parse-fail.rs | 2 +- src/test/run-pass/pipe-bank-proto.rs | 14 +-- src/test/run-pass/pipe-detect-term.rs | 4 +- .../run-pass/pipe-presentation-examples.rs | 4 +- src/test/run-pass/pipe-select.rs | 4 +- src/test/run-pass/region-dependent-addr-of.rs | 6 +- .../region-return-interior-of-option.rs | 2 +- src/test/run-pass/regions-bot.rs | 2 +- src/test/run-pass/ret-bang.rs | 2 +- src/test/run-pass/select-macro.rs | 4 +- src/test/run-pass/send-iloop.rs | 2 +- src/test/run-pass/size-and-align.rs | 2 +- src/test/run-pass/stat.rs | 2 +- src/test/run-pass/task-killjoin-rsrc.rs | 2 +- src/test/run-pass/task-killjoin.rs | 2 +- src/test/run-pass/terminate-in-initializer.rs | 4 +- src/test/run-pass/test-runner-hides-main.rs | 2 +- src/test/run-pass/unique-containing-tag.rs | 4 +- src/test/run-pass/unique-decl.rs | 2 +- src/test/run-pass/unique-pat.rs | 2 +- src/test/run-pass/unreachable-code-1.rs | 2 +- src/test/run-pass/unreachable-code.rs | 4 +- src/test/run-pass/unwind-box.rs | 2 +- src/test/run-pass/unwind-resource.rs | 2 +- src/test/run-pass/unwind-resource2.rs | 2 +- src/test/run-pass/unwind-unique.rs | 2 +- src/test/run-pass/use-uninit-alt2.rs | 2 +- src/test/run-pass/weird-exprs.rs | 2 +- 363 files changed, 910 insertions(+), 906 deletions(-) diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index ccd1b899ce34f..5557b1131766b 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -70,7 +70,7 @@ pub fn parse_config(args: ~[~str]) -> config { let matches = &match getopts::getopts(args_, opts) { Ok(m) => m, - Err(f) => die!(getopts::fail_str(f)) + Err(f) => fail!(getopts::fail_str(f)) }; fn opt_path(m: &getopts::Matches, nm: ~str) -> Path { @@ -133,7 +133,7 @@ pub fn str_mode(s: ~str) -> mode { ~"run-pass" => mode_run_pass, ~"pretty" => mode_pretty, ~"debug-info" => mode_debug_info, - _ => die!(~"invalid mode") + _ => fail!(~"invalid mode") } } @@ -151,7 +151,7 @@ pub fn run_tests(config: config) { let opts = test_opts(config); let tests = make_tests(config); let res = test::run_tests_console(&opts, tests); - if !res { die!(~"Some tests failed"); } + if !res { fail!(~"Some tests failed"); } } pub fn test_opts(config: config) -> test::TestOpts { diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 5c33c66209a37..6db55853f9ced 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -145,7 +145,7 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { match strs.len() { 1u => (strs[0], ~""), 2u => (strs[0], strs[1]), - n => die!(fmt!("Expected 1 or 2 strings, not %u", n)) + n => fail!(fmt!("Expected 1 or 2 strings, not %u", n)) } } } diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index a8e4d91d89a88..304266f0f7966 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -71,7 +71,7 @@ pub fn run(lib_path: ~str, os::close(pipe_in.out); os::close(pipe_out.in); os::close(pipe_err.in); - die!(); + fail!(); } @@ -99,7 +99,7 @@ pub fn run(lib_path: ~str, (2, s) => { errs = s; } - _ => { die!() } + _ => { fail!() } }; count -= 1; }; diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 83ab56309c13f..fe03ccbb3f8e8 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -202,7 +202,7 @@ actual:\n\ \n", expected, actual); io::stdout().write_str(msg); - die!(); + fail!(); } } @@ -518,7 +518,7 @@ fn compose_and_run_compiler( fn ensure_dir(path: &Path) { if os::path_is_dir(path) { return; } if !os::make_dir(path, 0x1c0i32) { - die!(fmt!("can't make dir %s", path.to_str())); + fail!(fmt!("can't make dir %s", path.to_str())); } } @@ -668,7 +668,7 @@ fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) { fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); } -fn fatal(err: ~str) -> ! { error(err); die!(); } +fn fatal(err: ~str) -> ! { error(err); fail!(); } fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! { let msg = @@ -686,5 +686,5 @@ stderr:\n\ \n", err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr); io::stdout().write_str(msg); - die!(); + fail!(); } diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index db976b580c7f1..782878e05c70f 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -295,7 +295,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, _ => { } } } - _ => die!(~"load_link: meta items must be name-values") + _ => fail!(~"load_link: meta items must be name-values") } } (name, vers, uuid) @@ -332,7 +332,7 @@ pub fn load_crate(filename: &Path) -> Option { } } _ => { - die!(~"crate attributes may not contain " + + fail!(~"crate attributes may not contain " + ~"meta_words"); } } @@ -435,7 +435,7 @@ pub fn rest(s: ~str, start: uint) -> ~str { pub fn need_dir(s: &Path) { if os::path_is_dir(s) { return; } if !os::make_dir(s, 493_i32 /* oct: 755 */) { - die!(fmt!("can't make_dir %s", s.to_str())); + fail!(fmt!("can't make_dir %s", s.to_str())); } } @@ -453,14 +453,14 @@ pub fn valid_pkg_name(s: &str) -> bool { pub fn parse_source(name: ~str, j: &json::Json) -> @Source { if !valid_pkg_name(name) { - die!(fmt!("'%s' is an invalid source name", name)); + fail!(fmt!("'%s' is an invalid source name", name)); } match *j { json::Object(ref j) => { let mut url = match j.find(&~"url") { Some(&json::String(u)) => copy u, - _ => die!(~"needed 'url' field in source") + _ => fail!(~"needed 'url' field in source") }; let method = match j.find(&~"method") { Some(&json::String(u)) => copy u, @@ -485,7 +485,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source { mut keyfp: keyfp, packages: DVec() }; } - _ => die!(~"needed dict value in source") + _ => fail!(~"needed dict value in source") }; } @@ -500,8 +500,8 @@ pub fn try_parse_sources(filename: &Path, debug!("source: %s", *k); } } - Ok(_) => die!(~"malformed sources.json"), - Err(e) => die!(fmt!("%s:%s", filename.to_str(), e.to_str())) + Ok(_) => fail!(~"malformed sources.json"), + Err(e) => fail!(fmt!("%s:%s", filename.to_str(), e.to_str())) } } @@ -662,7 +662,7 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options { let matches = &match getopts::getopts(argv, opts()) { result::Ok(m) => m, result::Err(f) => { - die!(fmt!("%s", getopts::fail_str(f))); + fail!(fmt!("%s", getopts::fail_str(f))); } }; @@ -675,10 +675,10 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options { let is_install = len > 1u && matches.free[1] == ~"install"; let is_uninstall = len > 1u && matches.free[1] == ~"uninstall"; - if G && g { die!(~"-G and -g both provided"); } + if G && g { fail!(~"-G and -g both provided"); } if !is_install && !is_uninstall && (g || G) { - die!(~"-g and -G are only valid for `install` and `uninstall|rm`"); + fail!(~"-g and -G are only valid for `install` and `uninstall|rm`"); } let mode = @@ -845,7 +845,7 @@ pub fn install_source(c: &mut Cargo, path: &Path) { } if vec::is_empty(cratefiles) { - die!(~"this doesn't look like a rust package (no .rc files)"); + fail!(~"this doesn't look like a rust package (no .rc files)"); } for cratefiles.each |cf| { @@ -889,7 +889,7 @@ pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) { let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", tarpath.to_str(), url]); if p.status != 0 { - die!(fmt!("fetch of %s failed: %s", url, p.err)); + fail!(fmt!("fetch of %s failed: %s", url, p.err)); } run::run_program(~"tar", ~[~"-x", ~"--strip-components=1", ~"-C", wd.to_str(), @@ -1123,7 +1123,7 @@ pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) { pub fn get_temp_workdir(c: &Cargo) -> Path { match tempfile::mkdtemp(&c.workdir, "cargo") { Some(wd) => wd, - None => die!(fmt!("needed temp dir: %s", + None => fail!(fmt!("needed temp dir: %s", c.workdir.to_str())) } } @@ -1138,7 +1138,7 @@ pub fn cmd_install(c: &mut Cargo) { wd.to_str()]); if status != 0 { - die!(fmt!("could not copy directory: %s", cwd.to_str())); + fail!(fmt!("could not copy directory: %s", cwd.to_str())); } install_source(c, &wd); diff --git a/src/libcargo/pgp.rs b/src/libcargo/pgp.rs index fe7808bad5d76..364effcd32f48 100644 --- a/src/libcargo/pgp.rs +++ b/src/libcargo/pgp.rs @@ -87,7 +87,7 @@ pub fn init(root: &Path) { p.input().write_str(signing_key()); let s = p.finish(); if s != 0 { - die!(~"pgp init failed"); + fail!(~"pgp init failed"); } } } @@ -98,7 +98,7 @@ pub fn add(root: &Path, key: &Path) { run::program_output(~"gpg", ~[~"--homedir", path.to_str(), ~"--import", key.to_str()]); if p.status != 0 { - die!(~"pgp add failed: " + p.out); + fail!(~"pgp add failed: " + p.out); } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index f7a369489d1ab..13e4595a77a80 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -150,7 +150,7 @@ pub pure fn is_digit_radix(c: char, radix: uint) -> bool { #[inline] pub pure fn to_digit(c: char, radix: uint) -> Option { if radix > 36 { - die!(fmt!("to_digit: radix %? is to high (maximum 36)", radix)); + fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix)); } let val = match c { '0' .. '9' => c as uint - ('0' as uint), @@ -173,7 +173,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option { #[inline] pub pure fn from_digit(num: uint, radix: uint) -> Option { if radix > 36 { - die!(fmt!("from_digit: radix %? is to high (maximum 36)", num)); + fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num)); } if num < radix { if num < 10 { diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index 8ad4ad7cd8cb8..fb44ff4514d8c 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -37,7 +37,7 @@ impl Condition { fn raise(t: T) -> U { let msg = fmt!("Unhandled condition: %s: %?", self.name, t); - self.raise_default(t, || die!(copy msg)) + self.raise_default(t, || fail!(copy msg)) } fn raise_default(t: T, default: &fn() -> U) -> U { diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 5f295bdcb83a9..0af0ecb16aa10 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -44,18 +44,18 @@ priv impl DListNode { match self.next { Some(neighbour) => match neighbour.prev { Some(me) => if !managed::mut_ptr_eq(self, me) { - die!(~"Asymmetric next-link in dlist node.") + fail!(~"Asymmetric next-link in dlist node.") }, - None => die!(~"One-way next-link in dlist node.") + None => fail!(~"One-way next-link in dlist node.") }, None => () } match self.prev { Some(neighbour) => match neighbour.next { Some(me) => if !managed::mut_ptr_eq(me, self) { - die!(~"Asymmetric prev-link in dlist node.") + fail!(~"Asymmetric prev-link in dlist node.") }, - None => die!(~"One-way prev-link in dlist node.") + None => fail!(~"One-way prev-link in dlist node.") }, None => () } @@ -72,7 +72,7 @@ impl DListNode { pure fn next_node(@mut self) -> @mut DListNode { match self.next_link() { Some(nobe) => nobe, - None => die!(~"This dlist node has no next neighbour.") + None => fail!(~"This dlist node has no next neighbour.") } } /// Get the previous node in the list, if there is one. @@ -84,7 +84,7 @@ impl DListNode { pure fn prev_node(@mut self) -> @mut DListNode { match self.prev_link() { Some(nobe) => nobe, - None => die!(~"This dlist node has no previous neighbour.") + None => fail!(~"This dlist node has no previous neighbour.") } } } @@ -136,21 +136,21 @@ priv impl DList { // These asserts could be stronger if we had node-root back-pointers, // but those wouldn't allow for O(1) append. if self.size == 0 { - die!(~"This dlist is empty; that node can't be on it.") + fail!(~"This dlist is empty; that node can't be on it.") } - if !nobe.linked { die!(~"That node isn't linked to any dlist.") } + if !nobe.linked { fail!(~"That node isn't linked to any dlist.") } if !((nobe.prev.is_some() || managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"), nobe)) && (nobe.next.is_some() || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), nobe))) { - die!(~"That node isn't on this dlist.") + fail!(~"That node isn't on this dlist.") } } fn make_mine(nobe: @mut DListNode) { if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked { - die!(~"Cannot insert node that's already on a dlist!") + fail!(~"Cannot insert node that's already on a dlist!") } nobe.linked = true; } @@ -322,7 +322,7 @@ impl DList { pure fn head_n(@mut self) -> @mut DListNode { match self.hd { Some(nobe) => nobe, - None => die!( + None => fail!( ~"Attempted to get the head of an empty dlist.") } } @@ -330,7 +330,7 @@ impl DList { pure fn tail_n(@mut self) -> @mut DListNode { match self.tl { Some(nobe) => nobe, - None => die!( + None => fail!( ~"Attempted to get the tail of an empty dlist.") } } @@ -344,7 +344,7 @@ impl DList { */ fn append(@mut self, them: @mut DList) { if managed::mut_ptr_eq(self, them) { - die!(~"Cannot append a dlist to itself!") + fail!(~"Cannot append a dlist to itself!") } if them.len() > 0 { self.link(self.tl, them.hd); @@ -361,7 +361,7 @@ impl DList { */ fn prepend(@mut self, them: @mut DList) { if managed::mut_ptr_eq(self, them) { - die!(~"Cannot prepend a dlist to itself!") + fail!(~"Cannot prepend a dlist to itself!") } if them.len() > 0 { self.link(them.tl, self.hd); diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index fe36ed159603c..b0c33dc6f2601 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -87,7 +87,7 @@ priv impl DVec { unsafe { let data: *() = cast::reinterpret_cast(&self.data); if data.is_null() { - die!(~"Recursive use of dvec"); + fail!(~"Recursive use of dvec"); } } } @@ -98,7 +98,7 @@ priv impl DVec { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { die!(~"Recursive use of dvec"); } + if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } return f(move data); } } @@ -175,7 +175,7 @@ impl DVec { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { die!(~"Recursive use of dvec"); } + if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } self.data = move ~[move t]; self.data.push_all_move(move data); } @@ -325,7 +325,7 @@ impl DVec { let length = self.len(); if length == 0 { - die!(~"attempt to retrieve the last element of an empty vector"); + fail!(~"attempt to retrieve the last element of an empty vector"); } return self.data[length - 1]; diff --git a/src/libcore/either.rs b/src/libcore/either.rs index b8f60c1a2d906..54c9f7b98793b 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -132,7 +132,8 @@ pub pure fn unwrap_left(eith: Either) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match move eith { - Left(move x) => move x, Right(_) => die!(~"either::unwrap_left Right") + Left(move x) => move x, + Right(_) => fail!(~"either::unwrap_left Right") } } @@ -141,7 +142,8 @@ pub pure fn unwrap_right(eith: Either) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match move eith { - Right(move x) => move x, Left(_) => die!(~"either::unwrap_right Left") + Right(move x) => move x, + Left(_) => fail!(~"either::unwrap_right Left") } } diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index aa4a7546f0239..3dbc3bef01733 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -335,7 +335,7 @@ pub mod ct { } #[cfg(test)] - fn die(s: &str) -> ! { die!(s.to_owned()) } + fn die(s: &str) -> ! { fail!(s.to_owned()) } #[test] fn test_parse_count() { diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index e53b7d29ebe7f..4e391d6ee0052 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -282,7 +282,7 @@ impl SipState : io::Writer { } fn seek(&self, _x: int, _s: io::SeekStyle) { - die!(); + fail!(); } fn tell(&self) -> uint { self.length diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index f8793f7e2aeae..fc117f99e9087 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -168,7 +168,7 @@ pub mod linear { /// True if there was no previous entry with that key fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { match self.bucket_for_key_with_hash(hash, &k) { - TableFull => { die!(~"Internal logic error"); } + TableFull => { fail!(~"Internal logic error"); } FoundHole(idx) => { debug!("insert fresh (%?->%?) at idx %?, hash %?", k, v, idx, hash); @@ -438,7 +438,7 @@ pub mod linear { pure fn get(&self, k: &K) -> &self/V { match self.find(k) { Some(v) => v, - None => die!(fmt!("No entry found for key: %?", k)), + None => fail!(fmt!("No entry found for key: %?", k)), } } } @@ -689,7 +689,7 @@ mod test_map { assert m.find(&1).is_none(); m.insert(1, 2); match m.find(&1) { - None => die!(), + None => fail!(), Some(v) => assert *v == 2 } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index c1e47439e9280..571d9344243a4 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -608,7 +608,7 @@ impl *libc::FILE: Writer { if nout != len as size_t { error!("error writing buffer"); log(error, os::last_os_error()); - die!(); + fail!(); } } } @@ -658,7 +658,7 @@ impl fd_t: Writer { if nout < 0 as ssize_t { error!("error writing buffer"); log(error, os::last_os_error()); - die!(); + fail!(); } count += nout as uint; } @@ -667,11 +667,11 @@ impl fd_t: Writer { } fn seek(&self, _offset: int, _whence: SeekStyle) { error!("need 64-bit foreign calls for seek, sorry"); - die!(); + fail!(); } fn tell(&self) -> uint { error!("need 64-bit foreign calls for tell, sorry"); - die!(); + fail!(); } fn flush(&self) -> int { 0 } fn get_type(&self) -> WriterType { @@ -1276,7 +1276,7 @@ mod tests { result::Err(copy e) => { assert e == ~"error opening not a file"; } - result::Ok(_) => die!() + result::Ok(_) => fail!() } } @@ -1317,7 +1317,7 @@ mod tests { result::Err(copy e) => { assert str::starts_with(e, "error opening"); } - result::Ok(_) => die!() + result::Ok(_) => fail!() } } @@ -1327,7 +1327,7 @@ mod tests { result::Err(copy e) => { assert str::starts_with(e, "error opening"); } - result::Ok(_) => die!() + result::Ok(_) => fail!() } } diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 2c2d0938eda2c..5f95c00f336b3 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -39,7 +39,7 @@ mod inst { // Check (weakly) that the user didn't do a remove. if self.size == 0 { - die!(~"The dlist became empty during iteration??") + fail!(~"The dlist became empty during iteration??") } if !nobe.linked || (!((nobe.prev.is_some() @@ -48,7 +48,7 @@ mod inst { && (nobe.next.is_some() || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), nobe)))) { - die!(~"Removing a dlist node during iteration is forbidden!") + fail!(~"Removing a dlist node during iteration is forbidden!") } link = nobe.next_link(); } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f66f6b90e9e3b..a36fa56fc79ba 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -221,7 +221,7 @@ pub pure fn min>(self: &IA) -> A { } } { Some(move val) => val, - None => die!(~"min called on empty iterator") + None => fail!(~"min called on empty iterator") } } @@ -236,7 +236,7 @@ pub pure fn max>(self: &IA) -> A { } } { Some(move val) => val, - None => die!(~"max called on empty iterator") + None => fail!(~"max called on empty iterator") } } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index 3c44c197f5ef6..49e0d0bdd8a65 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -46,7 +46,7 @@ pub fn unwrap(m: Mut) -> T { impl Data { fn borrow_mut(op: &fn(t: &mut T) -> R) -> R { match self.mode { - Immutable => die!(fmt!("%? currently immutable", + Immutable => fail!(fmt!("%? currently immutable", self.value)), ReadOnly | Mutable => {} } @@ -62,7 +62,7 @@ impl Data { fn borrow_imm(op: &fn(t: &T) -> R) -> R { match self.mode { - Mutable => die!(fmt!("%? currently mutable", + Mutable => fail!(fmt!("%? currently mutable", self.value)), ReadOnly | Immutable => {} } diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 6bea9e81197d3..eaed597dff780 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -402,7 +402,7 @@ pub pure fn to_str_hex(num: f32) -> ~str { pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = num::to_str_common( &num, rdx, true, true, num::SignNeg, num::DigAll); - if special { die!(~"number has a special value, \ + if special { fail!(~"number has a special value, \ try to_str_radix_special() if those are expected") } r } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 75f68fdafc72c..8aaa48524e2fe 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -427,7 +427,7 @@ pub pure fn to_str_hex(num: f64) -> ~str { pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = num::to_str_common( &num, rdx, true, true, num::SignNeg, num::DigAll); - if special { die!(~"number has a special value, \ + if special { fail!(~"number has a special value, \ try to_str_radix_special() if those are expected") } r } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 74bf50737f563..c7d391bab08d5 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -143,7 +143,7 @@ pub pure fn to_str_hex(num: float) -> ~str { pub pure fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = num::to_str_common( &num, radix, true, true, num::SignNeg, num::DigAll); - if special { die!(~"number has a special value, \ + if special { fail!(~"number has a special value, \ try to_str_radix_special() if those are expected") } r } @@ -509,16 +509,16 @@ pub fn test_from_str() { // note: NaN != NaN, hence this slightly complex test match from_str(~"NaN") { Some(f) => assert is_NaN(f), - None => die!() + None => fail!() } // note: -0 == 0, hence these slightly more complex tests match from_str(~"-0") { Some(v) if is_zero(v) => assert is_negative(v), - _ => die!() + _ => fail!() } match from_str(~"0") { Some(v) if is_zero(v) => assert is_positive(v), - _ => die!() + _ => fail!() } assert from_str(~"").is_none(); @@ -556,16 +556,16 @@ pub fn test_from_str_hex() { // note: NaN != NaN, hence this slightly complex test match from_str_hex(~"NaN") { Some(f) => assert is_NaN(f), - None => die!() + None => fail!() } // note: -0 == 0, hence these slightly more complex tests match from_str_hex(~"-0") { Some(v) if is_zero(v) => assert is_negative(v), - _ => die!() + _ => fail!() } match from_str_hex(~"0") { Some(v) if is_zero(v) => assert is_positive(v), - _ => die!() + _ => fail!() } assert from_str_hex(~"e") == Some(14.); assert from_str_hex(~"E") == Some(14.); diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 4c22a8001e9b8..71c06bc9d24d7 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -108,7 +108,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { let mut i = start; if step == 0 { - die!(~"range_step called with step == 0"); + fail!(~"range_step called with step == 0"); } else if step > 0 { // ascending while i < stop { if !it(i) { break } @@ -435,16 +435,16 @@ pub fn test_ranges() { // None of the `fail`s should execute. for range(10,0) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_rev(0,10) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_step(10,0,1) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_step(0,10,-1) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } } diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index bc5a42262ca9c..8435a7b8ea29f 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -260,10 +260,10 @@ pub pure fn to_str_bytes_common( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if radix as int < 2 { - die!(fmt!("to_str_bytes_common: radix %? to low, \ + fail!(fmt!("to_str_bytes_common: radix %? to low, \ must lie in the range [2, 36]", radix)); } else if radix as int > 36 { - die!(fmt!("to_str_bytes_common: radix %? to high, \ + fail!(fmt!("to_str_bytes_common: radix %? to high, \ must lie in the range [2, 36]", radix)); } @@ -539,19 +539,19 @@ pub pure fn from_str_bytes_common( ) -> Option { match exponent { ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' - => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ use of 'e' as decimal exponent", radix)), ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p' - => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ use of 'p' as binary exponent", radix)), _ if special && radix >= DIGIT_I_RADIX // first digit of 'inf' - => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ special values 'inf' and 'NaN'", radix)), _ if radix as int < 2 - => die!(fmt!("from_str_bytes_common: radix %? to low, \ + => fail!(fmt!("from_str_bytes_common: radix %? to low, \ must lie in the range [2, 36]", radix)), _ if radix as int > 36 - => die!(fmt!("from_str_bytes_common: radix %? to high, \ + => fail!(fmt!("from_str_bytes_common: radix %? to high, \ must lie in the range [2, 36]", radix)), _ => () } diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 4a3c571520195..0f74b73e1c502 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -76,7 +76,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { let mut i = start; if step == 0 { - die!(~"range_step called with step == 0"); + fail!(~"range_step called with step == 0"); } if step >= 0 { while i < stop { @@ -388,16 +388,16 @@ pub fn test_ranges() { // None of the `fail`s should execute. for range(0,0) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_rev(0,0) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_step(10,0,1) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } for range_step(0,1,-10) |_i| { - die!(~"unreachable"); + fail!(~"unreachable"); } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index c2af5f8b73b1c..e57d664c2aaee 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -75,7 +75,7 @@ pub pure fn get(opt: Option) -> T { match opt { Some(copy x) => return x, - None => die!(~"option::get none") + None => fail!(~"option::get none") } } @@ -97,7 +97,7 @@ pub pure fn get_ref(opt: &r/Option) -> &r/T { */ match *opt { Some(ref x) => x, - None => die!(~"option::get_ref none") + None => fail!(~"option::get_ref none") } } @@ -226,7 +226,7 @@ pub pure fn unwrap(opt: Option) -> T { */ match move opt { Some(move x) => move x, - None => die!(~"option::unwrap none") + None => fail!(~"option::unwrap none") } } @@ -240,7 +240,7 @@ pub fn swap_unwrap(opt: &mut Option) -> T { Fails if the value equals `None`. */ - if opt.is_none() { die!(~"option::swap_unwrap none") } + if opt.is_none() { fail!(~"option::swap_unwrap none") } unwrap(util::replace(opt, None)) } @@ -249,7 +249,7 @@ pub pure fn expect(opt: Option, reason: &str) -> T { //! As unwrap, but with a specified failure message. match move opt { Some(move val) => val, - None => die!(reason.to_owned()), + None => fail!(reason.to_owned()), } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index ce590092db8fc..6ed8d70642cce 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1333,7 +1333,7 @@ mod tests { assert (libc::fclose(ostream) == (0u as c_int)); let rs = os::copy_file(&in, &out); if (!os::path_exists(&in)) { - die!(fmt!("%s doesn't exist", in.to_str())); + fail!(fmt!("%s doesn't exist", in.to_str())); } assert(rs); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 10aa4e41a0d78..7964b081e4902 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -326,7 +326,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void { let killed = rustrt::task_wait_event(this, &mut event); if killed && !task::failing() { - die!(~"killed") + fail!(~"killed") } event } @@ -402,7 +402,7 @@ pub fn send(p: SendPacketBuffered, payload: T) -> bool { //unsafe { forget(p); } return true; } - Full => die!(~"duplicate send"), + Full => fail!(~"duplicate send"), Blocked => { debug!("waking up task for %?", p_); let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); @@ -520,7 +520,7 @@ pub fn try_recv(p: RecvPacketBuffered) debug!("woke up, p.state = %?", copy p.header.state); } Blocked => if first { - die!(~"blocking on already blocked packet") + fail!(~"blocking on already blocked packet") }, Full => { let mut payload = None; @@ -556,7 +556,7 @@ pub fn try_recv(p: RecvPacketBuffered) pub pure fn peek(p: &RecvPacketBuffered) -> bool { match unsafe {(*p.header()).state} { Empty | Terminated => false, - Blocked => die!(~"peeking on blocked packet"), + Blocked => fail!(~"peeking on blocked packet"), Full => true } } @@ -589,7 +589,7 @@ fn sender_terminate(p: *Packet) { } Full => { // This is impossible - die!(~"you dun goofed") + fail!(~"you dun goofed") } Terminated => { assert p.header.blocked_task.is_null(); @@ -652,7 +652,7 @@ fn wait_many(pkts: &[T]) -> uint { (*p).state = old; break; } - Blocked => die!(~"blocking on blocked packet"), + Blocked => fail!(~"blocking on blocked packet"), Empty => () } } @@ -725,7 +725,7 @@ pub fn select2( match i { 0 => Left((try_recv(move a), move b)), 1 => Right((move a, try_recv(move b))), - _ => die!(~"select2 return an invalid packet") + _ => fail!(~"select2 return an invalid packet") } } @@ -749,7 +749,7 @@ pub fn select2i(a: &A, b: &B) -> match wait_many([a.header(), b.header()]) { 0 => Left(()), 1 => Right(()), - _ => die!(~"wait returned unexpected index") + _ => fail!(~"wait returned unexpected index") } } @@ -827,7 +827,7 @@ impl SendPacketBuffered { //forget(packet); header }, - None => die!(~"packet already consumed") + None => fail!(~"packet already consumed") } } @@ -893,7 +893,7 @@ impl RecvPacketBuffered : Selectable { //forget(packet); header }, - None => die!(~"packet already consumed") + None => fail!(~"packet already consumed") } } } @@ -1089,7 +1089,7 @@ impl Port: Peekable { endp <-> self.endp; let peek = match &endp { &Some(ref endp) => pipes::peek(endp), - &None => die!(~"peeking empty stream") + &None => fail!(~"peeking empty stream") }; self.endp <-> endp; peek @@ -1102,7 +1102,7 @@ impl Port: Selectable { unsafe { match self.endp { Some(ref endp) => endp.header(), - None => die!(~"peeking empty stream") + None => fail!(~"peeking empty stream") } } } @@ -1319,7 +1319,7 @@ pub mod test { c1.send(~"abc"); match (move p1, move p2).select() { - Right(_) => die!(), + Right(_) => fail!(), _ => () } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 038f61350b2ae..e6ced90c0d3d9 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -233,7 +233,7 @@ pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) cast::forget(move ptr); // Also we have to free the (rejected) server endpoints. let _server: UnwrapProto = cast::transmute(move serverp); - die!(~"Another task is already unwrapping this ARC!"); + fail!(~"Another task is already unwrapping this ARC!"); } } } @@ -380,7 +380,8 @@ impl Exclusive { let rec = get_shared_mutable_state(&self.x); do (*rec).lock.lock { if (*rec).failed { - die!(~"Poisoned exclusive - another task failed inside!"); + fail!( + ~"Poisoned exclusive - another task failed inside!"); } (*rec).failed = true; let result = f(&mut (*rec).data); @@ -523,7 +524,7 @@ pub mod tests { let x2 = x.clone(); do task::spawn { for 10.times { task::yield(); } // try to let the unwrapper go - die!(); // punt it awake from its deadlock + fail!(); // punt it awake from its deadlock } let _z = unwrap_exclusive(move x); do x2.with |_hello| { } diff --git a/src/libcore/private/finally.rs b/src/libcore/private/finally.rs index 50c5ea70cbb40..30a309e80b049 100644 --- a/src/libcore/private/finally.rs +++ b/src/libcore/private/finally.rs @@ -93,7 +93,7 @@ fn test_fail() { let mut i = 0; do (|| { i = 10; - die!(); + fail!(); }).finally { assert failing(); assert i == 10; diff --git a/src/libcore/private/global.rs b/src/libcore/private/global.rs index cc46c19c3d27d..e1ab28ce7ecbb 100644 --- a/src/libcore/private/global.rs +++ b/src/libcore/private/global.rs @@ -269,7 +269,7 @@ fn test_modify() { Some(~shared_mutable_state(10)) } } - _ => die!() + _ => fail!() } } @@ -280,7 +280,7 @@ fn test_modify() { assert *v == 10; None }, - _ => die!() + _ => fail!() } } @@ -291,7 +291,7 @@ fn test_modify() { Some(~shared_mutable_state(10)) } } - _ => die!() + _ => fail!() } } } diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 520d411e4c430..f285f811f15d0 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -113,7 +113,7 @@ fn run_weak_task_service(port: Port) { // nobody will receive this shutdown_chan.send(()); } - None => die!() + None => fail!() } } Shutdown => break @@ -196,7 +196,7 @@ fn test_select_stream_and_oneshot() { do weaken_task |signal| { match select2i(&port, &signal) { Left(*) => (), - Right(*) => die!() + Right(*) => fail!() } } } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index a47bad008b872..5848a868f4478 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -294,7 +294,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_str(&self) -> bool { die!(); } + fn visit_str(&self) -> bool { fail!(); } fn visit_estr_box(&self) -> bool { do self.get::<@str> |s| { @@ -316,7 +316,7 @@ impl ReprVisitor : TyVisitor { // Type no longer exists, vestigial function. fn visit_estr_fixed(&self, _n: uint, _sz: uint, - _align: uint) -> bool { die!(); } + _align: uint) -> bool { fail!(); } fn visit_box(&self, mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('@'); @@ -352,7 +352,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { die!(); } + fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { fail!(); } fn visit_unboxed_vec(&self, mtbl: uint, inner: *TyDesc) -> bool { @@ -559,7 +559,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_constr(&self, _inner: *TyDesc) -> bool { die!(); } + fn visit_constr(&self, _inner: *TyDesc) -> bool { fail!(); } fn visit_closure_ptr(&self, _ck: uint) -> bool { true } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 7f1513173786b..fb824087f2199 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -41,7 +41,7 @@ pub pure fn get(res: &Result) -> T { match *res { Ok(copy t) => t, Err(ref the_err) => unsafe { - die!(fmt!("get called on error result: %?", *the_err)) + fail!(fmt!("get called on error result: %?", *the_err)) } } } @@ -58,7 +58,7 @@ pub pure fn get_ref(res: &a/Result) -> &a/T { match *res { Ok(ref t) => t, Err(ref the_err) => unsafe { - die!(fmt!("get_ref called on error result: %?", *the_err)) + fail!(fmt!("get_ref called on error result: %?", *the_err)) } } } @@ -74,7 +74,7 @@ pub pure fn get_ref(res: &a/Result) -> &a/T { pub pure fn get_err(res: &Result) -> U { match *res { Err(copy u) => u, - Ok(_) => die!(~"get_err called on ok result") + Ok(_) => fail!(~"get_err called on ok result") } } @@ -379,7 +379,7 @@ pub fn iter_vec2(ss: &[S], ts: &[T], pub pure fn unwrap(res: Result) -> T { match move res { Ok(move t) => move t, - Err(_) => die!(~"unwrap called on an err result") + Err(_) => fail!(~"unwrap called on an err result") } } @@ -388,7 +388,7 @@ pub pure fn unwrap(res: Result) -> T { pub pure fn unwrap_err(res: Result) -> U { match move res { Err(move u) => move u, - Ok(_) => die!(~"unwrap called on an ok result") + Ok(_) => fail!(~"unwrap called on an ok result") } } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 0ef22cfc5ec69..690486010ca4b 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -180,7 +180,7 @@ fn with_dirp(d: &Option<~str>, pub fn run_program(prog: &str, args: &[~str]) -> int { let pid = spawn_process(prog, args, &None, &None, 0i32, 0i32, 0i32); - if pid == -1 as pid_t { die!(); } + if pid == -1 as pid_t { fail!(); } return waitpid(pid); } @@ -210,7 +210,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { pipe_err.out); unsafe { - if pid == -1 as pid_t { die!(); } + if pid == -1 as pid_t { fail!(); } libc::close(pipe_input.in); libc::close(pipe_output.out); libc::close(pipe_err.out); @@ -330,7 +330,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput { os::close(pipe_in.out); os::close(pipe_out.in); os::close(pipe_err.in); - die!(); + fail!(); } os::close(pipe_in.out); @@ -364,7 +364,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput { errs = move s; } (n, _) => { - die!(fmt!("program_output received an unexpected file \ + fail!(fmt!("program_output received an unexpected file \ number: %u", n)); } }; @@ -478,7 +478,7 @@ mod tests { os::close(pipe_out.out); os::close(pipe_err.out); - if pid == -1i32 { die!(); } + if pid == -1i32 { fail!(); } let expected = ~"test"; writeclose(pipe_in.out, copy expected); let actual = readclose(pipe_out.in); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6665ab6c6f7ed..b01f422c84a25 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -3025,7 +3025,7 @@ mod tests { #[should_fail] fn test_as_bytes_fail() { // Don't double free - as_bytes::<()>(&~"", |_bytes| die!() ); + as_bytes::<()>(&~"", |_bytes| fail!() ); } #[test] @@ -3125,12 +3125,12 @@ mod tests { 0 => assert ch == 'x', 1 => assert ch == '\u03c0', 2 => assert ch == 'y', - _ => die!(~"test_chars_each failed") + _ => fail!(~"test_chars_each failed") } i += 1; } - chars_each(~"", |_ch| die!() ); // should not fail + chars_each(~"", |_ch| fail!() ); // should not fail } #[test] @@ -3142,7 +3142,7 @@ mod tests { 0 => assert bb == 'x' as u8, 1 => assert bb == 'y' as u8, 2 => assert bb == 'z' as u8, - _ => die!(~"test_bytes_each failed") + _ => fail!(~"test_bytes_each failed") } i += 1; } @@ -3204,7 +3204,7 @@ mod tests { ii += 1; } - words_each(~"", |_x| die!()); // should not fail + words_each(~"", |_x| fail!()); // should not fail } #[test] diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 5136af810e8d2..fe37a2e155f0b 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -133,15 +133,15 @@ fn test_tls_modify() { fn my_key(_x: @~str) { } local_data_modify(my_key, |data| { match data { - Some(@ref val) => die!(~"unwelcome value: " + *val), + Some(@ref val) => fail!(~"unwelcome value: " + *val), None => Some(@~"first data") } }); local_data_modify(my_key, |data| { match data { Some(@~"first data") => Some(@~"next data"), - Some(@ref val) => die!(~"wrong value: " + *val), - None => die!(~"missing value") + Some(@ref val) => fail!(~"wrong value: " + *val), + None => fail!(~"missing value") } }); assert *(local_data_pop(my_key).get()) == ~"next data"; @@ -212,11 +212,11 @@ fn test_tls_cleanup_on_failure() { local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); local_data_set(int_key, @42); - die!(); + fail!(); } } // Not quite nondeterministic. local_data_set(int_key, @31337); - die!(); + fail!(); } } diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 9240a67c69a3d..698463b214776 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -213,7 +213,7 @@ pub fn task() -> TaskBuilder { priv impl TaskBuilder { fn consume() -> TaskBuilder { if self.consumed { - die!(~"Cannot copy a task_builder"); // Fake move mode on self + fail!(~"Cannot copy a task_builder"); // Fake move mode on self } self.consumed = true; let notify_chan = replace(&mut self.opts.notify_chan, None); @@ -309,7 +309,7 @@ impl TaskBuilder { // sending out messages. if self.opts.notify_chan.is_some() { - die!(~"Can't set multiple future_results for one task!"); + fail!(~"Can't set multiple future_results for one task!"); } // Construct the future and give it to the caller. @@ -543,7 +543,7 @@ pub fn yield() { let task_ = rt::rust_get_task(); let killed = rt::rust_task_yield(task_); if killed && !failing() { - die!(~"killed"); + fail!(~"killed"); } } } @@ -689,24 +689,24 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port for iter::repeat(16) { task::yield(); } ch.send(()); // If killed first, grandparent hangs. } - die!(); // Shouldn't kill either (grand)parent or (grand)child. + fail!(); // Shouldn't kill either (grand)parent or (grand)child. } po.recv(); } #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails - do spawn_unlinked { die!(); } + do spawn_unlinked { fail!(); } } #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails - do spawn_supervised { die!(); } + do spawn_supervised { fail!(); } // Give child a chance to fail-but-not-kill-us. for iter::repeat(16) { task::yield(); } } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_fail_down() { do spawn_supervised { loop { task::yield(); } } - die!(); // Shouldn't leave a child hanging around. + fail!(); // Shouldn't leave a child hanging around. } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -728,7 +728,7 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails can_not_copy: None, .. b0 }; - do b1.spawn { die!(); } + do b1.spawn { fail!(); } po.recv(); // We should get punted awake } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -749,26 +749,26 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails .. b0 }; do b1.spawn { loop { task::yield(); } } - die!(); // *both* mechanisms would be wrong if this didn't kill the child + fail!(); // *both* mechanisms would be wrong if this didn't kill the child } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails let (po, _ch) = stream::<()>(); // Default options are to spawn linked & unsupervised. - do spawn { die!(); } + do spawn { fail!(); } po.recv(); // We should get punted awake } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails // Default options are to spawn linked & unsupervised. do spawn { loop { task::yield(); } } - die!(); + fail!(); } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails // Make sure the above test is the same as this one. do task().linked().spawn { loop { task::yield(); } } - die!(); + fail!(); } // A couple bonus linked failure tests - testing for failure propagation even @@ -783,7 +783,7 @@ fn test_spawn_failure_propagate_grandchild() { } } for iter::repeat(16) { task::yield(); } - die!(); + fail!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -795,7 +795,7 @@ fn test_spawn_failure_propagate_secondborn() { } } for iter::repeat(16) { task::yield(); } - die!(); + fail!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -807,7 +807,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() { } } for iter::repeat(16) { task::yield(); } - die!(); + fail!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -819,7 +819,7 @@ fn test_spawn_linked_sup_propagate_sibling() { } } for iter::repeat(16) { task::yield(); } - die!(); + fail!(); } #[test] @@ -863,7 +863,7 @@ fn test_future_result() { result = None; do task().future_result(|+r| { result = Some(move r); }).unlinked().spawn { - die!(); + fail!(); } assert option::unwrap(move result).recv() == Failure; } @@ -879,7 +879,7 @@ fn test_try_success() { ~"Success!" } { result::Ok(~"Success!") => (), - _ => die!() + _ => fail!() } } @@ -887,10 +887,10 @@ fn test_try_success() { #[ignore(cfg(windows))] fn test_try_fail() { match do try { - die!() + fail!() } { result::Err(()) => (), - result::Ok(()) => die!() + result::Ok(()) => fail!() } } @@ -1090,7 +1090,7 @@ fn test_unkillable() { yield(); // We want to fail after the unkillable task // blocks on recv - die!(); + fail!(); } unsafe { @@ -1125,7 +1125,7 @@ fn test_unkillable_nested() { yield(); // We want to fail after the unkillable task // blocks on recv - die!(); + fail!(); } unsafe { diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 22a0c870de649..a57e8a8ee44b7 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -644,7 +644,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { fn new_task_in_sched(opts: SchedOpts) -> *rust_task { if opts.foreign_stack_size != None { - die!(~"foreign_stack_size scheduler option unimplemented"); + fail!(~"foreign_stack_size scheduler option unimplemented"); } let num_threads = match opts.mode { @@ -655,11 +655,11 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { SingleThreaded => 1u, ThreadPerCore => unsafe { rt::rust_num_threads() }, ThreadPerTask => { - die!(~"ThreadPerTask scheduling mode unimplemented") + fail!(~"ThreadPerTask scheduling mode unimplemented") } ManualThreads(threads) => { if threads == 0u { - die!(~"can not create a scheduler with no threads"); + fail!(~"can not create a scheduler with no threads"); } threads } @@ -695,7 +695,7 @@ fn test_spawn_raw_unsupervise() { .. default_task_opts() }; do spawn_raw(move opts) { - die!(); + fail!(); } } @@ -725,7 +725,7 @@ fn test_spawn_raw_notify_failure() { .. default_task_opts() }; do spawn_raw(move opts) { - die!(); + fail!(); } assert notify_po.recv() == Failure; } diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 3b6a134bc52cd..87cbcdfe30b9a 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -96,7 +96,7 @@ fn choose_weighted_item(v: &[Item]) -> Item { */ pub fn unreachable() -> ! { - die!(~"internal error: entered unreachable code"); + fail!(~"internal error: entered unreachable code"); } mod tests { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 7f02ad79583e3..966928125a98a 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -239,7 +239,7 @@ pub pure fn init(v: &[const T]) -> ~[T] { /// Returns the last element of the slice `v`, failing if the slice is empty. pub pure fn last(v: &[const T]) -> T { - if len(v) == 0u { die!(~"last_unsafe: empty vector") } + if len(v) == 0u { fail!(~"last_unsafe: empty vector") } v[len(v) - 1u] } @@ -562,7 +562,7 @@ pub fn consume(mut v: ~[T], f: fn(uint, v: T)) { pub fn pop(v: &mut ~[T]) -> T { let ln = v.len(); if ln == 0 { - die!(~"sorry, cannot vec::pop an empty vector") + fail!(~"sorry, cannot vec::pop an empty vector") } let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); unsafe { @@ -583,7 +583,7 @@ pub fn pop(v: &mut ~[T]) -> T { pub fn swap_remove(v: &mut ~[T], index: uint) -> T { let ln = v.len(); if index >= ln { - die!(fmt!("vec::swap_remove - index %u >= length %u", index, ln)); + fail!(fmt!("vec::swap_remove - index %u >= length %u", index, ln)); } if index < ln - 1 { v[index] <-> v[ln - 1]; @@ -825,7 +825,7 @@ pub pure fn flat_map(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { pub pure fn map2(v0: &[T], v1: &[U], f: fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); - if v0_len != len(v1) { die!(); } + if v0_len != len(v1) { fail!(); } let mut u: ~[V] = ~[]; let mut i = 0u; while i < v0_len { @@ -2912,7 +2912,7 @@ mod tests { #[test] fn test_each_empty() { for each::(~[]) |_v| { - die!(); // should never be executed + fail!(); // should never be executed } } @@ -2939,7 +2939,7 @@ mod tests { #[test] fn test_reach_empty() { for rev_each::(~[]) |_v| { - die!(); // should never execute + fail!(); // should never execute } } @@ -3441,7 +3441,7 @@ mod tests { #[should_fail] fn test_from_fn_fail() { do from_fn(100) |v| { - if v == 50 { die!() } + if v == 50 { fail!() } (~0, @0) }; } @@ -3455,7 +3455,7 @@ mod tests { push((~0, @0)); push((~0, @0)); push((~0, @0)); - die!(); + fail!(); }; } @@ -3468,7 +3468,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3485,7 +3485,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3502,7 +3502,7 @@ mod tests { let mut i = 0; do splitn(v, 100) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3519,7 +3519,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3536,7 +3536,7 @@ mod tests { let mut i = 0; do rsplit(v) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3553,7 +3553,7 @@ mod tests { let mut i = 0; do rsplit(v) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3570,7 +3570,7 @@ mod tests { let mut i = 0; do rsplitn(v, 100) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3587,7 +3587,7 @@ mod tests { let mut i = 0; do rsplitn(v, 100) |_elt| { if i == 2 { - die!() + fail!() } i += 1; @@ -3603,7 +3603,7 @@ mod tests { let mut i = 0; do consume(v) |_i, _elt| { if i == 2 { - die!() + fail!() } i += 1; }; @@ -3617,7 +3617,7 @@ mod tests { let mut v = ~[]; do v.grow_fn(100) |i| { if i == 50 { - die!() + fail!() } (~0, @0) } @@ -3631,7 +3631,7 @@ mod tests { let mut i = 0; do map(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; ~[(~0, @0)] @@ -3646,7 +3646,7 @@ mod tests { let mut i = 0; do map_consume(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; ~[(~0, @0)] @@ -3661,7 +3661,7 @@ mod tests { let mut i = 0; do mapi(v) |_i, _elt| { if i == 2 { - die!() + fail!() } i += 0; ~[(~0, @0)] @@ -3676,7 +3676,7 @@ mod tests { let mut i = 0; do map(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; ~[(~0, @0)] @@ -3692,7 +3692,7 @@ mod tests { let mut i = 0; do map2(v, v) |_elt1, _elt2| { if i == 2 { - die!() + fail!() } i += 0; ~[(~0, @0)] @@ -3708,7 +3708,7 @@ mod tests { let mut i = 0; do filter_mapped(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; Some((~0, @0)) @@ -3724,7 +3724,7 @@ mod tests { let mut i = 0; do v.filtered |_elt| { if i == 2 { - die!() + fail!() } i += 0; true @@ -3740,7 +3740,7 @@ mod tests { let mut i = 0; do foldl((~0, @0), v) |_a, _b| { if i == 2 { - die!() + fail!() } i += 0; (~0, @0) @@ -3756,7 +3756,7 @@ mod tests { let mut i = 0; do foldr(v, (~0, @0)) |_a, _b| { if i == 2 { - die!() + fail!() } i += 0; (~0, @0) @@ -3771,7 +3771,7 @@ mod tests { let mut i = 0; do any(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3786,7 +3786,7 @@ mod tests { let mut i = 0; do any(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3801,7 +3801,7 @@ mod tests { let mut i = 0; do all(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; true @@ -3816,7 +3816,7 @@ mod tests { let mut i = 0; do alli(v) |_i, _elt| { if i == 2 { - die!() + fail!() } i += 0; true @@ -3831,7 +3831,7 @@ mod tests { let mut i = 0; do all2(v, v) |_elt1, _elt2| { if i == 2 { - die!() + fail!() } i += 0; true @@ -3847,7 +3847,7 @@ mod tests { let mut i = 0; do find(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3862,7 +3862,7 @@ mod tests { let mut i = 0; do position(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3877,7 +3877,7 @@ mod tests { let mut i = 0; do rposition(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3892,7 +3892,7 @@ mod tests { let mut i = 0; do each(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3907,7 +3907,7 @@ mod tests { let mut i = 0; do eachi(v) |_i, _elt| { if i == 2 { - die!() + fail!() } i += 0; false @@ -3923,7 +3923,7 @@ mod tests { let mut i = 0; for each_permutation(v) |_elt| { if i == 2 { - die!() + fail!() } i += 0; } @@ -3935,7 +3935,7 @@ mod tests { fn test_as_imm_buf_fail() { let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_imm_buf(v) |_buf, _i| { - die!() + fail!() } } @@ -3945,7 +3945,7 @@ mod tests { fn test_as_const_buf_fail() { let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_const_buf(v) |_buf, _i| { - die!() + fail!() } } @@ -3955,7 +3955,7 @@ mod tests { fn test_as_mut_buf_fail() { let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_mut_buf(v) |_buf, _i| { - die!() + fail!() } } diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index c8083554c8baf..6d0b2f8a76205 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -569,7 +569,7 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) { run::run_program(~"diff", ~[~"-w", ~"-u", ~"round-trip-a.rs", ~"round-trip-b.rs"]); - die!(~"Mismatch"); + fail!(~"Mismatch"); } } diff --git a/src/libfuzzer/rand_util.rs b/src/libfuzzer/rand_util.rs index ea8bd05c38ba7..cb074eecd6db4 100644 --- a/src/libfuzzer/rand_util.rs +++ b/src/libfuzzer/rand_util.rs @@ -42,7 +42,7 @@ fn shuffled(r : rand::rng, v : ~[T]) -> ~[T] { } // sample from a population without replacement -//fn sample(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { die!() } +//fn sample(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { fail!() } // Two ways to make a weighted choice. // * weighted_choice is O(number of choices) time diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 2b8e52888f180..df362b7798408 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -509,7 +509,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path, } ast::meta_list(_, _) => { // FIXME (#607): Implement this - die!(~"unimplemented meta_item variant"); + fail!(~"unimplemented meta_item variant"); } } } diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 4cca6757cc394..18e89635ab298 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -178,7 +178,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { let install_prefix = env!("CFG_PREFIX"); if install_prefix == ~"" { - die!(~"rustc compiled without CFG_PREFIX environment variable"); + fail!(~"rustc compiled without CFG_PREFIX environment variable"); } let tlib = filesearch::relative_target_lib_path(target_triple); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 4273f4f135b41..b0024bace37e0 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -506,7 +506,7 @@ pub fn host_triple() -> ~str { return if ht != ~"" { ht } else { - die!(~"rustc built without CFG_HOST_TRIPLE") + fail!(~"rustc built without CFG_HOST_TRIPLE") }; } @@ -841,7 +841,7 @@ pub fn build_output_filenames(input: input, pub fn early_error(emitter: diagnostic::Emitter, msg: ~str) -> ! { emitter(None, msg, diagnostic::fatal); - die!(); + fail!(); } pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) { @@ -869,7 +869,7 @@ pub mod test { let matches = &match getopts(~[~"--test"], optgroups()) { Ok(copy m) => m, - Err(copy f) => die!(~"test_switch_implies_cfg_test: " + + Err(copy f) => fail!(~"test_switch_implies_cfg_test: " + getopts::fail_str(f)) }; let sessopts = build_session_options( @@ -887,7 +887,7 @@ pub mod test { &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { Ok(copy m) => m, Err(copy f) => { - die!(~"test_switch_implies_cfg_test_unless_cfg_test: " + + fail!(~"test_switch_implies_cfg_test_unless_cfg_test: " + getopts::fail_str(f)); } }; diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 3a419ac9f59b4..4b63bb3721538 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1457,7 +1457,7 @@ pub fn float_width(llt: TypeRef) -> uint { 2 => 64u, 3 => 80u, 4 | 5 => 128u, - _ => die!(~"llvm_float_width called on a non-float type") + _ => fail!(~"llvm_float_width called on a non-float type") }; } } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 14dda96228206..cb56136f1c466 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -92,7 +92,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { let items = reader::get_doc(reader::Doc(data), tag_items); match maybe_find_item(item_id, items) { - None => die!(fmt!("lookup_item: id not found: %d", item_id)), + None => fail!(fmt!("lookup_item: id not found: %d", item_id)), Some(d) => d } } @@ -150,7 +150,7 @@ fn item_family(item: ebml::Doc) -> Family { 'g' => PublicField, 'j' => PrivateField, 'N' => InheritedField, - c => die!(fmt!("unexpected family char: %c", c)) + c => fail!(fmt!("unexpected family char: %c", c)) } } @@ -399,7 +399,7 @@ pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option { let mut found = None; let cls_items = match maybe_find_item(id, items) { Some(it) => it, - None => die!(fmt!("struct_dtor: class id not found \ + None => fail!(fmt!("struct_dtor: class id not found \ when looking up dtor for %d", id)) }; for reader::tagged_docs(cls_items, tag_item_dtor) |doc| { @@ -424,8 +424,8 @@ pub enum def_like { fn def_like_to_def(def_like: def_like) -> ast::def { match def_like { dl_def(def) => return def, - dl_impl(*) => die!(~"found impl in def_like_to_def"), - dl_field => die!(~"found field in def_like_to_def") + dl_impl(*) => fail!(~"found impl in def_like_to_def"), + dl_field => fail!(~"found field in def_like_to_def") } } @@ -626,7 +626,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { 'm' => { ast::m_mutbl } 'c' => { ast::m_const } _ => { - die!(fmt!("unknown mutability character: `%c`", ch as char)) + fail!(fmt!("unknown mutability character: `%c`", ch as char)) } } } @@ -643,7 +643,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { '~' => { return ast::sty_uniq(get_mutability(string[1])); } '&' => { return ast::sty_region(get_mutability(string[1])); } _ => { - die!(fmt!("unknown self type code: `%c`", self_ty_kind as char)); + fail!(fmt!("unknown self type code: `%c`", self_ty_kind as char)); } } } @@ -834,7 +834,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, StaticMethod => purity = ast::impure_fn, UnsafeStaticMethod => purity = ast::unsafe_fn, PureStaticMethod => purity = ast::pure_fn, - _ => die!() + _ => fail!() } static_impl_methods.push(StaticMethodInfo { @@ -867,7 +867,7 @@ pure fn family_to_visibility(family: Family) -> ast::visibility { PublicField => ast::public, PrivateField => ast::private, InheritedField => ast::inherited, - _ => die!() + _ => fail!() } } @@ -926,7 +926,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str { if id.crate != ast::local_crate { return ~"external"; } let it = match maybe_find_item(id.node, items) { Some(it) => it, - None => die!(fmt!("describe_def: item not found %?", id)) + None => fail!(fmt!("describe_def: item not found %?", id)) }; return item_family_to_str(item_family(it)); } @@ -1111,7 +1111,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { match cdata.cnum_map.find(&did.crate) { option::Some(n) => ast::def_id { crate: n, node: did.node }, - option::None => die!(~"didn't find a crate in the cnum_map") + option::None => fail!(~"didn't find a crate in the cnum_map") } } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 3c39a4032f539..12c5e3388dbe7 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -553,7 +553,7 @@ fn purity_static_method_family(p: purity) -> char { unsafe_fn => 'U', pure_fn => 'P', impure_fn => 'F', - _ => die!(~"extern fn can't be static") + _ => fail!(~"extern fn can't be static") } } @@ -879,7 +879,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, true, item.id, *m, /*bad*/copy m.tps); } } - item_mac(*) => die!(~"item macros unimplemented") + item_mac(*) => fail!(~"item macros unimplemented") } } @@ -936,7 +936,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_info_for_item(ecx, ebml_w, i, index, *pt); } - _ => die!(~"bad item") + _ => fail!(~"bad item") } } }, @@ -951,7 +951,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder, abi); } // case for separate item and foreign-item tables - _ => die!(~"bad foreign item") + _ => fail!(~"bad foreign item") } } }, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index dfccaf77dfd32..eac459ec703d0 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -108,7 +108,7 @@ fn make_target_lib_path(sysroot: &Path, fn get_or_default_sysroot() -> Path { match os::self_exe_path() { option::Some(ref p) => (*p).pop(), - option::None => die!(~"can't determine value for sysroot") + option::None => fail!(~"can't determine value for sysroot") } } @@ -176,7 +176,7 @@ fn get_cargo_lib_path_nearest() -> Result { pub fn libdir() -> ~str { let libdir = env!("CFG_LIBDIR"); if str::is_empty(libdir) { - die!(~"rustc compiled without CFG_LIBDIR environment variable"); + fail!(~"rustc compiled without CFG_LIBDIR environment variable"); } libdir } diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index c4cb154e21f0d..9e5b1db879f0c 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -150,10 +150,10 @@ pub fn crate_name_from_metas(+metas: ~[@ast::meta_item]) -> ~str { Some(ref n) => (/*bad*/copy *n), // FIXME (#2406): Probably want a warning here since the user // is using the wrong type of meta item. - _ => die!() + _ => fail!() } } - None => die!(~"expected to find the crate name") + None => fail!(~"expected to find the crate name") } } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index c4b3204799559..2599ceb2ef16e 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -190,7 +190,7 @@ fn parse_bound_region(st: @mut PState) -> ty::bound_region { assert next(st) == '|'; ty::br_cap_avoid(id, @parse_bound_region(st)) }, - _ => die!(~"parse_bound_region: bad input") + _ => fail!(~"parse_bound_region: bad input") } } @@ -215,7 +215,7 @@ fn parse_region(st: @mut PState) -> ty::Region { 't' => { ty::re_static } - _ => die!(~"parse_region: bad input") + _ => fail!(~"parse_region: bad input") } } @@ -223,7 +223,7 @@ fn parse_opt(st: @mut PState, f: fn() -> T) -> Option { match next(st) { 'n' => None, 's' => Some(f()), - _ => die!(~"parse_opt: bad input") + _ => fail!(~"parse_opt: bad input") } } @@ -256,7 +256,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { 'D' => return ty::mk_mach_int(st.tcx, ast::ty_i64), 'f' => return ty::mk_mach_float(st.tcx, ast::ty_f32), 'F' => return ty::mk_mach_float(st.tcx, ast::ty_f64), - _ => die!(~"parse_ty: bad numeric type") + _ => fail!(~"parse_ty: bad numeric type") } } 'c' => return ty::mk_char(st.tcx), @@ -360,7 +360,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { assert (next(st) == ']'); return ty::mk_struct(st.tcx, did, substs); } - c => { error!("unexpected char in type string: %c", c); die!();} + c => { error!("unexpected char in type string: %c", c); fail!();} } } @@ -412,14 +412,14 @@ fn parse_purity(c: char) -> purity { 'p' => pure_fn, 'i' => impure_fn, 'c' => extern_fn, - _ => die!(~"parse_purity: bad purity") + _ => fail!(~"parse_purity: bad purity") } } fn parse_abi(c: char) -> Abi { match c { 'r' => ast::RustAbi, - _ => die!(fmt!("parse_abi: bad ABI '%c'", c)) + _ => fail!(fmt!("parse_abi: bad ABI '%c'", c)) } } @@ -427,7 +427,7 @@ fn parse_onceness(c: char) -> ast::Onceness { match c { 'o' => ast::Once, 'm' => ast::Many, - _ => die!(~"parse_onceness: bad onceness") + _ => fail!(~"parse_onceness: bad onceness") } } @@ -440,7 +440,7 @@ fn parse_mode(st: @mut PState) -> ast::mode { '+' => ast::by_copy, '=' => ast::by_ref, '#' => ast::by_val, - _ => die!(~"bad mode") + _ => fail!(~"bad mode") }); return m; } @@ -490,7 +490,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } if colon_idx == len { error!("didn't find ':' when parsing def id"); - die!(); + fail!(); } let crate_part = vec::view(buf, 0u, colon_idx); @@ -498,12 +498,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as int, - None => die!(fmt!("internal error: parse_def_id: crate number \ + None => fail!(fmt!("internal error: parse_def_id: crate number \ expected, but found %?", crate_part)) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as int, - None => die!(fmt!("internal error: parse_def_id: id expected, but \ + None => fail!(fmt!("internal error: parse_def_id: id expected, but \ found %?", def_part)) }; ast::def_id { crate: crate_num, node: def_num } @@ -526,7 +526,7 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] { 'O' => ty::bound_durable, 'I' => ty::bound_trait(parse_ty(st, conv)), '.' => break, - _ => die!(~"parse_bounds: bad bounds") + _ => fail!(~"parse_bounds: bad bounds") }); } @bounds diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index a87ce02d5a30a..252de54cb9bbd 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -326,7 +326,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) { debug!("~~~~ %s", ~"]"); w.write_char(']'); } - ty::ty_err => die!(~"Shouldn't encode error type") + ty::ty_err => fail!(~"Shouldn't encode error type") } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 72da98be6b09d..af2465fe4d14d 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -304,7 +304,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { span: _}, _) => true, ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_), span: _}, _) => false, - ast::stmt_mac(*) => die!(~"unexpanded macro in astencode") + ast::stmt_mac(*) => fail!(~"unexpanded macro in astencode") } }; let blk_sans_items = ast::blk_ { @@ -717,7 +717,7 @@ impl reader::Decoder: vtable_decoder_helpers { ) } // hard to avoid - user input - _ => die!(~"bad enum variant") + _ => fail!(~"bad enum variant") } } } @@ -1288,6 +1288,6 @@ fn test_simplification() { assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner) == pprust::item_to_str(item_exp, ext_cx.parse_sess().interner); } - _ => die!() + _ => fail!() } } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 8890da1587d9c..6d4de6aeb9351 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -253,7 +253,7 @@ pub fn check_item_recursion(sess: Session, ast_map::node_item(it, _) => { (v.visit_item)(it, env, v); } - _ => die!(~"const not bound to an item") + _ => fail!(~"const not bound to an item") } } _ => () diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 1a3e42511295e..bd07ca84c9aad 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -147,11 +147,11 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) { } ty::ty_enum(id, _) => { let vid = match (*ctor) { variant(id) => id, - _ => die!(~"check_exhaustive: non-variant ctor") }; + _ => fail!(~"check_exhaustive: non-variant ctor") }; match vec::find(*ty::enum_variants(cx.tcx, id), |v| v.id == vid) { Some(v) => Some(cx.tcx.sess.str_of(v.name)), - None => die!(~"check_exhaustive: bad variant in ctor") + None => fail!(~"check_exhaustive: bad variant in ctor") } } ty::ty_unboxed_vec(*) | ty::ty_evec(*) => { @@ -366,7 +366,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt, return Some(variant(v.id)); } } - die!(); + fail!(); } else { None } } ty::ty_nil => None, @@ -377,7 +377,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt, None => (), Some(val(const_bool(true))) => true_found = true, Some(val(const_bool(false))) => false_found = true, - _ => die!(~"impossible case") + _ => fail!(~"impossible case") } } if true_found && false_found { None } @@ -445,10 +445,10 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint { ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u, ty::ty_enum(eid, _) => { let id = match ctor { variant(id) => id, - _ => die!(~"impossible case") }; + _ => fail!(~"impossible case") }; match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) { Some(v) => v.args.len(), - None => die!(~"impossible case") + None => fail!(~"impossible case") } } ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(), @@ -496,7 +496,7 @@ pub fn specialize(cx: @MatchCheckCtxt, compare_const_vals((*c_hi), e_v) <= 0 } single => true, - _ => die!(~"type error") + _ => fail!(~"type error") }; if match_ { Some(vec::tail(r)) } else { None } } @@ -529,7 +529,7 @@ pub fn specialize(cx: @MatchCheckCtxt, pat_rec(ref flds, _) => { let ty_flds = match /*bad*/copy ty::get(left_ty).sty { ty::ty_rec(flds) => flds, - _ => die!(~"bad type for pat_rec") + _ => fail!(~"bad type for pat_rec") }; let args = vec::map(ty_flds, |ty_fld| { match flds.find(|f| f.ident == ty_fld.ident) { @@ -595,7 +595,7 @@ pub fn specialize(cx: @MatchCheckCtxt, compare_const_vals((*c_hi), e_v) <= 0 } single => true, - _ => die!(~"type error") + _ => fail!(~"type error") }; if match_ { Some(vec::tail(r)) } else { None } } @@ -605,7 +605,7 @@ pub fn specialize(cx: @MatchCheckCtxt, range(ref lo, ref hi) => ((/*bad*/copy *lo), (/*bad*/copy *hi)), single => return Some(vec::tail(r)), - _ => die!(~"type error") + _ => fail!(~"type error") }; let v_lo = eval_const_expr(cx.tcx, lo), v_hi = eval_const_expr(cx.tcx, hi); diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index e01595d8d939d..ae83e996aba72 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -233,7 +233,7 @@ pub enum const_val { pub fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { match eval_const_expr_partial(tcx, e) { Ok(ref r) => (/*bad*/copy *r), - Err(ref s) => die!(/*bad*/copy *s) + Err(ref s) => fail!(/*bad*/copy *s) } } @@ -459,7 +459,7 @@ pub fn compare_const_vals(a: const_val, b: const_val) -> int { 1 } } - _ => die!(~"compare_const_vals: ill-typed comparison") + _ => fail!(~"compare_const_vals: ill-typed comparison") } } diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 0d3b7c36f6d92..2c39e41c57bc4 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -57,7 +57,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) ast::expr_path(*) => { let mut i = 0; match def_map.find(&expr.id) { - None => die!(~"path not found"), + None => fail!(~"path not found"), Some(df) => { let mut def = df; while i < depth { @@ -117,7 +117,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) -> pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { match tcx.freevars.find(&fid) { - None => die!(~"get_freevars: " + int::str(fid) + ~" has no freevars"), + None => fail!(~"get_freevars: " + int::str(fid) + ~" has no freevars"), Some(d) => return d } } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index a949b40bf7549..29a3a83364290 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -204,7 +204,7 @@ pub fn check_expr(e: @expr, cx: ctx, v: visit::vt) { }; if vec::len(*ts) != vec::len(*bounds) { // Fail earlier to make debugging easier - die!(fmt!("internal error: in kind::check_expr, length \ + fail!(fmt!("internal error: in kind::check_expr, length \ mismatch between actual and declared bounds: actual = \ %s (%u tys), declared = %? (%u tys)", tys_to_str(cx.tcx, *ts), ts.len(), diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 487148ddd97d7..da153778b9abb 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -485,7 +485,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::gt => v >= min, ast::ge => v > min, ast::eq | ast::ne => v >= min && v <= max, - _ => die!() + _ => fail!() } } @@ -544,7 +544,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::lit_int_unsuffixed(v) => v, _ => return true }, - _ => die!() + _ => fail!() }; is_valid(norm_binop, lit_val, min, max) } @@ -557,7 +557,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::lit_int_unsuffixed(v) => v as u64, _ => return true }, - _ => die!() + _ => fail!() }; is_valid(norm_binop, lit_val, min, max) } @@ -960,7 +960,7 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl, ty_to_str(tcx, arg_ty.ty), mode_to_str(arg_ast.mode)); error!("%?",arg_ast.ty.node); - die!() + fail!() } }; } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index ea840da73cd98..acb73e90c5d58 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -323,7 +323,7 @@ pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode) ForbidDuplicateModules | ForbidDuplicateTypes | ForbidDuplicateTypesAndValues => TypeNS, ForbidDuplicateValues => ValueNS, - OverwriteDuplicates => die!(~"OverwriteDuplicates has no namespace") + OverwriteDuplicates => fail!(~"OverwriteDuplicates has no namespace") } } @@ -618,7 +618,7 @@ pub impl NameBindings { fn get_module(@mut self) -> @Module { match self.get_module_if_available() { None => { - die!(~"get_module called on a node with no module \ + fail!(~"get_module called on a node with no module \ definition!") } Some(module_def) => module_def @@ -1337,7 +1337,7 @@ pub impl Resolver { } item_mac(*) => { - die!(~"item macros unimplemented") + fail!(~"item macros unimplemented") } } } @@ -1599,7 +1599,7 @@ pub impl Resolver { match existing_module.parent_link { NoParentLink | BlockParentLink(*) => { - die!(~"can't happen"); + fail!(~"can't happen"); } ModuleParentLink(parent_module, ident) => { let name_bindings = parent_module.children.get( @@ -1666,7 +1666,7 @@ pub impl Resolver { def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_use(*) | def_upvar(*) | def_region(*) | def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { - die!(fmt!("didn't expect `%?`", def)); + fail!(fmt!("didn't expect `%?`", def)); } } } @@ -2254,7 +2254,7 @@ pub impl Resolver { } UnboundResult => { /* Continue. */ } UnknownResult => { - die!(~"value result should be known at this point"); + fail!(~"value result should be known at this point"); } } match type_result { @@ -2264,7 +2264,7 @@ pub impl Resolver { } UnboundResult => { /* Continue. */ } UnknownResult => { - die!(~"type result should be known at this point"); + fail!(~"type result should be known at this point"); } } @@ -2417,7 +2417,7 @@ pub impl Resolver { binding"); } UnknownResult => { - die!(~"module result should be known at this point"); + fail!(~"module result should be known at this point"); } } @@ -3033,7 +3033,7 @@ pub impl Resolver { allowable_namespaces = namespaces; } GlobImport => { - die!(~"found `import *`, which is invalid"); + fail!(~"found `import *`, which is invalid"); } } @@ -3153,7 +3153,7 @@ pub impl Resolver { // Otherwise, proceed and write in the bindings. match module_.import_resolutions.find(&target_name) { None => { - die!(~"(resolving one-level renaming import) reduced graph \ + fail!(~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ import resolution name by now"); } @@ -3769,7 +3769,7 @@ pub impl Resolver { } item_mac(*) => { - die!(~"item macros unimplemented") + fail!(~"item macros unimplemented") } } @@ -4471,8 +4471,8 @@ pub impl Resolver { Success(target) => { match target.bindings.value_def { None => { - die!(~"resolved name in the value namespace to a set \ - of name bindings with no def?!"); + fail!(~"resolved name in the value namespace to a \ + set of name bindings with no def?!"); } Some(def) => { match def.def { @@ -4491,7 +4491,7 @@ pub impl Resolver { } Indeterminate => { - die!(~"unexpected indeterminate result"); + fail!(~"unexpected indeterminate result"); } Failed => { @@ -4652,7 +4652,7 @@ pub impl Resolver { } Indeterminate => { - die!(~"indeterminate unexpected"); + fail!(~"indeterminate unexpected"); } Success(resulting_module) => { @@ -4699,7 +4699,7 @@ pub impl Resolver { } Indeterminate => { - die!(~"indeterminate unexpected"); + fail!(~"indeterminate unexpected"); } Success(resulting_module) => { @@ -4777,7 +4777,7 @@ pub impl Resolver { } } Indeterminate => { - die!(~"unexpected indeterminate result"); + fail!(~"unexpected indeterminate result"); } Failed => { return None; diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index d9d3b63b6c9a5..492adc8631dc9 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -209,7 +209,7 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool { a_expr = e.get(); } UnitLikeStructLit(_) => { - die!(~"UnitLikeStructLit should have been handled \ + fail!(~"UnitLikeStructLit should have been handled \ above") } } @@ -222,7 +222,7 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool { b_expr = e.get(); } UnitLikeStructLit(_) => { - die!(~"UnitLikeStructLit should have been handled \ + fail!(~"UnitLikeStructLit should have been handled \ above") } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c61ff7d5e0267..9a82bb53e0105 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1874,7 +1874,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt, // works. So we have to cast to the destination's view of the type. let llarg = match fcx.llargs.find(&va.id) { Some(local_mem(x)) => x, - _ => die!(~"trans_enum_variant: how do we know this works?"), + _ => fail!(~"trans_enum_variant: how do we know this works?"), }; let arg_ty = arg_tys[i].ty; memcpy_ty(bcx, lldestptr, llarg, arg_ty); @@ -2016,7 +2016,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { let path = match ccx.tcx.items.get(&item.id) { ast_map::node_item(_, p) => p, // tjc: ? - _ => die!(~"trans_item"), + _ => fail!(~"trans_item"), }; match /*bad*/copy item.node { ast::item_fn(ref decl, purity, ref tps, ref body) => { @@ -2277,7 +2277,7 @@ pub fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { /*bad*/copy *match ccx.tcx.items.get(&i.id) { ast_map::node_item(_, p) => p, // separate map for paths? - _ => die!(~"item_path") + _ => fail!(~"item_path") }, ~[path_name(i.ident)]) } @@ -2364,7 +2364,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn); llfn } - _ => die!(~"get_item_val: weird result in table") + _ => fail!(~"get_item_val: weird result in table") } } ast_map::node_trait_method(trait_method, _, pth) => { @@ -2445,14 +2445,14 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ast::item_enum(_, _) => { register_fn(ccx, (*v).span, pth, id, enm.attrs) } - _ => die!(~"node_variant, shouldn't happen") + _ => fail!(~"node_variant, shouldn't happen") }; } ast::struct_variant_kind(_) => { - die!(~"struct variant kind unexpected in get_item_val") + fail!(~"struct variant kind unexpected in get_item_val") } ast::enum_variant_kind(_) => { - die!(~"enum variant kind unexpected in get_item_val") + fail!(~"enum variant kind unexpected in get_item_val") } } set_inline_hint(llfn); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 24e9d967facd2..43953b68f599b 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -33,7 +33,7 @@ pub fn terminate(cx: block, _: &str) { pub fn check_not_terminated(cx: block) { if cx.terminated { - die!(~"already terminated!"); + fail!(~"already terminated!"); } } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 00235c32d3c3d..bac91e17e0309 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { let elt = llvm::LLVMGetElementType(ty); ty_align(elt) } - _ => die!(~"ty_size: unhandled type") + _ => fail!(~"ty_size: unhandled type") }; } } @@ -122,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { let eltsz = ty_size(elt); len * eltsz } - _ => die!(~"ty_size: unhandled type") + _ => fail!(~"ty_size: unhandled type") }; } } @@ -215,7 +215,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { i += 1u; } } - _ => die!(~"classify: unhandled type") + _ => fail!(~"classify: unhandled type") } } } @@ -316,7 +316,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef { sse_ds_class => { tys.push(T_f64()); } - _ => die!(~"llregtype: unhandled class") + _ => fail!(~"llregtype: unhandled class") } i += 1u; } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 81fa221aac4de..709ab9365ed99 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -383,7 +383,7 @@ pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block, llfnty = T_ptr(struct_elt(llfnty, 0)); new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty); } - _ => die!() + _ => fail!() } Callee { bcx: callee.bcx, data: Fn(FnData { llfn: new_llval }) } }, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index f50cadc967124..7c6f03cb364bc 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -268,7 +268,7 @@ fn create_block(cx: block) -> @metadata { while cx.node_info.is_none() { match cx.parent { Some(b) => cx = b, - None => die!() + None => fail!() } } let sp = cx.node_info.get().span; @@ -553,7 +553,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::Ty) * elsewhere, not be self-contained. */ - die!(); + fail!(); /* fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { let ty = match ty::get(t).struct { @@ -669,7 +669,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) let name = match local.node.pat.node { ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), // FIXME this should be handled (#2533) - _ => die!(~"no single variable name for local") + _ => fail!(~"no single variable name for local") }; let loc = cx.sess.codemap.lookup_char_pos(local.span.lo); let ty = node_id_type(bcx, local.node.id); diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index bb14fce805354..718f41de00ada 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -498,7 +498,7 @@ pub fn trans_intrinsic(ccx: @crate_ctxt, if tp_sz != out_sz { let sp = match ccx.tcx.items.get(&ref_id.get()) { ast_map::node_expr(e) => e.span, - _ => die!(~"reinterpret_cast or forget has non-expr arg") + _ => fail!(~"reinterpret_cast or forget has non-expr arg") }; ccx.sess.span_fatal( sp, fmt!("reinterpret_cast called on types \ @@ -956,7 +956,7 @@ fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) None => match ccx.tcx.items.get(&i.id) { ast_map::node_foreign_item(_, abi, _) => abi, // ?? - _ => die!(~"abi_of_foreign_fn: not foreign") + _ => fail!(~"abi_of_foreign_fn: not foreign") }, Some(_) => match attr::foreign_abi(i.attrs) { either::Right(abi) => abi, diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index fb487b98e152f..a79a24ba4606f 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -253,7 +253,7 @@ pub fn trans_method_callee(bcx: block, trait_id, off, vtbl) } // how to get rid of this? - None => die!(~"trans_method_callee: missing param_substs") + None => fail!(~"trans_method_callee: missing param_substs") } } typeck::method_trait(_, off, vstore) => { @@ -265,7 +265,7 @@ pub fn trans_method_callee(bcx: block, mentry.explicit_self) } typeck::method_self(*) | typeck::method_super(*) => { - die!(~"method_self or method_super should have been handled \ + fail!(~"method_self or method_super should have been handled \ above") } } @@ -312,13 +312,13 @@ pub fn trans_static_method_callee(bcx: block, ast_map::node_trait_method(trait_method, _, _) => { ast_util::trait_method_to_ty_method(*trait_method).ident } - _ => die!(~"callee is not a trait method") + _ => fail!(~"callee is not a trait method") } } else { let path = csearch::get_item_path(bcx.tcx(), method_id); match path[path.len()-1] { path_name(s) => { s } - path_mod(_) => { die!(~"path doesn't have a name?") } + path_mod(_) => { fail!(~"path doesn't have a name?") } } }; debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \ @@ -348,7 +348,7 @@ pub fn trans_static_method_callee(bcx: block, FnData {llfn: PointerCast(bcx, lval, llty)} } _ => { - die!(~"vtable_param left in monomorphized \ + fail!(~"vtable_param left in monomorphized \ function's vtable substs"); } } @@ -369,7 +369,7 @@ pub fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, }, _) => { method_from_methods(/*bad*/copy *ms, name).get() } - _ => die!(~"method_with_name") + _ => fail!(~"method_with_name") } } else { csearch::get_impl_method(ccx.sess.cstore, impl_id, name) @@ -397,13 +397,13 @@ pub fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id, return pmi.method_info.did; } } - die!() + fail!() } - None => die!() + None => fail!() } } } - _ => die!(~"method_with_name") + _ => fail!(~"method_with_name") } } else { csearch::get_impl_method(ccx.sess.cstore, impl_id, name) @@ -422,14 +422,14 @@ pub fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, method_ty_param_count( ccx, source.method_id, source.impl_id) } - None => die!() + None => fail!() } } Some(ast_map::node_trait_method(@ast::provided(@ref m), _, _)) => { m.tps.len() } - copy e => die!(fmt!("method_ty_param_count %?", e)) + copy e => fail!(fmt!("method_ty_param_count %?", e)) } } else { csearch::get_type_param_count(ccx.sess.cstore, m_id) - @@ -494,7 +494,7 @@ pub fn trans_monomorphized_callee(bcx: block, mentry.explicit_self) } typeck::vtable_param(*) => { - die!(~"vtable_param left in monomorphized function's " + + fail!(~"vtable_param left in monomorphized function's " + "vtable substs"); } }; @@ -770,7 +770,7 @@ pub fn vtable_id(ccx: @crate_ctxt, } } // can't this be checked at the callee? - _ => die!(~"vtable_id") + _ => fail!(~"vtable_id") } } @@ -785,7 +785,7 @@ pub fn get_vtable(ccx: @crate_ctxt, typeck::vtable_static(id, substs, sub_vtables) => { make_impl_vtable(ccx, id, substs, sub_vtables) } - _ => die!(~"get_vtable: expected a static origin") + _ => fail!(~"get_vtable: expected a static origin") } } } diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index bf417e9a5f4f9..d56d28c982d7d 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -138,7 +138,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } item_const(*) | item_enum(*) | item_trait(*) => (), - item_mac(*) => die!(~"item macros unimplemented") + item_mac(*) => fail!(~"item macros unimplemented") } } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 3fd334c2d1508..af570e1f25909 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -148,7 +148,7 @@ pub fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ~"bswap16" | ~"bswap32" | ~"bswap64" => 0, // would be cool to make these an enum instead of strings! - _ => die!(~"unknown intrinsic in type_use") + _ => fail!(~"unknown intrinsic in type_use") }; for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index d38eef0fcf9f6..08885127761fc 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1505,7 +1505,7 @@ pub fn get_element_type(ty: t, i: uint) -> t { match /*bad*/copy get(ty).sty { ty_rec(flds) => return flds[i].mt.ty, ty_tup(ts) => return ts[i], - _ => die!(~"get_element_type called on invalid type") + _ => fail!(~"get_element_type called on invalid type") } } @@ -2788,7 +2788,7 @@ pub fn ty_fn_args(fty: t) -> ~[arg] { ty_bare_fn(ref f) => copy f.sig.inputs, ty_closure(ref f) => copy f.sig.inputs, ref s => { - die!(fmt!("ty_fn_args() called on non-fn type: %?", s)) + fail!(fmt!("ty_fn_args() called on non-fn type: %?", s)) } } } @@ -2797,7 +2797,8 @@ pub fn ty_closure_sigil(fty: t) -> Sigil { match get(fty).sty { ty_closure(ref f) => f.sigil, ref s => { - die!(fmt!("ty_closure_sigil() called on non-closure type: %?", s)) + fail!(fmt!("ty_closure_sigil() called on non-closure type: %?", + s)) } } } @@ -2807,7 +2808,7 @@ pub fn ty_fn_purity(fty: t) -> ast::purity { ty_bare_fn(ref f) => f.purity, ty_closure(ref f) => f.purity, ref s => { - die!(fmt!("ty_fn_purity() called on non-fn type: %?", s)) + fail!(fmt!("ty_fn_purity() called on non-fn type: %?", s)) } } } @@ -2817,7 +2818,7 @@ pub pure fn ty_fn_ret(fty: t) -> t { ty_bare_fn(ref f) => f.sig.output, ty_closure(ref f) => f.sig.output, ref s => { - die!(fmt!("ty_fn_ret() called on non-fn type: %?", s)) + fail!(fmt!("ty_fn_ret() called on non-fn type: %?", s)) } } } @@ -2834,7 +2835,7 @@ pub pure fn ty_vstore(ty: t) -> vstore { match get(ty).sty { ty_evec(_, vstore) => vstore, ty_estr(vstore) => vstore, - ref s => die!(fmt!("ty_vstore() called on invalid sty: %?", s)) + ref s => fail!(fmt!("ty_vstore() called on invalid sty: %?", s)) } } @@ -2843,7 +2844,7 @@ pub fn ty_region(ty: t) -> Region { ty_rptr(r, _) => r, ty_evec(_, vstore_slice(r)) => r, ty_estr(vstore_slice(r)) => r, - ref s => die!(fmt!("ty_region() invoked on in appropriate ty: %?", + ref s => fail!(fmt!("ty_region() invoked on in appropriate ty: %?", (*s))) } } @@ -3209,7 +3210,7 @@ pub fn stmt_node_id(s: @ast::stmt) -> ast::node_id { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { return id; } - ast::stmt_mac(*) => die!(~"unexpanded macro in trans") + ast::stmt_mac(*) => fail!(~"unexpanded macro in trans") } } @@ -3233,7 +3234,7 @@ pub fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field { match vec::find(get_fields(rec_ty), |f| f.ident == id) { Some(f) => f, // Do we only call this when we know the field is legit? - None => die!(fmt!("get_field: ty doesn't have a field %s", + None => fail!(fmt!("get_field: ty doesn't have a field %s", tcx.sess.str_of(id))) } } @@ -3242,7 +3243,7 @@ pub fn get_fields(rec_ty:t) -> ~[field] { match /*bad*/copy get(rec_ty).sty { ty_rec(fields) => fields, // Can we check at the caller? - _ => die!(~"get_fields: not a record type") + _ => fail!(~"get_fields: not a record type") } } @@ -3904,10 +3905,10 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] { } } ast::struct_variant_kind(_) => { - die!(~"struct variant kinds unimpl in enum_variants") + fail!(~"struct variant kinds unimpl in enum_variants") } ast::enum_variant_kind(_) => { - die!(~"enum variant kinds unimpl in enum_variants") + fail!(~"enum variant kinds unimpl in enum_variants") } } }) diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 45b0fa962ad91..eca368e5d7673 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1234,7 +1234,7 @@ pub impl LookupContext { let span = if did.crate == ast::local_crate { match self.tcx().items.find(&did.node) { Some(ast_map::node_method(m, _, _)) => m.span, - _ => die!(fmt!("report_static_candidate: bad item %?", did)) + _ => fail!(fmt!("report_static_candidate: bad item %?", did)) } } else { self.expr.span diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d6bd9aa96dd56..a8439c3c45964 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2097,7 +2097,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, inner_ty, fcx.expr_ty(loop_body)); } ref n => { - die!(fmt!( + fail!(fmt!( "check_loop_body expected expr_fn_block, not %?", n)) } } @@ -2394,7 +2394,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); } // argh - _ => die!(~"expected fn ty") + _ => fail!(~"expected fn ty") } fcx.write_ty(expr.id, fcx.node_ty(b.id)); } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 410b4a3e33d6e..c2a7292c48dc6 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -148,7 +148,7 @@ pub fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo, do fixup_ty(vcx, location_info, t, is_early).map |t_f| { match ty::get(*t_f).sty { ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f), - _ => die!(~"t_f should be a trait") + _ => fail!(~"t_f should be a trait") } } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index fdf936f7aec62..64ac5a9ae820e 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -135,7 +135,7 @@ pub fn get_base_type_def_id(inference_context: @mut InferCtxt, return Some(def_id); } _ => { - die!(~"get_base_type() returned a type that wasn't an \ + fail!(~"get_base_type() returned a type that wasn't an \ enum, class, or trait"); } } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 982a8d7d9574f..2a42e75f53d47 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -870,8 +870,8 @@ pub fn ty_of_item(ccx: @mut CrateCtxt, it: @ast::item) return tpt; } ast::item_impl(*) | ast::item_mod(_) | - ast::item_foreign_mod(_) => die!(), - ast::item_mac(*) => die!(~"item macros unimplemented") + ast::item_foreign_mod(_) => fail!(), + ast::item_mac(*) => fail!(~"item macros unimplemented") } } diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 416dcbcd30a1b..d79343e64a69d 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -102,7 +102,7 @@ impl Env { return match search_mod(self, &self.crate.node.module, 0, names) { Some(id) => id, None => { - die!(fmt!("No item found: `%s`", str::connect(names, "::"))); + fail!(fmt!("No item found: `%s`", str::connect(names, "::"))); } }; @@ -155,7 +155,7 @@ impl Env { fn assert_subtype(&self, a: ty::t, b: ty::t) { if !self.is_subtype(a, b) { - die!(fmt!("%s is not a subtype of %s, but it should be", + fail!(fmt!("%s is not a subtype of %s, but it should be", self.ty_to_str(a), self.ty_to_str(b))); } @@ -163,7 +163,7 @@ impl Env { fn assert_not_subtype(&self, a: ty::t, b: ty::t) { if self.is_subtype(a, b) { - die!(fmt!("%s is a subtype of %s, but it shouldn't be", + fail!(fmt!("%s is a subtype of %s, but it shouldn't be", self.ty_to_str(a), self.ty_to_str(b))); } @@ -240,7 +240,7 @@ impl Env { fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) { match self.lub().tys(t1, t2) { Err(e) => { - die!(fmt!("Unexpected error computing LUB: %?", e)) + fail!(fmt!("Unexpected error computing LUB: %?", e)) } Ok(t) => { self.assert_eq(t, t_lub); @@ -262,7 +262,7 @@ impl Env { self.ty_to_str(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - die!(fmt!("Unexpected error computing LUB: %?", e)) + fail!(fmt!("Unexpected error computing LUB: %?", e)) } Ok(t) => { self.assert_eq(t, t_glb); @@ -281,7 +281,7 @@ impl Env { match self.lub().tys(t1, t2) { Err(_) => {} Ok(t) => { - die!(fmt!("Unexpected success computing LUB: %?", + fail!(fmt!("Unexpected success computing LUB: %?", self.ty_to_str(t))) } } @@ -292,7 +292,7 @@ impl Env { match self.glb().tys(t1, t2) { Err(_) => {} Ok(t) => { - die!(fmt!("Unexpected success computing GLB: %?", + fail!(fmt!("Unexpected success computing GLB: %?", self.ty_to_str(t))) } } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 5273dbd30492f..62067a4bd7aae 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -368,7 +368,7 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) { } } // Fail so the process returns a failure code - die!(); + fail!(); } } } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index c595ebce65f1a..9669beae57589 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -119,7 +119,7 @@ fn parse_item_attrs( let attrs = match ctxt.ast_map.get(&id) { ast_map::node_item(item, _) => copy item.attrs, ast_map::node_foreign_item(item, _, _) => copy item.attrs, - _ => die!(~"parse_item_attrs: not an item") + _ => fail!(~"parse_item_attrs: not an item") }; parse_attrs(attrs) } @@ -183,7 +183,7 @@ fn fold_enum( copy ast_variant.node.attrs) } _ => { - die!(fmt!("Enum variant %s has id that's \ + fail!(fmt!("Enum variant %s has id that's \ not bound to an enum item", variant.name)) } @@ -258,7 +258,7 @@ fn merge_method_attrs( attr_parser::parse_desc(copy method.attrs)) }) } - _ => die!(~"unexpected item") + _ => fail!(~"unexpected item") } }; diff --git a/src/librustdoc/demo.rs b/src/librustdoc/demo.rs index ff6b745612dee..ffc0d668aed77 100644 --- a/src/librustdoc/demo.rs +++ b/src/librustdoc/demo.rs @@ -71,7 +71,7 @@ fn take_my_order_please( * This function is full of fail */ - die!(); + fail!(); } mod fortress_of_solitude { @@ -192,6 +192,6 @@ impl OmNomNomy: TheShunnedHouse { } fn construct(&self) -> bool { - die!(); + fail!(); } } diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index 822a423eae40c..0184945d6f8fd 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -322,7 +322,7 @@ fn structdoc_from_struct( fields: do struct_def.fields.map |field| { match field.node.kind { ast::named_field(ident, _, _) => to_str(ident), - ast::unnamed_field => die!( + ast::unnamed_field => fail!( ~"what is an unnamed struct field?") } }, diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 161642a2f3d97..bf499e2c5d0ec 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -539,7 +539,7 @@ fn write_sig(ctxt: &Ctxt, sig: Option<~str>) { ctxt.w.write_line(code_block_indent(sig)); ctxt.w.write_line(~""); } - None => die!(~"unimplemented") + None => fail!(~"unimplemented") } } diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index 9b5efb7c90dac..7577785d95422 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -145,7 +145,7 @@ fn pandoc_writer( if status != 0 { error!("pandoc-out: %s", stdout); error!("pandoc-err: %s", stderr); - die!(~"pandoc failed"); + fail!(~"pandoc failed"); } } } @@ -287,7 +287,7 @@ fn write_file(path: &Path, s: ~str) { result::Ok(writer) => { writer.write_str(s); } - result::Err(e) => die!(e) + result::Err(e) => fail!(e) } } diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 58a2e0e13246e..c14eb32022fb1 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -80,7 +80,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> { Some(pprust::fun_to_str(*decl, ident, copy *tys, extract::interner())) } - _ => die!(~"get_fn_sig: fn_id not bound to a fn item") + _ => fail!(~"get_fn_sig: fn_id not bound to a fn item") } } } @@ -113,7 +113,7 @@ fn fold_const( }, _) => { pprust::ty_to_str(ty, extract::interner()) } - _ => die!(~"fold_const: id not bound to a const item") + _ => fail!(~"fold_const: id not bound to a const item") } }}), .. doc @@ -150,7 +150,7 @@ fn fold_enum( pprust::variant_to_str( ast_variant, extract::interner()) } - _ => die!(~"enum variant not bound to an enum item") + _ => fail!(~"enum variant not bound to an enum item") } } }; @@ -229,7 +229,7 @@ fn get_method_sig( } } } - _ => die!(~"method not found") + _ => fail!(~"method not found") } } ast_map::node_item(@ast::item { @@ -246,10 +246,10 @@ fn get_method_sig( extract::interner() )) } - None => die!(~"method not found") + None => fail!(~"method not found") } } - _ => die!(~"get_method_sig: item ID not bound to trait or impl") + _ => fail!(~"get_method_sig: item ID not bound to trait or impl") } } } @@ -282,7 +282,7 @@ fn fold_impl( Some(pprust::ty_to_str( self_ty, extract::interner()))) } - _ => die!(~"expected impl") + _ => fail!(~"expected impl") } } }; @@ -315,7 +315,7 @@ fn should_add_impl_self_ty() { #[test] fn should_add_impl_method_sigs() { - let doc = test::mk_doc(~"impl int { fn a() -> int { die!() } }"); + let doc = test::mk_doc(~"impl int { fn a() -> int { fail!() } }"); assert doc.cratemod().impls()[0].methods[0].sig == Some(~"fn a() -> int"); } @@ -345,7 +345,7 @@ fn fold_type( extract::interner()) )) } - _ => die!(~"expected type") + _ => fail!(~"expected type") } } }, @@ -375,7 +375,7 @@ fn fold_struct( Some(pprust::item_to_str(item, extract::interner())) } - _ => die!(~"not an item") + _ => fail!(~"not an item") } } }, @@ -396,7 +396,7 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item { }; ast::item_struct(def, tys) } - _ => die!(~"not a struct") + _ => fail!(~"not a struct") }; @ast::item { diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index 062d784116039..87beeaf4ec210 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -178,10 +178,10 @@ fn run(repl: Repl, input: ~str) -> Repl { ast::expr_call(_, exprs, _) => { match exprs[0].node { ast::expr_block(blk) => @blk, - _ => die!() + _ => fail!() } } - _ => die!() + _ => fail!() }; debug!("recording input into repl history"); record(repl, blk, sess.parse_sess.interner) @@ -320,7 +320,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer, let mut end_multiline = false; while (!end_multiline) { match get_line(~"rusti| ") { - None => die!(~"unterminated multiline command :{ .. :}"), + None => fail!(~"unterminated multiline command :{ .. :}"), Some(line) => { if str::trim(line) == ~":}" { end_multiline = true; diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index ff28d2cbebf6f..0a51a7ef19145 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -224,7 +224,7 @@ pub fn unwrap_mutex_arc(arc: MutexARC) -> T { let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } = move inner; if failed { - die!(~"Can't unwrap poisoned MutexARC - another task failed inside!") + fail!(~"Can't unwrap poisoned MutexARC - another task failed inside!") } move data } @@ -235,9 +235,9 @@ pub fn unwrap_mutex_arc(arc: MutexARC) -> T { fn check_poison(is_mutex: bool, failed: bool) { if failed { if is_mutex { - die!(~"Poisoned MutexARC - another task failed inside!"); + fail!(~"Poisoned MutexARC - another task failed inside!"); } else { - die!(~"Poisoned rw_arc - another task failed inside!"); + fail!(~"Poisoned rw_arc - another task failed inside!"); } } } @@ -423,7 +423,7 @@ pub fn unwrap_rw_arc(arc: RWARC) -> T { let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } = move inner; if failed { - die!(~"Can't unwrap poisoned RWARC - another task failed inside!") + fail!(~"Can't unwrap poisoned RWARC - another task failed inside!") } move data } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index a2cbe27ea9045..9beb8e276ef98 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -303,6 +303,6 @@ fn test_arena_destructors_fail() { // get freed too. do arena.alloc { @20 }; // Now fail. - die!(); + fail!(); }; } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index d9e121798f183..10ea113f74e52 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -63,7 +63,7 @@ impl &[u8]: ToBase64 { str::push_char(&mut s, chars[(n >> 6u) & 63u]); str::push_char(&mut s, '='); } - _ => die!(~"Algebra is broken, please alert the math police") + _ => fail!(~"Algebra is broken, please alert the math police") } } s @@ -82,7 +82,7 @@ pub trait FromBase64 { impl ~[u8]: FromBase64 { pure fn from_base64() -> ~[u8] { - if self.len() % 4u != 0u { die!(~"invalid base64 length"); } + if self.len() % 4u != 0u { fail!(~"invalid base64 length"); } let len = self.len(); let mut padding = 0u; @@ -124,10 +124,10 @@ impl ~[u8]: FromBase64 { r.push(((n >> 10u) & 0xFFu) as u8); return copy r; } - _ => die!(~"invalid base64 padding") + _ => fail!(~"invalid base64 padding") } } else { - die!(~"invalid base64 character"); + fail!(~"invalid base64 character"); } i += 1u; diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 092a0d18a0fe4..2c713e58e9a86 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -245,7 +245,7 @@ impl BigUint : Modulo { } impl BigUint : Neg { - pure fn neg(&self) -> BigUint { die!() } + pure fn neg(&self) -> BigUint { fail!() } } impl BigUint : IntConvertible { @@ -332,7 +332,7 @@ pub impl BigUint { } pure fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) { - if other.is_zero() { die!() } + if other.is_zero() { fail!() } if self.is_zero() { return (Zero::zero(), Zero::zero()); } if *other == One::one() { return (copy *self, Zero::zero()); } @@ -523,7 +523,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) { 14 => (1475789056, 8), 15 => (2562890625, 8), 16 => (4294967296, 8), - _ => die!() + _ => fail!() } } @@ -547,7 +547,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) { 14 => (38416, 4), 15 => (50625, 4), 16 => (65536, 4), - _ => die!() + _ => fail!() } } @@ -797,7 +797,7 @@ pub impl BigInt { let d = BigInt::from_biguint(Plus, d_ui), m = BigInt::from_biguint(Plus, m_ui); match (self.sign, other.sign) { - (_, Zero) => die!(), + (_, Zero) => fail!(), (Plus, Plus) | (Zero, Plus) => (d, m), (Plus, Minus) | (Zero, Minus) => if m.is_zero() { (-d, Zero::zero()) @@ -828,7 +828,7 @@ pub impl BigInt { let q = BigInt::from_biguint(Plus, q_ui); let r = BigInt::from_biguint(Plus, r_ui); match (self.sign, other.sign) { - (_, Zero) => die!(), + (_, Zero) => fail!(), (Plus, Plus) | (Zero, Plus) => ( q, r), (Plus, Minus) | (Zero, Minus) => (-q, r), (Minus, Plus) => (-q, -r), @@ -1193,7 +1193,7 @@ mod biguint_tests { ~"2" + str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"), (10, match bits { - 32 => ~"8589934593", 16 => ~"131073", _ => die!() + 32 => ~"8589934593", 16 => ~"131073", _ => fail!() }), (16, ~"2" + @@ -1210,7 +1210,7 @@ mod biguint_tests { (10, match bits { 32 => ~"55340232229718589441", 16 => ~"12885032961", - _ => die!() + _ => fail!() }), (16, ~"3" + str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" + @@ -1257,7 +1257,7 @@ mod biguint_tests { fn check(n: uint, s: &str) { let n = factor(n); let ans = match BigUint::from_str_radix(s, 10) { - Some(x) => x, None => die!() + Some(x) => x, None => fail!() }; assert n == ans; } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index a94c4f790641d..d62fb2e8f6ec3 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -240,7 +240,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv { priv impl Bitv { fn die() -> ! { - die!(~"Tried to do operation on bit vectors with different sizes"); + fail!(~"Tried to do operation on bit vectors with different sizes"); } #[inline(always)] @@ -985,7 +985,7 @@ mod tests { let b = Bitv(14, true); b.clear(); for b.ones |i| { - die!(fmt!("found 1 at %?", i)); + fail!(fmt!("found 1 at %?", i)); } } @@ -994,7 +994,7 @@ mod tests { let b = Bitv(140, true); b.clear(); for b.ones |i| { - die!(fmt!("found 1 at %?", i)); + fail!(fmt!("found 1 at %?", i)); } } } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 10a896a40896f..f0ec3c1b9d767 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -32,7 +32,7 @@ impl Cell { /// Yields the value, failing if the cell is empty. fn take() -> T { if self.is_empty() { - die!(~"attempt to take an empty cell"); + fail!(~"attempt to take an empty cell"); } let mut value = None; @@ -43,7 +43,7 @@ impl Cell { /// Returns the value, failing if the cell is full. fn put_back(value: T) { if !self.is_empty() { - die!(~"attempt to put a value back into a full cell"); + fail!(~"attempt to put a value back into a full cell"); } self.value = Some(move value); } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 465c5d8f8feea..7d819ba0b3f22 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -57,7 +57,7 @@ pub fn create() -> Deque { move rv } fn get(elts: &DVec>, i: uint) -> T { - match (*elts).get_elt(i) { Some(move t) => t, _ => die!() } + match (*elts).get_elt(i) { Some(move t) => t, _ => fail!() } } struct Repr { diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 768d2dbf2d4ba..c332c7656b4c4 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -107,7 +107,7 @@ pub mod reader { (data[start + 2u] as uint) << 8u | (data[start + 3u] as uint), next: start + 4u}; - } else { error!("vint too big"); die!(); } + } else { error!("vint too big"); fail!(); } } pub fn Doc(data: @~[u8]) -> Doc { @@ -143,7 +143,7 @@ pub mod reader { Some(d) => d, None => { error!("failed to find block with tag %u", tg); - die!(); + fail!(); } } } @@ -230,7 +230,7 @@ pub mod reader { self.pos = r_doc.end; let str = doc_as_str(r_doc); if lbl != str { - die!(fmt!("Expected label %s but found %s", lbl, + fail!(fmt!("Expected label %s but found %s", lbl, str)); } } @@ -240,7 +240,7 @@ pub mod reader { fn next_doc(exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { - die!(~"no more documents in current node!"); + fail!(~"no more documents in current node!"); } let TaggedDoc { tag: r_tag, doc: r_doc } = doc_at(self.parent.data, self.pos); @@ -248,11 +248,11 @@ pub mod reader { copy self.parent.start, copy self.parent.end, copy self.pos, r_tag, r_doc.start, r_doc.end); if r_tag != (exp_tag as uint) { - die!(fmt!("expected EBML doc with tag %? but found tag %?", + fail!(fmt!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag)); } if r_doc.end > self.parent.end { - die!(fmt!("invalid EBML, child extends to 0x%x, \ + fail!(fmt!("invalid EBML, child extends to 0x%x, \ parent to 0x%x", r_doc.end, self.parent.end)); } self.pos = r_doc.end; @@ -295,7 +295,7 @@ pub mod reader { fn read_uint(&self) -> uint { let v = doc_as_u64(self.next_doc(EsUint)); if v > (::core::uint::max_value as u64) { - die!(fmt!("uint %? too large for this architecture", v)); + fail!(fmt!("uint %? too large for this architecture", v)); } v as uint } @@ -307,7 +307,7 @@ pub mod reader { fn read_int(&self) -> int { let v = doc_as_u64(self.next_doc(EsInt)) as i64; if v > (int::max_value as i64) || v < (int::min_value as i64) { - die!(fmt!("int %? out of range for this architecture", v)); + fail!(fmt!("int %? out of range for this architecture", v)); } v as int } @@ -315,14 +315,14 @@ pub mod reader { fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) as bool } - fn read_f64(&self) -> f64 { die!(~"read_f64()"); } - fn read_f32(&self) -> f32 { die!(~"read_f32()"); } - fn read_float(&self) -> float { die!(~"read_float()"); } + fn read_f64(&self) -> f64 { fail!(~"read_f64()"); } + fn read_f32(&self) -> f32 { fail!(~"read_f32()"); } + fn read_float(&self) -> float { fail!(~"read_float()"); } - fn read_char(&self) -> char { die!(~"read_char()"); } + fn read_char(&self) -> char { fail!(~"read_char()"); } fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } - fn read_managed_str(&self) -> @str { die!(~"read_managed_str()"); } + fn read_managed_str(&self) -> @str { fail!(~"read_managed_str()"); } // Compound types: fn read_owned(&self, f: fn() -> T) -> T { @@ -431,7 +431,7 @@ pub mod writer { n as u8]), 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, (n >> 8_u) as u8, n as u8]), - _ => die!(fmt!("vint to write too big: %?", n)) + _ => fail!(fmt!("vint to write too big: %?", n)) }; } @@ -440,7 +440,7 @@ pub mod writer { if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } - die!(fmt!("vint to write too big: %?", n)); + fail!(fmt!("vint to write too big: %?", n)); } pub fn Encoder(w: io::Writer) -> Encoder { @@ -602,17 +602,17 @@ pub mod writer { // FIXME (#2742): implement these fn emit_f64(&self, _v: f64) { - die!(~"Unimplemented: serializing an f64"); + fail!(~"Unimplemented: serializing an f64"); } fn emit_f32(&self, _v: f32) { - die!(~"Unimplemented: serializing an f32"); + fail!(~"Unimplemented: serializing an f32"); } fn emit_float(&self, _v: float) { - die!(~"Unimplemented: serializing a float"); + fail!(~"Unimplemented: serializing a float"); } fn emit_char(&self, _v: char) { - die!(~"Unimplemented: serializing a char"); + fail!(~"Unimplemented: serializing a char"); } fn emit_borrowed_str(&self, v: &str) { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index ba95fa5b66137..a7507a971c85f 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -262,7 +262,7 @@ pub impl,P:BytePort> FlatPort: GenericPort { fn recv() -> T { match self.try_recv() { Some(move val) => move val, - None => die!(~"port is closed") + None => fail!(~"port is closed") } } fn try_recv() -> Option { @@ -298,7 +298,7 @@ pub impl,P:BytePort> FlatPort: GenericPort { } } else { - die!(~"flatpipe: unrecognized command"); + fail!(~"flatpipe: unrecognized command"); } } } @@ -480,7 +480,7 @@ pub mod flatteners { Ok(move json) => { json::Decoder(move json) } - Err(e) => die!(fmt!("flatpipe: can't parse json: %?", e)) + Err(e) => fail!(fmt!("flatpipe: can't parse json: %?", e)) } } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 57b768a742f3c..ec71c30242cf2 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -65,14 +65,14 @@ impl Future { unsafe { match self.state { Forced(ref mut v) => { return cast::transmute(v); } - Evaluating => die!(~"Recursive forcing of future!"), + Evaluating => fail!(~"Recursive forcing of future!"), Pending(_) => {} } let mut state = Evaluating; self.state <-> state; match move state { - Forced(_) | Evaluating => die!(~"Logic error."), + Forced(_) | Evaluating => fail!(~"Logic error."), Pending(move f) => { self.state = Forced(move f()); self.get_ref() @@ -195,7 +195,7 @@ pub mod test { #[should_fail] #[ignore(cfg(target_os = "win32"))] pub fn test_futurefail() { - let f = spawn(|| die!()); + let f = spawn(|| fail!()); let _x: ~str = f.get(); } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index e3f8ef1b2b53b..3d6d0b1bb7d6b 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -349,7 +349,7 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] { Some(id) => mm.vals[id], None => { error!("No option '%s' defined", nm); - die!() + fail!() } }; } @@ -385,7 +385,7 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool { * argument */ pub fn opt_str(mm: &Matches, nm: &str) -> ~str { - return match opt_val(mm, nm) { Val(copy s) => s, _ => die!() }; + return match opt_val(mm, nm) { Val(copy s) => s, _ => fail!() }; } /** @@ -401,7 +401,7 @@ pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str { _ => () } } - die!(); + fail!(); } @@ -551,7 +551,7 @@ pub mod groups { match ((*lopt).short_name.len(), (*lopt).long_name.len()) { - (0,0) => die!(~"this long-format option was given no name"), + (0,0) => fail!(~"this long-format option was given no name"), (0,_) => ~[Opt {name: Long(((*lopt).long_name)), hasarg: (*lopt).hasarg, @@ -568,7 +568,7 @@ pub mod groups { hasarg: (*lopt).hasarg, occur: (*lopt).occur}], - (_,_) => die!(~"something is wrong with the long-form opt") + (_,_) => fail!(~"something is wrong with the long-form opt") } } @@ -599,7 +599,7 @@ pub mod groups { row += match short_name.len() { 0 => ~"", 1 => ~"-" + short_name + " ", - _ => die!(~"the short name should only be 1 char long"), + _ => fail!(~"the short name should only be 1 char long"), }; // long option @@ -669,7 +669,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => { die!(~"test_reqopt_long failed"); } + _ => { fail!(~"test_reqopt_long failed"); } } } @@ -680,7 +680,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionMissing_), - _ => die!() + _ => fail!() } } @@ -691,7 +691,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -702,7 +702,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -716,7 +716,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => die!() + _ => fail!() } } @@ -727,7 +727,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionMissing_), - _ => die!() + _ => fail!() } } @@ -738,7 +738,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -749,7 +749,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -765,7 +765,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => die!() + _ => fail!() } } @@ -776,7 +776,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => die!() + _ => fail!() } } @@ -787,7 +787,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -798,7 +798,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -812,7 +812,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => die!() + _ => fail!() } } @@ -823,7 +823,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => die!() + _ => fail!() } } @@ -834,7 +834,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -845,7 +845,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -858,7 +858,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (opt_present(m, ~"test")), - _ => die!() + _ => fail!() } } @@ -869,7 +869,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => die!() + _ => fail!() } } @@ -883,7 +883,7 @@ mod tests { log(error, fail_str(f)); check_fail_type(f, UnexpectedArgument_); } - _ => die!() + _ => fail!() } } @@ -894,7 +894,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -905,7 +905,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (opt_present(m, ~"t")), - _ => die!() + _ => fail!() } } @@ -916,7 +916,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => die!() + _ => fail!() } } @@ -931,7 +931,7 @@ mod tests { assert (m.free[0] == ~"20"); } - _ => die!() + _ => fail!() } } @@ -942,7 +942,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => die!() + _ => fail!() } } @@ -956,7 +956,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 1); } - _ => die!() + _ => fail!() } } @@ -969,7 +969,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 2); } - _ => die!() + _ => fail!() } } @@ -982,7 +982,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 2); } - _ => die!() + _ => fail!() } } @@ -995,7 +995,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"verbose") == 1); } - _ => die!() + _ => fail!() } } @@ -1008,7 +1008,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"verbose") == 2); } - _ => die!() + _ => fail!() } } @@ -1023,7 +1023,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => die!() + _ => fail!() } } @@ -1034,7 +1034,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => die!() + _ => fail!() } } @@ -1045,7 +1045,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -1062,7 +1062,7 @@ mod tests { assert (pair[0] == ~"20"); assert (pair[1] == ~"30"); } - _ => die!() + _ => fail!() } } @@ -1076,7 +1076,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => die!() + _ => fail!() } } @@ -1087,7 +1087,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => die!() + _ => fail!() } } @@ -1098,7 +1098,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => die!() + _ => fail!() } } @@ -1115,7 +1115,7 @@ mod tests { assert (pair[0] == ~"20"); assert (pair[1] == ~"30"); } - _ => die!() + _ => fail!() } } @@ -1126,7 +1126,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, UnrecognizedOption_), - _ => die!() + _ => fail!() } } @@ -1137,7 +1137,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, UnrecognizedOption_), - _ => die!() + _ => fail!() } } @@ -1169,7 +1169,7 @@ mod tests { assert (pair[1] == ~"-60 70"); assert (!opt_present(m, ~"notpresent")); } - _ => die!() + _ => fail!() } } @@ -1179,7 +1179,7 @@ mod tests { let opts = ~[optopt(~"e"), optopt(~"encrypt")]; let matches = &match getopts(args, opts) { result::Ok(move m) => m, - result::Err(_) => die!() + result::Err(_) => fail!() }; assert opts_present(matches, ~[~"e"]); assert opts_present(matches, ~[~"encrypt"]); @@ -1200,7 +1200,7 @@ mod tests { let opts = ~[optmulti(~"L"), optmulti(~"M")]; let matches = &match getopts(args, opts) { result::Ok(move m) => m, - result::Err(_) => die!() + result::Err(_) => fail!() }; assert opts_present(matches, ~[~"L"]); assert opts_str(matches, ~[~"L"]) == ~"foo"; diff --git a/src/libstd/json.rs b/src/libstd/json.rs index d5ad2f7fce735..95f9130fa372f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -257,7 +257,7 @@ pub impl PrettyEncoder: serialize::Encoder { fn emit_managed(&self, f: fn()) { f() } fn emit_enum(&self, name: &str, f: fn()) { - if name != "option" { die!(~"only supports option enum") } + if name != "option" { fail!(~"only supports option enum") } f() } fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { @@ -773,7 +773,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_nil"); match *self.pop() { Null => (), - _ => die!(~"not a null") + _ => fail!(~"not a null") } } @@ -793,7 +793,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_bool"); match *self.pop() { Boolean(b) => b, - _ => die!(~"not a boolean") + _ => fail!(~"not a boolean") } } @@ -803,13 +803,13 @@ pub impl Decoder: serialize::Decoder { debug!("read_float"); match *self.pop() { Number(f) => f, - _ => die!(~"not a number") + _ => fail!(~"not a number") } } fn read_char(&self) -> char { let v = str::chars(self.read_owned_str()); - if v.len() != 1 { die!(~"string must have one character") } + if v.len() != 1 { fail!(~"string must have one character") } v[0] } @@ -817,7 +817,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_str"); match *self.pop() { String(ref s) => copy *s, - _ => die!(~"not a string") + _ => fail!(~"not a string") } } @@ -825,7 +825,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_managed_str"); match *self.pop() { String(ref s) => s.to_managed(), - _ => die!(~"not a string") + _ => fail!(~"not a string") } } @@ -841,7 +841,7 @@ pub impl Decoder: serialize::Decoder { fn read_enum(&self, name: &str, f: fn() -> T) -> T { debug!("read_enum(%s)", name); - if name != ~"option" { die!(~"only supports the option enum") } + if name != ~"option" { fail!(~"only supports the option enum") } f() } @@ -856,7 +856,7 @@ pub impl Decoder: serialize::Decoder { fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); - if idx != 0 { die!(~"unknown index") } + if idx != 0 { fail!(~"unknown index") } f() } @@ -864,7 +864,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), - _ => die!(~"not a list"), + _ => fail!(~"not a list"), }; let res = f(len); self.pop(); @@ -875,7 +875,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), - _ => die!(~"not a list"), + _ => fail!(~"not a list"), }; let res = f(len); self.pop(); @@ -889,7 +889,7 @@ pub impl Decoder: serialize::Decoder { self.stack.push(&list[idx]); f() } - _ => die!(~"not a list"), + _ => fail!(~"not a list"), } } @@ -913,20 +913,20 @@ pub impl Decoder: serialize::Decoder { match *top { Object(ref obj) => { match obj.find(&name.to_owned()) { - None => die!(fmt!("no such field: %s", name)), + None => fail!(fmt!("no such field: %s", name)), Some(json) => { self.stack.push(json); f() } } } - Number(_) => die!(~"num"), - String(_) => die!(~"str"), - Boolean(_) => die!(~"bool"), - List(_) => die!(fmt!("list: %?", top)), - Null => die!(~"null"), + Number(_) => fail!(~"num"), + String(_) => fail!(~"str"), + Boolean(_) => fail!(~"bool"), + List(_) => fail!(fmt!("list: %?", top)), + Null => fail!(~"null"), - //_ => die!(fmt!("not an object: %?", *top)) + //_ => fail!(fmt!("not an object: %?", *top)) } } @@ -944,7 +944,7 @@ pub impl Decoder: serialize::Decoder { self.stack.push(&list[idx]); f() } - _ => die!(~"not a list") + _ => fail!(~"not a list") } } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 140c2013738de..5feac4ad454cd 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -93,7 +93,7 @@ pub pure fn len(ls: @List) -> uint { pub pure fn tail(ls: @List) -> @List { match *ls { Cons(_, tl) => return tl, - Nil => die!(~"list empty") + Nil => fail!(~"list empty") } } @@ -102,7 +102,7 @@ pub pure fn head(ls: @List) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad - _ => die!(~"head invoked on empty list") + _ => fail!(~"head invoked on empty list") } } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 511e80b0160f6..2f423f4c8d426 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -63,14 +63,14 @@ pub fn format_addr(ip: &IpAddr) -> ~str { Ipv4(ref addr) => unsafe { let result = uv_ip4_name(addr); if result == ~"" { - die!(~"failed to convert inner sockaddr_in address to str") + fail!(~"failed to convert inner sockaddr_in address to str") } result }, Ipv6(ref addr) => unsafe { let result = uv_ip6_name(addr); if result == ~"" { - die!(~"failed to convert inner sockaddr_in address to str") + fail!(~"failed to convert inner sockaddr_in address to str") } result } @@ -182,7 +182,7 @@ pub mod v4 { pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(move addr) => move addr, - result::Err(ref err_data) => die!(err_data.err_msg) + result::Err(ref err_data) => fail!(err_data.err_msg) } } // the simple, old style numberic representation of @@ -277,7 +277,7 @@ pub mod v6 { pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(move addr) => move addr, - result::Err(copy err_data) => die!(err_data.err_msg) + result::Err(copy err_data) => fail!(err_data.err_msg) } } pub fn try_parse_addr(ip: &str) -> result::Result { @@ -399,7 +399,7 @@ mod test { assert true; } result::Ok(ref addr) => { - die!(fmt!("Expected failure, but got addr %?", addr)); + fail!(fmt!("Expected failure, but got addr %?", addr)); } } } @@ -412,7 +412,7 @@ mod test { assert true; } result::Ok(ref addr) => { - die!(fmt!("Expected failure, but got addr %?", addr)); + fail!(fmt!("Expected failure, but got addr %?", addr)); } } } @@ -423,7 +423,7 @@ mod test { let iotask = &uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); if result::is_err(&ga_result) { - die!(~"got err result from net::ip::get_addr();") + fail!(~"got err result from net::ip::get_addr();") } // note really sure how to realiably test/assert // this.. mostly just wanting to see it work, atm. diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index c90518f1692b1..8addea9c30bb1 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -941,7 +941,7 @@ impl TcpSocketBuf: io::Reader { } else { debug!("ERROR sock_buf as io::reader.read err %? %?", err_data.err_name, err_data.err_msg); - die!() + fail!() } } else { @@ -1645,7 +1645,7 @@ pub mod test { hl_loop); match actual_resp_result.get_err() { ConnectionRefused => (), - _ => die!(~"unknown error.. expected connection_refused") + _ => fail!(~"unknown error.. expected connection_refused") } } pub fn impl_gl_tcp_ipv4_server_address_in_use() { @@ -1686,7 +1686,7 @@ pub mod test { assert true; } _ => { - die!(~"expected address_in_use listen error,"+ + fail!(~"expected address_in_use listen error,"+ ~"but got a different error varient. check logs."); } } @@ -1705,7 +1705,7 @@ pub mod test { assert true; } _ => { - die!(~"expected address_in_use listen error,"+ + fail!(~"expected address_in_use listen error,"+ ~"but got a different error varient. check logs."); } } @@ -1885,14 +1885,14 @@ pub mod test { if result::is_err(&listen_result) { match result::get_err(&listen_result) { GenericListenErr(ref name, ref msg) => { - die!(fmt!("SERVER: exited abnormally name %s msg %s", + fail!(fmt!("SERVER: exited abnormally name %s msg %s", *name, *msg)); } AccessDenied => { - die!(~"SERVER: exited abnormally, got access denied.."); + fail!(~"SERVER: exited abnormally, got access denied.."); } AddressInUse => { - die!(~"SERVER: exited abnormally, got address in use..."); + fail!(~"SERVER: exited abnormally, got address in use..."); } } } @@ -1911,7 +1911,7 @@ pub mod test { debug!("establish_cb %?", kill_ch); }, |new_conn, kill_ch| { - die!(fmt!("SERVER: shouldn't be called.. %? %?", + fail!(fmt!("SERVER: shouldn't be called.. %? %?", new_conn, kill_ch)); }); // err check on listen_result @@ -1919,7 +1919,7 @@ pub mod test { result::get_err(&listen_result) } else { - die!(~"SERVER: did not fail as expected") + fail!(~"SERVER: did not fail as expected") } } @@ -1963,7 +1963,7 @@ pub mod test { debug!("tcp_write_single err name: %s msg: %s", err_data.err_name, err_data.err_msg); // meh. torn on what to do here. - die!(~"tcp_write_single failed"); + fail!(~"tcp_write_single failed"); } } } diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index cea6d17e35d77..900b7068ce3d3 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -319,7 +319,7 @@ pub mod chained { pure fn get(&self, k: &K) -> V { let opt_v = self.find(k); if opt_v.is_none() { - die!(fmt!("Key not found in table: %?", k)); + fail!(fmt!("Key not found in table: %?", k)); } option::unwrap(move opt_v) } diff --git a/src/libstd/oldsmallintmap.rs b/src/libstd/oldsmallintmap.rs index 803e75e4cf7a3..c9e739e3c8b83 100644 --- a/src/libstd/oldsmallintmap.rs +++ b/src/libstd/oldsmallintmap.rs @@ -67,7 +67,7 @@ pub pure fn get(self: SmallIntMap, key: uint) -> T { match find(self, key) { None => { error!("smallintmap::get(): key not present"); - die!(); + fail!(); } Some(move v) => return v } diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index dbfa771e0a256..8ff90b940fb56 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -98,7 +98,7 @@ pub fn of_str(str: @~str) -> Rope { */ pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } - if byte_offset + byte_len > str::len(*str) { die!(); } + if byte_offset + byte_len > str::len(*str) { fail!(); } return node::Content(node::of_substr(str, byte_offset, byte_len)); } @@ -244,9 +244,9 @@ Section: Transforming ropes pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { if char_len == 0u { return node::Empty; } match (rope) { - node::Empty => die!(), + node::Empty => fail!(), node::Content(node) => if char_len > node::char_len(node) { - die!() + fail!() } else { return node::Content(node::sub_chars(node, char_offset, char_len)) } @@ -269,9 +269,9 @@ pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } match (rope) { - node::Empty => die!(), + node::Empty => fail!(), node::Content(node) =>if byte_len > node::byte_len(node) { - die!() + fail!() } else { return node::Content(node::sub_bytes(node, byte_offset, byte_len)) } @@ -548,7 +548,7 @@ pub pure fn byte_len(rope: Rope) -> uint { */ pub fn char_at(rope: Rope, pos: uint) -> char { match (rope) { - node::Empty => die!(), + node::Empty => fail!(), node::Content(x) => return node::char_at(x, pos) } } diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 972df73d21609..d4afdbf6f3094 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -389,7 +389,7 @@ pub impl> Option: Decodable { 0 => None, 1 => Some(d.read_enum_variant_arg( 0u, || Decodable::decode(d))), - _ => die!(fmt!("Bad variant for option: %u", i)) + _ => fail!(fmt!("Bad variant for option: %u", i)) } } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 788d1d1012d2a..e89f37878300c 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -83,7 +83,7 @@ pub fn sha1() -> Sha1 { st.len_high += 1u32; if st.len_high == 0u32 { // FIXME: Need better failure mode (#2346) - die!(); + fail!(); } } if st.msg_block_idx == msg_block_len { process_msg_block(st); } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 9c7d31e15f3fd..f8acbe8418086 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -546,7 +546,7 @@ impl MergeState { copy_vec(array, dest, array, c2, len2); array[dest+len2] <-> tmp[c1]; } else if len1 == 0 { - die!(~"Comparison violates its contract!"); + fail!(~"Comparison violates its contract!"); } else { assert len2 == 0; assert len1 > 1; @@ -664,7 +664,7 @@ impl MergeState { copy_vec(array, dest+1, array, c1+1, len1); array[dest] <-> tmp[c2]; } else if len2 == 0 { - die!(~"Comparison violates its contract!"); + fail!(~"Comparison violates its contract!"); } else { assert len1 == 0; assert len2 != 0; @@ -912,7 +912,7 @@ mod test_tim_sort { pure fn lt(&self, other: &CVal) -> bool { unsafe { let rng = rand::Rng(); - if rng.gen_float() > 0.995 { die!(~"It's happening!!!"); } + if rng.gen_float() > 0.995 { fail!(~"It's happening!!!"); } } (*self).val < other.val } @@ -968,7 +968,7 @@ mod test_tim_sort { }; tim_sort(arr); - die!(~"Guarantee the fail"); + fail!(~"Guarantee the fail"); } struct DVal { val: uint } @@ -1036,7 +1036,7 @@ mod big_tests { fn isSorted(arr: &[const T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { - die!(~"Array not sorted"); + fail!(~"Array not sorted"); } } } @@ -1108,7 +1108,7 @@ mod big_tests { fn isSorted(arr: &[const @T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { - die!(~"Array not sorted"); + fail!(~"Array not sorted"); } } } @@ -1191,7 +1191,7 @@ mod big_tests { task::local_data::local_data_set(self.key, @(y+1)); } } - _ => die!(~"Expected key to work"), + _ => fail!(~"Expected key to work"), } } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index b7e75897bf1e9..8a5741201c009 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -333,10 +333,10 @@ fn check_cvar_bounds(out_of_bounds: Option, id: uint, act: &str, blk: fn() -> U) -> U { match out_of_bounds { Some(0) => - die!(fmt!("%s with illegal ID %u - this lock has no condvars!", + fail!(fmt!("%s with illegal ID %u - this lock has no condvars!", act, id)), Some(length) => - die!(fmt!("%s with illegal ID %u - ID must be less than %u", + fail!(fmt!("%s with illegal ID %u - ID must be less than %u", act, id, length)), None => blk() } @@ -580,7 +580,7 @@ impl &RWlock { /// To be called inside of the write_downgrade block. fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a { if !ptr::ref_eq(self, token.lock) { - die!(~"Can't downgrade() with a different rwlock's write_mode!"); + fail!(~"Can't downgrade() with a different rwlock's write_mode!"); } unsafe { do task::unkillable { @@ -933,7 +933,7 @@ mod tests { let result: result::Result<(),()> = do task::try |move m2| { do m2.lock { - die!(); + fail!(); } }; assert result.is_err(); @@ -952,7 +952,7 @@ mod tests { do task::spawn |move p| { // linked let _ = p.recv(); // wait for sibling to get in the mutex task::yield(); - die!(); + fail!(); } do m2.lock_cond |cond| { c.send(()); // tell sibling go ahead @@ -994,7 +994,7 @@ mod tests { } do m2.lock { } c.send(move sibling_convos); // let parent wait on all children - die!(); + fail!(); }; assert result.is_err(); // child task must have finished by the time try returns @@ -1048,7 +1048,7 @@ mod tests { let _ = p.recv(); do m.lock_cond |cond| { if !cond.signal_on(0) { - die!(); // success; punt sibling awake. + fail!(); // success; punt sibling awake. } } }; @@ -1288,7 +1288,7 @@ mod tests { let result: result::Result<(),()> = do task::try |move x2| { do lock_rwlock_in_mode(x2, mode1) { - die!(); + fail!(); } }; assert result.is_err(); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index f3e96826a8e59..530761e48a201 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -121,9 +121,9 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) { let opts = match parse_opts(args) { either::Left(move o) => o, - either::Right(move m) => die!(m) + either::Right(move m) => fail!(m) }; - if !run_tests_console(&opts, tests) { die!(~"Some tests failed"); } + if !run_tests_console(&opts, tests) { fail!(~"Some tests failed"); } } // A variant optimized for invocation with a static test vector. @@ -284,7 +284,7 @@ pub fn run_tests_console(opts: &TestOpts, io::Truncate]) { result::Ok(w) => Some(w), result::Err(ref s) => { - die!(fmt!("can't open output file: %s", *s)) + fail!(fmt!("can't open output file: %s", *s)) } }, None => None @@ -800,7 +800,7 @@ mod tests { #[test] pub fn do_not_run_ignored_tests() { - fn f() { die!(); } + fn f() { fail!(); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), @@ -837,7 +837,7 @@ mod tests { #[test] #[ignore(cfg(windows))] pub fn test_should_fail() { - fn f() { die!(); } + fn f() { fail!(); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), @@ -876,7 +876,7 @@ mod tests { let args = ~[~"progname", ~"filter"]; let opts = match parse_opts(args) { either::Left(copy o) => o, - _ => die!(~"Malformed arg in first_free_arg_should_be_a_filter") + _ => fail!(~"Malformed arg in first_free_arg_should_be_a_filter") }; assert ~"filter" == opts.filter.get(); } @@ -886,7 +886,7 @@ mod tests { let args = ~[~"progname", ~"filter", ~"--ignored"]; let opts = match parse_opts(args) { either::Left(copy o) => o, - _ => die!(~"Malformed arg in parse_ignored_flag") + _ => fail!(~"Malformed arg in parse_ignored_flag") }; assert (opts.run_ignored); } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index f696d239d30df..622e1ea65d8b5 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1040,7 +1040,7 @@ mod tests { == Err(~"Invalid time"); match strptime(~"Fri Feb 13 15:31:30 2009", format) { - Err(copy e) => die!(e), + Err(copy e) => fail!(e), Ok(ref tm) => { assert tm.tm_sec == 30_i32; assert tm.tm_min == 31_i32; @@ -1060,7 +1060,7 @@ mod tests { fn test(s: &str, format: &str) -> bool { match strptime(s, format) { Ok(ref tm) => tm.strftime(format) == str::from_slice(s), - Err(copy e) => die!(e) + Err(copy e) => fail!(e) } } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 1da1bc60314d2..6e1e6a331a296 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -67,12 +67,12 @@ pub fn delayed_send(iotask: &IoTask, } else { let error_msg = uv::ll::get_last_err_info( loop_ptr); - die!(~"timer::delayed_send() start failed: " + + fail!(~"timer::delayed_send() start failed: " + error_msg); } } else { let error_msg = uv::ll::get_last_err_info(loop_ptr); - die!(~"timer::delayed_send() init failed: " + + fail!(~"timer::delayed_send() init failed: " + error_msg); } } @@ -157,7 +157,7 @@ extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t, } else { let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); let error_msg = uv::ll::get_last_err_info(loop_ptr); - die!(~"timer::sleep() init failed: "+error_msg); + fail!(~"timer::sleep() init failed: "+error_msg); } } } diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 9763f655a6f4e..6621eef8b0b42 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -184,11 +184,11 @@ mod test { simple_timer_cb, 1u, 0u); if(start_status != 0i32) { - die!(~"failure on ll::timer_start()"); + fail!(~"failure on ll::timer_start()"); } } else { - die!(~"failure on ll::timer_init()"); + fail!(~"failure on ll::timer_init()"); } } }; diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 69116ace9e860..d78761b70e3ef 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -382,7 +382,7 @@ fn unwrap s; match move s { - None => die!(), + None => fail!(), Some(Left(move v)) => move v, Some(Right(move port)) => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b109333c3b590..949e9ff447c9b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -37,7 +37,7 @@ pub impl ident: Encodable { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => die!(~"encode: TLS interner not set up"), + None => fail!(~"encode: TLS interner not set up"), Some(intr) => intr }; @@ -50,7 +50,7 @@ pub impl ident: Decodable { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => die!(~"decode: TLS interner not set up"), + None => fail!(~"decode: TLS interner not set up"), Some(intr) => intr }; diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 8be4b219ded82..9eeee943f8b24 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -320,7 +320,7 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node, cx.map.insert(ctor_id, node_struct_ctor(struct_def, item, p)); } - _ => die!(~"struct def parent wasn't an item") + _ => fail!(~"struct def parent wasn't an item") } } } @@ -404,7 +404,7 @@ pub fn node_item_query(items: map, id: node_id, error_msg: ~str) -> Result { match items.find(&id) { Some(node_item(it, _)) => query(it), - _ => die!(error_msg) + _ => fail!(error_msg) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index c659d6d602048..335dd4e3fa247 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -44,7 +44,7 @@ pub pure fn stmt_id(s: stmt) -> node_id { stmt_decl(_, id) => id, stmt_expr(_, id) => id, stmt_semi(_, id) => id, - stmt_mac(*) => die!(~"attempted to analyze unexpanded stmt") + stmt_mac(*) => fail!(~"attempted to analyze unexpanded stmt") } } @@ -53,7 +53,7 @@ pub fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { def_variant(enum_id, var_id) => { return {enm: enum_id, var: var_id} } - _ => die!(~"non-variant in variant_def_ids") + _ => fail!(~"non-variant in variant_def_ids") } } @@ -71,7 +71,7 @@ pub pure fn def_id_of_def(d: def) -> def_id { local_def(id) } - def_prim_ty(_) => die!() + def_prim_ty(_) => fail!() } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index d258393e3b954..22f1e2d47533b 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -198,7 +198,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { // FIXME (#607): Needs implementing // This involves probably sorting the list by name and // meta_item variant - die!(~"unimplemented meta_item variant") + fail!(~"unimplemented meta_item variant") } } } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index a509325faceca..b41e84a04f81f 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -401,7 +401,7 @@ pub impl CodeMap { for self.files.each |fm| { if fm.name == filename { return *fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) - die!(); // ("asking for " + filename + " which we don't know about"); + fail!(); // ("asking for " + filename + " which we don't know about"); } } @@ -421,7 +421,7 @@ priv impl CodeMap { } } if (a >= len) { - die!(fmt!("position %u does not resolve to a source location", + fail!(fmt!("position %u does not resolve to a source location", pos.to_uint())) } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 51ef085839d6a..e44ee4eef0a8c 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -66,7 +66,7 @@ struct CodemapT { impl CodemapT: span_handler { fn span_fatal(@mut self, sp: span, msg: &str) -> ! { self.handler.emit(Some((self.cm, sp)), msg, fatal); - die!(); + fail!(); } fn span_err(@mut self, sp: span, msg: &str) { self.handler.emit(Some((self.cm, sp)), msg, error); @@ -92,7 +92,7 @@ impl CodemapT: span_handler { impl HandlerT: handler { fn fatal(@mut self, msg: &str) -> ! { (self.emit)(None, msg, fatal); - die!(); + fail!(); } fn err(@mut self, msg: &str) { (self.emit)(None, msg, error); diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index acbe4d7fa23ef..c854fca64248d 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -812,7 +812,7 @@ fn mk_struct_fields(fields: ~[@ast::struct_field]) -> ~[field] { do fields.map |field| { let (ident, mutbl) = match field.node.kind { ast::named_field(ident, mutbl, _) => (ident, mutbl), - _ => die!(~"[auto_encode] does not support \ + _ => fail!(~"[auto_encode] does not support \ unnamed fields") }; @@ -954,9 +954,9 @@ fn mk_enum_ser_body( ast::tuple_variant_kind(args) => ser_variant(cx, span, variant.node.name, v_idx, args), ast::struct_variant_kind(*) => - die!(~"struct variants unimplemented"), + fail!(~"struct variants unimplemented"), ast::enum_variant_kind(*) => - die!(~"enum variants unimplemented"), + fail!(~"enum variants unimplemented"), } }; @@ -1047,9 +1047,9 @@ fn mk_enum_deser_body( } }, ast::struct_variant_kind(*) => - die!(~"struct variants unimplemented"), + fail!(~"struct variants unimplemented"), ast::enum_variant_kind(*) => - die!(~"enum variants unimplemented") + fail!(~"enum variants unimplemented") }; let pat = @ast::pat { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 18256369c78af..17197f64c5556 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -292,7 +292,7 @@ pub fn core_macros() -> ~str { ::core::sys::begin_unwind($msg, file!().to_owned(), line!()) ); () => ( - die!(~\"explicit failure\") + fail!(~\"explicit failure\") ) ) @@ -301,14 +301,14 @@ pub fn core_macros() -> ~str { ::core::sys::begin_unwind($msg, file!().to_owned(), line!()) ); () => ( - die!(~\"explicit failure\") + fail!(~\"explicit failure\") ) ) macro_rules! fail_unless( ($cond:expr) => { if !$cond { - die!(~\"assertion failed: \" + stringify!($cond)) + fail!(~\"assertion failed: \" + stringify!($cond)) } } ) diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 1502332859cc3..6a1708b8e2b51 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -40,13 +40,13 @@ pub impl parser::Parser: proto_parser { self.expect(token::COLON); let dir = match copy self.token { token::IDENT(n, _) => self.interner.get(n), - _ => die!() + _ => fail!() }; self.bump(); let dir = match dir { @~"send" => send, @~"recv" => recv, - _ => die!() + _ => fail!() }; let typarms = if self.token == token::LT { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 4a9a22de50f50..4522c7e0fd6c2 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -184,7 +184,7 @@ pub mod rt { Some(ast) => ast, None => { error!("Parse error with ```\n%s\n```", s); - die!() + fail!() } } } @@ -399,7 +399,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { ~[mk_ident(cx, sp, ident)]); } - INTERPOLATED(_) => die!(~"quote! with interpolated token"), + INTERPOLATED(_) => fail!(~"quote! with interpolated token"), _ => () } @@ -437,7 +437,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { DOLLAR => "DOLLAR", UNDERSCORE => "UNDERSCORE", EOF => "EOF", - _ => die!() + _ => fail!() }; build::mk_path(cx, sp, ids_ext(cx, ~[name.to_owned()])) @@ -467,7 +467,7 @@ fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree) } ast::tt_delim(ref tts) => mk_tts(cx, sp, *tts), - ast::tt_seq(*) => die!(~"tt_seq in quote!"), + ast::tt_seq(*) => fail!(~"tt_seq in quote!"), ast::tt_nonterminal(sp, ident) => { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 4b1194bb5f174..9e89e703c09bb 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -124,7 +124,7 @@ pub type matcher_pos = ~{ pub fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { match &mpu { &matcher_pos_up(Some(ref mp)) => copy (*mp), - _ => die!() + _ => fail!() } } @@ -361,7 +361,7 @@ pub fn parse(sess: parse_sess, fmt!("%s ('%s')", *sess.interner.get(name), *sess.interner.get(bind)) } - _ => die!() + _ => fail!() } }), ~" or "); return error(sp, fmt!( "Local ambiguity: multiple parsing options: \ @@ -386,7 +386,7 @@ pub fn parse(sess: parse_sess, parse_nt(rust_parser, *sess.interner.get(name)))); ei.idx += 1u; } - _ => die!() + _ => fail!() } cur_eis.push(move ei); diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index a8db06fe08546..1e17cf3543dd6 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -117,7 +117,7 @@ pub fn strip_doc_comment_decoration(comment: ~str) -> ~str { return str::connect(lines, ~"\n"); } - die!(~"not a doc-comment: " + comment); + fail!(~"not a doc-comment: " + comment); } fn read_to_eol(rdr: @mut StringReader) -> ~str { @@ -297,7 +297,7 @@ fn consume_comment(rdr: @mut StringReader, read_block_comment(rdr, code_to_the_left, comments); } else if rdr.curr == '#' && nextch(rdr) == '!' { read_shebang_comment(rdr, code_to_the_left, comments); - } else { die!(); } + } else { fail!(); } debug!("<<< consume comment"); } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index e8afd0b96a2a5..48ba94bdc33b7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -215,7 +215,7 @@ fn hex_digit_val(c: char) -> int { if in_range(c, '0', '9') { return (c as int) - ('0' as int); } if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; } if in_range(c, 'A', 'F') { return (c as int) - ('A' as int) + 10; } - die!(); + fail!(); } fn bin_digit_value(c: char) -> int { if c == '0' { return 0; } return 1; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6382413b08169..1fcd99e19469e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2538,7 +2538,7 @@ pub impl Parser { _ => None } } - _ => die!() + _ => fail!() }; match maybe_bound { @@ -3907,7 +3907,7 @@ pub impl Parser { let metadata = self.parse_optional_meta(); view_item_use(ident, metadata, self.get_id()) } else { - die!(); + fail!(); }; self.expect(token::SEMI); @ast::view_item { node: node, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b8d756d893adf..dbcb3d756c809 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -210,7 +210,7 @@ pub fn to_str(in: @ident_interner, t: Token) -> ~str { nt_block(*) => ~"block", nt_stmt(*) => ~"statement", nt_pat(*) => ~"pattern", - nt_expr(*) => die!(~"should have been handled above"), + nt_expr(*) => fail!(~"should have been handled above"), nt_ty(*) => ~"type", nt_ident(*) => ~"identifier", nt_path(*) => ~"path", @@ -263,7 +263,7 @@ pub fn flip_delimiter(t: token::Token) -> token::Token { token::RPAREN => token::LPAREN, token::RBRACE => token::LBRACE, token::RBRACKET => token::LBRACKET, - _ => die!() + _ => fail!() } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 4b9767ca6c84b..aeebcce1f2b27 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -519,7 +519,7 @@ pub impl Printer { } EOF => { // EOF should never get here. - die!(); + fail!(); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7a60696c0a2d0..b05461aa8d98f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -440,10 +440,10 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) { word(s.s, ~"]"); } ast::ty_mac(_) => { - die!(~"print_type doesn't know how to print a ty_mac"); + fail!(~"print_type doesn't know how to print a ty_mac"); } ast::ty_infer => { - die!(~"print_type shouldn't see a ty_infer"); + fail!(~"print_type shouldn't see a ty_infer"); } } @@ -637,7 +637,7 @@ pub fn print_enum_def(s: @ps, enum_definition: ast::enum_def, word_space(s, ~"="); match enum_definition.variants[0].node.kind { ast::tuple_variant_kind(args) => print_type(s, args[0].ty), - _ => die!(~"newtype syntax with struct?") + _ => fail!(~"newtype syntax with struct?") } word(s.s, ~";"); end(s); @@ -706,7 +706,7 @@ pub fn print_struct(s: @ps, } match field.node.kind { - ast::named_field(*) => die!(~"unexpected named field"), + ast::named_field(*) => fail!(~"unexpected named field"), ast::unnamed_field => { maybe_print_comment(s, field.span.lo); print_type(s, field.node.ty); @@ -729,7 +729,7 @@ pub fn print_struct(s: @ps, for struct_def.fields.each |field| { match field.node.kind { - ast::unnamed_field => die!(~"unexpected unnamed field"), + ast::unnamed_field => fail!(~"unexpected unnamed field"), ast::named_field(ident, mutability, visibility) => { hardbreak_if_not_bol(s); maybe_print_comment(s, field.span.lo); @@ -1015,7 +1015,7 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: ast::blk, } // BLEAH, constraints would be great here _ => { - die!(~"print_if saw if with weird alternative"); + fail!(~"print_if saw if with weird alternative"); } } } @@ -1316,7 +1316,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } end(s); // close enclosing cbox } - None => die!() + None => fail!() } } else { // the block will close the pattern's ibox @@ -2257,7 +2257,7 @@ pub mod test { fn string_check (given : &T, expected: &T) { if !(given == expected) { - die!(fmt!("given %?, expected %?",given,expected)); + fail!(fmt!("given %?, expected %?",given,expected)); } } diff --git a/src/libsyntax/util/testing.rs b/src/libsyntax/util/testing.rs index 39d3b003e6645..b6d333349a091 100644 --- a/src/libsyntax/util/testing.rs +++ b/src/libsyntax/util/testing.rs @@ -13,12 +13,12 @@ use core::cmp; pub pure fn check_equal_ptr (given : &T, expected: &T) { if !((given == expected) && (expected == given )) { - die!(fmt!("given %?, expected %?",given,expected)); + fail!(fmt!("given %?, expected %?",given,expected)); } } pub pure fn check_equal (given : T, expected: T) { if !((given == expected) && (expected == given )) { - die!(fmt!("given %?, expected %?",given,expected)); + fail!(fmt!("given %?, expected %?",given,expected)); } } diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index e9f799d1f7501..8f1c3d5bb5f52 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -25,7 +25,7 @@ pub fn alist_get(lst: alist, k: A) -> B { for lst.data.each |entry| { if eq_fn(entry.key, k) { return entry.value; } } - die!(); + fail!(); } #[inline] diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs index a27d7a771c5c3..6007b1f3d175e 100644 --- a/src/test/auxiliary/issue2378a.rs +++ b/src/test/auxiliary/issue2378a.rs @@ -14,7 +14,7 @@ impl methods for maybe { fn ~[](idx: uint) -> T { match self { just(t) { t } - nothing { die!(); } + nothing { fail!(); } } } } diff --git a/src/test/auxiliary/issue_2723_a.rs b/src/test/auxiliary/issue_2723_a.rs index ef74b61f93aea..b3fa8e73cc222 100644 --- a/src/test/auxiliary/issue_2723_a.rs +++ b/src/test/auxiliary/issue_2723_a.rs @@ -9,5 +9,5 @@ // except according to those terms. pub unsafe fn f(xs: ~[int]) { - xs.map(|_x| { unsafe fn q() { die!(); } }); + xs.map(|_x| { unsafe fn q() { fail!(); } }); } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index cda4f32ab5ceb..37be325f15bc6 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -36,6 +36,6 @@ impl bool: read { pub fn read(s: ~str) -> T { match read::readMaybe(s) { Some(x) => x, - _ => die!(~"read failed!") + _ => fail!(~"read failed!") } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 222307bd240df..e88cb62db7345 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -213,7 +213,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { match *c { white => { -1i64 } black(parent) => { parent } - _ => { die!(~"Found remaining gray nodes in BFS") } + _ => { fail!(~"Found remaining gray nodes in BFS") } } } } @@ -300,7 +300,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { match *c { white => { -1i64 } black(parent) => { parent } - _ => { die!(~"Found remaining gray nodes in BFS") } + _ => { fail!(~"Found remaining gray nodes in BFS") } } } } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 4a6eaad9e14ed..3d367c546838b 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -56,7 +56,7 @@ macro_rules! follow ( $(Some($message($($x,)* move next)) => { let $next = move next; move $e })+ - _ => { die!() } + _ => { fail!() } } ); @@ -67,7 +67,7 @@ macro_rules! follow ( $(Some($message(move next)) => { let $next = move next; move $e })+ - _ => { die!() } + _ => { fail!() } } ) ) diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 6de8d13529a58..27111ff3b6d45 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -63,7 +63,7 @@ fn show_digit(nn: uint) -> ~str { 7 => {~"seven"} 8 => {~"eight"} 9 => {~"nine"} - _ => {die!(~"expected digits from 0 to 9...")} + _ => {fail!(~"expected digits from 0 to 9...")} } } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 06b46eab7598b..ac695421059c7 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -68,7 +68,7 @@ fn parse_opts(argv: ~[~str]) -> Config { Ok(ref m) => { return Config {stress: getopts::opt_present(m, ~"stress")} } - Err(_) => { die!(); } + Err(_) => { fail!(); } } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 750874e80c3a4..885eaf01c4453 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -118,7 +118,7 @@ pub fn solve_grid(g: grid_t) { ptr = ptr + 1u; } else { // no: redo this field aft recoloring pred; unless there is none - if ptr == 0u { die!(~"No solution found for this sudoku"); } + if ptr == 0u { fail!(~"No solution found for this sudoku"); } ptr = ptr - 1u; } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 8e5ab45bae868..c67305bab8f31 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -69,7 +69,7 @@ fn r(l: @nillist) -> r { fn recurse_or_fail(depth: int, st: Option) { if depth == 0 { debug!("unwinding %.4f", precise_time_s()); - die!(); + fail!(); } else { let depth = depth - 1; diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 415df0e9fa8d9..06f4213ee7b93 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -46,6 +46,6 @@ fn main() { let (p,c) = pipes::stream(); child_generation(uint::from_str(args[1]).get(), move c); if p.try_recv().is_none() { - die!(~"it happened when we slumbered"); + fail!(~"it happened when we slumbered"); } } diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 3b1a20136b662..4a6195b1ae89c 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -77,7 +77,7 @@ fn main() { } // Grandparent group waits for middle group to be gone, then fails error!("Grandparent group wakes up and fails"); - die!(); + fail!(); }; assert x.is_err(); } diff --git a/src/test/compile-fail/alt-join.rs b/src/test/compile-fail/alt-join.rs index 1cce1dee2f79c..a94709c577466 100644 --- a/src/test/compile-fail/alt-join.rs +++ b/src/test/compile-fail/alt-join.rs @@ -11,7 +11,7 @@ // a good test that we merge paths correctly in the presence of a // variable that's used before it's declared -fn my_fail() -> ! { die!(); } +fn my_fail() -> ! { fail!(); } fn main() { match true { false => { my_fail(); } true => { } } diff --git a/src/test/compile-fail/bad-bang-ann.rs b/src/test/compile-fail/bad-bang-ann.rs index d044d9bdc964b..2ffb5dd29066f 100644 --- a/src/test/compile-fail/bad-bang-ann.rs +++ b/src/test/compile-fail/bad-bang-ann.rs @@ -12,7 +12,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: uint) -> ! { - if i < 0u { } else { die!(); } + if i < 0u { } else { fail!(); } //~^ ERROR expected `!` but found `()` } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs index fea31ef173826..1bffb0739e93f 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs @@ -20,6 +20,6 @@ fn main() { let x = Some(X { x: () }); match move x { Some(ref _y @ move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs index b58fe788846dd..cbf4855990915 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match move x { Some((ref _y, move _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs index 8f9682e662c69..9c14a53eba169 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs @@ -22,6 +22,6 @@ fn main() { let x = some2(X { x: () }, X { x: () }); match move x { some2(ref _y, move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - none2 => die!() + none2 => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs index 6c14dd4d14187..1d492fdd0f1f2 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match move x { Some((move _y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs index 45b5a896f6b11..82f4d57911b4c 100644 --- a/src/test/compile-fail/bind-by-move-no-guards.rs +++ b/src/test/compile-fail/bind-by-move-no-guards.rs @@ -13,8 +13,8 @@ fn main() { let x = Some(p); c.send(false); match move x { - Some(move z) if z.recv() => { die!() }, //~ ERROR cannot bind by-move into a pattern guard + Some(move z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard Some(move z) => { assert !z.recv(); }, - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs index c8b8ebecce812..e4e8cba4e9ce1 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs @@ -22,6 +22,6 @@ fn main() { let x = Some(X { x: () }); match x { Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs index 889ccb3fd9934..45f9415db9b75 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs @@ -24,6 +24,6 @@ fn main() { let x = Y { y: Some(X { x: () }) }; match x.y { Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs index 40196fe0817a4..0d845983c6e0d 100644 --- a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs +++ b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs @@ -20,6 +20,6 @@ fn main() { let x = Some(X { x: () }); match move x { Some(move _y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 6ce631c68a3dd..b3ef5f4d481c6 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -23,7 +23,7 @@ fn main() { x = X(Left((0,0))); //~ ERROR assigning to captured outer mutable variable (*f)() }, - _ => die!() + _ => fail!() } } } diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs index 9aec4b49ef260..a2ba5ad489167 100644 --- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -16,7 +16,7 @@ use core::either::{Either, Left, Right}; *x = Right(1.0); *z } - _ => die!() + _ => fail!() } } diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs index 0c2903765fc4b..37ee747069ccf 100644 --- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs +++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs @@ -14,7 +14,7 @@ fn main() { Some(ref m) => { msg = m; }, - None => { die!() } + None => { fail!() } } io::println(*msg); } diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index 940677002707b..deebff5f43a3c 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -2,7 +2,7 @@ fn a() -> &[int] { let vec = [1, 2, 3, 4]; let tail = match vec { //~ ERROR illegal borrow [_a, ..tail] => tail, - _ => die!(~"foo") + _ => fail!(~"foo") }; move tail } diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 0a200e736ba43..05ff85d612c82 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -4,7 +4,7 @@ fn a() { [~ref _a] => { vec[0] = ~4; //~ ERROR prohibited due to outstanding loan } - _ => die!(~"foo") + _ => fail!(~"foo") } } diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index 64bb571b2dcdc..e1ed0f0daa1e8 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -2,7 +2,7 @@ fn a() -> &int { let vec = [1, 2, 3, 4]; let tail = match vec { //~ ERROR illegal borrow [_a, ..tail] => &tail[0], - _ => die!(~"foo") + _ => fail!(~"foo") }; move tail } diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index a76649fb99099..66d4e601ec7b6 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -2,6 +2,6 @@ fn foo(f: fn() -> !) {} fn main() { // Type inference didn't use to be able to handle this: - foo(|| die!()); + foo(|| fail!()); foo(|| 22); //~ ERROR mismatched types } diff --git a/src/test/compile-fail/deref-non-pointer.rs b/src/test/compile-fail/deref-non-pointer.rs index ef84b11d5fc1c..5f93faef5fc1d 100644 --- a/src/test/compile-fail/deref-non-pointer.rs +++ b/src/test/compile-fail/deref-non-pointer.rs @@ -11,6 +11,6 @@ // error-pattern:cannot be dereferenced fn main() { match *1 { - _ => { die!(); } + _ => { fail!(); } } } diff --git a/src/test/compile-fail/die-not-unique.rs b/src/test/compile-fail/die-not-unique.rs index bbda5332c7700..29369f081d75d 100644 --- a/src/test/compile-fail/die-not-unique.rs +++ b/src/test/compile-fail/die-not-unique.rs @@ -1,5 +1,5 @@ // error-pattern:mismatched types fn main() { - die!("test"); + fail!("test"); } diff --git a/src/test/compile-fail/fail-expr.rs b/src/test/compile-fail/fail-expr.rs index 6d4f5ba2f4c1b..38a883d44dbda 100644 --- a/src/test/compile-fail/fail-expr.rs +++ b/src/test/compile-fail/fail-expr.rs @@ -10,4 +10,4 @@ // error-pattern:mismatched types -fn main() { die!(5); } +fn main() { fail!(5); } diff --git a/src/test/compile-fail/fail-simple.rs b/src/test/compile-fail/fail-simple.rs index eab577f713bd1..7def16770a790 100644 --- a/src/test/compile-fail/fail-simple.rs +++ b/src/test/compile-fail/fail-simple.rs @@ -12,5 +12,5 @@ // error-pattern:unexpected token fn main() { - die!(@); + fail!(@); } diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs index 8e32c0869624c..664063b466b2f 100644 --- a/src/test/compile-fail/fail-type-err.rs +++ b/src/test/compile-fail/fail-type-err.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern:expected `~str` but found `~[int]` -fn main() { die!(~[0i]); } +fn main() { fail!(~[0i]); } diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 3df9dc8300ad2..abc6fe50fab8e 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -14,7 +14,7 @@ trait vec_monad { impl ~[A]: vec_monad { fn bind(f: fn(A) -> ~[B]) { - let mut r = die!(); + let mut r = fail!(); for self.each |elt| { r += f(*elt); } //~^ WARNING unreachable expression //~^^ ERROR the type of this value must be known diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 51883aa97340f..3ab8f765ad545 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -9,7 +9,7 @@ // except according to those terms. fn fail_len(v: ~[const int]) -> uint { - let mut i = die!(); + let mut i = fail!(); for v.each |x| { i += 1u; } //~^ WARNING unreachable statement //~^^ ERROR the type of this value must be known diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index ef72f7245ac4f..a9f0ddbe74316 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - for vec::each(die!()) |i| { + for vec::each(fail!()) |i| { log (debug, i * 2); //~^ ERROR the type of this value must be known }; diff --git a/src/test/compile-fail/issue-2330.rs b/src/test/compile-fail/issue-2330.rs index abaeb37e6c26b..9ff9676b675fb 100644 --- a/src/test/compile-fail/issue-2330.rs +++ b/src/test/compile-fail/issue-2330.rs @@ -16,7 +16,7 @@ trait channel { // `chan` is not a trait, it's an enum impl int: chan { //~ ERROR can only implement trait types - fn send(v: int) { die!() } + fn send(v: int) { fail!() } } fn main() { diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index 37945839de4c8..409e1c1f04020 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -16,8 +16,8 @@ */ fn foo() { //~ ERROR this open brace is not closed match Some(x) { - Some(y) { die!(); } - None { die!(); } + Some(y) { fail!(); } + None { fail!(); } } fn bar() { diff --git a/src/test/compile-fail/issue-2611-3.rs b/src/test/compile-fail/issue-2611-3.rs index 7624e33e9add9..4bcdf9b299f4d 100644 --- a/src/test/compile-fail/issue-2611-3.rs +++ b/src/test/compile-fail/issue-2611-3.rs @@ -24,7 +24,7 @@ struct E { } impl E: A { - fn b(_x: F) -> F { die!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but + fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but } fn main() {} diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 1e923974d33cd..a20a182d85ec3 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -21,7 +21,7 @@ struct E { } impl E: A { - fn b(_x: F) -> F { die!() } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but + fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but } fn main() {} diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index e868d022d5758..f55feb80c32c6 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -22,7 +22,7 @@ struct E { impl E: A { // n.b. The error message is awful -- see #3404 - fn b(_x: G) -> G { die!() } //~ ERROR method `b` has an incompatible type + fn b(_x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type } fn main() {} diff --git a/src/test/compile-fail/issue-2817.rs b/src/test/compile-fail/issue-2817.rs index 45b7263429335..8c28fcdc7fcd7 100644 --- a/src/test/compile-fail/issue-2817.rs +++ b/src/test/compile-fail/issue-2817.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn uuid() -> uint { die!(); } +fn uuid() -> uint { fail!(); } -fn from_str(s: ~str) -> uint { die!(); } -fn to_str(u: uint) -> ~str { die!(); } -fn uuid_random() -> uint { die!(); } +fn from_str(s: ~str) -> uint { fail!(); } +fn to_str(u: uint) -> ~str { fail!(); } +fn uuid_random() -> uint { fail!(); } fn main() { do uint::range(0, 100000) |_i| { //~ ERROR Do-block body must return bool, but diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index cde878e122aec..fa9c4eb52170c 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -26,7 +26,7 @@ fn siphash(k0 : u64) -> siphash { //~^ ERROR unresolved name: k0 } } - die!(); + fail!(); } fn main() {} diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index 74136d955731d..40d65938795ff 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -37,6 +37,6 @@ fn main() { ~Element(ed) => match ed.kind { ~HTMLImageElement(d) if d.image.is_some() => { true } }, - _ => die!(~"WAT") //~ ERROR wat + _ => fail!(~"WAT") //~ ERROR wat }; } diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index 5fc692ed3ec72..364701de2d109 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -16,7 +16,7 @@ trait PTrait { impl P: PTrait { fn getChildOption() -> Option<@P> { const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant - die!(); + fail!(); } } diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index e910ea1fa5749..253563c12195c 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn g() -> ! { die!(); } +fn g() -> ! { fail!(); } fn f() -> ! { return 42i; //~ ERROR expected `!` but found `int` g(); //~ WARNING unreachable statement diff --git a/src/test/compile-fail/issue-897.rs b/src/test/compile-fail/issue-897.rs index f5f4b376a99cf..503574fce8773 100644 --- a/src/test/compile-fail/issue-897.rs +++ b/src/test/compile-fail/issue-897.rs @@ -10,6 +10,6 @@ fn f() -> ! { return 42i; //~ ERROR expected `!` but found `int` - die!(); //~ WARNING unreachable statement + fail!(); //~ WARNING unreachable statement } fn main() { } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index fcdf9438e3d9e..f852fb1d38e42 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -11,7 +11,7 @@ fn send(ch: _chan, -data: T) { log(debug, ch); log(debug, data); - die!(); + fail!(); } enum _chan = int; @@ -23,4 +23,4 @@ fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) { log(debug, message); //~ ERROR use of moved value: `message` } -fn main() { die!(); } +fn main() { fail!(); } diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index be842a4cdd7d8..7356c227360c8 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -2,7 +2,7 @@ // they occur as part of various kinds of expressions. struct Foo { f: A } -fn guard(_s: ~str) -> bool {die!()} +fn guard(_s: ~str) -> bool {fail!()} fn touch(_a: &A) {} fn f10() { diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index b8db996ebfa54..4d1db36237640 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -16,8 +16,8 @@ enum u { c, d } fn main() { let x = a(c); match x { - a(d) => { die!(~"hello"); } - b => { die!(~"goodbye"); } + a(d) => { fail!(~"hello"); } + b => { fail!(~"goodbye"); } } } diff --git a/src/test/compile-fail/noncopyable-match-pattern.rs b/src/test/compile-fail/noncopyable-match-pattern.rs index a123cf9fc6f30..9f21d5a647ae1 100644 --- a/src/test/compile-fail/noncopyable-match-pattern.rs +++ b/src/test/compile-fail/noncopyable-match-pattern.rs @@ -14,6 +14,6 @@ fn main() { Some(copy z) => { //~ ERROR copying a value of non-copyable type do z.with |b| { assert !*b; } } - None => die!() + None => fail!() } } diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs index ef4f0f4fb53e7..57eca3666ef14 100644 --- a/src/test/compile-fail/not-enough-arguments.rs +++ b/src/test/compile-fail/not-enough-arguments.rs @@ -13,7 +13,7 @@ // unrelated errors. fn foo(a: int, b: int, c: int, d:int) { - die!(); + fail!(); } fn main() { diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 7942a38caa0db..29eb1ec8d0a3f 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -17,6 +17,6 @@ use option::Some; enum bar { t1((), Option<~[int]>), t2, } -fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { die!(); } } } +fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } } fn main() { } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index 3b4200bb4be59..bb4e97f9101b9 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -21,7 +21,7 @@ fn foo(t: bar) { t1(_, Some::(x)) => { log(debug, x); } - _ => { die!(); } + _ => { fail!(); } } } diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index 2fc487d13d2eb..a9ba7082628b5 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -63,6 +63,6 @@ fn main() { } fn check_pp(expr: T, f: fn(pprust::ps, T), expect: str) { - die!(); + fail!(); } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 43b1d287739e6..fe382badb5cdf 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -58,6 +58,6 @@ fn main() { } fn check_pp(expr: T, f: fn(pprust::ps, T), expect: str) { - die!(); + fail!(); } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index 95a5222d14c4c..6deef8cee9e46 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> @fn(T) { die!(); } -fn subtype(x: @fn(T)) { die!(); } +fn of() -> @fn(T) { fail!(); } +fn subtype(x: @fn(T)) { fail!(); } fn test_fn(_x: &x/T, _y: &y/T, _z: &z/T) { // Here, x, y, and z are free. Other letters diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 3ead89b2082d1..526a5de7fefe2 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> @fn(T) { die!(); } -fn subtype(x: @fn(T)) { die!(); } +fn of() -> @fn(T) { fail!(); } +fn subtype(x: @fn(T)) { fail!(); } fn test_fn(_x: &x/T, _y: &y/T, _z: &z/T) { // Here, x, y, and z are free. Other letters diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index c6cd05b7a6526..a05d6a324de7b 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -16,7 +16,7 @@ extern mod core; fn last(v: ~[const &T]) -> core::Option { - die!(); + fail!(); } fn main() { diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs index ea40d8bd07762..4550d95aa5d02 100644 --- a/src/test/compile-fail/tag-type-args.rs +++ b/src/test/compile-fail/tag-type-args.rs @@ -14,4 +14,4 @@ enum quux { bar } fn foo(c: quux) { assert (false); } -fn main() { die!(); } +fn main() { fail!(); } diff --git a/src/test/compile-fail/warn-foreign-int-types.rs b/src/test/compile-fail/warn-foreign-int-types.rs index 801e3e710300e..bb6d754805b54 100644 --- a/src/test/compile-fail/warn-foreign-int-types.rs +++ b/src/test/compile-fail/warn-foreign-int-types.rs @@ -16,5 +16,5 @@ extern mod xx { fn main() { // let it fail to verify warning message - die!() + fail!() } diff --git a/src/test/pretty/issue-929.rs b/src/test/pretty/issue-929.rs index 7b24d256cb005..636fac82b6b00 100644 --- a/src/test/pretty/issue-929.rs +++ b/src/test/pretty/issue-929.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f() { if (1 == die!()) { } else { } } +fn f() { if (1 == fail!()) { } else { } } fn main() { } diff --git a/src/test/run-fail/alt-bot-fail.rs b/src/test/run-fail/alt-bot-fail.rs index ac465d81b7e13..2ba78e21374ea 100644 --- a/src/test/run-fail/alt-bot-fail.rs +++ b/src/test/run-fail/alt-bot-fail.rs @@ -14,6 +14,6 @@ fn foo(s: ~str) { } fn main() { let i = - match Some::(3) { None:: => { die!() } Some::(_) => { die!() } }; + match Some::(3) { None:: => { fail!() } Some::(_) => { fail!() } }; foo(i); } diff --git a/src/test/run-fail/alt-disc-bot.rs b/src/test/run-fail/alt-disc-bot.rs index c74e16f422208..afe2735e67d21 100644 --- a/src/test/run-fail/alt-disc-bot.rs +++ b/src/test/run-fail/alt-disc-bot.rs @@ -9,6 +9,6 @@ // except according to those terms. // error-pattern:quux -fn f() -> ! { die!(~"quux") } +fn f() -> ! { fail!(~"quux") } fn g() -> int { match f() { true => { 1 } false => { 0 } } } fn main() { g(); } diff --git a/src/test/run-fail/alt-wildcards.rs b/src/test/run-fail/alt-wildcards.rs index e30a73601c6ff..4730f1bc5602d 100644 --- a/src/test/run-fail/alt-wildcards.rs +++ b/src/test/run-fail/alt-wildcards.rs @@ -11,9 +11,9 @@ // error-pattern:squirrelcupcake fn cmp() -> int { match (option::Some('a'), option::None::) { - (option::Some(_), _) => { die!(~"squirrelcupcake"); } - (_, option::Some(_)) => { die!(); } - _ => { die!(~"wat"); } + (option::Some(_), _) => { fail!(~"squirrelcupcake"); } + (_, option::Some(_)) => { fail!(); } + _ => { fail!(~"wat"); } } } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index c367510994891..5cdddb0cda894 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -9,6 +9,6 @@ // except according to those terms. // error-pattern:meep -fn f(a: int, b: int, c: @int) { die!(~"moop"); } +fn f(a: int, b: int, c: @int) { fail!(~"moop"); } -fn main() { f(1, die!(~"meep"), @42); } +fn main() { f(1, fail!(~"meep"), @42); } diff --git a/src/test/run-fail/binop-fail-2.rs b/src/test/run-fail/binop-fail-2.rs index 1e553d1089dab..2f1eb65a43ac6 100644 --- a/src/test/run-fail/binop-fail-2.rs +++ b/src/test/run-fail/binop-fail-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } +fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); } fn main() { 3u == my_err(~"bye"); } diff --git a/src/test/run-fail/binop-fail.rs b/src/test/run-fail/binop-fail.rs index 1e553d1089dab..2f1eb65a43ac6 100644 --- a/src/test/run-fail/binop-fail.rs +++ b/src/test/run-fail/binop-fail.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } +fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); } fn main() { 3u == my_err(~"bye"); } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index f16e838aaf56a..85e0f3dd398ee 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -16,6 +16,6 @@ type port_id = int; enum chan_t = {task: task_id, port: port_id}; -fn send(ch: chan_t, data: T) { die!(); } +fn send(ch: chan_t, data: T) { fail!(); } -fn main() { die!(~"quux"); } +fn main() { fail!(~"quux"); } diff --git a/src/test/run-fail/die-macro-expr.rs b/src/test/run-fail/die-macro-expr.rs index 3d293fc805d5a..26d5ea4349de6 100644 --- a/src/test/run-fail/die-macro-expr.rs +++ b/src/test/run-fail/die-macro-expr.rs @@ -1,5 +1,5 @@ // error-pattern:test fn main() { - let i: int = die!(~"test"); + let i: int = fail!(~"test"); } \ No newline at end of file diff --git a/src/test/run-fail/die-macro-pure.rs b/src/test/run-fail/die-macro-pure.rs index 67eb6e6323010..74de57a8a25a4 100644 --- a/src/test/run-fail/die-macro-pure.rs +++ b/src/test/run-fail/die-macro-pure.rs @@ -1,7 +1,7 @@ // error-pattern:test pure fn f() { - die!(~"test"); + fail!(~"test"); } fn main() { diff --git a/src/test/run-fail/die-macro.rs b/src/test/run-fail/die-macro.rs index 0885c17e12174..6eb56a5be4e59 100644 --- a/src/test/run-fail/die-macro.rs +++ b/src/test/run-fail/die-macro.rs @@ -1,5 +1,5 @@ // error-pattern:test fn main() { - die!(~"test"); + fail!(~"test"); } \ No newline at end of file diff --git a/src/test/run-fail/doublefail.rs b/src/test/run-fail/doublefail.rs index 38e29d02fdd93..ce9678aa5eb6b 100644 --- a/src/test/run-fail/doublefail.rs +++ b/src/test/run-fail/doublefail.rs @@ -10,6 +10,6 @@ //error-pattern:One fn main() { - die!(~"One"); - die!(~"Two"); + fail!(~"One"); + fail!(~"Two"); } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index ac5eaefe32b5c..17fb14881a542 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -10,5 +10,5 @@ // error-pattern:wooooo fn main() { - let mut a = 1; if 1 == 1 { a = 2; } die!(~"woooo" + ~"o"); + let mut a = 1; if 1 == 1 { a = 2; } fail!(~"woooo" + ~"o"); } diff --git a/src/test/run-fail/explicit-fail.rs b/src/test/run-fail/explicit-fail.rs index acc5ef916686e..8c204b66e3657 100644 --- a/src/test/run-fail/explicit-fail.rs +++ b/src/test/run-fail/explicit-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit -fn main() { die!(); } +fn main() { fail!(); } diff --git a/src/test/run-fail/expr-alt-fail-fn.rs b/src/test/run-fail/expr-alt-fail-fn.rs index 6cb0f4f3260bc..6476e57a35b84 100644 --- a/src/test/run-fail/expr-alt-fail-fn.rs +++ b/src/test/run-fail/expr-alt-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { die!() } +fn f() -> ! { fail!() } fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; } diff --git a/src/test/run-fail/expr-alt-fail.rs b/src/test/run-fail/expr-alt-fail.rs index b70382955e301..e2bf6052a1038 100644 --- a/src/test/run-fail/expr-alt-fail.rs +++ b/src/test/run-fail/expr-alt-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let x = match true { false => { 0 } true => { die!() } }; } +fn main() { let x = match true { false => { 0 } true => { fail!() } }; } diff --git a/src/test/run-fail/expr-fn-fail.rs b/src/test/run-fail/expr-fn-fail.rs index 2b840a71b8b41..e645ea34df564 100644 --- a/src/test/run-fail/expr-fn-fail.rs +++ b/src/test/run-fail/expr-fn-fail.rs @@ -12,6 +12,6 @@ // error-pattern:explicit failure -fn f() -> ! { die!() } +fn f() -> ! { fail!() } fn main() { f(); } diff --git a/src/test/run-fail/expr-if-fail-fn.rs b/src/test/run-fail/expr-if-fail-fn.rs index cd6efa7302a46..99f798147f28f 100644 --- a/src/test/run-fail/expr-if-fail-fn.rs +++ b/src/test/run-fail/expr-if-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { die!() } +fn f() -> ! { fail!() } fn g() -> int { let x = if true { f() } else { 10 }; return x; } diff --git a/src/test/run-fail/expr-if-fail.rs b/src/test/run-fail/expr-if-fail.rs index d39a0271e64de..c1663866519b7 100644 --- a/src/test/run-fail/expr-if-fail.rs +++ b/src/test/run-fail/expr-if-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let x = if false { 0 } else if true { die!() } else { 10 }; } +fn main() { let x = if false { 0 } else if true { fail!() } else { 10 }; } diff --git a/src/test/run-fail/extern-fail.rs b/src/test/run-fail/extern-fail.rs index 7f59d499fd3b1..7227be11e8064 100644 --- a/src/test/run-fail/extern-fail.rs +++ b/src/test/run-fail/extern-fail.rs @@ -37,7 +37,7 @@ fn main() { do task::spawn { let result = count(5u); debug!("result = %?", result); - die!(); + fail!(); }; } } diff --git a/src/test/run-fail/fail-arg.rs b/src/test/run-fail/fail-arg.rs index 4ead0db2d42f9..fc365613cf16c 100644 --- a/src/test/run-fail/fail-arg.rs +++ b/src/test/run-fail/fail-arg.rs @@ -11,4 +11,4 @@ // error-pattern:woe fn f(a: int) { log(debug, a); } -fn main() { f(die!(~"woe")); } +fn main() { f(fail!(~"woe")); } diff --git a/src/test/run-fail/fail-main.rs b/src/test/run-fail/fail-main.rs index 2755f8e47a219..50031261bfca9 100644 --- a/src/test/run-fail/fail-main.rs +++ b/src/test/run-fail/fail-main.rs @@ -10,4 +10,4 @@ // error-pattern:moop extern mod std; -fn main() { die!(~"moop"); } +fn main() { fail!(~"moop"); } diff --git a/src/test/run-fail/fail-parens.rs b/src/test/run-fail/fail-parens.rs index 144a36bd730c5..5ba907b0eb63c 100644 --- a/src/test/run-fail/fail-parens.rs +++ b/src/test/run-fail/fail-parens.rs @@ -13,8 +13,8 @@ // error-pattern:oops fn bigfail() { - while (die!(~"oops")) { if (die!()) { - match (die!()) { () => { + while (fail!(~"oops")) { if (fail!()) { + match (fail!()) { () => { } } }}; diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 3e6f8a433c68a..10d8903838143 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -11,4 +11,4 @@ // error-pattern:meh extern mod std; -fn main() { let str_var: ~str = ~"meh"; die!(fmt!("%s", str_var)); } +fn main() { let str_var: ~str = ~"meh"; fail!(fmt!("%s", str_var)); } diff --git a/src/test/run-fail/for-each-loop-fail.rs b/src/test/run-fail/for-each-loop-fail.rs index bbae1b1739da9..fa62a9c5c34c9 100644 --- a/src/test/run-fail/for-each-loop-fail.rs +++ b/src/test/run-fail/for-each-loop-fail.rs @@ -10,4 +10,4 @@ // error-pattern:moop extern mod std; -fn main() { for uint::range(0u, 10u) |_i| { die!(~"moop"); } } +fn main() { for uint::range(0u, 10u) |_i| { fail!(~"moop"); } } diff --git a/src/test/run-fail/if-check-fail.rs b/src/test/run-fail/if-check-fail.rs index f0bc250f1cbfa..5f9da798ffab2 100644 --- a/src/test/run-fail/if-check-fail.rs +++ b/src/test/run-fail/if-check-fail.rs @@ -19,7 +19,7 @@ fn foo(x: uint) { if even(x) { log(debug, x); } else { - die!(~"Number is odd"); + fail!(~"Number is odd"); } } diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs index 1212b550cfbc9..d558ff1e3b84b 100644 --- a/src/test/run-fail/if-cond-bot.rs +++ b/src/test/run-fail/if-cond-bot.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } +fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); } fn main() { if my_err(~"bye") { } } diff --git a/src/test/run-fail/issue-1459.rs b/src/test/run-fail/issue-1459.rs index bb97e5b2b6add..7f8cc7459de44 100644 --- a/src/test/run-fail/issue-1459.rs +++ b/src/test/run-fail/issue-1459.rs @@ -10,5 +10,5 @@ // error-pattern:roflcopter fn main() { - log (die!(~"roflcopter"), 2); + log (fail!(~"roflcopter"), 2); } diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index deb8192fc3be2..a518816533e48 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -15,6 +15,6 @@ use io::ReaderUtil; fn main() { do io::with_str_reader(~"") |rdr| { - match rdr.read_char() { '=' => { } _ => { die!() } } + match rdr.read_char() { '=' => { } _ => { fail!() } } } } diff --git a/src/test/run-fail/issue-2272.rs b/src/test/run-fail/issue-2272.rs index de7475b3303dc..5ce89bc181496 100644 --- a/src/test/run-fail/issue-2272.rs +++ b/src/test/run-fail/issue-2272.rs @@ -22,5 +22,5 @@ fn main() { }, a: ~0 }; - die!(); + fail!(); } diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index a4c329a41fc3a..04a0f47fc06fd 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -15,7 +15,7 @@ use std::arc; enum e { e(arc::ARC) } -fn foo() -> e {die!();} +fn foo() -> e {fail!();} fn main() { let f = foo(); diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs index ca4774cd53ebc..3ae6eccd5e214 100644 --- a/src/test/run-fail/issue-3029.rs +++ b/src/test/run-fail/issue-3029.rs @@ -11,7 +11,7 @@ // error-pattern:so long fn main() { let x = ~[], y = ~[3]; - die!(~"so long"); + fail!(~"so long"); x += y; ~"good" + ~"bye"; } diff --git a/src/test/run-fail/issue-948.rs b/src/test/run-fail/issue-948.rs index ddb3eecdbf12c..2f9a1e8a05875 100644 --- a/src/test/run-fail/issue-948.rs +++ b/src/test/run-fail/issue-948.rs @@ -14,5 +14,5 @@ struct Point { x: int, y: int } fn main() { let origin = Point {x: 0, y: 0}; - let f: Point = Point {x: (die!(~"beep boop")),.. origin}; + let f: Point = Point {x: (fail!(~"beep boop")),.. origin}; } diff --git a/src/test/run-fail/linked-failure2.rs b/src/test/run-fail/linked-failure2.rs index f020cb7eafdf0..1402020c357ec 100644 --- a/src/test/run-fail/linked-failure2.rs +++ b/src/test/run-fail/linked-failure2.rs @@ -12,7 +12,7 @@ // error-pattern:fail -fn child() { die!(); } +fn child() { fail!(); } fn main() { let (p, _c) = pipes::stream::<()>(); diff --git a/src/test/run-fail/linked-failure3.rs b/src/test/run-fail/linked-failure3.rs index 78e3798399c1f..cb03a71aabcdd 100644 --- a/src/test/run-fail/linked-failure3.rs +++ b/src/test/run-fail/linked-failure3.rs @@ -12,7 +12,7 @@ // error-pattern:fail -fn grandchild() { die!(~"grandchild dies"); } +fn grandchild() { fail!(~"grandchild dies"); } fn child() { let (p, _c) = pipes::stream::(); diff --git a/src/test/run-fail/morestack1.rs b/src/test/run-fail/morestack1.rs index 63a7cc7ed893c..f4faac0b2aba6 100644 --- a/src/test/run-fail/morestack1.rs +++ b/src/test/run-fail/morestack1.rs @@ -13,7 +13,7 @@ fn getbig(i: int) { if i != 0 { getbig(i - 1); } else { - die!(); + fail!(); } } diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 8236489834d11..d5f438385986d 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -27,7 +27,7 @@ fn getbig_call_c_and_fail(i: int) { } else { unsafe { rustrt::rust_get_argc(); - die!(); + fail!(); } } } diff --git a/src/test/run-fail/morestack3.rs b/src/test/run-fail/morestack3.rs index 01296a8296903..e97e56ea0f9e2 100644 --- a/src/test/run-fail/morestack3.rs +++ b/src/test/run-fail/morestack3.rs @@ -19,7 +19,7 @@ fn getbig_and_fail(&&i: int) { if i != 0 { getbig_and_fail(i - 1); } else { - die!(); + fail!(); } } diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs index e8b6785d1e800..30e9147cff7e8 100644 --- a/src/test/run-fail/morestack4.rs +++ b/src/test/run-fail/morestack4.rs @@ -19,7 +19,7 @@ fn getbig_and_fail(&&i: int) { if i != 0 { getbig_and_fail(i - 1); } else { - die!(); + fail!(); } } diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs index 32d8f84292bd6..f432abe85ab25 100644 --- a/src/test/run-fail/rhs-type.rs +++ b/src/test/run-fail/rhs-type.rs @@ -14,4 +14,4 @@ struct T { t: ~str } -fn main() { let pth = die!(~"bye"); let rs: T = T {t: pth}; } +fn main() { let pth = fail!(~"bye"); let rs: T = T {t: pth}; } diff --git a/src/test/run-fail/rt-log-trunc.rs b/src/test/run-fail/rt-log-trunc.rs index a27404e46fe6f..07cf24e2feb36 100644 --- a/src/test/run-fail/rt-log-trunc.rs +++ b/src/test/run-fail/rt-log-trunc.rs @@ -12,7 +12,7 @@ // error-pattern:[...] fn main() { - die!(~"\ + fail!(~"\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs index de4b062d7003a..ed08022f44908 100644 --- a/src/test/run-fail/rt-set-exit-status-fail.rs +++ b/src/test/run-fail/rt-set-exit-status-fail.rs @@ -16,5 +16,5 @@ fn main() { // normally. In this case we're going to fail, so instead of of // returning 50 the process will return the typical rt failure code. os::set_exit_status(50); - die!(); + fail!(); } diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index ece9f5fdc51e2..e936270d4b865 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -34,5 +34,5 @@ fn main() { do task::spawn { let i = r(5); }; - die!(); + fail!(); } diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index 48adac555863b..fd898e31347dd 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -17,5 +17,5 @@ mod m { pub fn exported() { } #[test] - fn unexported() { die!(~"runned an unexported test"); } + fn unexported() { fail!(~"runned an unexported test"); } } diff --git a/src/test/run-fail/spawnfail.rs b/src/test/run-fail/spawnfail.rs index e7bfe1b67c5f3..8431f7bb74d98 100644 --- a/src/test/run-fail/spawnfail.rs +++ b/src/test/run-fail/spawnfail.rs @@ -15,7 +15,7 @@ extern mod std; // We don't want to see any invalid reads fn main() { fn f() { - die!(); + fail!(); } task::spawn(|| f() ); } diff --git a/src/test/run-fail/task-comm-recv-block.rs b/src/test/run-fail/task-comm-recv-block.rs index 0b36977d9b558..bd866b9f9e7c7 100644 --- a/src/test/run-fail/task-comm-recv-block.rs +++ b/src/test/run-fail/task-comm-recv-block.rs @@ -12,7 +12,7 @@ fn goodfail() { task::yield(); - die!(~"goodfail"); + fail!(~"goodfail"); } fn main() { @@ -21,5 +21,5 @@ fn main() { // We shouldn't be able to get past this recv since there's no // message available let i: int = po.recv(); - die!(~"badfail"); + fail!(~"badfail"); } diff --git a/src/test/run-fail/unique-fail.rs b/src/test/run-fail/unique-fail.rs index 0cb37dfd260ad..86fde5b7f9781 100644 --- a/src/test/run-fail/unique-fail.rs +++ b/src/test/run-fail/unique-fail.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern: fail -fn main() { ~die!(); } +fn main() { ~fail!(); } diff --git a/src/test/run-fail/unwind-alt.rs b/src/test/run-fail/unwind-alt.rs index 559c7c2d89d42..1b28dd0e8ef2d 100644 --- a/src/test/run-fail/unwind-alt.rs +++ b/src/test/run-fail/unwind-alt.rs @@ -15,7 +15,7 @@ fn test_box() { } fn test_str() { let res = match false { true => { ~"happy" }, - _ => die!(~"non-exhaustive match failure") }; + _ => fail!(~"non-exhaustive match failure") }; assert res == ~"happy"; } fn main() { diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index ca6d154f4e60f..6128e96d7bc40 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-fn.rs b/src/test/run-fail/unwind-box-fn.rs index 94a03142beca2..e1d959694e2d1 100644 --- a/src/test/run-fail/unwind-box-fn.rs +++ b/src/test/run-fail/unwind-box-fn.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index 13b1bc36ba95d..920ddbb5bf24c 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } struct r { diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs index 1469a56a6d41b..aaf714fff9c4c 100644 --- a/src/test/run-fail/unwind-box-str.rs +++ b/src/test/run-fail/unwind-box-str.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/run-fail/unwind-box-trait.rs index d41e0f193243d..1602964b481e7 100644 --- a/src/test/run-fail/unwind-box-trait.rs +++ b/src/test/run-fail/unwind-box-trait.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } trait i { diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs index 8f24d2922f995..22a5c72b68cf2 100644 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ b/src/test/run-fail/unwind-box-unique-unique.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs index 8a1dcef5ca51d..3ae4000c2b1bd 100644 --- a/src/test/run-fail/unwind-box-unique.rs +++ b/src/test/run-fail/unwind-box-unique.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs index e2559e66eaed1..d8afdd5a6614d 100644 --- a/src/test/run-fail/unwind-box-vec.rs +++ b/src/test/run-fail/unwind-box-vec.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs index 02761fef97684..21308945253b5 100644 --- a/src/test/run-fail/unwind-box.rs +++ b/src/test/run-fail/unwind-box.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs index f6a3fa1ab67bc..34257b15b7fd8 100644 --- a/src/test/run-fail/unwind-closure.rs +++ b/src/test/run-fail/unwind-closure.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn f(a: @int) { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-fail.rs b/src/test/run-fail/unwind-fail.rs index 5c776b5fd7adc..4d4bc0d53eba2 100644 --- a/src/test/run-fail/unwind-fail.rs +++ b/src/test/run-fail/unwind-fail.rs @@ -12,5 +12,5 @@ fn main() { @0; - die!(); + fail!(); } diff --git a/src/test/run-fail/unwind-initializer-indirect.rs b/src/test/run-fail/unwind-initializer-indirect.rs index 69106602ec891..e7f8a86654310 100644 --- a/src/test/run-fail/unwind-initializer-indirect.rs +++ b/src/test/run-fail/unwind-initializer-indirect.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> @int { die!(); } +fn f() -> @int { fail!(); } fn main() { let a: @int = f(); diff --git a/src/test/run-fail/unwind-initializer.rs b/src/test/run-fail/unwind-initializer.rs index 7047a77a6e777..0293e5ba07e59 100644 --- a/src/test/run-fail/unwind-initializer.rs +++ b/src/test/run-fail/unwind-initializer.rs @@ -12,6 +12,6 @@ fn main() { let a: @int = { - die!(); + fail!(); }; } diff --git a/src/test/run-fail/unwind-interleaved.rs b/src/test/run-fail/unwind-interleaved.rs index 4dac04d379d4f..142813bcc30b7 100644 --- a/src/test/run-fail/unwind-interleaved.rs +++ b/src/test/run-fail/unwind-interleaved.rs @@ -12,7 +12,7 @@ fn a() { } -fn b() { die!(); } +fn b() { fail!(); } fn main() { let x = ~[0]; diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 7c5782a181313..135c5eecc2e9b 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn x(it: fn(int)) { - die!(); + fail!(); it(0); } diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index 8621209fd5d1a..f17f9fb9154bb 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -16,5 +16,5 @@ fn x(it: fn(int)) { } fn main() { - x(|_x| die!() ); + x(|_x| fail!() ); } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 89d6dd4970ee6..1fff98c433846 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -21,7 +21,7 @@ fn main() { let cheese = copy cheese; let f = fn@() { let chew = mush + cheese; - die!(~"so yummy") + fail!(~"so yummy") }; f(); }); diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index a504e374b9505..572d5a90751d1 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -22,7 +22,7 @@ fn main() { arr += ~[@~"key stuff"]; map.insert(copy arr, arr + ~[@~"value stuff"]); if arr.len() == 5 { - die!(); + fail!(); } } } diff --git a/src/test/run-fail/unwind-move.rs b/src/test/run-fail/unwind-move.rs index 2419edf650c42..539896e831319 100644 --- a/src/test/run-fail/unwind-move.rs +++ b/src/test/run-fail/unwind-move.rs @@ -10,7 +10,7 @@ // error-pattern:fail fn f(-_a: @int) { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-nested.rs b/src/test/run-fail/unwind-nested.rs index 450c982eb3f37..ca9a761cfa1e1 100644 --- a/src/test/run-fail/unwind-nested.rs +++ b/src/test/run-fail/unwind-nested.rs @@ -15,7 +15,7 @@ fn main() { { let b = @0; { - die!(); + fail!(); } } } diff --git a/src/test/run-fail/unwind-partial-box.rs b/src/test/run-fail/unwind-partial-box.rs index 7a5c81eed7a1f..d1e3b63698bc5 100644 --- a/src/test/run-fail/unwind-partial-box.rs +++ b/src/test/run-fail/unwind-partial-box.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { die!(); } +fn f() -> ~[int] { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs index 12f0a7b47853c..5976add8800a4 100644 --- a/src/test/run-fail/unwind-partial-unique.rs +++ b/src/test/run-fail/unwind-partial-unique.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { die!(); } +fn f() -> ~[int] { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. diff --git a/src/test/run-fail/unwind-partial-vec.rs b/src/test/run-fail/unwind-partial-vec.rs index 87df161cfd3ad..d51c83a06d9c0 100644 --- a/src/test/run-fail/unwind-partial-vec.rs +++ b/src/test/run-fail/unwind-partial-vec.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { die!(); } +fn f() -> ~[int] { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs index 324783893f96e..378816476e4dd 100644 --- a/src/test/run-fail/unwind-rec.rs +++ b/src/test/run-fail/unwind-rec.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn build() -> ~[int] { - die!(); + fail!(); } struct Blk { node: ~[int] } diff --git a/src/test/run-fail/unwind-rec2.rs b/src/test/run-fail/unwind-rec2.rs index 0e2c279e98ab2..1abf6d53600b9 100644 --- a/src/test/run-fail/unwind-rec2.rs +++ b/src/test/run-fail/unwind-rec2.rs @@ -15,7 +15,7 @@ fn build1() -> ~[int] { } fn build2() -> ~[int] { - die!(); + fail!(); } struct Blk { node: ~[int], span: ~[int] } diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs index a5ff830249503..8b9d1a6645714 100644 --- a/src/test/run-fail/unwind-resource-fail.rs +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -12,7 +12,7 @@ struct r { i: int, - drop { die!(~"squirrel") } + drop { fail!(~"squirrel") } } fn r(i: int) -> r { r { i: i } } diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs index 69575e6e13a60..9c2c1a24a5e66 100644 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ b/src/test/run-fail/unwind-resource-fail2.rs @@ -13,7 +13,7 @@ struct r { i: int, - drop { die!(~"wombat") } + drop { fail!(~"wombat") } } fn r(i: int) -> r { r { i: i } } @@ -21,5 +21,5 @@ fn r(i: int) -> r { r { i: i } } fn main() { @0; let r = move r(0); - die!(); + fail!(); } diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index 10adfdf1fa3d6..514c780da0969 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -19,7 +19,7 @@ fn faily_box(i: @int) -> faily_box { faily_box { i: i } } impl faily_box : Drop { fn finalize(&self) { - die!(~"quux"); + fail!(~"quux"); } } diff --git a/src/test/run-fail/unwind-stacked.rs b/src/test/run-fail/unwind-stacked.rs index 42a4a7e376d5c..a8faa550c8fbe 100644 --- a/src/test/run-fail/unwind-stacked.rs +++ b/src/test/run-fail/unwind-stacked.rs @@ -12,7 +12,7 @@ fn f() { let a = @0; - die!(); + fail!(); } fn g() { diff --git a/src/test/run-fail/unwind-tup.rs b/src/test/run-fail/unwind-tup.rs index 6cd234ae77062..b135b9f609b88 100644 --- a/src/test/run-fail/unwind-tup.rs +++ b/src/test/run-fail/unwind-tup.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn fold_local() -> @~[int]{ - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-tup2.rs b/src/test/run-fail/unwind-tup2.rs index 83ed7efcd44ba..5e299c52a2905 100644 --- a/src/test/run-fail/unwind-tup2.rs +++ b/src/test/run-fail/unwind-tup2.rs @@ -15,7 +15,7 @@ fn fold_local() -> @~[int]{ } fn fold_remote() -> @~[int]{ - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-uninitialized.rs b/src/test/run-fail/unwind-uninitialized.rs index 56321e3382955..e45c5c94ed4b1 100644 --- a/src/test/run-fail/unwind-uninitialized.rs +++ b/src/test/run-fail/unwind-uninitialized.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn f() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs index e9de0c4520a05..53b2a55602c29 100644 --- a/src/test/run-fail/unwind-unique.rs +++ b/src/test/run-fail/unwind-unique.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - die!(); + fail!(); } fn main() { diff --git a/src/test/run-fail/while-body-fails.rs b/src/test/run-fail/while-body-fails.rs index de483d6dc4798..73718b0d0b6d0 100644 --- a/src/test/run-fail/while-body-fails.rs +++ b/src/test/run-fail/while-body-fails.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern:quux -fn main() { let x: int = { while true { die!(~"quux"); } ; 8 } ; } +fn main() { let x: int = { while true { fail!(~"quux"); } ; 8 } ; } diff --git a/src/test/run-fail/while-fail.rs b/src/test/run-fail/while-fail.rs index 951737aa9b265..22cbf215e9e66 100644 --- a/src/test/run-fail/while-fail.rs +++ b/src/test/run-fail/while-fail.rs @@ -10,5 +10,5 @@ // error-pattern:giraffe fn main() { - die!({ while true { die!(~"giraffe")}; ~"clandestine" }); + fail!({ while true { fail!(~"giraffe")}; ~"clandestine" }); } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 2a27be56bec86..b50836beaa2e6 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -37,5 +37,5 @@ fn main() { assert same_length(chars, ints); let ps = zip(chars, ints); - die!(~"the impossible happened"); + fail!(~"the impossible happened"); } diff --git a/src/test/run-pass/alt-bot-2.rs b/src/test/run-pass/alt-bot-2.rs index 2ca1881417e9d..ba897bd92c017 100644 --- a/src/test/run-pass/alt-bot-2.rs +++ b/src/test/run-pass/alt-bot-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // n.b. This was only ever failing with optimization disabled. -fn a() -> int { match return 1 { 2 => 3, _ => die!() } } +fn a() -> int { match return 1 { 2 => 3, _ => fail!() } } pub fn main() { a(); } diff --git a/src/test/run-pass/alt-bot.rs b/src/test/run-pass/alt-bot.rs index cb30c5e96a09b..d4887c4415e63 100644 --- a/src/test/run-pass/alt-bot.rs +++ b/src/test/run-pass/alt-bot.rs @@ -11,6 +11,6 @@ pub fn main() { let i: int = - match Some::(3) { None:: => { die!() } Some::(_) => { 5 } }; + match Some::(3) { None:: => { fail!() } Some::(_) => { 5 } }; log(debug, i); } diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index 53ec6e0ed85ea..647be966df4ad 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -22,7 +22,7 @@ fn foo(s: @int) { log(debug, y); // ref up then down } - _ => { debug!("?"); die!(); } + _ => { debug!("?"); fail!(); } } log(debug, ::core::sys::refcount(s)); assert (::core::sys::refcount(s) == count + 1u); diff --git a/src/test/run-pass/alt-pattern-lit.rs b/src/test/run-pass/alt-pattern-lit.rs index 91e2643dd75e9..22512a47fe0f0 100644 --- a/src/test/run-pass/alt-pattern-lit.rs +++ b/src/test/run-pass/alt-pattern-lit.rs @@ -14,7 +14,7 @@ fn altlit(f: int) -> int { match f { 10 => { debug!("case 10"); return 20; } 11 => { debug!("case 11"); return 22; } - _ => die!(~"the impossible happened") + _ => fail!(~"the impossible happened") } } diff --git a/src/test/run-pass/alt-range.rs b/src/test/run-pass/alt-range.rs index b4e40a7b7ab07..b3634b498b1dd 100644 --- a/src/test/run-pass/alt-range.rs +++ b/src/test/run-pass/alt-range.rs @@ -11,31 +11,31 @@ pub fn main() { match 5u { 1u..5u => {} - _ => die!(~"should match range"), + _ => fail!(~"should match range"), } match 5u { - 6u..7u => die!(~"shouldn't match range"), + 6u..7u => fail!(~"shouldn't match range"), _ => {} } match 5u { - 1u => die!(~"should match non-first range"), + 1u => fail!(~"should match non-first range"), 2u..6u => {} - _ => die!(~"math is broken") + _ => fail!(~"math is broken") } match 'c' { 'a'..'z' => {} - _ => die!(~"should suppport char ranges") + _ => fail!(~"should suppport char ranges") } match -3 { -7..5 => {} - _ => die!(~"should match signed range") + _ => fail!(~"should match signed range") } match 3.0 { 1.0..5.0 => {} - _ => die!(~"should match float range") + _ => fail!(~"should match float range") } match -1.5 { -3.6..3.6 => {} - _ => die!(~"should match negative float range") + _ => fail!(~"should match negative float range") } } diff --git a/src/test/run-pass/alt-ref-binding-in-guard-3256.rs b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs index 407d496236fec..a04d8d4618a27 100644 --- a/src/test/run-pass/alt-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs @@ -14,6 +14,6 @@ pub fn main() { Some(ref z) if z.with(|b| *b) => { do z.with |b| { assert *b; } }, - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index 57e47854ce87d..d98dc11801e29 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -11,21 +11,21 @@ // Issue #53 pub fn main() { - match ~"test" { ~"not-test" => die!(), ~"test" => (), _ => die!() } + match ~"test" { ~"not-test" => fail!(), ~"test" => (), _ => fail!() } enum t { tag1(~str), tag2, } match tag1(~"test") { - tag2 => die!(), - tag1(~"not-test") => die!(), + tag2 => fail!(), + tag1(~"not-test") => fail!(), tag1(~"test") => (), - _ => die!() + _ => fail!() } - let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => die!() }; + let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() }; assert (x == 1); - match ~"a" { ~"a" => { } ~"b" => { }, _ => die!() } + match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() } } diff --git a/src/test/run-pass/attr-main-2.rs b/src/test/run-pass/attr-main-2.rs index b343799e00a4e..741f700663330 100644 --- a/src/test/run-pass/attr-main-2.rs +++ b/src/test/run-pass/attr-main-2.rs @@ -11,7 +11,7 @@ // xfail-fast pub fn main() { - die!() + fail!() } #[main] diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index 5a7ac1042d3be..b7fa7915aa587 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -11,6 +11,6 @@ // Check that issue #954 stays fixed pub fn main() { - match -1 { -1 => {}, _ => die!(~"wat") } + match -1 { -1 => {}, _ => fail!(~"wat") } assert 1-1 == 0; } diff --git a/src/test/run-pass/bind-by-move.rs b/src/test/run-pass/bind-by-move.rs index 4c30d1e00d948..bdcc629566462 100644 --- a/src/test/run-pass/bind-by-move.rs +++ b/src/test/run-pass/bind-by-move.rs @@ -19,6 +19,6 @@ pub fn main() { let x = Some(p); match move x { Some(move z) => { dispose(z); }, - None => die!() + None => fail!() } } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index e9c2eec510a9b..d85a51997e1a6 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -35,14 +35,14 @@ pub fn main() { assert false; } match do vec::all(v) |e| { float::is_negative(*e) } { - true => { die!(~"incorrect answer."); } + true => { fail!(~"incorrect answer."); } false => { } } match 3 { _ if do vec::any(v) |e| { float::is_negative(*e) } => { } _ => { - die!(~"wrong answer."); + fail!(~"wrong answer."); } } diff --git a/src/test/run-pass/boxed-class-type-substitution.rs b/src/test/run-pass/boxed-class-type-substitution.rs index 9e6af13dca22f..4fe553ec03958 100644 --- a/src/test/run-pass/boxed-class-type-substitution.rs +++ b/src/test/run-pass/boxed-class-type-substitution.rs @@ -15,7 +15,7 @@ type Tree = { mut parent: Option, }; -fn empty() -> Tree { die!() } +fn empty() -> Tree { fail!() } struct Box { tree: Tree<@Box> diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index a0230d0298132..347f44b2afa6a 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -108,7 +108,7 @@ impl cat { pure fn get(&self, k: &int) -> &self/T { match self.find(k) { Some(v) => { v } - None => { die!(~"epic fail"); } + None => { fail!(~"epic fail"); } } } diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index c7c42c7fcac08..74dc2e3a0cf44 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -10,7 +10,7 @@ // xfail-win32 fn adder(+x: @int, +y: @int) -> int { return *x + *y; } -fn failer() -> @int { die!(); } +fn failer() -> @int { fail!(); } pub fn main() { assert(result::is_err(&task::try(|| { adder(@2, failer()); () diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 33b5d275a45d6..1c2da8ff3ec1c 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -81,7 +81,7 @@ mod m { // Since the bogus configuration isn't defined main will just be // parsed, but nothing further will be done with it #[cfg(bogus)] -pub fn main() { die!() } +pub fn main() { fail!() } pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible @@ -95,7 +95,7 @@ pub fn main() { fn test_in_fn_ctxt() { #[cfg(bogus)] - fn f() { die!() } + fn f() { fail!() } fn f() { } f(); diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index 1a41efd41d1f3..6e75758ff77b6 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -19,18 +19,18 @@ const X: Foo = Baz; pub fn main() { match X { Baz => {} - _ => die!() + _ => fail!() } match Y { Bar(s) => assert(s == 2654435769), - _ => die!() + _ => fail!() } match Z { Quux(d,h) => { assert(d == 0x123456789abcdef0); assert(h == 0x1234); } - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/const-enum-byref-self.rs b/src/test/run-pass/const-enum-byref-self.rs index 6751a0787e4ad..19311cb17325a 100644 --- a/src/test/run-pass/const-enum-byref-self.rs +++ b/src/test/run-pass/const-enum-byref-self.rs @@ -15,7 +15,7 @@ impl E { fn method(&self) { match *self { V => {} - VV(*) => die!() + VV(*) => fail!() } } } diff --git a/src/test/run-pass/const-enum-byref.rs b/src/test/run-pass/const-enum-byref.rs index f3ea9e08343ef..a8d24dc300a85 100644 --- a/src/test/run-pass/const-enum-byref.rs +++ b/src/test/run-pass/const-enum-byref.rs @@ -14,7 +14,7 @@ const C: E = V; fn f(a: &E) { match *a { V => {} - VV(*) => die!() + VV(*) => fail!() } } diff --git a/src/test/run-pass/const-enum-ptr.rs b/src/test/run-pass/const-enum-ptr.rs index 6ca27fb58b0c2..92b74902efb13 100644 --- a/src/test/run-pass/const-enum-ptr.rs +++ b/src/test/run-pass/const-enum-ptr.rs @@ -14,6 +14,6 @@ const C: &static/E = &V0; fn main() { match *C { V0 => (), - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index b386bbf7f5e76..ed9075f4932dd 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -16,10 +16,10 @@ const C1: E = C[1]; fn main() { match C0 { V0 => (), - _ => die!() + _ => fail!() } match C1 { V1(n) => assert(n == 0xDEADBEE), - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index a7b0373848080..60023889305d4 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -14,10 +14,10 @@ const C: &static/[E] = &[V0, V1(0xDEADBEE), V0]; fn main() { match C[1] { V1(n) => assert(n == 0xDEADBEE), - _ => die!() + _ => fail!() } match C[2] { V0 => (), - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 4925d6c0f07df..b95c42fc49389 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -14,10 +14,10 @@ const C: [E * 3] = [V0, V1(0xDEADBEE), V0]; fn main() { match C[1] { V1(n) => assert(n == 0xDEADBEE), - _ => die!() + _ => fail!() } match C[2] { V0 => (), - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/const-nullary-enum.rs b/src/test/run-pass/const-nullary-enum.rs index 5a266e4c15aad..cbc862185a8d8 100644 --- a/src/test/run-pass/const-nullary-enum.rs +++ b/src/test/run-pass/const-nullary-enum.rs @@ -19,11 +19,11 @@ const X: Foo = Bar; pub fn main() { match X { Bar => {} - Baz | Boo => die!() + Baz | Boo => fail!() } match Y { Baz => {} - Bar | Boo => die!() + Bar | Boo => fail!() } } diff --git a/src/test/run-pass/die-macro.rs b/src/test/run-pass/die-macro.rs index 1174cb5df9265..c4f5e2640ee1d 100644 --- a/src/test/run-pass/die-macro.rs +++ b/src/test/run-pass/die-macro.rs @@ -1,9 +1,9 @@ -// Just testing that die!() type checks in statement or expr +// Just testing that fail!() type checks in statement or expr fn f() { - die!(); + fail!(); - let x: int = die!(); + let x: int = fail!(); } pub fn main() { diff --git a/src/test/run-pass/expr-alt-box.rs b/src/test/run-pass/expr-alt-box.rs index fd1a5ad496928..004d101dd27b7 100644 --- a/src/test/run-pass/expr-alt-box.rs +++ b/src/test/run-pass/expr-alt-box.rs @@ -15,13 +15,13 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { @100 } _ => die!(~"wat") }; + let res = match true { true => { @100 } _ => fail!(~"wat") }; assert (*res == 100); } fn test_str() { let res = match true { true => { ~"happy" }, - _ => die!(~"not happy at all") }; + _ => fail!(~"not happy at all") }; assert (res == ~"happy"); } diff --git a/src/test/run-pass/expr-alt-fail-all.rs b/src/test/run-pass/expr-alt-fail-all.rs index e806907129f1a..5234f58578e9d 100644 --- a/src/test/run-pass/expr-alt-fail-all.rs +++ b/src/test/run-pass/expr-alt-fail-all.rs @@ -17,6 +17,6 @@ pub fn main() { let x = match true { true => { 10 } - false => { match true { true => { die!() } false => { die!() } } } + false => { match true { true => { fail!() } false => { fail!() } } } }; } diff --git a/src/test/run-pass/expr-alt-fail.rs b/src/test/run-pass/expr-alt-fail.rs index f26f1f1e6f753..7838ea70b4228 100644 --- a/src/test/run-pass/expr-alt-fail.rs +++ b/src/test/run-pass/expr-alt-fail.rs @@ -9,12 +9,12 @@ // except according to those terms. fn test_simple() { - let r = match true { true => { true } false => { die!() } }; + let r = match true { true => { true } false => { fail!() } }; assert (r == true); } fn test_box() { - let r = match true { true => { ~[10] } false => { die!() } }; + let r = match true { true => { ~[10] } false => { fail!() } }; assert (r[0] == 10); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index ecb2bf91702e4..81e14b186388e 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -15,7 +15,7 @@ type compare = fn@(@T, @T) -> bool; fn test_generic(expected: @T, eq: compare) { - let actual: @T = match true { true => { expected }, _ => die!() }; + let actual: @T = match true { true => { expected }, _ => fail!() }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index 6962f4b5e0f0d..9176e8672b2e1 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -16,7 +16,7 @@ type compare = fn@(T, T) -> bool; fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected }, _ => die!(~"wat") }; + let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index b0a5af1cd538b..36c591da853b2 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -16,7 +16,7 @@ type compare = fn@(~T, ~T) -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { true => { copy expected }, - _ => die!(~"wat") + _ => fail!(~"wat") }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index 02bc248fc4fff..2a504c2e2bd4f 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -18,7 +18,7 @@ type compare = fn@(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => copy expected, - _ => die!(~"wat") + _ => fail!(~"wat") }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index a3281ba57f1c2..d631e4eac5ebf 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -15,7 +15,7 @@ type compare = fn@(T, T) -> bool; fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected }, _ => die!(~"wat") }; + let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-struct.rs b/src/test/run-pass/expr-alt-struct.rs index bcf07586f244a..620881d30e3ce 100644 --- a/src/test/run-pass/expr-alt-struct.rs +++ b/src/test/run-pass/expr-alt-struct.rs @@ -17,7 +17,7 @@ struct R { i: int } fn test_rec() { - let rs = match true { true => R {i: 100}, _ => die!() }; + let rs = match true { true => R {i: 100}, _ => fail!() }; assert (rs.i == 100); } diff --git a/src/test/run-pass/expr-alt-unique.rs b/src/test/run-pass/expr-alt-unique.rs index 1ce8e2d7624b6..2865da3dd1fd2 100644 --- a/src/test/run-pass/expr-alt-unique.rs +++ b/src/test/run-pass/expr-alt-unique.rs @@ -15,7 +15,7 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { ~100 }, _ => die!() }; + let res = match true { true => { ~100 }, _ => fail!() }; assert (*res == 100); } diff --git a/src/test/run-pass/expr-if-fail-all.rs b/src/test/run-pass/expr-if-fail-all.rs index a4c5799f4453a..19a046fd27e0d 100644 --- a/src/test/run-pass/expr-if-fail-all.rs +++ b/src/test/run-pass/expr-if-fail-all.rs @@ -10,4 +10,4 @@ // When all branches of an if expression result in fail, the entire if // expression results in fail. -pub fn main() { let x = if true { 10 } else { if true { die!() } else { die!() } }; } +pub fn main() { let x = if true { 10 } else { if true { fail!() } else { fail!() } }; } diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index 698db97407c3e..61f118d184073 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test_if_fail() { let x = if false { die!() } else { 10 }; assert (x == 10); } +fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert (x == 10); } fn test_else_fail() { - let x = if true { 10 } else { die!() }; + let x = if true { 10 } else { fail!() }; assert (x == 10); } fn test_elseif_fail() { - let x = if false { 0 } else if false { die!() } else { 10 }; + let x = if false { 0 } else if false { fail!() } else { 10 }; assert (x == 10); } diff --git a/src/test/run-pass/for-loop-fail.rs b/src/test/run-pass/for-loop-fail.rs index 55ffc3d025883..f885d8120e08f 100644 --- a/src/test/run-pass/for-loop-fail.rs +++ b/src/test/run-pass/for-loop-fail.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub fn main() { let x: ~[int] = ~[]; for x.each |_i| { die!(~"moop"); } } +pub fn main() { let x: ~[int] = ~[]; for x.each |_i| { fail!(~"moop"); } } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index baed91df0202a..ad52127604662 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -21,7 +21,7 @@ pub fn main() { match getopts(args, opts) { result::Ok(ref m) => assert !opt_present(m, "b"), - result::Err(ref f) => die!(fail_str(copy *f)) + result::Err(ref f) => fail!(fail_str(copy *f)) }; } diff --git a/src/test/run-pass/if-bot.rs b/src/test/run-pass/if-bot.rs index c830ff1e3eb40..8c6a82b41441b 100644 --- a/src/test/run-pass/if-bot.rs +++ b/src/test/run-pass/if-bot.rs @@ -11,6 +11,6 @@ pub fn main() { - let i: int = if false { die!() } else { 5 }; + let i: int = if false { fail!() } else { 5 }; log(debug, i); } diff --git a/src/test/run-pass/if-check.rs b/src/test/run-pass/if-check.rs index b4170fa6acc5a..5a516ba98619e 100644 --- a/src/test/run-pass/if-check.rs +++ b/src/test/run-pass/if-check.rs @@ -18,7 +18,7 @@ fn foo(x: uint) { if even(x) { log(debug, x); } else { - die!(); + fail!(); } } diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index d36cb99309214..b277b880c76b8 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -9,5 +9,5 @@ // except according to those terms. // xfail-test -pub fn main() { let early_error: fn@(str) -> ! = {|msg| die!() }; } +pub fn main() { let early_error: fn@(str) -> ! = {|msg| fail!() }; } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index 0e974a8e6a8ed..8e4036b36be6b 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -15,7 +15,7 @@ struct foo { impl foo { fn bar>(c: C) -> B { - die!(); + fail!(); } } diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index f491d5f86fa86..12e9157ba2473 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -15,7 +15,7 @@ trait clam { } enum foo = int; impl foo { - fn bar>(c: C) -> B { die!(); } + fn bar>(c: C) -> B { fail!(); } } pub fn main() { } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 0827d280cf782..0cae04b60bc74 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -53,9 +53,9 @@ pub mod pipes { #[abi = "rust-intrinsic"] mod rusti { - pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { die!(); } - pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { die!(); } - pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { die!(); } + pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail!(); } + pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail!(); } + pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail!(); } } // We should consider moving this to ::core::unsafe, although I @@ -89,7 +89,7 @@ pub mod pipes { // The receiver will eventually clean this up. unsafe { forget(move p); } } - full => { die!(~"duplicate send") } + full => { fail!(~"duplicate send") } blocked => { // The receiver will eventually clean this up. @@ -132,7 +132,7 @@ pub mod pipes { } full => { // This is impossible - die!(~"you dun goofed") + fail!(~"you dun goofed") } terminated => { // I have to clean up, use drop_glue @@ -149,7 +149,7 @@ pub mod pipes { } blocked => { // this shouldn't happen. - die!(~"terminating a blocked packet") + fail!(~"terminating a blocked packet") } terminated | full => { // I have to clean up, use drop_glue @@ -269,7 +269,7 @@ pub mod pingpong { pub fn do_pong(-c: pong) -> (ping, ()) { let packet = ::pipes::recv(move c); if packet.is_none() { - die!(~"sender closed the connection") + fail!(~"sender closed the connection") } (pingpong::liberate_pong(option::unwrap(move packet)), ()) } @@ -284,7 +284,7 @@ pub mod pingpong { pub fn do_ping(-c: ping) -> (pong, ()) { let packet = ::pipes::recv(move c); if packet.is_none() { - die!(~"sender closed the connection") + fail!(~"sender closed the connection") } (pingpong::liberate_ping(option::unwrap(move packet)), ()) } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 25d460656fdef..d6804d83d72c8 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -54,7 +54,7 @@ fn square_from_char(c: char) -> square { ' ' => { empty } _ => { error!("invalid square: %?", c); - die!() + fail!() } } } diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs index a2c181569cec0..02b147e65fce1 100644 --- a/src/test/run-pass/issue-3168.rs +++ b/src/test/run-pass/issue-3168.rs @@ -17,7 +17,7 @@ pub fn main() { do task::spawn |move p2| { p2.recv(); error!("sibling fails"); - die!(); + fail!(); } let (p3,c3) = pipes::stream(); c.send(move c3); diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index 911e50a0ed7bb..b5f2a1d22a6e5 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -19,7 +19,7 @@ pub fn main() { do task::spawn |move p2| { p2.recv(); error!("sibling fails"); - die!(); + fail!(); } let (p3,c3) = pipes::stream(); c.send(move c3); diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs index e12d2cbae4de3..d3820c1e54712 100644 --- a/src/test/run-pass/issue-3895.rs +++ b/src/test/run-pass/issue-3895.rs @@ -14,6 +14,6 @@ pub fn main() { match BadChar { _ if true => BadChar, - BadChar | BadSyntax => die!() , + BadChar | BadSyntax => fail!() , }; } diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass/issue-4016.rs index a8204d56f451e..515b342faf3df 100644 --- a/src/test/run-pass/issue-4016.rs +++ b/src/test/run-pass/issue-4016.rs @@ -21,7 +21,7 @@ trait JD : Deserializable { } fn exec() { let doc = result::unwrap(json::from_str("")); let _v: T = deserialize(&json::Deserializer(move doc)); - die!() + fail!() } pub fn main() {} diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs index b96d017eb9e78..f0ae9af1d2094 100644 --- a/src/test/run-pass/iter-eachi.rs +++ b/src/test/run-pass/iter-eachi.rs @@ -16,7 +16,7 @@ pub fn main() { } assert c == 5u; - for None::.eachi |i, v| { die!(); } + for None::.eachi |i, v| { fail!(); } let mut c = 0u; for Some(1u).eachi |i, v| { diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index 77dfbe237e3fd..9c04ccdcba0aa 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -15,7 +15,7 @@ fn lp(s: ~str, f: fn(~str) -> T) -> T { let r = f(s); return (move r); } - die!(); + fail!(); } fn apply(s: ~str, f: fn(~str) -> T) -> T { diff --git a/src/test/run-pass/lots-a-fail.rs b/src/test/run-pass/lots-a-fail.rs index 41c3516bef26d..ed9e6e540305d 100644 --- a/src/test/run-pass/lots-a-fail.rs +++ b/src/test/run-pass/lots-a-fail.rs @@ -12,7 +12,7 @@ extern mod std; fn die() { - die!(); + fail!(); } fn iloop() { diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 4bb87ab0cca97..ad8f7b9cecf57 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -17,7 +17,7 @@ macro_rules! overly_complicated ( Some($pat) => { $res } - _ => { die!(); } + _ => { fail!(); } } }) diff --git a/src/test/run-pass/negative.rs b/src/test/run-pass/negative.rs index 5b80a746260ae..d92496c4b7b40 100644 --- a/src/test/run-pass/negative.rs +++ b/src/test/run-pass/negative.rs @@ -11,6 +11,6 @@ pub fn main() { match -5 { -5 => {} - _ => { die!() } + _ => { fail!() } } } diff --git a/src/test/run-pass/nested-alts.rs b/src/test/run-pass/nested-alts.rs index f3b667209a0c0..5ba4e1208c85e 100644 --- a/src/test/run-pass/nested-alts.rs +++ b/src/test/run-pass/nested-alts.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn baz() -> ! { die!(); } +fn baz() -> ! { fail!(); } fn foo() { match Some::(5) { diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index a753ec4b68b44..149e346bb477b 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -24,7 +24,7 @@ pub fn main() { } } - // fn b(x:int) -> int { die!(); } + // fn b(x:int) -> int { fail!(); } let z = b(42); assert(z.i == 42); diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs index 470aa43d1ad42..eee2d18be8e33 100644 --- a/src/test/run-pass/nested-pattern.rs +++ b/src/test/run-pass/nested-pattern.rs @@ -16,7 +16,7 @@ enum t { foo(int, uint), bar(int, Option), } fn nested(o: t) { match o { - bar(i, Some::(_)) => { error!("wrong pattern matched"); die!(); } + bar(i, Some::(_)) => { error!("wrong pattern matched"); fail!(); } _ => { error!("succeeded"); } } } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index c4cc15197357e..846136c242c36 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -16,7 +16,7 @@ struct C { mut c: int } pub fn main() { match A {a: 10, b: @20} { x@A {a, b: @20} => { assert x.a == 10; assert a == 10; } - A {b, _} => { die!(); } + A {b, _} => { fail!(); } } let x@B {b, _} = B {a: 10, b: C {mut c: 20}}; x.b.c = 30; diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 604edc5e447cf..c0095b5296509 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -23,7 +23,7 @@ impl dtor : Drop { fn unwrap(+o: Option) -> T { match move o { Some(move v) => move v, - None => die!() + None => fail!() } } diff --git a/src/test/run-pass/parse-fail.rs b/src/test/run-pass/parse-fail.rs index c280bc0dde52d..087926e8da512 100644 --- a/src/test/run-pass/parse-fail.rs +++ b/src/test/run-pass/parse-fail.rs @@ -12,6 +12,6 @@ // -*- rust -*- -fn dont_call_me() { die!(); log(debug, 1); } +fn dont_call_me() { fail!(); log(debug, 1); } pub fn main() { } diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index 995ad4e71c0a1..d79160a41c44a 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -62,7 +62,7 @@ macro_rules! follow ( $(Some($message($($($x,)+)* next)) => { let $next = move_it!(next); $e })+ - _ => { die!() } + _ => { fail!() } } ); ) @@ -73,7 +73,7 @@ fn client_follow(+bank: bank::client::login) { let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); let bank = switch(move bank, follow! ( ok -> connected { move connected } - invalid -> _next { die!(~"bank closed the connected") } + invalid -> _next { fail!(~"bank closed the connected") } )); let bank = client::deposit(move bank, 100.00); @@ -83,7 +83,7 @@ fn client_follow(+bank: bank::client::login) { io::println(~"Yay! I got money!"); } insufficient_funds -> _next { - die!(~"someone stole my money") + fail!(~"someone stole my money") } )); } @@ -96,8 +96,8 @@ fn bank_client(+bank: bank::client::login) { Some(ok(connected)) => { move_it!(connected) } - Some(invalid(_)) => { die!(~"login unsuccessful") } - None => { die!(~"bank closed the connection") } + Some(invalid(_)) => { fail!(~"login unsuccessful") } + None => { fail!(~"bank closed the connection") } }; let bank = client::deposit(move bank, 100.00); @@ -107,10 +107,10 @@ fn bank_client(+bank: bank::client::login) { io::println(~"Yay! I got money!"); } Some(insufficient_funds(_)) => { - die!(~"someone stole my money") + fail!(~"someone stole my money") } None => { - die!(~"bank closed the connection") + fail!(~"bank closed the connection") } } } diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index 0bd06909ebb8e..6831170734d14 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -33,7 +33,7 @@ pub fn main() { pipes::spawn_service(oneshot::init, |p| { match try_recv(move p) { - Some(*) => { die!() } + Some(*) => { fail!() } None => { } } }); @@ -48,7 +48,7 @@ fn failtest() { let (c, p) = oneshot::init(); do task::spawn_with(move c) |_c| { - die!(); + fail!(); } error!("%?", recv(move p)); diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs index b16f02e78deb7..401c32b67f9d4 100644 --- a/src/test/run-pass/pipe-presentation-examples.rs +++ b/src/test/run-pass/pipe-presentation-examples.rs @@ -39,7 +39,7 @@ macro_rules! select_if ( let $next = move next; move $e })+ - _ => die!() + _ => fail!() } } else { select_if!( @@ -57,7 +57,7 @@ macro_rules! select_if ( $index:expr, $count:expr, } => { - die!() + fail!() } ) diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 362fe3265f6f3..62765d71398fc 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -94,7 +94,7 @@ fn test_select2() { match pipes::select2(move ap, move bp) { either::Left(*) => { } - either::Right(*) => { die!() } + either::Right(*) => { fail!() } } stream::client::send(move bc, ~"abc"); @@ -107,7 +107,7 @@ fn test_select2() { stream::client::send(move bc, ~"abc"); match pipes::select2(move ap, move bp) { - either::Left(*) => { die!() } + either::Left(*) => { fail!() } either::Right(*) => { } } diff --git a/src/test/run-pass/region-dependent-addr-of.rs b/src/test/run-pass/region-dependent-addr-of.rs index ab6d9cd58ea50..ca6e48d15180c 100644 --- a/src/test/run-pass/region-dependent-addr-of.rs +++ b/src/test/run-pass/region-dependent-addr-of.rs @@ -54,21 +54,21 @@ fn get_v5(a: &v/A, i: uint) -> &v/int { fn get_v6_a(a: &v/A, i: uint) -> &v/int { match a.value.v6 { Some(ref v) => &v.f, - None => die!() + None => fail!() } } fn get_v6_b(a: &v/A, i: uint) -> &v/int { match *a { A { value: B { v6: Some(ref v), _ } } => &v.f, - _ => die!() + _ => fail!() } } fn get_v6_c(a: &v/A, i: uint) -> &v/int { match a { &A { value: B { v6: Some(ref v), _ } } => &v.f, - _ => die!() + _ => fail!() } } diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs index b71707488e8c4..249b00e68129b 100644 --- a/src/test/run-pass/region-return-interior-of-option.rs +++ b/src/test/run-pass/region-return-interior-of-option.rs @@ -11,7 +11,7 @@ fn get(opt: &r/Option) -> &r/T { match *opt { Some(ref v) => v, - None => die!(~"none") + None => fail!(~"none") } } diff --git a/src/test/run-pass/regions-bot.rs b/src/test/run-pass/regions-bot.rs index 3c7a6dcbb85e7..3be9d72c690a2 100644 --- a/src/test/run-pass/regions-bot.rs +++ b/src/test/run-pass/regions-bot.rs @@ -10,7 +10,7 @@ // A very limited test of the "bottom" region -fn produce_static() -> &static/T { die!(); } +fn produce_static() -> &static/T { fail!(); } fn foo(x: &T) -> &uint { produce_static() } diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index 5086e8af50a53..167c4c14a1e51 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn my_err(s: ~str) -> ! { log(error, s); die!(); } +fn my_err(s: ~str) -> ! { log(error, s); fail!(); } fn okay(i: uint) -> int { if i == 3u { my_err(~"I don't like three"); } else { return 42; } diff --git a/src/test/run-pass/select-macro.rs b/src/test/run-pass/select-macro.rs index 83746c728e8cc..45df9cfa610c9 100644 --- a/src/test/run-pass/select-macro.rs +++ b/src/test/run-pass/select-macro.rs @@ -19,7 +19,7 @@ macro_rules! select_if ( $index:expr, $count:expr } => { - die!() + fail!() }; { @@ -40,7 +40,7 @@ macro_rules! select_if ( let $next = move next; move $e })+ - _ => die!() + _ => fail!() } } else { select_if!( diff --git a/src/test/run-pass/send-iloop.rs b/src/test/run-pass/send-iloop.rs index 848eb64235d87..f1b9c85a0ff1a 100644 --- a/src/test/run-pass/send-iloop.rs +++ b/src/test/run-pass/send-iloop.rs @@ -12,7 +12,7 @@ extern mod std; fn die() { - die!(); + fail!(); } fn iloop() { diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index b94439e6b9d82..89ba351e6e41c 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -16,7 +16,7 @@ enum clam { a(T, int), b, } fn uhoh(v: ~[clam]) { match v[1] { - a::(ref t, ref u) => { debug!("incorrect"); log(debug, u); die!(); } + a::(ref t, ref u) => { debug!("incorrect"); log(debug, u); fail!(); } b:: => { debug!("correct"); } } } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index e71444294dc1a..21d494e008867 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -20,7 +20,7 @@ pub fn main() { { match io::file_writer(&path, [io::Create, io::Truncate]) { - Err(copy e) => die!(e), + Err(copy e) => fail!(e), Ok(f) => { for uint::range(0, 1000) |_i| { f.write_u8(0); diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 65cc8e897d632..3af59a09ad04a 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -69,7 +69,7 @@ fn supervised() { // runs first, but I can imagine that changing. error!("supervised task=%?", task::get_task); task::yield(); - die!(); + fail!(); } fn supervisor() { diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs index 7ab533bd8701d..563e35be3d63b 100644 --- a/src/test/run-pass/task-killjoin.rs +++ b/src/test/run-pass/task-killjoin.rs @@ -20,7 +20,7 @@ fn supervised() { // currently not needed because the supervisor runs first, but I can // imagine that changing. task::yield(); - die!(); + fail!(); } fn supervisor() { diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 183db464fe291..cb169c3a6389d 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -21,12 +21,12 @@ fn test_cont() { let mut i = 0; while i < 1 { i += 1; let x: @int = loop; } } fn test_ret() { let x: @int = return; } fn test_fail() { - fn f() { let x: @int = die!(); } + fn f() { let x: @int = fail!(); } task::try(|| f() ); } fn test_fail_indirect() { - fn f() -> ! { die!(); } + fn f() -> ! { fail!(); } fn g() { let x: @int = f(); } task::try(|| g() ); } diff --git a/src/test/run-pass/test-runner-hides-main.rs b/src/test/run-pass/test-runner-hides-main.rs index 0c7710585a9c4..74b63e4dd27d4 100644 --- a/src/test/run-pass/test-runner-hides-main.rs +++ b/src/test/run-pass/test-runner-hides-main.rs @@ -15,4 +15,4 @@ extern mod std; // Building as a test runner means that a synthetic main will be run, // not ours -pub fn main() { die!(); } +pub fn main() { fail!(); } diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index 05d5796734051..babba058f5232 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -17,13 +17,13 @@ pub fn main() { t1(a) { assert a == 10; } - _ { die!(); } + _ { fail!(); } }*/ /*alt x { ~t1(a) { assert a == 10; } - _ { die!(); } + _ { fail!(); } }*/ } diff --git a/src/test/run-pass/unique-decl.rs b/src/test/run-pass/unique-decl.rs index 2bc95754e088d..31c1936b05a4c 100644 --- a/src/test/run-pass/unique-decl.rs +++ b/src/test/run-pass/unique-decl.rs @@ -13,5 +13,5 @@ pub fn main() { } fn f(i: ~int) -> ~int { - die!(); + fail!(); } diff --git a/src/test/run-pass/unique-pat.rs b/src/test/run-pass/unique-pat.rs index 82e3f6c9486c1..0b9ad6ee194e7 100644 --- a/src/test/run-pass/unique-pat.rs +++ b/src/test/run-pass/unique-pat.rs @@ -11,7 +11,7 @@ fn simple() { match ~true { ~true => { } - _ => { die!(); } + _ => { fail!(); } } } diff --git a/src/test/run-pass/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs index 54cd961dbf67f..8e900aa7ff3c4 100644 --- a/src/test/run-pass/unreachable-code-1.rs +++ b/src/test/run-pass/unreachable-code-1.rs @@ -12,7 +12,7 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = move die!(); + let c = move fail!(); id(c); //~ WARNING unreachable statement } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index 5c046ff0d1617..75b2bf090ba65 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -12,7 +12,7 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = move die!(); + let c = move fail!(); id(c); } @@ -20,7 +20,7 @@ fn call_id_2() { id(true) && id(return); } fn call_id_3() { id(return) && id(return); } -fn log_fail() { log(error, die!()); } +fn log_fail() { log(error, fail!()); } fn log_ret() { log(error, return); } diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs index 80bdc9adf419d..90e8d41d26a2d 100644 --- a/src/test/run-pass/unwind-box.rs +++ b/src/test/run-pass/unwind-box.rs @@ -13,7 +13,7 @@ extern mod std; fn f() { let a = @0; - die!(); + fail!(); } pub fn main() { diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 5e885f781e21c..fbe0e4711e110 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -34,7 +34,7 @@ fn complainer(c: SharedChan) -> complainer { fn f(c: SharedChan) { let _c = move complainer(c); - die!(); + fail!(); } pub fn main() { diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs index 52a64863e721a..55b286aee7ea0 100644 --- a/src/test/run-pass/unwind-resource2.rs +++ b/src/test/run-pass/unwind-resource2.rs @@ -27,7 +27,7 @@ fn complainer(c: @int) -> complainer { fn f() { let c = move complainer(@0); - die!(); + fail!(); } pub fn main() { diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index 5edf4de3be32e..8b0850cff774d 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -13,7 +13,7 @@ extern mod std; fn f() { let a = ~0; - die!(); + fail!(); } pub fn main() { diff --git a/src/test/run-pass/use-uninit-alt2.rs b/src/test/run-pass/use-uninit-alt2.rs index af0c796ca2713..37ba2260a08ac 100644 --- a/src/test/run-pass/use-uninit-alt2.rs +++ b/src/test/run-pass/use-uninit-alt2.rs @@ -12,7 +12,7 @@ fn foo(o: myoption) -> int { let mut x: int; - match o { none:: => { die!(); } some::(t) => { x = 5; } } + match o { none:: => { fail!(); } some::(t) => { x = 5; } } return x; } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 5ade882528965..28a5a5ca47b55 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -69,7 +69,7 @@ fn canttouchthis() -> uint { fn angrydome() { loop { if break { } } let mut i = 0; - loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => die!(~"wat") } } + loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => fail!(~"wat") } } break; } } From 5a4695d407b63faae33c37499dc3c9bac43dfaf8 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Wed, 13 Feb 2013 23:19:27 -0800 Subject: [PATCH 90/92] update tutorial and manual to use new `impl Trait for Type` syntax --- doc/rust.md | 24 ++++++++++++------------ doc/tutorial.md | 33 ++++++++++++++++----------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index 3013fe0e0eb8e..30896307aeebf 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1209,7 +1209,7 @@ to pointers to the trait name, used as a type. ~~~~ # trait Shape { } -# impl int: Shape { } +# impl Shape for int { } # let mycircle = 0; let myshape: Shape = @mycircle as @Shape; @@ -1233,7 +1233,7 @@ For example: trait Num { static pure fn from_int(n: int) -> Self; } -impl float: Num { +impl Num for float { static pure fn from_int(n: int) -> float { n as float } } let x: float = Num::from_int(42); @@ -1269,8 +1269,8 @@ Likewise, supertrait methods may also be called on trait objects. ~~~ {.xfail-test} # trait Shape { fn area() -> float; } # trait Circle : Shape { fn radius() -> float; } -# impl int: Shape { fn area() -> float { 0.0 } } -# impl int: Circle { fn radius() -> float { 0.0 } } +# impl Shape for int { fn area() -> float { 0.0 } } +# impl Circle for int { fn radius() -> float { 0.0 } } # let mycircle = 0; let mycircle: Circle = @mycircle as @Circle; @@ -1292,7 +1292,7 @@ Implementations are defined with the keyword `impl`. type Circle = {radius: float, center: Point}; -impl Circle: Shape { +impl Shape for Circle { fn draw(s: Surface) { do_draw_circle(s, self); } fn bounding_box() -> BoundingBox { let r = self.radius; @@ -1303,9 +1303,9 @@ impl Circle: Shape { ~~~~ It is possible to define an implementation without referring to a trait. -The methods in such an implementation can only be used statically -(as direct calls on the values of the type that the implementation targets). -In such an implementation, the type after the colon is omitted. +The methods in such an implementation can only be used +as direct calls on the values of the type that the implementation targets. +In such an implementation, the trait type and `for` after `impl` are omitted. Such implementations are limited to nominal types (enums, structs), and the implementation must appear in the same module or a sub-module as the `self` type. @@ -1320,10 +1320,10 @@ Implementation parameters are written after after the `impl` keyword. ~~~~ # trait Seq { } -impl ~[T]: Seq { +impl Seq for ~[T] { ... } -impl u32: Seq { +impl Seq for u32 { /* Treat the integer as a sequence of bits */ } ~~~~ @@ -2801,7 +2801,7 @@ trait Printable { fn to_str() -> ~str; } -impl int: Printable { +impl Printable for int { fn to_str() -> ~str { int::to_str(self) } } @@ -2844,7 +2844,7 @@ trait Printable { fn make_string() -> ~str; } -impl ~str: Printable { +impl Printable for ~str { fn make_string() -> ~str { copy self } } ~~~~~~~~ diff --git a/doc/tutorial.md b/doc/tutorial.md index 1087689b9bee1..a825b7f535f72 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1909,7 +1909,7 @@ struct TimeBomb { explosivity: uint } -impl TimeBomb : Drop { +impl Drop for TimeBomb { fn finalize(&self) { for iter::repeat(self.explosivity) { io::println("blam!"); @@ -1943,11 +1943,11 @@ and `&str`. ~~~~ # trait Printable { fn print(&self); } -impl int: Printable { +impl Printable for int { fn print(&self) { io::println(fmt!("%d", *self)) } } -impl &str: Printable { +impl Printable for &str { fn print(&self) { io::println(*self) } } @@ -1966,7 +1966,7 @@ trait Seq { fn iter(&self, b: fn(v: &T)); } -impl ~[T]: Seq { +impl Seq for ~[T] { fn len(&self) -> uint { vec::len(*self) } fn iter(&self, b: fn(v: &T)) { for vec::each(*self) |elt| { b(elt); } @@ -1978,7 +1978,7 @@ The implementation has to explicitly declare the type parameter that it binds, `T`, before using it to specify its trait type. Rust requires this declaration because the `impl` could also, for example, specify an implementation of `Seq`. The trait type (appearing -after the colon in the `impl`) *refers* to a type, rather than +between `impl` and `for`) *refers* to a type, rather than defining one. The type parameters bound by a trait are in scope in each of the @@ -2000,7 +2000,7 @@ trait Eq { } // In an impl, `self` refers just to the value of the receiver -impl int: Eq { +impl Eq for int { fn equals(&self, other: &int) -> bool { *other == *self } } ~~~~ @@ -2021,10 +2021,10 @@ trait Shape { static fn new(area: float) -> Self; } struct Circle { radius: float } struct Square { length: float } -impl Circle: Shape { +impl Shape for Circle { static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } } } -impl Square: Shape { +impl Shape for Square { static fn new(area: float) -> Square { Square { length: sqrt(area) } } } @@ -2084,7 +2084,7 @@ However, consider this function: ~~~~ # type Circle = int; type Rectangle = int; -# impl int: Drawable { fn draw(&self) {} } +# impl Drawable for int { fn draw(&self) {} } # fn new_circle() -> int { 1 } trait Drawable { fn draw(&self); } @@ -2120,9 +2120,8 @@ value to an object: # fn new_rectangle() -> Rectangle { true } # fn draw_all(shapes: &[@Drawable]) {} -impl Circle: Drawable { fn draw(&self) { ... } } - -impl Rectangle: Drawable { fn draw(&self) { ... } } +impl Drawable for Circle { fn draw(&self) { ... } } +impl Drawable for Rectangle { fn draw(&self) { ... } } let c: @Circle = @new_circle(); let r: @Rectangle = @new_rectangle(); @@ -2140,7 +2139,7 @@ for example, an `@Circle` may not be cast to an `~Drawable`. ~~~ # type Circle = int; type Rectangle = int; # trait Drawable { fn draw(&self); } -# impl int: Drawable { fn draw(&self) {} } +# impl Drawable for int { fn draw(&self) {} } # fn new_circle() -> int { 1 } # fn new_rectangle() -> int { 2 } // A managed object @@ -2180,10 +2179,10 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`. # use float::sqrt; # fn square(x: float) -> float { x * x } struct CircleStruct { center: Point, radius: float } -impl CircleStruct: Circle { +impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } } -impl CircleStruct: Shape { +impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } } ~~~~ @@ -2215,8 +2214,8 @@ Likewise, supertrait methods may also be called on trait objects. # use float::sqrt; # struct Point { x: float, y: float } # struct CircleStruct { center: Point, radius: float } -# impl CircleStruct: Circle { fn radius(&self) -> float { sqrt(self.area() / pi) } } -# impl CircleStruct: Shape { fn area(&self) -> float { pi * square(self.radius) } } +# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } } +# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } } let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f}; let mycircle: Circle = concrete as @Circle; From 216e85fadf465c25fe7bc4a9f06f8162ec12b552 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Feb 2013 17:07:26 -0800 Subject: [PATCH 91/92] libcore: Move the numeric operations out of Num. r=brson Sadly I could not use trait inheritance due to a type parameter substitution bug. --- src/libcore/core.rc | 2 +- src/libcore/num/f32.rs | 43 ++++++++++++------- src/libcore/num/f64.rs | 43 ++++++++++++------- src/libcore/num/float.rs | 43 ++++++++++++------- src/libcore/num/int-template.rs | 40 +++++++++++------- src/libcore/num/num.rs | 44 +++++++++----------- src/libcore/num/uint-template.rs | 40 +++++++++++------- src/libcore/prelude.rs | 2 +- src/test/compile-fail/autoderef-full-lval.rs | 2 +- src/test/run-pass/issue-3149.rs | 10 ++--- src/test/run-pass/trait-inheritance-num.rs | 2 +- src/test/run-pass/trait-inheritance-num1.rs | 4 +- src/test/run-pass/trait-inheritance-num2.rs | 2 +- src/test/run-pass/trait-inheritance-num3.rs | 4 +- src/test/run-pass/trait-inheritance-num5.rs | 2 +- 15 files changed, 165 insertions(+), 118 deletions(-) diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 7bf64d5b6684b..5b6c40e09ef07 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -199,7 +199,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector}; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::{Num, NumCast}; +pub use num::NumCast; pub use ptr::Ptr; pub use to_str::ToStr; pub use clone::Clone; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index eaed597dff780..d27393fe50783 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -13,8 +13,9 @@ use cmath; use cmp; use libc::{c_float, c_int}; -use num; use num::NumCast; +use num; +use ops; use option::Option; use from_str; use to_str; @@ -271,21 +272,6 @@ impl f32 : cmp::Ord { pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) } } -impl f32: num::Num { - #[inline(always)] - pure fn add(&self, other: &f32) -> f32 { return *self + *other; } - #[inline(always)] - pure fn sub(&self, other: &f32) -> f32 { return *self - *other; } - #[inline(always)] - pure fn mul(&self, other: &f32) -> f32 { return *self * *other; } - #[inline(always)] - pure fn div(&self, other: &f32) -> f32 { return *self / *other; } - #[inline(always)] - pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; } - #[inline(always)] - pure fn neg(&self) -> f32 { return -*self; } -} - impl f32: num::Zero { #[inline(always)] static pure fn zero() -> f32 { 0.0 } @@ -320,6 +306,31 @@ pub impl f32: NumCast { #[inline(always)] pure fn to_float(&self) -> float { *self as float } } +#[cfg(notest)] +impl ops::Add for f32 { + pure fn add(&self, other: &f32) -> f32 { *self + *other } +} +#[cfg(notest)] +impl ops::Sub for f32 { + pure fn sub(&self, other: &f32) -> f32 { *self - *other } +} +#[cfg(notest)] +impl ops::Mul for f32 { + pure fn mul(&self, other: &f32) -> f32 { *self * *other } +} +#[cfg(notest)] +impl ops::Div for f32 { + pure fn div(&self, other: &f32) -> f32 { *self / *other } +} +#[cfg(notest)] +impl ops::Modulo for f32 { + pure fn modulo(&self, other: &f32) -> f32 { *self % *other } +} +#[cfg(notest)] +impl ops::Neg for f32 { + pure fn neg(&self) -> f32 { -*self } +} + #[abi="rust-intrinsic"] pub extern { fn floorf32(val: f32) -> f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 8aaa48524e2fe..d189a0254eba8 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -14,8 +14,9 @@ use cmath; use cmp; use libc::{c_double, c_int}; use libc; -use num; use num::NumCast; +use num; +use ops; use option::Option; use to_str; use from_str; @@ -296,21 +297,6 @@ impl f64 : cmp::Ord { pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) } } -impl f64: num::Num { - #[inline(always)] - pure fn add(&self, other: &f64) -> f64 { return *self + *other; } - #[inline(always)] - pure fn sub(&self, other: &f64) -> f64 { return *self - *other; } - #[inline(always)] - pure fn mul(&self, other: &f64) -> f64 { return *self * *other; } - #[inline(always)] - pure fn div(&self, other: &f64) -> f64 { return *self / *other; } - #[inline(always)] - pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; } - #[inline(always)] - pure fn neg(&self) -> f64 { return -*self; } -} - pub impl f64: NumCast { /** * Cast `n` to an `f64` @@ -345,6 +331,31 @@ impl f64: num::One { static pure fn one() -> f64 { 1.0 } } +#[cfg(notest)] +impl ops::Add for f64 { + pure fn add(&self, other: &f64) -> f64 { *self + *other } +} +#[cfg(notest)] +impl ops::Sub for f64 { + pure fn sub(&self, other: &f64) -> f64 { *self - *other } +} +#[cfg(notest)] +impl ops::Mul for f64 { + pure fn mul(&self, other: &f64) -> f64 { *self * *other } +} +#[cfg(notest)] +impl ops::Div for f64 { + pure fn div(&self, other: &f64) -> f64 { *self / *other } +} +#[cfg(notest)] +impl ops::Modulo for f64 { + pure fn modulo(&self, other: &f64) -> f64 { *self % *other } +} +#[cfg(notest)] +impl ops::Neg for f64 { + pure fn neg(&self) -> f64 { -*self } +} + #[abi="rust-intrinsic"] pub extern { fn floorf64(val: f64) -> f64; diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index c7d391bab08d5..bbea58f5cf5dc 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -25,8 +25,9 @@ use m_float = f64; use cmp::{Eq, Ord}; use cmp; use f64; -use num; use num::NumCast; +use num; +use ops; use option::{None, Option, Some}; use str; use uint; @@ -404,21 +405,6 @@ impl float : Ord { pure fn gt(&self, other: &float) -> bool { (*self) > (*other) } } -impl float: num::Num { - #[inline(always)] - pub pure fn add(&self, other: &float) -> float { return *self + *other; } - #[inline(always)] - pub pure fn sub(&self, other: &float) -> float { return *self - *other; } - #[inline(always)] - pub pure fn mul(&self, other: &float) -> float { return *self * *other; } - #[inline(always)] - pub pure fn div(&self, other: &float) -> float { return *self / *other; } - #[inline(always)] - pure fn modulo(&self, other: &float) -> float { return *self % *other; } - #[inline(always)] - pure fn neg(&self) -> float { return -*self; } -} - impl float: num::Zero { #[inline(always)] static pure fn zero() -> float { 0.0 } @@ -486,6 +472,31 @@ impl float: num::Round { } } +#[cfg(notest)] +impl ops::Add for float { + pure fn add(&self, other: &float) -> float { *self + *other } +} +#[cfg(notest)] +impl ops::Sub for float { + pure fn sub(&self, other: &float) -> float { *self - *other } +} +#[cfg(notest)] +impl ops::Mul for float { + pure fn mul(&self, other: &float) -> float { *self * *other } +} +#[cfg(notest)] +impl ops::Div for float { + pure fn div(&self, other: &float) -> float { *self / *other } +} +#[cfg(notest)] +impl ops::Modulo for float { + pure fn modulo(&self, other: &float) -> float { *self % *other } +} +#[cfg(notest)] +impl ops::Neg for float { + pure fn neg(&self) -> float { -*self } +} + #[test] pub fn test_from_str() { assert from_str(~"3") == Some(3.); diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 71c06bc9d24d7..c25938a187fda 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -166,21 +166,6 @@ impl T : Eq { pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } } -impl T: num::Num { - #[inline(always)] - pure fn add(&self, other: &T) -> T { return *self + *other; } - #[inline(always)] - pure fn sub(&self, other: &T) -> T { return *self - *other; } - #[inline(always)] - pure fn mul(&self, other: &T) -> T { return *self * *other; } - #[inline(always)] - pure fn div(&self, other: &T) -> T { return *self / *other; } - #[inline(always)] - pure fn modulo(&self, other: &T) -> T { return *self % *other; } - #[inline(always)] - pure fn neg(&self) -> T { return -*self; } -} - impl T: num::Zero { #[inline(always)] static pure fn zero() -> T { 0 } @@ -203,6 +188,31 @@ impl T: num::Round { pure fn fract(&self) -> T { 0 } } +#[cfg(notest)] +impl ops::Add for T { + pure fn add(&self, other: &T) -> T { *self + *other } +} +#[cfg(notest)] +impl ops::Sub for T { + pure fn sub(&self, other: &T) -> T { *self - *other } +} +#[cfg(notest)] +impl ops::Mul for T { + pure fn mul(&self, other: &T) -> T { *self * *other } +} +#[cfg(notest)] +impl ops::Div for T { + pure fn div(&self, other: &T) -> T { *self / *other } +} +#[cfg(notest)] +impl ops::Modulo for T { + pure fn modulo(&self, other: &T) -> T { *self % *other } +} +#[cfg(notest)] +impl ops::Neg for T { + pure fn neg(&self) -> T { -*self } +} + // String conversion functions and impl str -> num /// Parse a string as a number in base 10. diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 8435a7b8ea29f..44cd66363fb28 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -10,22 +10,13 @@ //! An interface for numeric types use core::cmp::{Ord, Eq}; +use ops::{Add, Div, Modulo, Mul, Neg, Sub}; use option::{None, Option, Some}; use char; use str; use kinds::Copy; use vec; -pub trait Num { - // FIXME: Trait composition. (#2616) - pure fn add(&self, other: &Self) -> Self; - pure fn sub(&self, other: &Self) -> Self; - pure fn mul(&self, other: &Self) -> Self; - pure fn div(&self, other: &Self) -> Self; - pure fn modulo(&self, other: &Self) -> Self; - pure fn neg(&self) -> Self; -} - pub trait IntConvertible { pure fn to_int(&self) -> int; static pure fn from_int(n: int) -> Self; @@ -39,7 +30,7 @@ pub trait One { static pure fn one() -> Self; } -pub pure fn abs(v: T) -> T { +pub pure fn abs>(v: T) -> T { if v < Zero::zero() { v.neg() } else { v } } @@ -109,7 +100,7 @@ pub trait FromStrRadix { /// Dynamically calculates the value `inf` (`1/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn infinity() -> T { +pub pure fn infinity>() -> T { let _0: T = Zero::zero(); let _1: T = One::one(); _1 / _0 @@ -118,7 +109,7 @@ pub pure fn infinity() -> T { /// Dynamically calculates the value `-inf` (`-1/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn neg_infinity() -> T { +pub pure fn neg_infinity+Neg>() -> T { let _0: T = Zero::zero(); let _1: T = One::one(); - _1 / _0 @@ -127,7 +118,7 @@ pub pure fn neg_infinity() -> T { /// Dynamically calculates the value `NaN` (`0/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn NaN() -> T { +pub pure fn NaN>() -> T { let _0: T = Zero::zero(); _0 / _0 } @@ -135,27 +126,28 @@ pub pure fn NaN() -> T { /// Returns `true` if `num` has the value `inf` (`1/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn is_infinity(num: &T) -> bool { +pub pure fn is_infinity>(num: &T) -> bool { (*num) == (infinity::()) } /// Returns `true` if `num` has the value `-inf` (`-1/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn is_neg_infinity(num: &T) -> bool { +pub pure fn is_neg_infinity+Neg>(num: &T) + -> bool { (*num) == (neg_infinity::()) } /// Returns `true` if `num` has the value `NaN` (is not equal to itself). #[inline(always)] -pub pure fn is_NaN(num: &T) -> bool { +pub pure fn is_NaN(num: &T) -> bool { (*num) != (*num) } /// Returns `true` if `num` has the value `-0` (`1/num == -1/0`). /// Can fail on integer types. #[inline(always)] -pub pure fn is_neg_zero(num: &T) -> bool { +pub pure fn is_neg_zero+Neg>(num: &T) -> bool { let _1: T = One::one(); let _0: T = Zero::zero(); *num == _0 && is_neg_infinity(&(_1 / *num)) @@ -174,8 +166,8 @@ pub pure fn is_neg_zero(num: &T) -> bool { * - If code written to use this function doesn't care about it, it's * probably assuming that `x^0` always equals `1`. */ -pub pure fn pow_with_uint(radix: uint, - pow: uint) -> T { +pub pure fn pow_with_uint+Mul>( + radix: uint, pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -256,7 +248,8 @@ pub enum SignFormat { * those special values, and `special` is `false`, because then the * algorithm just does normal calculations on them. */ -pub pure fn to_str_bytes_common( +pub pure fn to_str_bytes_common+ + Neg+Modulo+Mul>( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if radix as int < 2 { @@ -478,7 +471,8 @@ pub pure fn to_str_bytes_common( * `to_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn to_str_common( +pub pure fn to_str_common+Neg + +Modulo+Mul>( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { let (bytes, special) = to_str_bytes_common(num, radix, special, @@ -533,7 +527,8 @@ priv const DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; * - Could accept option to allow ignoring underscores, allowing for numbers * formated like `FF_AE_FF_FF`. */ -pub pure fn from_str_bytes_common( +pub pure fn from_str_bytes_common+ + Mul+Sub+Neg+Add>( buf: &[u8], radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { @@ -720,7 +715,8 @@ pub pure fn from_str_bytes_common( * `from_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn from_str_common( +pub pure fn from_str_common+Mul+ + Sub+Neg+Add>( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 0f74b73e1c502..adfd50e20e791 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -130,21 +130,6 @@ impl T : Eq { pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } } -impl T: num::Num { - #[inline(always)] - pure fn add(&self, other: &T) -> T { return *self + *other; } - #[inline(always)] - pure fn sub(&self, other: &T) -> T { return *self - *other; } - #[inline(always)] - pure fn mul(&self, other: &T) -> T { return *self * *other; } - #[inline(always)] - pure fn div(&self, other: &T) -> T { return *self / *other; } - #[inline(always)] - pure fn modulo(&self, other: &T) -> T { return *self % *other; } - #[inline(always)] - pure fn neg(&self) -> T { return -*self; } -} - impl T: num::Zero { #[inline(always)] static pure fn zero() -> T { 0 } @@ -167,6 +152,31 @@ impl T: num::Round { pure fn fract(&self) -> T { 0 } } +#[cfg(notest)] +impl ops::Add for T { + pure fn add(&self, other: &T) -> T { *self + *other } +} +#[cfg(notest)] +impl ops::Sub for T { + pure fn sub(&self, other: &T) -> T { *self - *other } +} +#[cfg(notest)] +impl ops::Mul for T { + pure fn mul(&self, other: &T) -> T { *self * *other } +} +#[cfg(notest)] +impl ops::Div for T { + pure fn div(&self, other: &T) -> T { *self / *other } +} +#[cfg(notest)] +impl ops::Modulo for T { + pure fn modulo(&self, other: &T) -> T { *self % *other } +} +#[cfg(notest)] +impl ops::Neg for T { + pure fn neg(&self) -> T { -*self } +} + // String conversion functions and impl str -> num /// Parse a string as a number in base 10. diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 5b4726d482d9e..b50fa265f030d 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -29,7 +29,7 @@ pub use container::{Container, Mutable, Map, Set}; pub use hash::Hash; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::{Num, NumCast}; +pub use num::NumCast; pub use path::GenericPath; pub use path::Path; pub use path::PosixPath; diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index c76bd192e6a70..fec5c994de780 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: binary operation + cannot be applied to type +// error-pattern: mismatched types type clam = {x: @int, y: @int}; type fish = {a: @int}; diff --git a/src/test/run-pass/issue-3149.rs b/src/test/run-pass/issue-3149.rs index 805aac92937db..df102f93c2bb7 100644 --- a/src/test/run-pass/issue-3149.rs +++ b/src/test/run-pass/issue-3149.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pure fn Matrix4(m11: T, m12: T, m13: T, m14: T, - m21: T, m22: T, m23: T, m24: T, - m31: T, m32: T, m33: T, m34: T, - m41: T, m42: T, m43: T, m44: T) - -> Matrix4 { +pure fn Matrix4(m11: T, m12: T, m13: T, m14: T, + m21: T, m22: T, m23: T, m24: T, + m31: T, m32: T, m33: T, m34: T, + m41: T, m42: T, m43: T, m44: T) + -> Matrix4 { Matrix4 { m11: m11, m12: m12, m13: m13, m14: m14, diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index c7a049b2f34e0..4e46d6b2b18b0 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -16,7 +16,7 @@ use num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; -pub trait NumExt: Num NumCast Eq Ord {} +pub trait NumExt: NumCast Eq Ord {} pub trait FloatExt: NumExt FuzzyEq {} diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index a9cbd4e622c40..03230dc39af35 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Using the real Num from core - use cmp::Ord; use num::NumCast::from; -pub trait NumExt: Num NumCast Ord { } +pub trait NumExt: NumCast Ord { } fn greater_than_one(n: &T) -> bool { *n > from(1) diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index 6829990bc5acd..fb2969a839824 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -38,7 +38,7 @@ pub impl f64: TypeExt {} pub impl float: TypeExt {} -pub trait NumExt: TypeExt Eq Ord Num NumCast {} +pub trait NumExt: TypeExt Eq Ord NumCast {} pub impl u8: NumExt {} pub impl u16: NumExt {} diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index 32775164d35ef..30cc54230223f 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -11,7 +11,7 @@ use cmp::{Eq, Ord}; use num::NumCast::from; -pub trait NumExt: Eq Ord Num NumCast {} +pub trait NumExt: Eq Ord NumCast {} pub impl f32: NumExt {} @@ -19,4 +19,4 @@ fn num_eq_one(n: T) { io::println(fmt!("%?", n == from(1))) } pub fn main() { num_eq_one(1f32); // you need to actually use the function to trigger the ICE -} \ No newline at end of file +} diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index 13c75224e5f88..c2b88c59f874f 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -11,7 +11,7 @@ use cmp::{Eq, Ord}; use num::NumCast::from; -pub trait NumExt: Eq Num NumCast {} +pub trait NumExt: Eq NumCast {} pub impl f32: NumExt {} pub impl int: NumExt {} From 4699ac67c6b48331852f3960430a3c8cfcaf7b90 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 14 Feb 2013 13:09:09 -0800 Subject: [PATCH 92/92] Remove all final references to die! --- src/libcore/hashmap.rs | 6 +++--- src/libcore/os.rs | 4 ++-- src/libstd/json.rs | 4 ++-- src/libstd/test.rs | 2 +- src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs | 2 +- .../compile-fail/borrowck-borrow-from-stack-variable.rs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index fc117f99e9087..9e9aa1f160632 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -159,7 +159,7 @@ pub mod linear { pure fn value_for_bucket(&self, idx: uint) -> &self/V { match self.buckets[idx] { Some(ref bkt) => &bkt.value, - None => die!(~"LinearMap::find: internal logic error"), + None => fail!(~"LinearMap::find: internal logic error"), } } @@ -373,7 +373,7 @@ pub mod linear { let hash = k.hash_keyed(self.k0, self.k1) as uint; let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => die!(~"Internal logic error"), + TableFull => fail!(~"Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { self.buckets[idx] = Some(Bucket{hash: hash, key: k, @@ -403,7 +403,7 @@ pub mod linear { let hash = k.hash_keyed(self.k0, self.k1) as uint; let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => die!(~"Internal logic error"), + TableFull => fail!(~"Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { let v = f(&k); diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 6ed8d70642cce..8a6a241d87067 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -849,7 +849,7 @@ pub fn last_os_error() -> ~str { let err = strerror_r(errno() as c_int, &buf[0], TMPBUF_SZ as size_t); if err < 0 { - die!(~"strerror_r failure"); + fail!(~"strerror_r failure"); } str::raw::from_c_str(&buf[0]) @@ -887,7 +887,7 @@ pub fn last_os_error() -> ~str { &mut buf[0], TMPBUF_SZ as DWORD, ptr::null()); if res == 0 { - die!(fmt!("[%?] FormatMessage failure", errno())); + fail!(fmt!("[%?] FormatMessage failure", errno())); } str::raw::from_c_str(&buf[0]) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 95f9130fa372f..989caaabb309f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1284,13 +1284,13 @@ mod tests { // Should they be in their own crate? pub pure fn check_equal_ptr (given : &T, expected: &T) { if !((given == expected) && (expected == given )) { - die!(fmt!("given %?, expected %?",given,expected)); + fail!(fmt!("given %?, expected %?",given,expected)); } } pub pure fn check_equal (given : T, expected: T) { if !((given == expected) && (expected == given )) { - die!(fmt!("given %?, expected %?",given,expected)); + fail!(fmt!("given %?, expected %?",given,expected)); } } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 530761e48a201..2eae377b91af5 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -143,7 +143,7 @@ pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) { TestDescAndFn { testfn: StaticBenchFn(f), desc: copy t.desc }, _ => { - die! (~"non-static tests passed to test::test_main_static"); + fail!(~"non-static tests passed to test::test_main_static"); } } }; diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs index 47b6b4de64281..005908f86d87d 100644 --- a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -18,7 +18,7 @@ struct Bar { int2: int, } -fn make_foo() -> ~Foo { die!() } +fn make_foo() -> ~Foo { fail!() } fn borrow_same_field_twice_mut_mut() { let mut foo = make_foo(); diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs index 30757cc6e7798..035e293bc36b6 100644 --- a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -18,7 +18,7 @@ struct Bar { int2: int, } -fn make_foo() -> Foo { die!() } +fn make_foo() -> Foo { fail!() } fn borrow_same_field_twice_mut_mut() { let mut foo = make_foo();