Skip to content

Commit 70222b7

Browse files
committed
Remove unnecessary allocations flagged by lint from fuzzer
1 parent d4724c1 commit 70222b7

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
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) {

0 commit comments

Comments
 (0)