auto merge of #6657 : sanxiyn/rust/allocation, r=thestinger

This commit is contained in:
bors 2013-05-21 11:40:41 -07:00
commit 73597a5bd5
13 changed files with 88 additions and 88 deletions

View File

@ -38,7 +38,7 @@ pub enum test_mode { tm_converge, tm_run, }
pub struct Context { mode: test_mode } // + rng
pub fn write_file(filename: &Path, content: &str) {
result::get(&io::file_writer(filename, ~[io::Create, io::Truncate]))
result::get(&io::file_writer(filename, [io::Create, io::Truncate]))
.write_str(content);
}
@ -47,12 +47,12 @@ pub fn contains(haystack: &str, needle: &str) -> bool {
}
pub fn find_rust_files(files: &mut ~[Path], path: &Path) {
if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") {
if path.filetype() == Some(~".rs") && !contains(path.to_str(), "utf8") {
// ignoring "utf8" tests because something is broken
files.push(path.clone());
} else if os::path_is_dir(path)
&& !contains(path.to_str(), ~"compile-fail")
&& !contains(path.to_str(), ~"build") {
&& !contains(path.to_str(), "compile-fail")
&& !contains(path.to_str(), "build") {
for os::list_dir_path(path).each |p| {
find_rust_files(&mut *files, *p);
}
@ -406,34 +406,34 @@ pub fn check_whole_compiler(code: &str,
pub fn removeIfExists(filename: &Path) {
// So sketchy!
assert!(!contains(filename.to_str(), ~" "));
run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]);
assert!(!contains(filename.to_str(), " "));
run::program_output("bash", [~"-c", ~"rm " + filename.to_str()]);
}
pub fn removeDirIfExists(filename: &Path) {
// So sketchy!
assert!(!contains(filename.to_str(), ~" "));
run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]);
assert!(!contains(filename.to_str(), " "));
run::program_output("bash", [~"-c", ~"rm -r " + filename.to_str()]);
}
pub fn check_running(exe_filename: &Path) -> happiness {
let p = run::program_output(
~"/Users/jruderman/scripts/timed_run_rust_program.py",
~[exe_filename.to_str()]);
"/Users/jruderman/scripts/timed_run_rust_program.py",
[exe_filename.to_str()]);
let comb = p.out + ~"\n" + p.err;
if str::len(comb) > 1u {
error!("comb comb comb: %?", comb);
}
if contains(comb, ~"Assertion failed:") {
if contains(comb, "Assertion failed:") {
failed(~"C++ assertion failure")
} else if contains(comb, ~"leaked memory in rust main loop") {
} else if contains(comb, "leaked memory in rust main loop") {
// might also use exit code 134
//failed("Leaked")
known_bug(~"https://github.com/mozilla/rust/issues/910")
} else if contains(comb, ~"src/rt/") {
} else if contains(comb, "src/rt/") {
failed(~"Mentioned src/rt/")
} else if contains(comb, ~"malloc") {
} else if contains(comb, "malloc") {
failed(~"Mentioned malloc")
} else {
match p.status {
@ -457,26 +457,26 @@ pub fn check_running(exe_filename: &Path) -> happiness {
pub fn check_compiling(filename: &Path) -> happiness {
let p = run::program_output(
~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
stage1/bin/rustc",
~[filename.to_str()]);
[filename.to_str()]);
//error!("Status: %d", p.status);
if p.status == 0 {
passed
} else if p.err != ~"" {
if contains(p.err, ~"error:") {
if contains(p.err, "error:") {
cleanly_rejected(~"rejected with span_error")
} else {
error!("Stderr: %?", p.err);
failed(~"Unfamiliar error message")
}
} else if contains(p.out, ~"Assertion") && contains(p.out, ~"failed") {
} else if contains(p.out, "Assertion") && contains(p.out, "failed") {
error!("Stdout: %?", p.out);
failed(~"Looks like an llvm assertion failure")
} else if contains(p.out, ~"internal compiler error unimplemented") {
} else if contains(p.out, "internal compiler error unimplemented") {
known_bug(~"Something unimplemented")
} else if contains(p.out, ~"internal compiler error") {
} else if contains(p.out, "internal compiler error") {
error!("Stdout: %?", p.out);
failed(~"internal compiler error")
@ -603,8 +603,8 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
error!("Did not converge after %u iterations!", i);
write_file(&Path("round-trip-a.rs"), *oldv);
write_file(&Path("round-trip-b.rs"), *newv);
run::run_program(~"diff",
~[~"-w", ~"-u", ~"round-trip-a.rs",
run::run_program("diff",
[~"-w", ~"-u", ~"round-trip-a.rs",
~"round-trip-b.rs"]);
fail!("Mismatch");
}
@ -635,7 +635,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
}
let s = @result::get(&io::read_whole_file_str(file));
if contains(*s, ~"#") {
if contains(*s, "#") {
loop; // Macros are confusing
}
if cx.mode == tm_converge && content_might_not_converge(*s) {

View File

@ -26,7 +26,7 @@ fn doc_metas(
attrs: ~[ast::attribute]
) -> ~[@ast::meta_item] {
let doc_attrs = attr::find_attrs_by_name(attrs, ~"doc");
let doc_attrs = attr::find_attrs_by_name(attrs, "doc");
let doc_metas = do doc_attrs.map |attr| {
attr::attr_meta(attr::desugar_doc_attr(attr))
};
@ -36,7 +36,7 @@ fn doc_metas(
pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
let link_metas = attr::find_linkage_metas(attrs);
let name = attr::last_meta_item_value_str_by_name(link_metas, ~"name");
let name = attr::last_meta_item_value_str_by_name(link_metas, "name");
CrateAttrs {
name: name.map(|s| copy **s)
@ -58,7 +58,7 @@ pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool {
do doc_metas(attrs).find |meta| {
match attr::get_meta_item_list(*meta) {
Some(metas) => {
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
let hiddens = attr::find_meta_items_by_name(metas, "hidden");
!hiddens.is_empty()
}
None => false

View File

@ -70,12 +70,12 @@ fn opts() -> ~[(getopts::Opt, ~str)] {
pub fn usage() {
use core::io::println;
println(~"Usage: rustdoc [options] <cratefile>\n");
println(~"Options:\n");
println("Usage: rustdoc [options] <cratefile>\n");
println("Options:\n");
for opts().each |opt| {
println(fmt!(" %s", opt.second()));
}
println(~"");
println("");
}
pub fn default_config(input_crate: &Path) -> Config {
@ -227,7 +227,7 @@ pub fn maybe_find_pandoc(
};
let pandoc = do vec::find(possible_pandocs) |pandoc| {
let output = program_output(*pandoc, ~[~"--version"]);
let output = program_output(*pandoc, [~"--version"]);
debug!("testing pandoc cmd %s: %?", *pandoc, output);
output.status == 0
};

View File

@ -104,7 +104,7 @@ fn first_sentence(s: ~str) -> Option<~str> {
let paras = paragraphs(s);
if !paras.is_empty() {
let first_para = paras.head();
Some(str::replace(first_sentence_(*first_para), ~"\n", ~" "))
Some(str::replace(first_sentence_(*first_para), "\n", " "))
} else {
None
}
@ -132,7 +132,7 @@ fn first_sentence_(s: &str) -> ~str {
str::to_owned(str::slice(s, 0, idx - 1))
}
_ => {
if str::ends_with(s, ~".") {
if str::ends_with(s, ".") {
str::to_owned(s)
} else {
str::to_owned(s)

View File

@ -20,7 +20,7 @@ pub fn mk_pass() -> Pass {
}
fn escape(s: &str) -> ~str {
str::replace(s, ~"\\", ~"\\\\")
str::replace(s, "\\", "\\\\")
}
#[test]

View File

@ -124,24 +124,24 @@ pub fn pandoc_header_id(header: &str) -> ~str {
return header;
fn remove_formatting(s: &str) -> ~str {
str::replace(s, ~"`", ~"")
str::replace(s, "`", "")
}
fn remove_punctuation(s: &str) -> ~str {
let s = str::replace(s, ~"<", ~"");
let s = str::replace(s, ~">", ~"");
let s = str::replace(s, ~"[", ~"");
let s = str::replace(s, ~"]", ~"");
let s = str::replace(s, ~"(", ~"");
let s = str::replace(s, ~")", ~"");
let s = str::replace(s, ~"@~", ~"");
let s = str::replace(s, ~"~", ~"");
let s = str::replace(s, ~"/", ~"");
let s = str::replace(s, ~":", ~"");
let s = str::replace(s, ~"&", ~"");
let s = str::replace(s, ~"^", ~"");
let s = str::replace(s, ~",", ~"");
let s = str::replace(s, ~"'", ~"");
let s = str::replace(s, ~"+", ~"");
let s = str::replace(s, "<", "");
let s = str::replace(s, ">", "");
let s = str::replace(s, "[", "");
let s = str::replace(s, "]", "");
let s = str::replace(s, "(", "");
let s = str::replace(s, ")", "");
let s = str::replace(s, "@~", "");
let s = str::replace(s, "~", "");
let s = str::replace(s, "/", "");
let s = str::replace(s, ":", "");
let s = str::replace(s, "&", "");
let s = str::replace(s, "^", "");
let s = str::replace(s, ",", "");
let s = str::replace(s, "'", "");
let s = str::replace(s, "+", "");
return s;
}
fn replace_with_hyphens(s: &str) -> ~str {
@ -149,8 +149,8 @@ fn replace_with_hyphens(s: &str) -> ~str {
// XXX: Hacky implementation here that only covers
// one or two spaces.
let s = str::trim(s);
let s = str::replace(s, ~" ", ~"-");
let s = str::replace(s, ~" ", ~"-");
let s = str::replace(s, " ", "-");
let s = str::replace(s, " ", "-");
return s;
}
// FIXME: #4318 Instead of to_ascii and to_str_ascii, could use

View File

@ -110,7 +110,7 @@ fn make_title(page: doc::Page) -> ~str {
}
};
let title = markdown_pass::header_text(item);
let title = str::replace(title, ~"`", ~"");
let title = str::replace(title, "`", "");
return title;
}
@ -169,7 +169,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
}
pub fn header_name(doc: doc::ItemTag) -> ~str {
let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::");
let fullpath = str::connect(doc.path() + ~[doc.name()], "::");
match &doc {
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
fullpath
@ -471,7 +471,7 @@ fn write_methods(ctxt: &Ctxt, docs: &[doc::MethodDoc]) {
}
fn write_method(ctxt: &Ctxt, doc: doc::MethodDoc) {
write_header_(ctxt, H3, header_text_(~"Method", doc.name));
write_header_(ctxt, H3, header_text_("Method", doc.name));
write_fnlike(
ctxt,
copy doc.sig,

View File

@ -101,7 +101,7 @@ fn pandoc_writer(
use core::io::WriterUtil;
debug!("pandoc cmd: %s", pandoc_cmd);
debug!("pandoc args: %s", str::connect(pandoc_args, ~" "));
debug!("pandoc args: %s", str::connect(pandoc_args, " "));
let pipe_in = os::pipe();
let pipe_out = os::pipe();
@ -198,7 +198,7 @@ pub fn make_filename(
}
}
doc::ItemPage(doc) => {
str::connect(doc.path() + ~[doc.name()], ~"_")
str::connect(doc.path() + ~[doc.name()], "_")
}
}
};
@ -213,7 +213,7 @@ pub fn make_filename(
fn write_file(path: &Path, s: ~str) {
use core::io::WriterUtil;
match io::file_writer(path, ~[io::Create, io::Truncate]) {
match io::file_writer(path, [io::Create, io::Truncate]) {
result::Ok(writer) => {
writer.write_str(s);
}

View File

@ -149,7 +149,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
}
fn parse_header(line: ~str) -> Option<~str> {
if str::starts_with(line, ~"# ") {
if str::starts_with(line, "# ") {
Some(str::slice(line, 2u, str::len(line)).to_owned())
} else {
None

View File

@ -82,7 +82,7 @@ fn unindent(s: &str) -> ~str {
str::slice(*line, min_indent, str::len(*line)).to_owned()
}
};
str::connect(unindented, ~"\n")
str::connect(unindented, "\n")
} else {
s.to_str()
}

View File

@ -126,14 +126,14 @@ impl<'self> PkgScript<'self> {
&exe, @copy os::args()[0],
driver::cu_everything);
debug!("Running program: %s %s %s", exe.to_str(), root.to_str(), what);
let status = run::run_program(exe.to_str(), ~[root.to_str(), what]);
let status = run::run_program(exe.to_str(), [root.to_str(), what]);
if status != 0 {
return (~[], status);
}
else {
debug!("Running program (configs): %s %s %s",
exe.to_str(), root.to_str(), ~"configs");
let output = run::program_output(exe.to_str(), ~[root.to_str(), ~"configs"]);
exe.to_str(), root.to_str(), "configs");
let output = run::program_output(exe.to_str(), [root.to_str(), ~"configs"]);
// Run the configs() function to get the configs
let mut cfgs = ~[];
for str::each_word(output.out) |w| {
@ -360,9 +360,9 @@ pub fn main() {
io::println("WARNING: The Rust package manager is experimental and may be unstable");
let args = os::args();
let opts = ~[getopts::optflag(~"h"), getopts::optflag(~"help"),
getopts::optflag(~"j"), getopts::optflag(~"json"),
getopts::optmulti(~"c"), getopts::optmulti(~"cfg")];
let opts = ~[getopts::optflag("h"), getopts::optflag("help"),
getopts::optflag("j"), getopts::optflag("json"),
getopts::optmulti("c"), getopts::optmulti("cfg")];
let matches = &match getopts::getopts(args, opts) {
result::Ok(m) => m,
result::Err(f) => {
@ -371,10 +371,10 @@ pub fn main() {
return;
}
};
let help = getopts::opt_present(matches, ~"h") ||
getopts::opt_present(matches, ~"help");
let json = getopts::opt_present(matches, ~"j") ||
getopts::opt_present(matches, ~"json");
let help = getopts::opt_present(matches, "h") ||
getopts::opt_present(matches, "help");
let json = getopts::opt_present(matches, "j") ||
getopts::opt_present(matches, "json");
let mut args = copy matches.free;
args.shift();
@ -428,7 +428,7 @@ pub impl Crate {
fn flag(&self, flag: ~str) -> Crate {
Crate {
flags: vec::append(copy self.flags, ~[flag]),
flags: vec::append(copy self.flags, [flag]),
.. copy *self
}
}
@ -442,7 +442,7 @@ pub impl Crate {
fn cfg(&self, cfg: ~str) -> Crate {
Crate {
cfgs: vec::append(copy self.cfgs, ~[cfg]),
cfgs: vec::append(copy self.cfgs, [cfg]),
.. copy *self
}
}
@ -546,7 +546,7 @@ impl PkgSrc {
let url = fmt!("https://%s", self.id.remote_path.to_str());
util::note(fmt!("git clone %s %s", url, local.to_str()));
if run::program_output(~"git", ~[~"clone", copy url, local.to_str()]).status != 0 {
if run::program_output("git", [~"clone", copy url, local.to_str()]).status != 0 {
util::note(fmt!("fetching %s failed: can't clone repository", url));
return false;
}

View File

@ -11,7 +11,7 @@
use core::io;
pub fn general() {
io::println(~"Usage: rustpkg [options] <cmd> [args..]
io::println("Usage: rustpkg [options] <cmd> [args..]
Where <cmd> is one of:
build, clean, do, info, install, prefer, test, uninstall, unprefer
@ -23,7 +23,7 @@ pub fn general() {
}
pub fn build() {
io::println(~"rustpkg [options..] build
io::println("rustpkg [options..] build
Build all targets described in the package script in the current
directory.
@ -33,21 +33,21 @@ pub fn build() {
}
pub fn clean() {
io::println(~"rustpkg clean
io::println("rustpkg clean
Remove all build files in the work cache for the package in the current
directory.");
}
pub fn do_cmd() {
io::println(~"rustpkg do <cmd>
io::println("rustpkg do <cmd>
Runs a command in the package script. You can listen to a command
by tagging a function with the attribute `#[pkg_do(cmd)]`.");
}
pub fn info() {
io::println(~"rustpkg [options..] info
io::println("rustpkg [options..] info
Probe the package script in the current directory for information.
@ -56,7 +56,7 @@ pub fn info() {
}
pub fn install() {
io::println(~"rustpkg [options..] install [url] [target]
io::println("rustpkg [options..] install [url] [target]
Install a package from a URL by Git or cURL (FTP, HTTP, etc.).
If target is provided, Git will checkout the branch or tag before
@ -76,14 +76,14 @@ pub fn install() {
}
pub fn uninstall() {
io::println(~"rustpkg uninstall <id|name>[@version]
io::println("rustpkg uninstall <id|name>[@version]
Remove a package by id or name and optionally version. If the package(s)
is/are depended on by another package then they cannot be removed.");
}
pub fn prefer() {
io::println(~"rustpkg [options..] prefer <id|name>[@version]
io::println("rustpkg [options..] prefer <id|name>[@version]
By default all binaries are given a unique name so that multiple versions can
coexist. The prefer command will symlink the uniquely named binary to
@ -101,7 +101,7 @@ pub fn prefer() {
}
pub fn unprefer() {
io::println(~"rustpkg [options..] unprefer <id|name>[@version]
io::println("rustpkg [options..] unprefer <id|name>[@version]
Remove all symlinks from the store to the binary directory for a package
name and optionally version. If version is not supplied, the latest version
@ -110,7 +110,7 @@ pub fn unprefer() {
}
pub fn test() {
io::println(~"rustpkg [options..] test
io::println("rustpkg [options..] test
Build all targets described in the package script in the current directory
with the test flag. The test bootstraps will be run afterwards and the output

View File

@ -208,7 +208,7 @@ fn fold_item(ctx: @mut ReadyCtx,
fold: @fold::ast_fold) -> Option<@ast::item> {
ctx.path.push(item.ident);
let attrs = attr::find_attrs_by_name(item.attrs, ~"pkg_do");
let attrs = attr::find_attrs_by_name(item.attrs, "pkg_do");
if attrs.len() > 0 {
let mut cmds = ~[];
@ -281,7 +281,7 @@ pub fn note(msg: ~str) {
if term::color_supported() {
term::fg(out, term::color_green);
out.write_str(~"note: ");
out.write_str("note: ");
term::reset(out);
out.write_line(msg);
} else {
@ -294,7 +294,7 @@ pub fn warn(msg: ~str) {
if term::color_supported() {
term::fg(out, term::color_yellow);
out.write_str(~"warning: ");
out.write_str("warning: ");
term::reset(out);
out.write_line(msg);
} else {
@ -307,7 +307,7 @@ pub fn error(msg: ~str) {
if term::color_supported() {
term::fg(out, term::color_red);
out.write_str(~"error: ");
out.write_str("error: ");
term::reset(out);
out.write_line(msg);
} else {
@ -353,8 +353,8 @@ pub fn compile_input(sysroot: Option<@Path>,
debug!("compiling %s into %s",
in_file.to_str(),
out_file.to_str());
debug!("flags: %s", str::connect(flags, ~" "));
debug!("cfgs: %s", str::connect(cfgs, ~" "));
debug!("flags: %s", str::connect(flags, " "));
debug!("cfgs: %s", str::connect(cfgs, " "));
debug!("compile_input's sysroot = %?", sysroot);
let crate_type = match what {