Skip to content

Use @str instead of @~str in the compiler. #7086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/libfuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,13 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
intr,
span_handler,
crate2,
fname.to_str(),
fname.to_managed(),
rdr,
a,
pprust::no_ann(),
false)
};
@string
string.to_managed()
};
match cx.mode {
tm_converge => check_roundtrip_convergence(str3, 1),
Expand All @@ -361,9 +361,9 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
thing_label,
i,
j);
let safe_to_run = !(content_is_dangerous_to_run(*str3)
let safe_to_run = !(content_is_dangerous_to_run(str3)
|| has_raw_pointers(crate2));
check_whole_compiler(*str3,
check_whole_compiler(str3,
&Path(file_label),
safe_to_run);
}
Expand Down Expand Up @@ -502,28 +502,28 @@ pub fn check_compiling(filename: &Path) -> happiness {
}


pub fn parse_and_print(code: @~str) -> ~str {
pub fn parse_and_print(code: @str) -> @str {
let filename = Path("tmp.rs");
let sess = parse::new_parse_sess(option::None);
write_file(&filename, *code);
let crate = parse::parse_crate_from_source_str(filename.to_str(),
write_file(&filename, code);
let crate = parse::parse_crate_from_source_str(filename.to_str().to_managed(),
code,
~[],
sess);
do io::with_str_reader(*code) |rdr| {
do io::with_str_reader(code) |rdr| {
let filename = filename.to_str();
do as_str |a| {
pprust::print_crate(sess.cm,
// Assuming there are no token_trees
token::mk_fake_ident_interner(),
copy sess.span_diagnostic,
crate,
filename.to_str(),
filename.to_managed(),
rdr,
a,
pprust::no_ann(),
false)
}
}.to_managed()
}
}

Expand Down Expand Up @@ -598,15 +598,15 @@ pub fn file_might_not_converge(filename: &Path) -> bool {
return false;
}

pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
pub fn check_roundtrip_convergence(code: @str, maxIters: uint) {
let mut i = 0u;
let mut newv = code;
let mut oldv = code;

while i < maxIters {
oldv = newv;
if content_might_not_converge(*oldv) { return; }
newv = @parse_and_print(oldv);
if content_might_not_converge(oldv) { return; }
newv = parse_and_print(oldv);
if oldv == newv { break; }
i += 1u;
}
Expand All @@ -615,8 +615,8 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
error!("Converged after %u iterations", i);
} else {
error!("Did not converge after %u iterations!", i);
write_file(&Path("round-trip-a.rs"), *oldv);
write_file(&Path("round-trip-b.rs"), *newv);
write_file(&Path("round-trip-a.rs"), oldv);
write_file(&Path("round-trip-b.rs"), newv);
run::process_status("diff", [~"-w", ~"-u", ~"round-trip-a.rs", ~"round-trip-b.rs"]);
fail!("Mismatch");
}
Expand All @@ -626,8 +626,8 @@ pub fn check_convergence(files: &[Path]) {
error!("pp convergence tests: %u files", files.len());
for files.each |file| {
if !file_might_not_converge(file) {
let s = @result::get(&io::read_whole_file_str(file));
if !content_might_not_converge(*s) {
let s = result::get(&io::read_whole_file_str(file)).to_managed();
if !content_might_not_converge(s) {
error!("pp converge: %s", file.to_str());
// Change from 7u to 2u once
// https://github.com/mozilla/rust/issues/850 is fixed
Expand All @@ -646,26 +646,26 @@ pub fn check_variants(files: &[Path], cx: Context) {
loop;
}

let s = @result::get(&io::read_whole_file_str(file));
if contains(*s, "#") {
let s = result::get(&io::read_whole_file_str(file)).to_managed();
if s.contains_char('#') {
loop; // Macros are confusing
}
if cx.mode == tm_converge && content_might_not_converge(*s) {
if cx.mode == tm_converge && content_might_not_converge(s) {
loop;
}
if cx.mode == tm_run && content_is_dangerous_to_compile(*s) {
if cx.mode == tm_run && content_is_dangerous_to_compile(s) {
loop;
}

let file_str = file.to_str();

error!("check_variants: %?", file_str);
let sess = parse::new_parse_sess(None);
let crate = parse::parse_crate_from_source_str(file_str.to_str(),
let crate = parse::parse_crate_from_source_str(file_str.to_managed(),
s,
~[],
sess);
io::with_str_reader(*s, |rdr| {
io::with_str_reader(s, |rdr| {
let file_str = file_str.to_str();
error!("%s",
as_str(|a| {
Expand All @@ -675,7 +675,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
token::mk_fake_ident_interner(),
copy sess.span_diagnostic,
crate,
file_str.to_str(),
file_str.to_managed(),
rdr,
a,
pprust::no_ann(),
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,16 @@ pub fn build_link_meta(sess: Session,
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas);
for linkage_metas.each |meta| {
if *attr::get_meta_item_name(*meta) == ~"name" {
if "name" == attr::get_meta_item_name(*meta) {
match attr::get_meta_item_value_str(*meta) {
// Changing attr would avoid the need for the copy
// here
Some(v) => { name = Some(v.to_managed()); }
Some(v) => { name = Some(v); }
None => cmh_items.push(*meta)
}
} else if *attr::get_meta_item_name(*meta) == ~"vers" {
} else if "vers" == attr::get_meta_item_name(*meta) {
match attr::get_meta_item_value_str(*meta) {
Some(v) => { vers = Some(v.to_managed()); }
Some(v) => { vers = Some(v); }
None => cmh_items.push(*meta)
}
} else { cmh_items.push(*meta); }
Expand All @@ -518,7 +518,7 @@ pub fn build_link_meta(sess: Session,
// This calculates CMH as defined above
fn crate_meta_extras_hash(symbol_hasher: &mut hash::State,
cmh_items: ~[@ast::meta_item],
dep_hashes: ~[~str]) -> @str {
dep_hashes: ~[@str]) -> @str {
fn len_and_str(s: &str) -> ~str {
fmt!("%u_%s", s.len(), s)
}
Expand All @@ -532,14 +532,14 @@ pub fn build_link_meta(sess: Session,
fn hash(symbol_hasher: &mut hash::State, m: &@ast::meta_item) {
match m.node {
ast::meta_name_value(key, value) => {
write_string(symbol_hasher, len_and_str(*key));
write_string(symbol_hasher, len_and_str(key));
write_string(symbol_hasher, len_and_str_lit(value));
}
ast::meta_word(name) => {
write_string(symbol_hasher, len_and_str(*name));
write_string(symbol_hasher, len_and_str(name));
}
ast::meta_list(name, ref mis) => {
write_string(symbol_hasher, len_and_str(*name));
write_string(symbol_hasher, len_and_str(name));
for mis.each |m_| {
hash(symbol_hasher, m_);
}
Expand Down Expand Up @@ -706,7 +706,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str {

for ss.each |s| {
match *s { path_name(s) | path_mod(s) => {
let sani = sanitize(*sess.str_of(s));
let sani = sanitize(sess.str_of(s));
n += fmt!("%u%s", sani.len(), sani);
} }
}
Expand Down Expand Up @@ -912,7 +912,7 @@ pub fn link_args(sess: Session,
}

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

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