Permalink
Browse files

use + mode for (almost) everything when not using legacy modes

  • Loading branch information...
nikomatsakis committed Sep 20, 2012
1 parent 37aee97 commit 267ab11cca722c1c83dcb6df949961390af787c1
Showing with 133 additions and 68 deletions.
  1. +2 −0 src/cargo/cargo.rc
  2. +1 −1 src/compiletest/compiletest.rs
  3. +20 −5 src/libcore/pipes.rs
  4. +1 −1 src/libcore/uint-template.rs
  5. +1 −1 src/libcore/vec.rs
  6. +1 −1 src/rustc/front/intrinsic.rs
  7. +25 −5 src/rustc/middle/ty.rs
  8. +9 −2 src/rustc/middle/typeck.rs
  9. +2 −2 src/rustc/middle/typeck/check.rs
  10. +1 −1 src/test/bench/core-map.rs
  11. +1 −1 src/test/bench/core-std.rs
  12. +1 −1 src/test/bench/core-uint-to-str.rs
  13. +1 −1 src/test/bench/core-vec-append.rs
  14. +1 −1 src/test/bench/graph500-bfs.rs
  15. +1 −1 src/test/bench/msgsend-pipes-shared.rs
  16. +1 −1 src/test/bench/msgsend-pipes.rs
  17. +1 −1 src/test/bench/msgsend-ring-mutex-arcs.rs
  18. +1 −1 src/test/bench/msgsend-ring-pipes.rs
  19. +1 −1 src/test/bench/msgsend-ring-rw-arcs.rs
  20. +1 −1 src/test/bench/msgsend-ring.rs
  21. +1 −1 src/test/bench/msgsend.rs
  22. +1 −1 src/test/bench/shootout-ackermann.rs
  23. +1 −1 src/test/bench/shootout-binarytrees.rs
  24. +1 −1 src/test/bench/shootout-chameneos-redux.rs
  25. +2 −2 src/test/bench/shootout-fannkuchredux.rs
  26. +1 −1 src/test/bench/shootout-fasta.rs
  27. +1 −1 src/test/bench/shootout-fibo.rs
  28. +1 −1 src/test/bench/shootout-k-nucleotide-pipes.rs
  29. +1 −1 src/test/bench/shootout-k-nucleotide.rs
  30. +1 −1 src/test/bench/shootout-mandelbrot.rs
  31. +1 −1 src/test/bench/shootout-nbody.rs
  32. +1 −1 src/test/bench/shootout-pfib.rs
  33. +1 −1 src/test/bench/shootout-spectralnorm.rs
  34. +1 −1 src/test/bench/shootout-threadring.rs
  35. +1 −1 src/test/bench/std-smallintmap.rs
  36. +1 −1 src/test/bench/sudoku.rs
  37. +1 −1 src/test/bench/task-perf-jargon-metal-smoke.rs
  38. +1 −1 src/test/bench/task-perf-linked-failure.rs
  39. +1 −1 src/test/bench/task-perf-one-million.rs
  40. +1 −1 src/test/bench/task-perf-spawnalot.rs
  41. +1 −1 src/test/bench/task-perf-word-count-generic.rs
  42. +1 −1 src/test/compile-fail/bad-main.rs
  43. +1 −0 src/test/run-pass/alt-pattern-drop.rs
  44. +1 −1 src/test/run-pass/argv.rs
  45. +1 −1 src/test/run-pass/command-line-args.rs
  46. +1 −1 src/test/run-pass/foreign2.rs
  47. +1 −1 src/test/run-pass/import4.rs
  48. +1 −1 src/test/run-pass/import5.rs
  49. +1 −1 src/test/run-pass/import7.rs
  50. +2 −2 src/test/run-pass/issue-2834.rs
  51. +1 −1 src/test/run-pass/main-ivec.rs
  52. +20 −0 src/test/run-pass/non-legacy-modes.rs
  53. +2 −2 src/test/run-pass/option-ext.rs
  54. +1 −1 src/test/run-pass/path.rs
  55. +1 −1 src/test/run-pass/swap-2.rs
  56. +1 −1 src/test/run-pass/tag-in-block.rs
  57. +1 −1 src/test/run-pass/type-param.rs
  58. +1 −1 src/test/run-pass/type-ptr.rs
View
@@ -19,6 +19,8 @@
#[no_core];
#[legacy_exports];
+#[legacy_modes];
+
#[allow(vecs_implicitly_copyable,
non_implicitly_copyable_typarams)];
#[allow(non_camel_case_types)];
@@ -12,7 +12,7 @@ use common::mode_pretty;
use common::mode;
use util::logv;
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let config = parse_config(args);
log_config(config);
run_tests(config);
View
@@ -256,16 +256,31 @@ fn entangle_buffer<T: Send, Tstart: Send>(
(SendPacketBuffered(p), RecvPacketBuffered(p))
}
+#[cfg(stage0)]
#[abi = "rust-intrinsic"]
#[doc(hidden)]
extern mod rusti {
#[legacy_exports];
- fn atomic_xchg(dst: &mut int, src: int) -> int;
- fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
- fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
+ fn atomic_xchg(dst: &mut int, ++src: int) -> int;
+ fn atomic_xchg_acq(dst: &mut int, ++src: int) -> int;
+ fn atomic_xchg_rel(dst: &mut int, ++src: int) -> int;
- fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
- fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
+ fn atomic_xadd_acq(dst: &mut int, ++src: int) -> int;
+ fn atomic_xsub_rel(dst: &mut int, ++src: int) -> int;
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[abi = "rust-intrinsic"]
+#[doc(hidden)]
+extern mod rusti {
+ #[legacy_exports];
+ fn atomic_xchg(dst: &mut int, +src: int) -> int;
+ fn atomic_xchg_acq(dst: &mut int, +src: int) -> int;
+ fn atomic_xchg_rel(dst: &mut int, +src: int) -> int;
+
+ fn atomic_xadd_acq(dst: &mut int, +src: int) -> int;
+ fn atomic_xsub_rel(dst: &mut int, +src: int) -> int;
}
// If I call the rusti versions directly from a polymorphic function,
@@ -240,7 +240,7 @@ pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
}
vec::raw::form_slice(ptr::offset(p, i),
- len - i, f)
+ len - i, f)
}
}
}
View
@@ -1723,7 +1723,7 @@ mod raw {
* not bytes).
*/
#[inline(always)]
- unsafe fn form_slice<T,U>(p: *T, len: uint, f: fn(&&v: &[T]) -> U) -> U {
+ unsafe fn form_slice<T,U>(p: *T, len: uint, f: fn(v: &[T]) -> U) -> U {
let pair = (p, len * sys::size_of::<T>());
let v : *(&blk/[T]) =
::cast::reinterpret_cast(&ptr::addr_of(pair));
@@ -116,6 +116,6 @@ mod intrinsic {
extern mod rusti {
#[legacy_exports];
fn get_tydesc<T>() -> *();
- fn visit_tydesc(td: *TyDesc, &&tv: TyVisitor);
+ fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
}
}
View
@@ -133,6 +133,7 @@ export type_is_numeric;
export type_is_pod;
export type_is_scalar;
export type_is_immediate;
+export type_is_borrowed;
export type_is_sequence;
export type_is_signed;
export type_is_structural;
@@ -1090,13 +1091,21 @@ pure fn mach_sty(cfg: @session::config, t: t) -> sty {
}
fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
- return if ty::type_is_immediate(ty) {
- ast::by_val
- } else if tcx.legacy_modes || type_is_fn(ty) {
- // ^^^^^^^^^^^^^^
+ return if type_is_fn(ty) {
+ // ^^^^^^^^^^^^^^
// FIXME(#2202) --- We retain by-ref by default to workaround a memory
// leak that otherwise results when @fn is upcast to &fn.
ast::by_ref
+ } else if tcx.legacy_modes {
+ if type_is_borrowed(ty) {
+ // the old mode default was ++ for things like &ptr, but to be
+ // forward-compatible with non-legacy, we should use +
+ ast::by_copy
+ } else if ty::type_is_immediate(ty) {
+ ast::by_val
+ } else {
+ ast::by_ref
+ }
} else {
ast::by_copy
};
@@ -1107,6 +1116,18 @@ fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
_ => false
}
}
+
+ fn type_is_borrowed(ty: t) -> bool {
+ match ty::get(ty).sty {
+ ty::ty_rptr(*) => true,
+ ty_evec(_, vstore_slice(_)) => true,
+ ty_estr(vstore_slice(_)) => true,
+
+ // technically, we prob ought to include
+ // &fn(), but that is treated specially due to #2202
+ _ => false
+ }
+ }
}
// Returns the narrowest lifetime enclosing the evaluation of the expression
@@ -1575,7 +1596,6 @@ fn type_is_immediate(ty: t) -> bool {
type_is_unique(ty) || type_is_region_ptr(ty);
}
-
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
match cx.needs_drop_cache.find(ty) {
Some(result) => return result,
View
@@ -256,7 +256,14 @@ fn require_same_types(
}
}
-fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool {
+fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
+ match ty::resolved_mode(tcx, a.mode) {
+ ast::by_val => { /*ok*/ }
+ _ => {
+ return false;
+ }
+ }
+
match ty::get(a.ty).sty {
ty::ty_evec(mt, vstore_uniq) => {
if mt.mutbl != ast::m_imm { return false; }
@@ -300,7 +307,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
tcx.sess.span_err(
main_span,
fmt!("Wrong type in main function: found `%s`, \
- expected `extern fn(~[str]) -> ()` \
+ expected `extern fn(++v: ~[~str]) -> ()` \
or `extern fn() -> ()`",
ty_to_str(tcx, main_t)));
}
@@ -2609,10 +2609,10 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
~"atomic_xchg" | ~"atomic_xadd" | ~"atomic_xsub" |
~"atomic_xchg_acq" | ~"atomic_xadd_acq" | ~"atomic_xsub_acq" |
~"atomic_xchg_rel" | ~"atomic_xadd_rel" | ~"atomic_xsub_rel" => {
- (0u, ~[arg(ast::by_val,
+ (0u, ~[arg(ast::by_copy,
ty::mk_mut_rptr(tcx, ty::re_bound(ty::br_anon(0)),
ty::mk_int(tcx))),
- arg(ast::by_val, ty::mk_int(tcx))],
+ arg(ast::by_copy, ty::mk_int(tcx))],
ty::mk_int(tcx))
}
@@ -142,7 +142,7 @@ fn empty_results() -> Results {
}
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let num_keys = {
if args.len() == 2 {
uint::from_str(args[1]).get()
@@ -8,7 +8,7 @@ use std::map::{Map, HashMap};
use io::{Reader, ReaderUtil};
-fn main(argv: ~[~str]) {
+fn main(++argv: ~[~str]) {
#macro[
[#bench[id],
maybe_run_test(argv, #stringify(id), id)
@@ -1,4 +1,4 @@
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"10000000"]
} else if args.len() <= 1u {
@@ -20,7 +20,7 @@ fn collect_dvec(num: uint) -> ~[uint] {
return dvec::unwrap(move result);
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"50000000"]
} else if args.len() <= 1u {
@@ -384,7 +384,7 @@ fn validate(edges: ~[(node_id, node_id)],
true
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"15", ~"48"]
} else if args.len() <= 1u {
@@ -90,7 +90,7 @@ fn run(args: &[~str]) {
assert result == num_bytes * size;
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"10000"]
} else if args.len() <= 1u {
@@ -87,7 +87,7 @@ fn run(args: &[~str]) {
assert result == num_bytes * size;
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"8"]
} else if args.len() <= 1u {
@@ -56,7 +56,7 @@ fn thread_ring(i: uint,
};
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {
@@ -52,7 +52,7 @@ fn thread_ring(i: uint,
};
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {
@@ -56,7 +56,7 @@ fn thread_ring(i: uint,
};
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {
@@ -21,7 +21,7 @@ fn thread_ring(i: uint,
};
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {
@@ -57,7 +57,7 @@ fn run(args: ~[~str]) {
io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput));
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"10000"]
} else if args.len() <= 1u {
@@ -12,7 +12,7 @@ fn ack(m: int, n: int) -> int {
}
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"12"]
} else if args.len() <= 1u {
@@ -25,7 +25,7 @@ fn bottom_up_tree(arena: &r/arena::Arena,
return arena.alloc(|| nil);
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"17"]
} else if args.len() <= 1u {
@@ -178,7 +178,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
io::println(show_number(creatures_met));
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"200000"]
} else if args.len() <= 1u {
@@ -5,7 +5,7 @@ fn fannkuch(n: int) -> int {
fn perm1init(i: uint) -> int { return i as int; }
let perm = vec::to_mut(vec::from_elem(n as uint, 0));
- let perm1 = vec::to_mut(vec::from_fn(n as uint, perm1init));
+ let perm1 = vec::to_mut(vec::from_fn(n as uint, |i| perm1init(i)));
let count = vec::to_mut(vec::from_elem(n as uint, 0));
let mut f = 0;
let mut i = 0;
@@ -56,7 +56,7 @@ fn fannkuch(n: int) -> int {
return flips;
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"10"]
} else if args.len() <= 1u {
@@ -70,7 +70,7 @@ fn make_repeat_fasta(wr: io::Writer, id: ~str, desc: ~str, s: ~str, n: int) unsa
fn acid(ch: char, prob: u32) -> aminoacids { return {ch: ch, prob: prob}; }
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
// alioth tests k-nucleotide with this data at 25,000,000
~[~"", ~"5000000"]
@@ -8,7 +8,7 @@ fn fib(n: int) -> int {
}
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"40"]
} else if args.len() <= 1u {
@@ -128,7 +128,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>,
}
// given a FASTA file on stdin, process sequence THREE
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598)
@@ -125,7 +125,7 @@ fn make_sequence_processor(sz: uint, from_parent: comm::Port<~[u8]>,
}
// given a FASTA file on stdin, process sequence THREE
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598)
@@ -151,7 +151,7 @@ fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
}
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"4000", ~"10"]
} else {
@@ -14,7 +14,7 @@ extern mod libc {
fn sqrt(n: float) -> float;
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"4000000"]
} else if args.len() <= 1u {
@@ -81,7 +81,7 @@ fn stress(num_tasks: int) {
for results.each |r| { future::get(r); }
}
-fn main(args: ~[~str]) {
+fn main(++args: ~[~str]) {
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"20"]
} else if args.len() <= 1u {
Oops, something went wrong.

0 comments on commit 267ab11

Please sign in to comment.