Skip to content

Commit aa67254

Browse files
committed
auto merge of #14032 : pcwalton/rust/detildestr, r=alexcrichton
r? @brson
2 parents e454851 + 7f8f3dc commit aa67254

Some content is hidden

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

50 files changed

+773
-629
lines changed

src/librustc/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub fn crate_id_hash(crate_id: &CrateId) -> ~str {
536536
// the crate id in the hash because lookups are only done by (name/vers),
537537
// not by path.
538538
let mut s = Sha256::new();
539-
s.input_str(crate_id.short_name_with_version());
539+
s.input_str(crate_id.short_name_with_version().as_slice());
540540
truncated_hash_result(&mut s).slice_to(8).to_owned()
541541
}
542542

@@ -566,7 +566,7 @@ fn symbol_hash(tcx: &ty::ctxt,
566566
// to be independent of one another in the crate.
567567

568568
symbol_hasher.reset();
569-
symbol_hasher.input_str(link_meta.crateid.name);
569+
symbol_hasher.input_str(link_meta.crateid.name.as_slice());
570570
symbol_hasher.input_str("-");
571571
symbol_hasher.input_str(link_meta.crate_hash.as_str());
572572
symbol_hasher.input_str("-");

src/librustc/driver/driver.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
143143
fn parse_cfgspecs(cfgspecs: Vec<~str> )
144144
-> ast::CrateConfig {
145145
cfgspecs.move_iter().map(|s| {
146-
parse::parse_meta_from_source_str("cfgspec".to_str(),
147-
s,
146+
parse::parse_meta_from_source_str("cfgspec".to_strbuf(),
147+
s.to_strbuf(),
148148
Vec::new(),
149149
&parse::new_parse_sess())
150150
}).collect::<ast::CrateConfig>()
@@ -175,8 +175,8 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
175175
parse::parse_crate_from_file(&(*file), cfg.clone(), &sess.parse_sess)
176176
}
177177
StrInput(ref src) => {
178-
parse::parse_crate_from_source_str(anon_src(),
179-
(*src).clone(),
178+
parse::parse_crate_from_source_str(anon_src().to_strbuf(),
179+
src.to_strbuf(),
180180
cfg.clone(),
181181
&sess.parse_sess)
182182
}
@@ -528,7 +528,7 @@ fn write_out_deps(sess: &Session,
528528
// write Makefile-compatible dependency rules
529529
let files: Vec<~str> = sess.codemap().files.borrow()
530530
.iter().filter(|fmap| fmap.is_real_file())
531-
.map(|fmap| fmap.name.clone())
531+
.map(|fmap| fmap.name.to_owned())
532532
.collect();
533533
let mut file = try!(io::File::create(&deps_filename));
534534
for path in out_filenames.iter() {
@@ -604,20 +604,20 @@ impl pprust::PpAnn for IdentifiedAnnotation {
604604
match node {
605605
pprust::NodeItem(item) => {
606606
try!(pp::space(&mut s.s));
607-
s.synth_comment(item.id.to_str())
607+
s.synth_comment(item.id.to_str().to_strbuf())
608608
}
609609
pprust::NodeBlock(blk) => {
610610
try!(pp::space(&mut s.s));
611-
s.synth_comment("block ".to_owned() + blk.id.to_str())
611+
s.synth_comment((format!("block {}", blk.id)).to_strbuf())
612612
}
613613
pprust::NodeExpr(expr) => {
614614
try!(pp::space(&mut s.s));
615-
try!(s.synth_comment(expr.id.to_str()));
615+
try!(s.synth_comment(expr.id.to_str().to_strbuf()));
616616
s.pclose()
617617
}
618618
pprust::NodePat(pat) => {
619619
try!(pp::space(&mut s.s));
620-
s.synth_comment("pat ".to_owned() + pat.id.to_str())
620+
s.synth_comment((format!("pat {}", pat.id)).to_strbuf())
621621
}
622622
}
623623
}
@@ -692,7 +692,7 @@ pub fn pretty_print_input(sess: Session,
692692
pprust::print_crate(sess.codemap(),
693693
sess.diagnostic(),
694694
&krate,
695-
src_name,
695+
src_name.to_strbuf(),
696696
&mut rdr,
697697
out,
698698
&IdentifiedAnnotation,
@@ -707,7 +707,7 @@ pub fn pretty_print_input(sess: Session,
707707
pprust::print_crate(annotation.analysis.ty_cx.sess.codemap(),
708708
annotation.analysis.ty_cx.sess.diagnostic(),
709709
&krate,
710-
src_name,
710+
src_name.to_strbuf(),
711711
&mut rdr,
712712
out,
713713
&annotation,
@@ -717,7 +717,7 @@ pub fn pretty_print_input(sess: Session,
717717
pprust::print_crate(sess.codemap(),
718718
sess.diagnostic(),
719719
&krate,
720-
src_name,
720+
src_name.to_strbuf(),
721721
&mut rdr,
722722
out,
723723
&pprust::NoAnn,

src/librustc/driver/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ cgoptions!(
471471
)
472472

473473
// Seems out of place, but it uses session, so I'm putting it here
474-
pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> ~str) -> T {
474+
pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> StrBuf)
475+
-> T {
475476
diagnostic::expect(sess.diagnostic(), opt, msg)
476477
}
477478

src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn generate_test_harness(sess: &Session, krate: ast::Crate)
168168
cx.ext_cx.bt_push(ExpnInfo {
169169
call_site: DUMMY_SP,
170170
callee: NameAndSpan {
171-
name: "test".to_owned(),
171+
name: "test".to_strbuf(),
172172
format: MacroAttribute,
173173
span: None
174174
}
@@ -398,7 +398,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::Item {
398398

399399
fn is_test_crate(krate: &ast::Crate) -> bool {
400400
match attr::find_crateid(krate.attrs.as_slice()) {
401-
Some(ref s) if "test" == s.name => true,
401+
Some(ref s) if "test" == s.name.as_slice() => true,
402402
_ => false
403403
}
404404
}
@@ -427,7 +427,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
427427

428428
let name_lit: ast::Lit =
429429
nospan(ast::LitStr(token::intern_and_get_ident(
430-
ast_util::path_name_i(path.as_slice())),
430+
ast_util::path_name_i(path.as_slice()).as_slice()),
431431
ast::CookedStr));
432432

433433
let name_expr = @ast::Expr {

src/librustc/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,11 @@ fn parse_crate_attrs(sess: &session::Session, input: &d::Input) ->
352352
&sess.parse_sess)
353353
}
354354
d::StrInput(ref src) => {
355-
parse::parse_crate_attrs_from_source_str(d::anon_src(),
356-
(*src).clone(),
357-
Vec::new(),
358-
&sess.parse_sess)
355+
parse::parse_crate_attrs_from_source_str(
356+
d::anon_src().to_strbuf(),
357+
src.to_strbuf(),
358+
Vec::new(),
359+
&sess.parse_sess)
359360
}
360361
};
361362
result.move_iter().collect()

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@ impl<'a> CrateLoader for Loader<'a> {
428428
};
429429
let macros = decoder::get_exported_macros(library.metadata.as_slice());
430430
let registrar = decoder::get_macro_registrar_fn(library.metadata.as_slice()).map(|id| {
431-
decoder::get_symbol(library.metadata.as_slice(), id)
431+
decoder::get_symbol(library.metadata.as_slice(), id).to_strbuf()
432432
});
433433
let mc = MacroCrate {
434434
lib: library.dylib.clone(),
435-
macros: macros.move_iter().collect(),
435+
macros: macros.move_iter().map(|x| x.to_strbuf()).collect(),
436436
registrar_symbol: registrar,
437437
};
438438
if should_link {

src/librustc/metadata/csearch.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,17 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
207207
let all_items = reader::get_doc(reader::Doc(cdata.data()), tag_items);
208208
let class_doc = expect(tcx.sess.diagnostic(),
209209
decoder::maybe_find_item(class_id.node, all_items),
210-
|| format!("get_field_type: class ID {:?} not found",
211-
class_id) );
210+
|| {
211+
(format!("get_field_type: class ID {:?} not found",
212+
class_id)).to_strbuf()
213+
});
212214
let the_field = expect(tcx.sess.diagnostic(),
213215
decoder::maybe_find_item(def.node, class_doc),
214-
|| format!("get_field_type: in class {:?}, field ID {:?} not found",
215-
class_id, def) );
216+
|| {
217+
(format!("get_field_type: in class {:?}, field ID {:?} not found",
218+
class_id,
219+
def)).to_strbuf()
220+
});
216221
let ty = decoder::item_type(def, the_field, tcx, &*cdata);
217222
ty::ty_param_bounds_and_ty {
218223
generics: ty::Generics {type_param_defs: Rc::new(Vec::new()),

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ impl<'a, 'b, 'c> Visitor<()> for MacroDefVisitor<'a, 'b, 'c> {
15631563
let def = self.ecx.tcx.sess.codemap().span_to_snippet(item.span)
15641564
.expect("Unable to find source for macro");
15651565
self.ebml_w.start_tag(tag_macro_def);
1566-
self.ebml_w.wr_str(def);
1566+
self.ebml_w.wr_str(def.as_slice());
15671567
self.ebml_w.end_tag();
15681568
}
15691569
_ => {}

src/librustc/middle/dataflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> {
112112
"".to_owned()
113113
};
114114

115-
try!(ps.synth_comment(format!("id {}: {}{}{}", id, entry_str,
116-
gens_str, kills_str)));
115+
try!(ps.synth_comment((format!("id {}: {}{}{}", id, entry_str,
116+
gens_str, kills_str)).to_strbuf()));
117117
try!(pp::space(&mut ps.s));
118118
}
119119
Ok(())

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: ~str, sp: Span) {
569569
fn check_pat(cx: &mut Context, pat: &Pat) {
570570
let var_name = match pat.node {
571571
PatWild => Some("_".to_owned()),
572-
PatIdent(_, ref path, _) => Some(path_to_str(path)),
572+
PatIdent(_, ref path, _) => Some(path_to_str(path).to_owned()),
573573
_ => None
574574
};
575575

0 commit comments

Comments
 (0)