Skip to content

Commit da510bf

Browse files
committed
auto merge of #7086 : huonw/rust/5048, r=graydon
Fixes #5048. I'm sure this reduces memory usage, but I can't get cgroups to work properly to actually measure memory. (It doesn't appear to offer much speed improvement, but I'm fairly sure it's not slower.) This is quite huge, so it'd be nice to get a resolution soon.
2 parents 84bed97 + 5ebffd4 commit da510bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1329
-1341
lines changed

src/libfuzzer/fuzzer.rc

+24-24
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
345345
intr,
346346
span_handler,
347347
crate2,
348-
fname.to_str(),
348+
fname.to_managed(),
349349
rdr,
350350
a,
351351
pprust::no_ann(),
352352
false)
353353
};
354-
@string
354+
string.to_managed()
355355
};
356356
match cx.mode {
357357
tm_converge => check_roundtrip_convergence(str3, 1),
@@ -361,9 +361,9 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
361361
thing_label,
362362
i,
363363
j);
364-
let safe_to_run = !(content_is_dangerous_to_run(*str3)
364+
let safe_to_run = !(content_is_dangerous_to_run(str3)
365365
|| has_raw_pointers(crate2));
366-
check_whole_compiler(*str3,
366+
check_whole_compiler(str3,
367367
&Path(file_label),
368368
safe_to_run);
369369
}
@@ -502,28 +502,28 @@ pub fn check_compiling(filename: &Path) -> happiness {
502502
}
503503

504504

505-
pub fn parse_and_print(code: @~str) -> ~str {
505+
pub fn parse_and_print(code: @str) -> @str {
506506
let filename = Path("tmp.rs");
507507
let sess = parse::new_parse_sess(option::None);
508-
write_file(&filename, *code);
509-
let crate = parse::parse_crate_from_source_str(filename.to_str(),
508+
write_file(&filename, code);
509+
let crate = parse::parse_crate_from_source_str(filename.to_str().to_managed(),
510510
code,
511511
~[],
512512
sess);
513-
do io::with_str_reader(*code) |rdr| {
513+
do io::with_str_reader(code) |rdr| {
514514
let filename = filename.to_str();
515515
do as_str |a| {
516516
pprust::print_crate(sess.cm,
517517
// Assuming there are no token_trees
518518
token::mk_fake_ident_interner(),
519519
copy sess.span_diagnostic,
520520
crate,
521-
filename.to_str(),
521+
filename.to_managed(),
522522
rdr,
523523
a,
524524
pprust::no_ann(),
525525
false)
526-
}
526+
}.to_managed()
527527
}
528528
}
529529

@@ -598,15 +598,15 @@ pub fn file_might_not_converge(filename: &Path) -> bool {
598598
return false;
599599
}
600600

601-
pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
601+
pub fn check_roundtrip_convergence(code: @str, maxIters: uint) {
602602
let mut i = 0u;
603603
let mut newv = code;
604604
let mut oldv = code;
605605

606606
while i < maxIters {
607607
oldv = newv;
608-
if content_might_not_converge(*oldv) { return; }
609-
newv = @parse_and_print(oldv);
608+
if content_might_not_converge(oldv) { return; }
609+
newv = parse_and_print(oldv);
610610
if oldv == newv { break; }
611611
i += 1u;
612612
}
@@ -615,8 +615,8 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
615615
error!("Converged after %u iterations", i);
616616
} else {
617617
error!("Did not converge after %u iterations!", i);
618-
write_file(&Path("round-trip-a.rs"), *oldv);
619-
write_file(&Path("round-trip-b.rs"), *newv);
618+
write_file(&Path("round-trip-a.rs"), oldv);
619+
write_file(&Path("round-trip-b.rs"), newv);
620620
run::process_status("diff", [~"-w", ~"-u", ~"round-trip-a.rs", ~"round-trip-b.rs"]);
621621
fail!("Mismatch");
622622
}
@@ -626,8 +626,8 @@ pub fn check_convergence(files: &[Path]) {
626626
error!("pp convergence tests: %u files", files.len());
627627
for files.each |file| {
628628
if !file_might_not_converge(file) {
629-
let s = @result::get(&io::read_whole_file_str(file));
630-
if !content_might_not_converge(*s) {
629+
let s = result::get(&io::read_whole_file_str(file)).to_managed();
630+
if !content_might_not_converge(s) {
631631
error!("pp converge: %s", file.to_str());
632632
// Change from 7u to 2u once
633633
// https://github.com/mozilla/rust/issues/850 is fixed
@@ -646,26 +646,26 @@ pub fn check_variants(files: &[Path], cx: Context) {
646646
loop;
647647
}
648648

649-
let s = @result::get(&io::read_whole_file_str(file));
650-
if contains(*s, "#") {
649+
let s = result::get(&io::read_whole_file_str(file)).to_managed();
650+
if s.contains_char('#') {
651651
loop; // Macros are confusing
652652
}
653-
if cx.mode == tm_converge && content_might_not_converge(*s) {
653+
if cx.mode == tm_converge && content_might_not_converge(s) {
654654
loop;
655655
}
656-
if cx.mode == tm_run && content_is_dangerous_to_compile(*s) {
656+
if cx.mode == tm_run && content_is_dangerous_to_compile(s) {
657657
loop;
658658
}
659659

660660
let file_str = file.to_str();
661661

662662
error!("check_variants: %?", file_str);
663663
let sess = parse::new_parse_sess(None);
664-
let crate = parse::parse_crate_from_source_str(file_str.to_str(),
664+
let crate = parse::parse_crate_from_source_str(file_str.to_managed(),
665665
s,
666666
~[],
667667
sess);
668-
io::with_str_reader(*s, |rdr| {
668+
io::with_str_reader(s, |rdr| {
669669
let file_str = file_str.to_str();
670670
error!("%s",
671671
as_str(|a| {
@@ -675,7 +675,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
675675
token::mk_fake_ident_interner(),
676676
copy sess.span_diagnostic,
677677
crate,
678-
file_str.to_str(),
678+
file_str.to_managed(),
679679
rdr,
680680
a,
681681
pprust::no_ann(),

src/librustc/back/link.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,16 @@ pub fn build_link_meta(sess: Session,
493493
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
494494
attr::require_unique_names(sess.diagnostic(), linkage_metas);
495495
for linkage_metas.each |meta| {
496-
if *attr::get_meta_item_name(*meta) == ~"name" {
496+
if "name" == attr::get_meta_item_name(*meta) {
497497
match attr::get_meta_item_value_str(*meta) {
498498
// Changing attr would avoid the need for the copy
499499
// here
500-
Some(v) => { name = Some(v.to_managed()); }
500+
Some(v) => { name = Some(v); }
501501
None => cmh_items.push(*meta)
502502
}
503-
} else if *attr::get_meta_item_name(*meta) == ~"vers" {
503+
} else if "vers" == attr::get_meta_item_name(*meta) {
504504
match attr::get_meta_item_value_str(*meta) {
505-
Some(v) => { vers = Some(v.to_managed()); }
505+
Some(v) => { vers = Some(v); }
506506
None => cmh_items.push(*meta)
507507
}
508508
} else { cmh_items.push(*meta); }
@@ -518,7 +518,7 @@ pub fn build_link_meta(sess: Session,
518518
// This calculates CMH as defined above
519519
fn crate_meta_extras_hash(symbol_hasher: &mut hash::State,
520520
cmh_items: ~[@ast::meta_item],
521-
dep_hashes: ~[~str]) -> @str {
521+
dep_hashes: ~[@str]) -> @str {
522522
fn len_and_str(s: &str) -> ~str {
523523
fmt!("%u_%s", s.len(), s)
524524
}
@@ -532,14 +532,14 @@ pub fn build_link_meta(sess: Session,
532532
fn hash(symbol_hasher: &mut hash::State, m: &@ast::meta_item) {
533533
match m.node {
534534
ast::meta_name_value(key, value) => {
535-
write_string(symbol_hasher, len_and_str(*key));
535+
write_string(symbol_hasher, len_and_str(key));
536536
write_string(symbol_hasher, len_and_str_lit(value));
537537
}
538538
ast::meta_word(name) => {
539-
write_string(symbol_hasher, len_and_str(*name));
539+
write_string(symbol_hasher, len_and_str(name));
540540
}
541541
ast::meta_list(name, ref mis) => {
542-
write_string(symbol_hasher, len_and_str(*name));
542+
write_string(symbol_hasher, len_and_str(name));
543543
for mis.each |m_| {
544544
hash(symbol_hasher, m_);
545545
}
@@ -706,7 +706,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str {
706706

707707
for ss.each |s| {
708708
match *s { path_name(s) | path_mod(s) => {
709-
let sani = sanitize(*sess.str_of(s));
709+
let sani = sanitize(sess.str_of(s));
710710
n += fmt!("%u%s", sani.len(), sani);
711711
} }
712712
}
@@ -912,7 +912,7 @@ pub fn link_args(sess: Session,
912912
}
913913

914914
let ula = cstore::get_used_link_args(cstore);
915-
for ula.each |arg| { args.push(/*bad*/copy *arg); }
915+
for ula.each |arg| { args.push(arg.to_owned()); }
916916

917917
// Add all the link args for external crates.
918918
do cstore::iter_crate_data(cstore) |crate_num, _| {

0 commit comments

Comments
 (0)