Permalink
Browse files

Switch the compiler over to using ~[] notation instead of []/~. Closes

  • Loading branch information...
1 parent e6baf44 commit 98e161f00e8850b0f5c6a3a9f1b22b222c2355b7 @msullivan msullivan committed Jun 29, 2012
Showing 420 changed files with 4,078 additions and 4,079 deletions.
View
Oops, something went wrong.
View
@@ -1,4 +1,4 @@
-fn gpg(args: [str]/~) -> { status: int, out: str, err: str } {
+fn gpg(args: ~[str]) -> { status: int, out: str, err: str } {
ret run::program_output("gpg", args);
}
@@ -59,15 +59,15 @@ fn signing_key_fp() -> str {
}
fn supported() -> bool {
- let r = gpg(["--version"]/~);
+ let r = gpg(~["--version"]);
r.status == 0
}
fn init(root: str) {
let p = path::connect(root, "gpg");
if !os::path_is_dir(p) {
os::make_dir(p, 0x1c0i32);
- let p = run::start_program("gpg", ["--homedir", p, "--import"]/~);
+ let p = run::start_program("gpg", ~["--homedir", p, "--import"]);
p.input().write_str(signing_key());
let s = p.finish();
if s != 0 {
@@ -79,16 +79,16 @@ fn init(root: str) {
fn add(root: str, key: str) {
let path = path::connect(root, "gpg");
let p =
- run::program_output("gpg", ["--homedir", path, "--import", key]/~);
+ run::program_output("gpg", ~["--homedir", path, "--import", key]);
if p.status != 0 {
fail "pgp add failed: " + p.out;
}
}
fn verify(root: str, data: str, sig: str, keyfp: str) -> bool {
let path = path::connect(root, "gpg");
- let p = gpg(["--homedir", path, "--with-fingerprint", "--verify", sig,
- data]/~);
+ let p = gpg(~["--homedir", path, "--with-fingerprint", "--verify", sig,
+ data]);
let res = "Primary key fingerprint: " + keyfp;
for str::split_char(p.err, '\n').each {|line|
if line == res { ret true; }
@@ -21,22 +21,23 @@ import common::mode_pretty;
import common::mode;
import util::logv;
-fn main(args: [str]/~) {
+fn main(args: ~[str]) {
let config = parse_config(args);
log_config(config);
run_tests(config);
}
-fn parse_config(args: [str]/~) -> config {
+fn parse_config(args: ~[str]) -> config {
let opts =
- [getopts::reqopt("compile-lib-path"), getopts::reqopt("run-lib-path"),
- getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
- getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
- getopts::reqopt("stage-id"),
- getopts::reqopt("mode"), getopts::optflag("ignored"),
- getopts::optopt("runtool"), getopts::optopt("rustcflags"),
- getopts::optflag("verbose"),
- getopts::optopt("logfile")]/~;
+ ~[getopts::reqopt("compile-lib-path"),
+ getopts::reqopt("run-lib-path"),
+ getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
+ getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
+ getopts::reqopt("stage-id"),
+ getopts::reqopt("mode"), getopts::optflag("ignored"),
+ getopts::optopt("runtool"), getopts::optopt("rustcflags"),
+ getopts::optflag("verbose"),
+ getopts::optopt("logfile")];
check (vec::is_not_empty(args));
let args_ = vec::tail(args);
@@ -132,9 +133,9 @@ fn test_opts(config: config) -> test::test_opts {
}
}
-fn make_tests(config: config) -> [test::test_desc]/~ {
+fn make_tests(config: config) -> ~[test::test_desc] {
#debug("making tests from %s", config.src_base);
- let mut tests = []/~;
+ let mut tests = ~[];
for os::list_dir_path(config.src_base).each {|file|
let file = file;
#debug("inspecting file %s", file);
@@ -148,8 +149,8 @@ fn make_tests(config: config) -> [test::test_desc]/~ {
fn is_test(config: config, testfile: str) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
- alt config.mode { mode_pretty { [".rs"]/~ } _ { [".rc", ".rs"]/~ } };
- let invalid_prefixes = [".", "#", "~"]/~;
+ alt config.mode { mode_pretty { ~[".rs"] } _ { ~[".rc", ".rs"] } };
+ let invalid_prefixes = ~[".", "#", "~"];
let name = path::basename(testfile);
let mut valid = false;
@@ -8,8 +8,8 @@ export expected_error;
type expected_error = { line: uint, kind: str, msg: str };
// Load any test directives embedded in the file
-fn load_errors(testfile: str) -> [expected_error]/~ {
- let mut error_patterns = []/~;
+fn load_errors(testfile: str) -> ~[expected_error] {
+ let mut error_patterns = ~[];
let rdr = result::get(io::file_reader(testfile));
let mut line_num = 1u;
while !rdr.eof() {
@@ -20,11 +20,11 @@ fn load_errors(testfile: str) -> [expected_error]/~ {
ret error_patterns;
}
-fn parse_expected(line_num: uint, line: str) -> [expected_error]/~ unsafe {
+fn parse_expected(line_num: uint, line: str) -> ~[expected_error] unsafe {
let error_tag = "//!";
let mut idx;
alt str::find_str(line, error_tag) {
- option::none { ret []/~; }
+ option::none { ret ~[]; }
option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
}
@@ -49,5 +49,5 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error]/~ unsafe {
#debug("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
- ret [{line: line_num - adjust_line, kind: kind, msg: msg}]/~;
+ ret ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
}
@@ -10,23 +10,23 @@ export is_test_ignored;
type test_props = {
// Lines that should be expected, in order, on standard out
- error_patterns: [str]/~,
+ error_patterns: ~[str],
// Extra flags to pass to the compiler
compile_flags: option<str>,
// If present, the name of a file that this test should match when
// pretty-printed
pp_exact: option<str>,
// Modules from aux directory that should be compiled
- aux_builds: [str]/~,
+ aux_builds: ~[str],
// Environment settings to use during execution
- exec_env: [(str,str)]/~
+ exec_env: ~[(str,str)]
};
// Load any test directives embedded in the file
fn load_props(testfile: str) -> test_props {
- let mut error_patterns = []/~;
- let mut aux_builds = []/~;
- let mut exec_env = []/~;
+ let mut error_patterns = ~[];
+ let mut aux_builds = ~[];
+ let mut exec_env = ~[];
let mut compile_flags = option::none;
let mut pp_exact = option::none;
for iter_header(testfile) {|ln|
@@ -5,7 +5,7 @@ import libc::{c_int, pid_t};
export run;
#[cfg(target_os = "win32")]
-fn target_env(lib_path: str, prog: str) -> [(str,str)]/~ {
+fn target_env(lib_path: str, prog: str) -> ~[(str,str)] {
let mut env = os::env();
@@ -27,16 +27,16 @@ fn target_env(lib_path: str, prog: str) -> [(str,str)]/~ {
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
-fn target_env(_lib_path: str, _prog: str) -> [(str,str)]/~ {
- []/~
+fn target_env(_lib_path: str, _prog: str) -> ~[(str,str)] {
+ ~[]
}
// FIXME (#2659): This code is duplicated in core::run::program_output
fn run(lib_path: str,
prog: str,
- args: [str]/~,
- env: [(str, str)]/~,
+ args: ~[str],
+ env: ~[(str, str)],
input: option<str>) -> {status: int, out: str, err: str} {
let pipe_in = os::pipe();
@@ -92,7 +92,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
let rounds =
alt props.pp_exact { option::some(_) { 1 } option::none { 2 } };
- let mut srcs = [result::get(io::read_whole_file_str(testfile))]/~;
+ let mut srcs = ~[result::get(io::read_whole_file_str(testfile))];
let mut round = 0;
while round < rounds {
@@ -139,12 +139,12 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
fn print_source(config: config, testfile: str, src: str) -> procres {
compose_and_run(config, testfile, make_pp_args(config, testfile),
- []/~, config.compile_lib_path, option::some(src))
+ ~[], config.compile_lib_path, option::some(src))
}
fn make_pp_args(config: config, _testfile: str) -> procargs {
let prog = config.rustc_path;
- let args = ["-", "--pretty", "normal"]/~;
+ let args = ~["-", "--pretty", "normal"];
ret {prog: prog, args: args};
}
@@ -178,8 +178,8 @@ actual:\n\
fn make_typecheck_args(config: config, testfile: str) -> procargs {
let prog = config.rustc_path;
- let mut args = ["-", "--no-trans", "--lib", "-L", config.build_base,
- "-L", aux_output_dir_name(config, testfile)]/~;
+ let mut args = ~["-", "--no-trans", "--lib", "-L", config.build_base,
+ "-L", aux_output_dir_name(config, testfile)];
args += split_maybe_args(config.rustcflags);
ret {prog: prog, args: args};
}
@@ -227,7 +227,7 @@ fn check_error_patterns(props: test_props,
}
}
-fn check_expected_errors(expected_errors: [errors::expected_error]/~,
+fn check_expected_errors(expected_errors: ~[errors::expected_error],
testfile: str,
procres: procres) {
@@ -286,13 +286,13 @@ fn check_expected_errors(expected_errors: [errors::expected_error]/~,
}
}
-type procargs = {prog: str, args: [str]/~};
+type procargs = {prog: str, args: ~[str]};
type procres = {status: int, stdout: str, stderr: str, cmdline: str};
fn compile_test(config: config, props: test_props,
testfile: str) -> procres {
- let link_args = ["-L", aux_output_dir_name(config, testfile)]/~;
+ let link_args = ~["-L", aux_output_dir_name(config, testfile)];
compose_and_run_compiler(
config, props, testfile,
make_compile_args(config, props, link_args,
@@ -319,14 +319,14 @@ fn compose_and_run_compiler(
ensure_dir(aux_output_dir_name(config, testfile));
}
- let extra_link_args = ["-L", aux_output_dir_name(config, testfile)]/~;
+ let extra_link_args = ~["-L", aux_output_dir_name(config, testfile)];
vec::iter(props.aux_builds) {|rel_ab|
let abs_ab = path::connect(config.aux_base, rel_ab);
let aux_args =
- make_compile_args(config, props, ["--lib"]/~ + extra_link_args,
+ make_compile_args(config, props, ~["--lib"] + extra_link_args,
{|a,b|make_lib_name(a, b, testfile)}, abs_ab);
- let auxres = compose_and_run(config, abs_ab, aux_args, []/~,
+ let auxres = compose_and_run(config, abs_ab, aux_args, ~[],
config.compile_lib_path, option::none);
if auxres.status != 0 {
fatal_procres(
@@ -335,7 +335,7 @@ fn compose_and_run_compiler(
}
}
- compose_and_run(config, testfile, args, []/~,
+ compose_and_run(config, testfile, args, ~[],
config.compile_lib_path, input)
}
@@ -348,19 +348,19 @@ fn ensure_dir(path: path) {
fn compose_and_run(config: config, testfile: str,
procargs: procargs,
- procenv: [(str, str)]/~,
+ procenv: ~[(str, str)],
lib_path: str,
input: option<str>) -> procres {
ret program_output(config, testfile, lib_path,
procargs.prog, procargs.args, procenv, input);
}
-fn make_compile_args(config: config, props: test_props, extras: [str]/~,
+fn make_compile_args(config: config, props: test_props, extras: ~[str],
xform: fn(config, str) -> str, testfile: str) ->
procargs {
let prog = config.rustc_path;
- let mut args = [testfile, "-o", xform(config, testfile),
- "-L", config.build_base]/~ + extras;
+ let mut args = ~[testfile, "-o", xform(config, testfile),
+ "-L", config.build_base] + extras;
args += split_maybe_args(config.rustcflags);
args += split_maybe_args(props.compile_flags);
ret {prog: prog, args: args};
@@ -390,12 +390,12 @@ fn make_run_args(config: config, _props: test_props, testfile: str) ->
split_maybe_args(runtool)
};
- let args = toolargs + [make_exe_name(config, testfile)]/~;
+ let args = toolargs + ~[make_exe_name(config, testfile)];
ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))};
}
-fn split_maybe_args(argstr: option<str>) -> [str]/~ {
- fn rm_whitespace(v: [str]/~) -> [str]/~ {
+fn split_maybe_args(argstr: option<str>) -> ~[str] {
+ fn rm_whitespace(v: ~[str]) -> ~[str] {
fn flt(&&s: str) -> option<str> {
if !str::is_whitespace(s) { option::some(s) } else { option::none }
}
@@ -404,12 +404,12 @@ fn split_maybe_args(argstr: option<str>) -> [str]/~ {
alt argstr {
option::some(s) { rm_whitespace(str::split_char(s, ' ')) }
- option::none { []/~ }
+ option::none { ~[] }
}
}
fn program_output(config: config, testfile: str, lib_path: str, prog: str,
- args: [str]/~, env: [(str, str)]/~,
+ args: ~[str], env: ~[(str, str)],
input: option<str>) -> procres {
let cmdline =
{
@@ -429,12 +429,12 @@ fn program_output(config: config, testfile: str, lib_path: str, prog: str,
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
-fn make_cmdline(_libpath: str, prog: str, args: [str]/~) -> str {
+fn make_cmdline(_libpath: str, prog: str, args: ~[str]) -> str {
#fmt["%s %s", prog, str::connect(args, " ")]
}
#[cfg(target_os = "win32")]
-fn make_cmdline(libpath: str, prog: str, args: [str]/~) -> str {
+fn make_cmdline(libpath: str, prog: str, args: ~[str]) -> str {
#fmt["%s %s %s", lib_path_cmd_prefix(libpath), prog,
str::connect(args, " ")]
}
@@ -454,7 +454,7 @@ fn dump_output(config: config, testfile: str, out: str, err: str) {
fn dump_output_file(config: config, testfile: str, out: str, extension: str) {
let outfile = make_out_name(config, testfile, extension);
let writer = result::get(
- io::file_writer(outfile, [io::create, io::truncate]/~));
+ io::file_writer(outfile, ~[io::create, io::truncate]));
writer.write_str(out);
}
@@ -1,7 +1,7 @@
use std;
import vec;
-fn vec_equal<T>(v: [T]/~, u: [T]/~,
+fn vec_equal<T>(v: ~[T], u: ~[T],
element_equality_test: fn@(&&T, &&T) -> bool) ->
bool {
let Lv = vec::len(v);
@@ -20,11 +20,11 @@ pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { ret a == b; }
fn main() {
assert (builtin_equal(5, 5));
assert (!builtin_equal(5, 4));
- assert (!vec_equal([5, 5]/~, [5]/~, bind builtin_equal(_, _)));
- assert (!vec_equal([5, 5]/~, [5]/~, builtin_equal_int));
- assert (!vec_equal([5, 5]/~, [5, 4]/~, builtin_equal_int));
- assert (!vec_equal([5, 5]/~, [4, 5]/~, builtin_equal_int));
- assert (vec_equal([5, 5]/~, [5, 5]/~, builtin_equal_int));
+ assert (!vec_equal(~[5, 5], ~[5], bind builtin_equal(_, _)));
+ assert (!vec_equal(~[5, 5], ~[5], builtin_equal_int));
+ assert (!vec_equal(~[5, 5], ~[5, 4], builtin_equal_int));
+ assert (!vec_equal(~[5, 5], ~[4, 5], builtin_equal_int));
+ assert (vec_equal(~[5, 5], ~[5, 5], builtin_equal_int));
#error("Pass");
}
Oops, something went wrong.

0 comments on commit 98e161f

Please sign in to comment.