Skip to content

Commit 73597a5

Browse files
committed
auto merge of #6657 : sanxiyn/rust/allocation, r=thestinger
2 parents 64963d6 + 70222b7 commit 73597a5

13 files changed

+88
-88
lines changed

src/libfuzzer/fuzzer.rc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum test_mode { tm_converge, tm_run, }
3838
pub struct Context { mode: test_mode } // + rng
3939

4040
pub fn write_file(filename: &Path, content: &str) {
41-
result::get(&io::file_writer(filename, ~[io::Create, io::Truncate]))
41+
result::get(&io::file_writer(filename, [io::Create, io::Truncate]))
4242
.write_str(content);
4343
}
4444

@@ -47,12 +47,12 @@ pub fn contains(haystack: &str, needle: &str) -> bool {
4747
}
4848

4949
pub fn find_rust_files(files: &mut ~[Path], path: &Path) {
50-
if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") {
50+
if path.filetype() == Some(~".rs") && !contains(path.to_str(), "utf8") {
5151
// ignoring "utf8" tests because something is broken
5252
files.push(path.clone());
5353
} else if os::path_is_dir(path)
54-
&& !contains(path.to_str(), ~"compile-fail")
55-
&& !contains(path.to_str(), ~"build") {
54+
&& !contains(path.to_str(), "compile-fail")
55+
&& !contains(path.to_str(), "build") {
5656
for os::list_dir_path(path).each |p| {
5757
find_rust_files(&mut *files, *p);
5858
}
@@ -406,34 +406,34 @@ pub fn check_whole_compiler(code: &str,
406406

407407
pub fn removeIfExists(filename: &Path) {
408408
// So sketchy!
409-
assert!(!contains(filename.to_str(), ~" "));
410-
run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]);
409+
assert!(!contains(filename.to_str(), " "));
410+
run::program_output("bash", [~"-c", ~"rm " + filename.to_str()]);
411411
}
412412

413413
pub fn removeDirIfExists(filename: &Path) {
414414
// So sketchy!
415-
assert!(!contains(filename.to_str(), ~" "));
416-
run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]);
415+
assert!(!contains(filename.to_str(), " "));
416+
run::program_output("bash", [~"-c", ~"rm -r " + filename.to_str()]);
417417
}
418418

419419
pub fn check_running(exe_filename: &Path) -> happiness {
420420
let p = run::program_output(
421-
~"/Users/jruderman/scripts/timed_run_rust_program.py",
422-
~[exe_filename.to_str()]);
421+
"/Users/jruderman/scripts/timed_run_rust_program.py",
422+
[exe_filename.to_str()]);
423423
let comb = p.out + ~"\n" + p.err;
424424
if str::len(comb) > 1u {
425425
error!("comb comb comb: %?", comb);
426426
}
427427

428-
if contains(comb, ~"Assertion failed:") {
428+
if contains(comb, "Assertion failed:") {
429429
failed(~"C++ assertion failure")
430-
} else if contains(comb, ~"leaked memory in rust main loop") {
430+
} else if contains(comb, "leaked memory in rust main loop") {
431431
// might also use exit code 134
432432
//failed("Leaked")
433433
known_bug(~"https://github.com/mozilla/rust/issues/910")
434-
} else if contains(comb, ~"src/rt/") {
434+
} else if contains(comb, "src/rt/") {
435435
failed(~"Mentioned src/rt/")
436-
} else if contains(comb, ~"malloc") {
436+
} else if contains(comb, "malloc") {
437437
failed(~"Mentioned malloc")
438438
} else {
439439
match p.status {
@@ -457,26 +457,26 @@ pub fn check_running(exe_filename: &Path) -> happiness {
457457

458458
pub fn check_compiling(filename: &Path) -> happiness {
459459
let p = run::program_output(
460-
~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
460+
"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
461461
stage1/bin/rustc",
462-
~[filename.to_str()]);
462+
[filename.to_str()]);
463463

464464
//error!("Status: %d", p.status);
465465
if p.status == 0 {
466466
passed
467467
} else if p.err != ~"" {
468-
if contains(p.err, ~"error:") {
468+
if contains(p.err, "error:") {
469469
cleanly_rejected(~"rejected with span_error")
470470
} else {
471471
error!("Stderr: %?", p.err);
472472
failed(~"Unfamiliar error message")
473473
}
474-
} else if contains(p.out, ~"Assertion") && contains(p.out, ~"failed") {
474+
} else if contains(p.out, "Assertion") && contains(p.out, "failed") {
475475
error!("Stdout: %?", p.out);
476476
failed(~"Looks like an llvm assertion failure")
477-
} else if contains(p.out, ~"internal compiler error unimplemented") {
477+
} else if contains(p.out, "internal compiler error unimplemented") {
478478
known_bug(~"Something unimplemented")
479-
} else if contains(p.out, ~"internal compiler error") {
479+
} else if contains(p.out, "internal compiler error") {
480480
error!("Stdout: %?", p.out);
481481
failed(~"internal compiler error")
482482

@@ -603,8 +603,8 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
603603
error!("Did not converge after %u iterations!", i);
604604
write_file(&Path("round-trip-a.rs"), *oldv);
605605
write_file(&Path("round-trip-b.rs"), *newv);
606-
run::run_program(~"diff",
607-
~[~"-w", ~"-u", ~"round-trip-a.rs",
606+
run::run_program("diff",
607+
[~"-w", ~"-u", ~"round-trip-a.rs",
608608
~"round-trip-b.rs"]);
609609
fail!("Mismatch");
610610
}
@@ -635,7 +635,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
635635
}
636636

637637
let s = @result::get(&io::read_whole_file_str(file));
638-
if contains(*s, ~"#") {
638+
if contains(*s, "#") {
639639
loop; // Macros are confusing
640640
}
641641
if cx.mode == tm_converge && content_might_not_converge(*s) {

src/librustdoc/attr_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn doc_metas(
2626
attrs: ~[ast::attribute]
2727
) -> ~[@ast::meta_item] {
2828

29-
let doc_attrs = attr::find_attrs_by_name(attrs, ~"doc");
29+
let doc_attrs = attr::find_attrs_by_name(attrs, "doc");
3030
let doc_metas = do doc_attrs.map |attr| {
3131
attr::attr_meta(attr::desugar_doc_attr(attr))
3232
};
@@ -36,7 +36,7 @@ fn doc_metas(
3636

3737
pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
3838
let link_metas = attr::find_linkage_metas(attrs);
39-
let name = attr::last_meta_item_value_str_by_name(link_metas, ~"name");
39+
let name = attr::last_meta_item_value_str_by_name(link_metas, "name");
4040

4141
CrateAttrs {
4242
name: name.map(|s| copy **s)
@@ -58,7 +58,7 @@ pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool {
5858
do doc_metas(attrs).find |meta| {
5959
match attr::get_meta_item_list(*meta) {
6060
Some(metas) => {
61-
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
61+
let hiddens = attr::find_meta_items_by_name(metas, "hidden");
6262
!hiddens.is_empty()
6363
}
6464
None => false

src/librustdoc/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ fn opts() -> ~[(getopts::Opt, ~str)] {
7070
pub fn usage() {
7171
use core::io::println;
7272

73-
println(~"Usage: rustdoc [options] <cratefile>\n");
74-
println(~"Options:\n");
73+
println("Usage: rustdoc [options] <cratefile>\n");
74+
println("Options:\n");
7575
for opts().each |opt| {
7676
println(fmt!(" %s", opt.second()));
7777
}
78-
println(~"");
78+
println("");
7979
}
8080

8181
pub fn default_config(input_crate: &Path) -> Config {
@@ -227,7 +227,7 @@ pub fn maybe_find_pandoc(
227227
};
228228

229229
let pandoc = do vec::find(possible_pandocs) |pandoc| {
230-
let output = program_output(*pandoc, ~[~"--version"]);
230+
let output = program_output(*pandoc, [~"--version"]);
231231
debug!("testing pandoc cmd %s: %?", *pandoc, output);
232232
output.status == 0
233233
};

src/librustdoc/desc_to_brief_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn first_sentence(s: ~str) -> Option<~str> {
104104
let paras = paragraphs(s);
105105
if !paras.is_empty() {
106106
let first_para = paras.head();
107-
Some(str::replace(first_sentence_(*first_para), ~"\n", ~" "))
107+
Some(str::replace(first_sentence_(*first_para), "\n", " "))
108108
} else {
109109
None
110110
}
@@ -132,7 +132,7 @@ fn first_sentence_(s: &str) -> ~str {
132132
str::to_owned(str::slice(s, 0, idx - 1))
133133
}
134134
_ => {
135-
if str::ends_with(s, ~".") {
135+
if str::ends_with(s, ".") {
136136
str::to_owned(s)
137137
} else {
138138
str::to_owned(s)

src/librustdoc/escape_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn mk_pass() -> Pass {
2020
}
2121

2222
fn escape(s: &str) -> ~str {
23-
str::replace(s, ~"\\", ~"\\\\")
23+
str::replace(s, "\\", "\\\\")
2424
}
2525

2626
#[test]

src/librustdoc/markdown_index_pass.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,33 +124,33 @@ pub fn pandoc_header_id(header: &str) -> ~str {
124124
return header;
125125
126126
fn remove_formatting(s: &str) -> ~str {
127-
str::replace(s, ~"`", ~"")
127+
str::replace(s, "`", "")
128128
}
129129
fn remove_punctuation(s: &str) -> ~str {
130-
let s = str::replace(s, ~"<", ~"");
131-
let s = str::replace(s, ~">", ~"");
132-
let s = str::replace(s, ~"[", ~"");
133-
let s = str::replace(s, ~"]", ~"");
134-
let s = str::replace(s, ~"(", ~"");
135-
let s = str::replace(s, ~")", ~"");
136-
let s = str::replace(s, ~"@~", ~"");
137-
let s = str::replace(s, ~"~", ~"");
138-
let s = str::replace(s, ~"/", ~"");
139-
let s = str::replace(s, ~":", ~"");
140-
let s = str::replace(s, ~"&", ~"");
141-
let s = str::replace(s, ~"^", ~"");
142-
let s = str::replace(s, ~",", ~"");
143-
let s = str::replace(s, ~"'", ~"");
144-
let s = str::replace(s, ~"+", ~"");
130+
let s = str::replace(s, "<", "");
131+
let s = str::replace(s, ">", "");
132+
let s = str::replace(s, "[", "");
133+
let s = str::replace(s, "]", "");
134+
let s = str::replace(s, "(", "");
135+
let s = str::replace(s, ")", "");
136+
let s = str::replace(s, "@~", "");
137+
let s = str::replace(s, "~", "");
138+
let s = str::replace(s, "/", "");
139+
let s = str::replace(s, ":", "");
140+
let s = str::replace(s, "&", "");
141+
let s = str::replace(s, "^", "");
142+
let s = str::replace(s, ",", "");
143+
let s = str::replace(s, "'", "");
144+
let s = str::replace(s, "+", "");
145145
return s;
146146
}
147147
fn replace_with_hyphens(s: &str) -> ~str {
148148
// Collapse sequences of whitespace to a single dash
149149
// XXX: Hacky implementation here that only covers
150150
// one or two spaces.
151151
let s = str::trim(s);
152-
let s = str::replace(s, ~" ", ~"-");
153-
let s = str::replace(s, ~" ", ~"-");
152+
let s = str::replace(s, " ", "-");
153+
let s = str::replace(s, " ", "-");
154154
return s;
155155
}
156156
// FIXME: #4318 Instead of to_ascii and to_str_ascii, could use

src/librustdoc/markdown_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn make_title(page: doc::Page) -> ~str {
110110
}
111111
};
112112
let title = markdown_pass::header_text(item);
113-
let title = str::replace(title, ~"`", ~"");
113+
let title = str::replace(title, "`", "");
114114
return title;
115115
}
116116

@@ -169,7 +169,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
169169
}
170170

171171
pub fn header_name(doc: doc::ItemTag) -> ~str {
172-
let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::");
172+
let fullpath = str::connect(doc.path() + ~[doc.name()], "::");
173173
match &doc {
174174
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
175175
fullpath
@@ -471,7 +471,7 @@ fn write_methods(ctxt: &Ctxt, docs: &[doc::MethodDoc]) {
471471
}
472472

473473
fn write_method(ctxt: &Ctxt, doc: doc::MethodDoc) {
474-
write_header_(ctxt, H3, header_text_(~"Method", doc.name));
474+
write_header_(ctxt, H3, header_text_("Method", doc.name));
475475
write_fnlike(
476476
ctxt,
477477
copy doc.sig,

src/librustdoc/markdown_writer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn pandoc_writer(
101101
use core::io::WriterUtil;
102102
103103
debug!("pandoc cmd: %s", pandoc_cmd);
104-
debug!("pandoc args: %s", str::connect(pandoc_args, ~" "));
104+
debug!("pandoc args: %s", str::connect(pandoc_args, " "));
105105

106106
let pipe_in = os::pipe();
107107
let pipe_out = os::pipe();
@@ -198,7 +198,7 @@ pub fn make_filename(
198198
}
199199
}
200200
doc::ItemPage(doc) => {
201-
str::connect(doc.path() + ~[doc.name()], ~"_")
201+
str::connect(doc.path() + ~[doc.name()], "_")
202202
}
203203
}
204204
};
@@ -213,7 +213,7 @@ pub fn make_filename(
213213
fn write_file(path: &Path, s: ~str) {
214214
use core::io::WriterUtil;
215215

216-
match io::file_writer(path, ~[io::Create, io::Truncate]) {
216+
match io::file_writer(path, [io::Create, io::Truncate]) {
217217
result::Ok(writer) => {
218218
writer.write_str(s);
219219
}

src/librustdoc/sectionalize_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
149149
}
150150

151151
fn parse_header(line: ~str) -> Option<~str> {
152-
if str::starts_with(line, ~"# ") {
152+
if str::starts_with(line, "# ") {
153153
Some(str::slice(line, 2u, str::len(line)).to_owned())
154154
} else {
155155
None

src/librustdoc/unindent_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn unindent(s: &str) -> ~str {
8282
str::slice(*line, min_indent, str::len(*line)).to_owned()
8383
}
8484
};
85-
str::connect(unindented, ~"\n")
85+
str::connect(unindented, "\n")
8686
} else {
8787
s.to_str()
8888
}

src/librustpkg/rustpkg.rc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ impl<'self> PkgScript<'self> {
126126
&exe, @copy os::args()[0],
127127
driver::cu_everything);
128128
debug!("Running program: %s %s %s", exe.to_str(), root.to_str(), what);
129-
let status = run::run_program(exe.to_str(), ~[root.to_str(), what]);
129+
let status = run::run_program(exe.to_str(), [root.to_str(), what]);
130130
if status != 0 {
131131
return (~[], status);
132132
}
133133
else {
134134
debug!("Running program (configs): %s %s %s",
135-
exe.to_str(), root.to_str(), ~"configs");
136-
let output = run::program_output(exe.to_str(), ~[root.to_str(), ~"configs"]);
135+
exe.to_str(), root.to_str(), "configs");
136+
let output = run::program_output(exe.to_str(), [root.to_str(), ~"configs"]);
137137
// Run the configs() function to get the configs
138138
let mut cfgs = ~[];
139139
for str::each_word(output.out) |w| {
@@ -360,9 +360,9 @@ pub fn main() {
360360
io::println("WARNING: The Rust package manager is experimental and may be unstable");
361361

362362
let args = os::args();
363-
let opts = ~[getopts::optflag(~"h"), getopts::optflag(~"help"),
364-
getopts::optflag(~"j"), getopts::optflag(~"json"),
365-
getopts::optmulti(~"c"), getopts::optmulti(~"cfg")];
363+
let opts = ~[getopts::optflag("h"), getopts::optflag("help"),
364+
getopts::optflag("j"), getopts::optflag("json"),
365+
getopts::optmulti("c"), getopts::optmulti("cfg")];
366366
let matches = &match getopts::getopts(args, opts) {
367367
result::Ok(m) => m,
368368
result::Err(f) => {
@@ -371,10 +371,10 @@ pub fn main() {
371371
return;
372372
}
373373
};
374-
let help = getopts::opt_present(matches, ~"h") ||
375-
getopts::opt_present(matches, ~"help");
376-
let json = getopts::opt_present(matches, ~"j") ||
377-
getopts::opt_present(matches, ~"json");
374+
let help = getopts::opt_present(matches, "h") ||
375+
getopts::opt_present(matches, "help");
376+
let json = getopts::opt_present(matches, "j") ||
377+
getopts::opt_present(matches, "json");
378378
let mut args = copy matches.free;
379379

380380
args.shift();
@@ -428,7 +428,7 @@ pub impl Crate {
428428

429429
fn flag(&self, flag: ~str) -> Crate {
430430
Crate {
431-
flags: vec::append(copy self.flags, ~[flag]),
431+
flags: vec::append(copy self.flags, [flag]),
432432
.. copy *self
433433
}
434434
}
@@ -442,7 +442,7 @@ pub impl Crate {
442442

443443
fn cfg(&self, cfg: ~str) -> Crate {
444444
Crate {
445-
cfgs: vec::append(copy self.cfgs, ~[cfg]),
445+
cfgs: vec::append(copy self.cfgs, [cfg]),
446446
.. copy *self
447447
}
448448
}
@@ -546,7 +546,7 @@ impl PkgSrc {
546546
let url = fmt!("https://%s", self.id.remote_path.to_str());
547547
util::note(fmt!("git clone %s %s", url, local.to_str()));
548548

549-
if run::program_output(~"git", ~[~"clone", copy url, local.to_str()]).status != 0 {
549+
if run::program_output("git", [~"clone", copy url, local.to_str()]).status != 0 {
550550
util::note(fmt!("fetching %s failed: can't clone repository", url));
551551
return false;
552552
}

0 commit comments

Comments
 (0)