diff options
| author | bors <bors@rust-lang.org> | 2014-07-08 20:06:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-08 20:06:40 +0000 |
| commit | 8bb34a3146e6ba4bc7902a85de90cf4f8064ace0 (patch) | |
| tree | f5dd9ae1066eb755649fcced85e998d72147de19 /src/librustc | |
| parent | 35e21346216cc4c5a3b22bb6fb316f8c867f8c92 (diff) | |
| parent | 12c334a77b897f7b1cb6cff3c56a71ecb89c82af (diff) | |
| download | rust-8bb34a3146e6ba4bc7902a85de90cf4f8064ace0.tar.gz rust-8bb34a3146e6ba4bc7902a85de90cf4f8064ace0.zip | |
auto merge of #15493 : brson/rust/tostr, r=pcwalton
This updates https://github.com/rust-lang/rust/pull/15075. Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path. Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage. Closes #15046.
Diffstat (limited to 'src/librustc')
73 files changed, 714 insertions, 704 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index f1856850701..4f915342ee0 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -773,7 +773,7 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems, pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext, t: ty::t, name: &str) -> String { - let s = ppaux::ty_to_str(ccx.tcx(), t); + let s = ppaux::ty_to_string(ccx.tcx(), t); let path = [PathName(token::intern(s.as_slice())), gensym_name(name)]; let hash = get_symbol_hash(ccx, t); diff --git a/src/librustc/back/svh.rs b/src/librustc/back/svh.rs index 24b9ff970aa..324ed3b567e 100644 --- a/src/librustc/back/svh.rs +++ b/src/librustc/back/svh.rs @@ -340,13 +340,13 @@ mod svh_visitor { // trees might be faster. Implementing this is far // easier in short term. let macro_defn_as_string = - pprust::to_str(|pp_state| pp_state.print_mac(macro)); + pprust::to_string(|pp_state| pp_state.print_mac(macro)); macro_defn_as_string.hash(self.st); } else { // It is not possible to observe any kind of macro // invocation at this stage except `macro_rules!`. fail!("reached macro somehow: {}", - pprust::to_str(|pp_state| pp_state.print_mac(macro))); + pprust::to_string(|pp_state| pp_state.print_mac(macro))); } visit::walk_mac(self, macro, e); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 7e34ff2dbbd..6a016edcd28 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -594,7 +594,7 @@ impl pprust::PpAnn for IdentifiedAnnotation { match node { pprust::NodeItem(item) => { try!(pp::space(&mut s.s)); - s.synth_comment(item.id.to_str()) + s.synth_comment(item.id.to_string()) } pprust::NodeBlock(blk) => { try!(pp::space(&mut s.s)); @@ -602,7 +602,7 @@ impl pprust::PpAnn for IdentifiedAnnotation { } pprust::NodeExpr(expr) => { try!(pp::space(&mut s.s)); - try!(s.synth_comment(expr.id.to_str())); + try!(s.synth_comment(expr.id.to_string())); s.pclose() } pprust::NodePat(pat) => { @@ -636,7 +636,7 @@ impl pprust::PpAnn for TypedAnnotation { try!(pp::word(&mut s.s, "as")); try!(pp::space(&mut s.s)); try!(pp::word(&mut s.s, - ppaux::ty_to_str( + ppaux::ty_to_string( tcx, ty::expr_ty(tcx, expr)).as_slice())); s.pclose() diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index 807c2590566..ad0d8cac1e3 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -251,7 +251,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> { match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) { Ok(m) => m, Err(f) => { - early_error(f.to_str().as_slice()); + early_error(f.to_string().as_slice()); } }; @@ -450,7 +450,7 @@ fn monitor(f: proc():Send) { emitter.emit(None, note.as_slice(), diagnostic::Note) } - match r.read_to_str() { + match r.read_to_string() { Ok(s) => println!("{}", s), Err(e) => { emitter.emit(None, diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index b2c6840ad22..0860d111a9e 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -347,7 +347,7 @@ fn mk_test_module(cx: &TestCtxt) -> Gc<ast::Item> { span: DUMMY_SP, }; - debug!("Synthetic test module:\n{}\n", pprust::item_to_str(&item)); + debug!("Synthetic test module:\n{}\n", pprust::item_to_string(&item)); box(GC) item } diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index d07e74493be..a4425183cde 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1883,7 +1883,7 @@ impl TypeNames { self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x)) } - pub fn type_to_str(&self, ty: Type) -> String { + pub fn type_to_string(&self, ty: Type) -> String { unsafe { let s = llvm::LLVMTypeToString(ty.to_ref()); let ret = from_c_str(s); @@ -1893,11 +1893,11 @@ impl TypeNames { } pub fn types_to_str(&self, tys: &[Type]) -> String { - let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect(); + let strs: Vec<String> = tys.iter().map(|t| self.type_to_string(*t)).collect(); format!("[{}]", strs.connect(",")) } - pub fn val_to_str(&self, val: ValueRef) -> String { + pub fn val_to_string(&self, val: ValueRef) -> String { unsafe { let s = llvm::LLVMValueToString(val); let ret = from_c_str(s); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 7b8026e32e0..98a6f7d5ed3 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -31,7 +31,7 @@ use middle::trans::adt; // for `adt::is_ffi_safe` use middle::typeck::astconv::ast_ty_to_ty; use middle::typeck::infer; use middle::{typeck, ty, def, pat_util, stability}; -use util::ppaux::{ty_to_str}; +use util::ppaux::{ty_to_string}; use util::nodemap::NodeSet; use lint::{Context, LintPass, LintArray}; @@ -412,14 +412,14 @@ impl HeapMemory { }); if n_uniq > 0 { - let s = ty_to_str(cx.tcx, ty); + let s = ty_to_string(cx.tcx, ty); let m = format!("type uses owned (Box type) pointers: {}", s); cx.span_lint(OWNED_HEAP_MEMORY, span, m.as_slice()); cx.span_lint(HEAP_MEMORY, span, m.as_slice()); } if n_box > 0 { - let s = ty_to_str(cx.tcx, ty); + let s = ty_to_string(cx.tcx, ty); let m = format!("type uses managed (@ type) pointers: {}", s); cx.span_lint(MANAGED_HEAP_MEMORY, span, m.as_slice()); cx.span_lint(HEAP_MEMORY, span, m.as_slice()); diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 79fbd73c23d..61aaf068c10 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -666,7 +666,7 @@ pub fn check_crate(tcx: &ty::ctxt, for &(lint, span, ref msg) in v.iter() { tcx.sess.span_bug(span, format!("unprocessed lint {} at {}: {}", - lint.as_str(), tcx.map.node_to_str(*id), *msg).as_slice()) + lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice()) } } diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 29566fb1e7c..edf46c214ba 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -148,12 +148,12 @@ fn extract_crate_info(e: &Env, i: &ast::ViewItem) -> Option<CrateInfo> { ident, path_opt); let name = match *path_opt { Some((ref path_str, _)) => { - let name = path_str.get().to_str(); + let name = path_str.get().to_string(); validate_crate_name(Some(e.sess), name.as_slice(), Some(i.span)); name } - None => ident.get().to_str(), + None => ident.get().to_string(), }; Some(CrateInfo { ident: ident.get().to_string(), diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index d16f24a0ad1..0b9ed37c838 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1067,7 +1067,7 @@ fn list_crate_attributes(md: ebml::Doc, hash: &Svh, let r = get_attributes(md); for attr in r.iter() { - try!(write!(out, "{}\n", pprust::attribute_to_str(attr))); + try!(write!(out, "{}\n", pprust::attribute_to_string(attr))); } write!(out, "\n\n") diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 0ec9e31872b..6c544e3809a 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -101,7 +101,7 @@ fn encode_impl_type_basename(ebml_w: &mut Encoder, name: Ident) { } pub fn encode_def_id(ebml_w: &mut Encoder, id: DefId) { - ebml_w.wr_tagged_str(tag_def_id, def_to_str(id).as_slice()); + ebml_w.wr_tagged_str(tag_def_id, def_to_string(id).as_slice()); } #[deriving(Clone)] @@ -116,7 +116,7 @@ fn encode_trait_ref(ebml_w: &mut Encoder, tag: uint) { let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag, - ds: def_to_str, + ds: def_to_string, tcx: ecx.tcx, abbrevs: &ecx.type_abbrevs }; @@ -141,7 +141,7 @@ fn encode_family(ebml_w: &mut Encoder, c: char) { ebml_w.end_tag(); } -pub fn def_to_str(did: DefId) -> String { +pub fn def_to_string(did: DefId) -> String { format!("{}:{}", did.krate, did.node) } @@ -151,7 +151,7 @@ fn encode_ty_type_param_defs(ebml_w: &mut Encoder, tag: uint) { let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag, - ds: def_to_str, + ds: def_to_string, tcx: ecx.tcx, abbrevs: &ecx.type_abbrevs }; @@ -172,7 +172,7 @@ fn encode_region_param_defs(ebml_w: &mut Encoder, ebml_w.end_tag(); ebml_w.wr_tagged_str(tag_region_param_def_def_id, - def_to_str(param.def_id).as_slice()); + def_to_string(param.def_id).as_slice()); ebml_w.wr_tagged_u64(tag_region_param_def_space, param.space.to_uint() as u64); @@ -204,7 +204,7 @@ fn encode_bounds_and_type(ebml_w: &mut Encoder, fn encode_variant_id(ebml_w: &mut Encoder, vid: DefId) { ebml_w.start_tag(tag_items_data_item_variant); - let s = def_to_str(vid); + let s = def_to_string(vid); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); } @@ -214,7 +214,7 @@ pub fn write_type(ecx: &EncodeContext, typ: ty::t) { let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag, - ds: def_to_str, + ds: def_to_string, tcx: ecx.tcx, abbrevs: &ecx.type_abbrevs }; @@ -236,7 +236,7 @@ fn encode_method_fty(ecx: &EncodeContext, let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag, - ds: def_to_str, + ds: def_to_string, tcx: ecx.tcx, abbrevs: &ecx.type_abbrevs }; @@ -266,14 +266,14 @@ fn encode_disr_val(_: &EncodeContext, ebml_w: &mut Encoder, disr_val: ty::Disr) { ebml_w.start_tag(tag_disr_val); - let s = disr_val.to_str(); + let s = disr_val.to_string(); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); } fn encode_parent_item(ebml_w: &mut Encoder, id: DefId) { ebml_w.start_tag(tag_items_data_parent_item); - let s = def_to_str(id); + let s = def_to_string(id); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); } @@ -291,7 +291,7 @@ fn encode_struct_fields(ebml_w: &mut Encoder, encode_struct_field_family(ebml_w, f.vis); encode_def_id(ebml_w, f.id); ebml_w.start_tag(tag_item_field_origin); - let s = def_to_str(origin); + let s = def_to_string(origin); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); ebml_w.end_tag(); @@ -382,7 +382,7 @@ fn encode_reexported_static_method(ebml_w: &mut Encoder, exp.name, token::get_ident(method_ident)); ebml_w.start_tag(tag_items_data_item_reexport); ebml_w.start_tag(tag_items_data_item_reexport_def_id); - ebml_w.wr_str(def_to_str(method_def_id).as_slice()); + ebml_w.wr_str(def_to_string(method_def_id).as_slice()); ebml_w.end_tag(); ebml_w.start_tag(tag_items_data_item_reexport_name); ebml_w.wr_str(format!("{}::{}", @@ -529,7 +529,7 @@ fn encode_reexports(ecx: &EncodeContext, id); ebml_w.start_tag(tag_items_data_item_reexport); ebml_w.start_tag(tag_items_data_item_reexport_def_id); - ebml_w.wr_str(def_to_str(exp.def_id).as_slice()); + ebml_w.wr_str(def_to_string(exp.def_id).as_slice()); ebml_w.end_tag(); ebml_w.start_tag(tag_items_data_item_reexport_name); ebml_w.wr_str(exp.name.as_slice()); @@ -562,12 +562,12 @@ fn encode_info_for_mod(ecx: &EncodeContext, // Encode info about all the module children. for item in md.items.iter() { ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(local_def(item.id)).as_slice()); + ebml_w.wr_str(def_to_string(local_def(item.id)).as_slice()); ebml_w.end_tag(); each_auxiliary_node_id(*item, |auxiliary_node_id| { ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(local_def( + ebml_w.wr_str(def_to_string(local_def( auxiliary_node_id)).as_slice()); ebml_w.end_tag(); true @@ -579,10 +579,10 @@ fn encode_info_for_mod(ecx: &EncodeContext, debug!("(encoding info for module) ... encoding impl {} \ ({:?}/{:?})", token::get_ident(ident), - did, ecx.tcx.map.node_to_str(did)); + did, ecx.tcx.map.node_to_string(did)); ebml_w.start_tag(tag_mod_impl); - ebml_w.wr_str(def_to_str(local_def(did)).as_slice()); + ebml_w.wr_str(def_to_string(local_def(did)).as_slice()); ebml_w.end_tag(); } _ => {} @@ -659,7 +659,7 @@ fn encode_provided_source(ebml_w: &mut Encoder, source_opt: Option<DefId>) { for source in source_opt.iter() { ebml_w.start_tag(tag_item_method_provided_source); - let s = def_to_str(*source); + let s = def_to_string(*source); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); } @@ -906,7 +906,7 @@ fn encode_info_for_item(ecx: &EncodeContext, } debug!("encoding info for item at {}", - tcx.sess.codemap().span_to_str(item.span)); + tcx.sess.codemap().span_to_string(item.span)); let def_id = local_def(item.id); let stab = stability::lookup(tcx, ast_util::local_def(item.id)); @@ -977,7 +977,7 @@ fn encode_info_for_item(ecx: &EncodeContext, // Encode all the items in this module. for foreign_item in fm.items.iter() { ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(local_def(foreign_item.id)).as_slice()); + ebml_w.wr_str(def_to_string(local_def(foreign_item.id)).as_slice()); ebml_w.end_tag(); } encode_visibility(ebml_w, vis); @@ -1101,7 +1101,7 @@ fn encode_info_for_item(ecx: &EncodeContext, } for &method_def_id in methods.iter() { ebml_w.start_tag(tag_item_impl_method); - let s = def_to_str(method_def_id); + let s = def_to_string(method_def_id); ebml_w.writer.write(s.as_bytes()); ebml_w.end_tag(); } @@ -1161,7 +1161,7 @@ fn encode_info_for_item(ecx: &EncodeContext, ebml_w.end_tag(); ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(method_def_id).as_slice()); + ebml_w.wr_str(def_to_string(method_def_id).as_slice()); ebml_w.end_tag(); } encode_path(ebml_w, path.clone()); @@ -1314,7 +1314,7 @@ fn my_visit_foreign_item(ni: &ForeignItem, // See above let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) }; debug!("writing foreign item {}::{}", - ecx.tcx.map.path_to_str(ni.id), + ecx.tcx.map.path_to_string(ni.id), token::get_ident(ni.ident)); let mut ebml_w = unsafe { @@ -1680,12 +1680,12 @@ fn encode_misc_info(ecx: &EncodeContext, ebml_w.start_tag(tag_misc_info_crate_items); for &item in krate.module.items.iter() { ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(local_def(item.id)).as_slice()); + ebml_w.wr_str(def_to_string(local_def(item.id)).as_slice()); ebml_w.end_tag(); each_auxiliary_node_id(item, |auxiliary_node_id| { ebml_w.start_tag(tag_mod_child); - ebml_w.wr_str(def_to_str(local_def( + ebml_w.wr_str(def_to_string(local_def( auxiliary_node_id)).as_slice()); ebml_w.end_tag(); true @@ -1926,7 +1926,7 @@ pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> String { let mut wr = MemWriter::new(); tyencode::enc_ty(&mut wr, &tyencode::ctxt { diag: tcx.sess.diagnostic(), - ds: def_to_str, + ds: def_to_string, tcx: tcx, abbrevs: &RefCell::new(HashMap::new()) }, t); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index d7a7d2902b4..11b1687dc55 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -28,7 +28,7 @@ use middle::subst; use middle::subst::VecPerParamSpace; use middle::typeck::{MethodCall, MethodCallee, MethodOrigin}; use middle::{ty, typeck}; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; use syntax::{ast, ast_map, ast_util, codemap, fold}; use syntax::codemap::Span; @@ -86,7 +86,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, e::IIMethodRef(_, _, m) => m.id, }; debug!("> Encoding inlined item: {} ({})", - ecx.tcx.map.path_to_str(id), + ecx.tcx.map.path_to_string(id), ebml_w.writer.tell()); let ii = simplify_ast(ii); @@ -99,7 +99,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, ebml_w.end_tag(); debug!("< Encoded inlined fn: {} ({})", - ecx.tcx.map.path_to_str(id), + ecx.tcx.map.path_to_string(id), ebml_w.writer.tell()); } @@ -119,7 +119,7 @@ pub fn decode_inlined_item(cdata: &cstore::crate_metadata, debug!("> Decoding inlined fn: {}::?", { // Do an Option dance to use the path after it is moved below. - let s = ast_map::path_to_str(ast_map::Values(path.iter())); + let s = ast_map::path_to_string(ast_map::Values(path.iter())); path_as_str = Some(s); path_as_str.as_ref().map(|x| x.as_slice()) }); @@ -147,7 +147,7 @@ pub fn decode_inlined_item(cdata: &cstore::crate_metadata, match ii { ast::IIItem(i) => { debug!(">>> DECODED ITEM >>>\n{}\n<<< DECODED ITEM <<<", - syntax::print::pprust::item_to_str(&*i)); + syntax::print::pprust::item_to_string(&*i)); } _ => { } } @@ -826,7 +826,7 @@ impl<'a> get_ty_str_ctxt for e::EncodeContext<'a> { fn ty_str_ctxt<'a>(&'a self) -> tyencode::ctxt<'a> { tyencode::ctxt { diag: self.tcx.sess.diagnostic(), - ds: e::def_to_str, + ds: e::def_to_string, tcx: self.tcx, abbrevs: &self.type_abbrevs } @@ -1391,7 +1391,7 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext, c::tag_table_node_type => { let ty = val_dsr.read_ty(xcx); debug!("inserting ty for node {:?}: {}", - id, ty_to_str(dcx.tcx, ty)); + id, ty_to_string(dcx.tcx, ty)); dcx.tcx.node_types.borrow_mut().insert(id as uint, ty); } c::tag_table_item_subst => { @@ -1561,7 +1561,7 @@ fn test_simplification() { ).unwrap()); match (item_out, item_exp) { (ast::IIItem(item_out), ast::IIItem(item_exp)) => { - assert!(pprust::item_to_str(item_out) == pprust::item_to_str(item_exp)); + assert!(pprust::item_to_string(item_out) == pprust::item_to_string(item_exp)); } _ => fail!() } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index df208b9cdc1..db8ab8c83fb 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -351,7 +351,7 @@ impl<'a> CheckLoanCtxt<'a> { "it".to_string() } else { format!("`{}`", - self.bccx.loan_path_to_str(&*old_loan.loan_path)) + self.bccx.loan_path_to_string(&*old_loan.loan_path)) }; match (new_loan.kind, old_loan.kind) { @@ -360,7 +360,7 @@ impl<'a> CheckLoanCtxt<'a> { new_loan.span, format!("cannot borrow `{}` as mutable \ more than once at a time", - self.bccx.loan_path_to_str( + self.bccx.loan_path_to_string( &*new_loan.loan_path)).as_slice()); } @@ -369,7 +369,7 @@ impl<'a> CheckLoanCtxt<'a> { new_loan.span, format!("closure requires unique access to `{}` \ but {} is already borrowed", - self.bccx.loan_path_to_str(&*new_loan.loan_path), + self.bccx.loan_path_to_string(&*new_loan.loan_path), old_pronoun).as_slice()); } @@ -378,7 +378,7 @@ impl<'a> CheckLoanCtxt<'a> { new_loan.span, format!("cannot borrow `{}` as {} because \ previous closure requires unique access", - self.bccx.loan_path_to_str(&*new_loan.loan_path), + self.bccx.loan_path_to_string(&*new_loan.loan_path), new_loan.kind.to_user_str()).as_slice()); } @@ -387,7 +387,7 @@ impl<'a> CheckLoanCtxt<'a> { new_loan.span, format!("cannot borrow `{}` as {} because \ {} is also borrowed as {}", - self.bccx.loan_path_to_str(&*new_loan.loan_path), + self.bccx.loan_path_to_string(&*new_loan.loan_path), new_loan.kind.to_user_str(), old_pronoun, old_loan.kind.to_user_str()).as_slice()); @@ -399,7 +399,7 @@ impl<'a> CheckLoanCtxt<'a> { self.bccx.span_note( span, format!("borrow occurs due to use of `{}` in closure", - self.bccx.loan_path_to_str( + self.bccx.loan_path_to_string( &*new_loan.loan_path)).as_slice()); } _ => { } @@ -410,7 +410,7 @@ impl<'a> CheckLoanCtxt<'a> { format!("the mutable borrow prevents subsequent \ moves, borrows, or modification of `{0}` \ until the borrow ends", - self.bccx.loan_path_to_str( + self.bccx.loan_path_to_string( &*old_loan.loan_path)) } @@ -418,14 +418,14 @@ impl<'a> CheckLoanCtxt<'a> { format!("the immutable borrow prevents subsequent \ moves or mutable borrows of `{0}` \ until the borrow ends", - self.bccx.loan_path_to_str(&*old_loan.loan_path)) + self.bccx.loan_path_to_string(&*old_loan.loan_path)) } ty::UniqueImmBorrow => { format!("the unique capture prevents subsequent \ moves or borrows of `{0}` \ until the borrow ends", - self.bccx.loan_path_to_str(&*old_loan.loan_path)) + self.bccx.loan_path_to_string(&*old_loan.loan_path)) } }; @@ -433,7 +433,7 @@ impl<'a> CheckLoanCtxt<'a> { euv::ClosureCapture(_) => { format!("previous borrow of `{}` occurs here due to \ use in closure", - self.bccx.loan_path_to_str(&*old_loan.loan_path)) + self.bccx.loan_path_to_string(&*old_loan.loan_path)) } euv::OverloadedOperator(..) | @@ -442,7 +442,7 @@ impl<'a> CheckLoanCtxt<'a> { euv::ClosureInvocation(..) | euv::RefBinding(..) => { format!("previous borrow of `{}` occurs here", - self.bccx.loan_path_to_str(&*old_loan.loan_path)) + self.bccx.loan_path_to_string(&*old_loan.loan_path)) } }; @@ -518,12 +518,12 @@ impl<'a> CheckLoanCtxt<'a> { self.bccx.span_err( span, format!("cannot use `{}` because it was mutably borrowed", - self.bccx.loan_path_to_str(copy_path).as_slice()) + self.bccx.loan_path_to_string(copy_path).as_slice()) .as_slice()); self.bccx.span_note( loan_span, format!("borrow of `{}` occurs here", - self.bccx.loan_path_to_str(&*loan_path).as_slice()) + self.bccx.loan_path_to_string(&*loan_path).as_slice()) .as_slice()); } } @@ -543,19 +543,19 @@ impl<'a> CheckLoanCtxt<'a> { let err_message = match move_kind { move_data::Captured => format!("cannot move `{}` into closure because it is borrowed", - self.bccx.loan_path_to_str(move_path).as_slice()), + self.bccx.loan_path_to_string(move_path).as_slice()), move_data::Declared | move_data::MoveExpr | move_data::MovePat => format!("cannot move out of `{}` because it is borrowed", - self.bccx.loan_path_to_str(move_path).as_slice()) + self.bccx.loan_path_to_string(move_path).as_slice()) }; self.bccx.span_err(span, err_message.as_slice()); self.bccx.span_note( loan_span, format!("borrow of `{}` occurs here", - self.bccx.loan_path_to_str(&*loan_path).as_slice()) + self.bccx.loan_path_to_string(&*loan_path).as_slice()) .as_slice()); } } @@ -567,7 +567,7 @@ impl<'a> CheckLoanCtxt<'a> { borrow_kind: ty::BorrowKind) -> UseError { debug!("analyze_restrictions_on_use(expr_id={:?}, use_path={})", - self.tcx().map.node_to_str(expr_id), + self.tcx().map.node_to_string(expr_id), use_path.repr(self.tcx())); let mut ret = UseOk; @@ -690,15 +690,15 @@ impl<'a> CheckLoanCtxt<'a> { assignment_span, format!("cannot assign to {} {} `{}`", assignee_cmt.mutbl.to_user_str(), - self.bccx.cmt_to_str(&*assignee_cmt), - self.bccx.loan_path_to_str(&*lp)).as_slice()); + self.bccx.cmt_to_string(&*assignee_cmt), + self.bccx.loan_path_to_string(&*lp)).as_slice()); } None => { self.bccx.span_err( assignment_span, format!("cannot assign to {} {}", assignee_cmt.mutbl.to_user_str(), - self.bccx.cmt_to_str(&*assignee_cmt)).as_slice()); + self.bccx.cmt_to_string(&*assignee_cmt)).as_slice()); } } return; @@ -824,10 +824,10 @@ impl<'a> CheckLoanCtxt<'a> { self.bccx.span_err( span, format!("cannot assign to `{}` because it is borrowed", - self.bccx.loan_path_to_str(loan_path)).as_slice()); + self.bccx.loan_path_to_string(loan_path)).as_slice()); self.bccx.span_note( loan.span, format!("borrow of `{}` occurs here", - self.bccx.loan_path_to_str(loan_path)).as_slice()); + self.bccx.loan_path_to_string(loan_path)).as_slice()); } } diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index f5c91f7b1b3..9876e12d5cc 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -120,7 +120,7 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) { bccx.span_err( move_from.span, format!("cannot move out of {}", - bccx.cmt_to_str(&*move_from)).as_slice()); + bccx.cmt_to_string(&*move_from)).as_slice()); } mc::cat_downcast(ref b) | @@ -145,7 +145,7 @@ fn note_move_destination(bccx: &BorrowckCtxt, move_to_span: codemap::Span, pat_ident: &ast::Ident, is_first_note: bool) { - let pat_name = pprust::ident_to_str(pat_ident); + let pat_name = pprust::ident_to_string(pat_ident); if is_first_note { bccx.span_note( move_to_span, diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 9ab3202b909..426a1fbede5 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -418,7 +418,7 @@ impl<'a> BorrowckCtxt<'a> { pub fn report(&self, err: BckError) { self.span_err( err.span, - self.bckerr_to_str(&err).as_slice()); + self.bckerr_to_string(&err).as_slice()); self.note_and_explain_bckerr(err); } @@ -439,7 +439,7 @@ impl<'a> BorrowckCtxt<'a> { use_span, format!("{} of possibly uninitialized variable: `{}`", verb, - self.loan_path_to_str(lp)).as_slice()); + self.loan_path_to_string(lp)).as_slice()); } _ => { let partially = if lp == moved_lp {""} else {"partially "}; @@ -448,7 +448,7 @@ impl<'a> BorrowckCtxt<'a> { format!("{} of {}moved value: `{}`", verb, partially, - self.loan_path_to_str(lp)).as_slice()); + self.loan_path_to_string(lp)).as_slice()); } } @@ -472,7 +472,7 @@ impl<'a> BorrowckCtxt<'a> { self.tcx.sess.span_note( expr_span, format!("`{}` moved here because it has type `{}`, which is {}", - self.loan_path_to_str(moved_lp), + self.loan_path_to_string(moved_lp), expr_ty.user_string(self.tcx), suggestion).as_slice()); } @@ -483,7 +483,7 @@ impl<'a> BorrowckCtxt<'a> { format!("`{}` moved here because it has type `{}`, \ which is moved by default (use `ref` to \ override)", - self.loan_path_to_str(moved_lp), + self.loan_path_to_string(moved_lp), pat_ty.user_string(self.tcx)).as_slice()); } @@ -506,7 +506,7 @@ impl<'a> BorrowckCtxt<'a> { expr_span, format!("`{}` moved into closure environment here because it \ has type `{}`, which is {}", - self.loan_path_to_str(moved_lp), + self.loan_path_to_string(moved_lp), expr_ty.user_string(self.tcx), suggestion).as_slice()); } @@ -536,7 +536,7 @@ impl<'a> BorrowckCtxt<'a> { self.tcx.sess.span_err( span, format!("re-assignment of immutable variable `{}`", - self.loan_path_to_str(lp)).as_slice()); + self.loan_path_to_string(lp)).as_slice()); self.tcx.sess.span_note(assign.span, "prior assignment occurs here"); } @@ -552,20 +552,20 @@ impl<'a> BorrowckCtxt<'a> { self.tcx.sess.span_end_note(s, m); } - pub fn bckerr_to_str(&self, err: &BckError) -> String { + pub fn bckerr_to_string(&self, err: &BckError) -> String { match err.code { err_mutbl => { let descr = match opt_loan_path(&err.cmt) { None => { format!("{} {}", err.cmt.mutbl.to_user_str(), - self.cmt_to_str(&*err.cmt)) + self.cmt_to_string(&*err.cmt)) } Some(lp) => { format!("{} {} `{}`", err.cmt.mutbl.to_user_str(), - self.cmt_to_str(&*err.cmt), - self.loan_path_to_str(&*lp)) + self.cmt_to_string(&*err.cmt), + self.loan_path_to_string(&*lp)) } }; @@ -589,7 +589,7 @@ impl<'a> BorrowckCtxt<'a> { let msg = match opt_loan_path(&err.cmt) { None => "borrowed value".to_string(), Some(lp) => { - format!("`{}`", self.loan_path_to_str(&*lp)) + format!("`{}`", self.loan_path_to_string(&*lp)) } }; format!("{} does not live long enough", msg) @@ -597,9 +597,9 @@ impl<'a> BorrowckCtxt<'a> { err_borrowed_pointer_too_short(..) => { let descr = match opt_loan_path(&err.cmt) { Some(lp) => { - format!("`{}`", self.loan_path_to_str(&*lp)) + format!("`{}`", self.loan_path_to_string(&*lp)) } - None => self.cmt_to_str(&*err.cmt), + None => self.cmt_to_string(&*err.cmt), }; format!("lifetime of {} is too short to guarantee \ @@ -691,9 +691,9 @@ impl<'a> BorrowckCtxt<'a> { err_borrowed_pointer_too_short(loan_scope, ptr_scope) => { let descr = match opt_loan_path(&err.cmt) { Some(lp) => { - format!("`{}`", self.loan_path_to_str(&*lp)) + format!("`{}`", self.loan_path_to_string(&*lp)) } - None => self.cmt_to_str(&*err.cmt), + None => self.cmt_to_string(&*err.cmt), }; note_and_explain_region( self.tcx, @@ -710,7 +710,7 @@ impl<'a> BorrowckCtxt<'a> { } } - pub fn append_loan_path_to_str(&self, + pub fn append_loan_path_to_string(&self, loan_path: &LoanPath, out: &mut String) { match *loan_path { @@ -720,7 +720,7 @@ impl<'a> BorrowckCtxt<'a> { } LpExtend(ref lp_base, _, LpInterior(mc::InteriorField(fname))) => { - self.append_autoderefd_loan_path_to_str(&**lp_base, out); + self.append_autoderefd_loan_path_to_string(&**lp_base, out); match fname { mc::NamedField(fname) => { out.push_char('.'); @@ -728,24 +728,24 @@ impl<'a> BorrowckCtxt<'a> { } mc::PositionalField(idx) => { out.push_char('#'); // invent a notation here - out.push_str(idx.to_str().as_slice()); + out.push_str(idx.to_string().as_slice()); } } } LpExtend(ref lp_base, _, LpInterior(mc::InteriorElement(_))) => { - self.append_autoderefd_loan_path_to_str(&**lp_base, out); + self.append_autoderefd_loan_path_to_string(&**lp_base, out); out.push_str("[..]"); } LpExtend(ref lp_base, _, LpDeref(_)) => { out.push_char('*'); - self.append_loan_path_to_str(&**lp_base, out); + self.append_loan_path_to_string(&**lp_base, out); } } } - pub fn append_autoderefd_loan_path_to_str(&self, + pub fn append_autoderefd_loan_path_to_string(&self, loan_path: &LoanPath, out: &mut String) { match *loan_path { @@ -753,23 +753,23 @@ impl<'a> BorrowckCtxt<'a> { // For a path like `(*x).f` or `(*x)[3]`, autoderef // rules would normally allow users to omit the `*x`. // So just serialize such paths to `x.f` or x[3]` respectively. - self.append_autoderefd_loan_path_to_str(&**lp_base, out) + self.append_autoderefd_loan_path_to_string(&**lp_base, out) } LpVar(..) | LpUpvar(..) | LpExtend(_, _, LpInterior(..)) => { - self.append_loan_path_to_str(loan_path, out) + self.append_loan_path_to_string(loan_path, out) } } } - pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> String { + pub fn loan_path_to_string(&self, loan_path: &LoanPath) -> String { let mut result = String::new(); - self.append_loan_path_to_str(loan_path, &mut result); + self.append_loan_path_to_string(loan_path, &mut result); result } - pub fn cmt_to_str(&self, cmt: &mc::cmt_) -> String { - self.mc().cmt_to_str(cmt) + pub fn cmt_to_string(&self, cmt: &mc::cmt_) -> String { + self.mc().cmt_to_string(cmt) } } @@ -815,11 +815,11 @@ impl Repr for LoanPath { fn repr(&self, tcx: &ty::ctxt) -> String { match self { &LpVar(id) => { - format!("$({})", tcx.map.node_to_str(id)) + format!("$({})", tcx.map.node_to_string(id)) } &LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => { - let s = tcx.map.node_to_str(var_id); + let s = tcx.map.node_to_string(var_id); format!("$({} captured by id={})", s, closure_expr_id) } diff --git a/src/librustc/middle/cfg/graphviz.rs b/src/librustc/middle/cfg/graphviz.rs index c33580d869b..9f44f0babc7 100644 --- a/src/librustc/middle/cfg/graphviz.rs +++ b/src/librustc/middle/cfg/graphviz.rs @@ -64,7 +64,7 @@ impl<'a> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a> { } else if n.data.id == ast::DUMMY_NODE_ID { dot::LabelStr("(dummy_node)".into_maybe_owned()) } else { - let s = self.ast_map.node_to_str(n.data.id); + let s = self.ast_map.node_to_string(n.data.id); // left-aligns the lines let s = replace_newline_with_backslash_l(s); dot::EscStr(s.into_maybe_owned()) @@ -80,7 +80,7 @@ impl<'a> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a> { } else { put_one = true; } - let s = self.ast_map.node_to_str(node_id); + let s = self.ast_map.node_to_string(node_id); // left-aligns the lines let s = replace_newline_with_backslash_l(s); label = label.append(format!("exiting scope_{} {}", diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index cf886702d86..33bf6ceed4f 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -108,7 +108,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) { .span_err(e.span, format!("can not cast to `{}` in a constant \ expression", - ppaux::ty_to_str(v.tcx, ety)).as_slice()) + ppaux::ty_to_string(v.tcx, ety)).as_slice()) } } ExprPath(ref pth) => { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 6ba112bf353..599f5f4024f 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -22,10 +22,10 @@ use syntax::ast::*; use syntax::ast_util::{is_unguarded, walk_pat}; use syntax::codemap::{Span, Spanned, DUMMY_SP}; use syntax::owned_slice::OwnedSlice; -use syntax::print::pprust::pat_to_str; +use syntax::print::pprust::pat_to_string; use syntax::visit; use syntax::visit::{Visitor, FnKind}; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; struct Matrix(Vec<Vec<Gc<Pat>>>); @@ -47,7 +47,7 @@ impl fmt::Show for Matrix { let &Matrix(ref m) = self; let pretty_printed_matrix: Vec<Vec<String>> = m.iter().map(|row| { - row.iter().map(|&pat| pat_to_str(pat)).collect::<Vec<String>>() + row.iter().map(|&pat| pat_to_string(pat)).collect::<Vec<String>>() }).collect(); let column_count = m.iter().map(|row| row.len()).max().unwrap_or(0u); @@ -147,7 +147,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) { // We know the type is inhabited, so this must be wrong cx.tcx.sess.span_err(ex.span, format!("non-exhaustive patterns: \ type {} is non-empty", - ty_to_str(cx.tcx, pat_ty)).as_slice()); + ty_to_string(cx.tcx, pat_ty)).as_slice()); } // If the type *is* empty, it's vacuously exhaustive return; @@ -222,7 +222,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, m: &Matrix) { [] => wild(), _ => unreachable!() }; - let msg = format!("non-exhaustive patterns: `{0}` not covered", pat_to_str(&*witness)); + let msg = format!("non-exhaustive patterns: `{0}` not covered", + pat_to_string(&*witness)); cx.tcx.sess.span_err(sp, msg.as_slice()); } NotUseful => { @@ -780,7 +781,7 @@ fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) { Some(pat) => { let msg = format!( "refutable pattern in {} binding: `{}` not covered", - name, pat_to_str(&*pat) + name, pat_to_string(&*pat) ); cx.tcx.sess.span_err(loc.pat.span, msg.as_slice()); }, @@ -802,7 +803,7 @@ fn check_fn(cx: &mut MatchCheckCtxt, Some(pat) => { let msg = format!( "refutable pattern in function argument: `{}` not covered", - pat_to_str(&*pat) + pat_to_string(&*pat) ); cx.tcx.sess.span_err(input.pat.span, msg.as_slice()); }, diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index 33949ee5b16..1e948afb701 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -75,7 +75,7 @@ impl<'a> CheckStaticVisitor<'a> { impl<'a> Visitor<bool> for CheckStaticVisitor<'a> { fn visit_item(&mut self, i: &ast::Item, _is_const: bool) { - debug!("visit_item(item={})", pprust::item_to_str(i)); + debug!("visit_item(item={})", pprust::item_to_string(i)); match i.node { ast::ItemStatic(_, mutability, ref expr) => { match mutability { @@ -99,7 +99,7 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> { /// of a static item, this method does nothing but walking /// down through it. fn visit_expr(&mut self, e: &ast::Expr, is_const: bool) { - debug!("visit_expr(expr={})", pprust::expr_to_str(e)); + debug!("visit_expr(expr={})", pprust::expr_to_string(e)); if !is_const { return visit::walk_expr(self, e, is_const); diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 5ac85833e22..7d9178162a6 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -164,18 +164,18 @@ impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> { let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index); let (start, end) = self.compute_id_range_frozen(cfgidx); let on_entry = self.on_entry.slice(start, end); - let entry_str = bits_to_str(on_entry); + let entry_str = bits_to_string(on_entry); let gens = self.gens.slice(start, end); let gens_str = if gens.iter().any(|&u| u != 0) { - format!(" gen: {}", bits_to_str(gens)) + format!(" gen: {}", bits_to_string(gens)) } else { "".to_string() }; let kills = self.kills.slice(start, end); let kills_str = if kills.iter().any(|&u| u != 0) { - format!(" kill: {}", bits_to_str(kills)) + format!(" kill: {}", bits_to_string(kills)) } else { "".to_string() }; @@ -289,7 +289,7 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { fn apply_gen_kill(&mut self, cfgidx: CFGIndex, bits: &mut [uint]) { //! Applies the gen and kill sets for `id` to `bits` debug!("{:s} apply_gen_kill(cfgidx={}, bits={}) [before]", - self.analysis_name, cfgidx, mut_bits_to_str(bits)); + self.analysis_name, cfgidx, mut_bits_to_string(bits)); let (start, end) = self.compute_id_range(cfgidx); let gens = self.gens.slice(start, end); bitwise(bits, gens, &Union); @@ -297,7 +297,7 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { bitwise(bits, kills, &Subtract); debug!("{:s} apply_gen_kill(cfgidx={}, bits={}) [after]", - self.analysis_name, cfgidx, mut_bits_to_str(bits)); + self.analysis_name, cfgidx, mut_bits_to_string(bits)); } fn compute_id_range_frozen(&self, cfgidx: CFGIndex) -> (uint, uint) { @@ -334,7 +334,7 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { let (start, end) = self.compute_id_range_frozen(cfgidx); let on_entry = self.on_entry.slice(start, end); debug!("{:s} each_bit_on_entry_frozen(id={:?}, on_entry={})", - self.analysis_name, id, bits_to_str(on_entry)); + self.analysis_name, id, bits_to_string(on_entry)); self.each_bit(on_entry, f) } @@ -348,7 +348,7 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { let (start, end) = self.compute_id_range_frozen(cfgidx); let gens = self.gens.slice(start, end); debug!("{:s} each_gen_bit(id={:?}, gens={})", - self.analysis_name, id, bits_to_str(gens)); + self.analysis_name, id, bits_to_string(gens)); self.each_bit(gens, f) } @@ -426,10 +426,10 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { if changed { let bits = self.kills.mut_slice(start, end); debug!("{:s} add_kills_from_flow_exits flow_exit={} bits={} [before]", - self.analysis_name, flow_exit, mut_bits_to_str(bits)); + self.analysis_name, flow_exit, mut_bits_to_string(bits)); bits.copy_from(orig_kills.as_slice()); debug!("{:s} add_kills_from_flow_exits flow_exit={} bits={} [after]", - self.analysis_name, flow_exit, mut_bits_to_str(bits)); + self.analysis_name, flow_exit, mut_bits_to_string(bits)); } true }); @@ -483,10 +483,10 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { cfg: &cfg::CFG, in_out: &mut [uint]) { debug!("DataFlowContext::walk_cfg(in_out={}) {:s}", - bits_to_str(in_out), self.dfcx.analysis_name); + bits_to_string(in_out), self.dfcx.analysis_name); cfg.graph.each_node(|node_index, node| { debug!("DataFlowContext::walk_cfg idx={} id={} begin in_out={}", - node_index, node.data.id, bits_to_str(in_out)); + node_index, node.data.id, bits_to_string(in_out)); let (start, end) = self.dfcx.compute_id_range(node_index); @@ -526,7 +526,7 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { let source = edge.source(); let cfgidx = edge.target(); debug!("{:s} propagate_bits_into_entry_set_for(pred_bits={}, {} to {})", - self.dfcx.analysis_name, bits_to_str(pred_bits), source, cfgidx); + self.dfcx.analysis_name, bits_to_string(pred_bits), source, cfgidx); let (start, end) = self.dfcx.compute_id_range(cfgidx); let changed = { // (scoping mutable borrow of self.dfcx.on_entry) @@ -536,17 +536,17 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { if changed { debug!("{:s} changed entry set for {:?} to {}", self.dfcx.analysis_name, cfgidx, - bits_to_str(self.dfcx.on_entry.slice(start, end))); + bits_to_string(self.dfcx.on_entry.slice(start, end))); self.changed = true; } } } -fn mut_bits_to_str(words: &mut [uint]) -> String { - bits_to_str(words) +fn mut_bits_to_string(words: &mut [uint]) -> String { + bits_to_string(words) } -fn bits_to_str(words: &[uint]) -> String { +fn bits_to_string(words: &[uint]) -> String { let mut result = String::new(); let mut sep = '['; @@ -582,7 +582,7 @@ fn bitwise<Op:BitwiseOperator>(out_vec: &mut [uint], fn set_bit(words: &mut [uint], bit: uint) -> bool { debug!("set_bit: words={} bit={}", - mut_bits_to_str(words), bit_str(bit)); + mut_bits_to_string(words), bit_str(bit)); let word = bit / uint::BITS; let bit_in_word = bit % uint::BITS; let bit_mask = 1 << bit_in_word; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 2333b329996..782a380e23a 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -68,7 +68,7 @@ impl<'a> EffectCheckVisitor<'a> { _ => return }; debug!("effect: checking index with base type {}", - ppaux::ty_to_str(self.tcx, base_type)); + ppaux::ty_to_string(self.tcx, base_type)); match ty::get(base_type).sty { ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty { ty::ty_str => { @@ -147,7 +147,7 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> { let method_call = MethodCall::expr(expr.id); let base_type = self.tcx.method_map.borrow().get(&method_call).ty; debug!("effect: method call case, base type is {}", - ppaux::ty_to_str(self.tcx, base_type)); + ppaux::ty_to_string(self.tcx, base_type)); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "invocation of unsafe method") @@ -156,7 +156,7 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> { ast::ExprCall(base, _) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: call case, base type is {}", - ppaux::ty_to_str(self.tcx, base_type)); + ppaux::ty_to_string(self.tcx, base_type)); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "call to unsafe function") } @@ -164,7 +164,7 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> { ast::ExprUnary(ast::UnDeref, base) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: unary case, base type is {}", - ppaux::ty_to_str(self.tcx, base_type)); + ppaux::ty_to_string(self.tcx, base_type)); match ty::get(base_type).sty { ty::ty_ptr(_) => { self.require_unsafe(expr.span, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index a7154e78bc5..d432ced5226 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -15,13 +15,13 @@ use middle::subst; use middle::ty; use middle::typeck::{MethodCall, NoAdjustment}; use middle::typeck; -use util::ppaux::{Repr, ty_to_str}; +use util::ppaux::{Repr, ty_to_string}; use util::ppaux::UserString; use syntax::ast::*; use syntax::attr; use syntax::codemap::Span; -use syntax::print::pprust::{expr_to_str, ident_to_str}; +use syntax::print::pprust::{expr_to_string, ident_to_string}; use syntax::{visit}; use syntax::visit::Visitor; @@ -126,7 +126,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t cx.tcx.sess.span_err(self_type.span, format!("the type `{}', which does not fulfill `{}`, cannot implement this \ trait", - ty_to_str(cx.tcx, self_ty), + ty_to_string(cx.tcx, self_ty), missing.user_string(cx.tcx)).as_slice()); cx.tcx.sess.span_note(self_type.span, format!("types implementing this trait must fulfill `{}`", @@ -246,7 +246,7 @@ fn check_fn( } pub fn check_expr(cx: &mut Context, e: &Expr) { - debug!("kind::check_expr({})", expr_to_str(e)); + debug!("kind::check_expr({})", expr_to_string(e)); // Handle any kind bounds on type parameters check_bounds_on_type_parameters(cx, e); @@ -492,7 +492,7 @@ pub fn check_typaram_bounds(cx: &Context, sp, format!("instantiating a type parameter with an incompatible type \ `{}`, which does not fulfill `{}`", - ty_to_str(cx.tcx, ty), + ty_to_string(cx.tcx, ty), missing.user_string(cx.tcx)).as_slice()); }); } @@ -509,14 +509,14 @@ pub fn check_freevar_bounds(cx: &Context, sp: Span, ty: ty::t, format!("cannot implicitly borrow variable of type `{}` in a \ bounded stack closure (implicit reference does not \ fulfill `{}`)", - ty_to_str(cx.tcx, rty), + ty_to_string(cx.tcx, rty), missing.user_string(cx.tcx)).as_slice()) } None => { cx.tcx.sess.span_err(sp, format!("cannot capture variable of type `{}`, which does \ not fulfill `{}`, in a bounded closure", - ty_to_str(cx.tcx, ty), + ty_to_string(cx.tcx, ty), missing.user_string(cx.tcx)).as_slice()) } } @@ -533,20 +533,20 @@ pub fn check_trait_cast_bounds(cx: &Context, sp: Span, ty: ty::t, cx.tcx.sess.span_err(sp, format!("cannot pack type `{}`, which does not fulfill \ `{}`, as a trait bounded by {}", - ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx), + ty_to_string(cx.tcx, ty), missing.user_string(cx.tcx), bounds.user_string(cx.tcx)).as_slice()); }); } fn check_copy(cx: &Context, ty: ty::t, sp: Span, reason: &str) { debug!("type_contents({})={}", - ty_to_str(cx.tcx, ty), - ty::type_contents(cx.tcx, ty).to_str()); + ty_to_string(cx.tcx, ty), + ty::type_contents(cx.tcx, ty).to_string()); if ty::type_moves_by_default(cx.tcx, ty) { cx.tcx.sess.span_err( sp, format!("copying a value of non-copyable type `{}`", - ty_to_str(cx.tcx, ty)).as_slice()); + ty_to_string(cx.tcx, ty)).as_slice()); cx.tcx.sess.span_note(sp, format!("{}", reason).as_slice()); } } @@ -558,7 +558,7 @@ pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool { tcx.sess.span_err(sp, format!("value may contain references; \ add `'static` bound to `{}`", - ty_to_str(tcx, ty)).as_slice()); + ty_to_string(tcx, ty)).as_slice()); } _ => { tcx.sess.span_err(sp, "value may contain references"); @@ -643,7 +643,7 @@ pub fn check_cast_for_escaping_regions( // source_span, // format!("source contains reference with lifetime \ // not found in the target type `{}`", - // ty_to_str(cx.tcx, target_ty))); + // ty_to_string(cx.tcx, target_ty))); // note_and_explain_region( // cx.tcx, "source data is only valid for ", r, ""); // } @@ -683,7 +683,7 @@ fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: String, sp: Span) { format!("variable `{}` has dynamically sized type \ `{}`", name, - ty_to_str(tcx, ty)).as_slice()); + ty_to_string(tcx, ty)).as_slice()); } } @@ -691,7 +691,7 @@ fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: String, sp: Span) { fn check_pat(cx: &mut Context, pat: &Pat) { let var_name = match pat.node { PatWild => Some("_".to_string()), - PatIdent(_, ref path1, _) => Some(ident_to_str(&path1.node).to_string()), + PatIdent(_, ref path1, _) => Some(ident_to_string(&path1.node).to_string()), _ => None }; @@ -702,7 +702,7 @@ fn check_pat(cx: &mut Context, pat: &Pat) { match ty { Some(ty) => { debug!("kind: checking sized-ness of variable {}: {}", - name, ty_to_str(cx.tcx, *ty)); + name, ty_to_string(cx.tcx, *ty)); check_sized(cx.tcx, *ty, name, pat.span); } None => {} // extern fn args diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index a3306245762..79742d31734 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -121,7 +121,7 @@ use syntax::ast::*; use syntax::codemap::{BytePos, original_sp, Span}; use syntax::parse::token::special_idents; use syntax::parse::token; -use syntax::print::pprust::{expr_to_str, block_to_str}; +use syntax::print::pprust::{expr_to_string, block_to_string}; use syntax::{visit, ast_util}; use syntax::visit::{Visitor, FnKind}; @@ -152,17 +152,17 @@ enum LiveNodeKind { ExitNode } -fn live_node_kind_to_str(lnk: LiveNodeKind, cx: &ty::ctxt) -> String { +fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String { let cm = cx.sess.codemap(); match lnk { FreeVarNode(s) => { - format!("Free var node [{}]", cm.span_to_str(s)) + format!("Free var node [{}]", cm.span_to_string(s)) } ExprNode(s) => { - format!("Expr node [{}]", cm.span_to_str(s)) + format!("Expr node [{}]", cm.span_to_string(s)) } VarDefNode(s) => { - format!("Var def node [{}]", cm.span_to_str(s)) + format!("Var def node [{}]", cm.span_to_string(s)) } ExitNode => "Exit node".to_string(), } @@ -272,8 +272,8 @@ impl<'a> IrMaps<'a> { self.lnks.push(lnk); self.num_live_nodes += 1; - debug!("{} is of kind {}", ln.to_str(), - live_node_kind_to_str(lnk, self.tcx)); + debug!("{} is of kind {}", ln.to_string(), + live_node_kind_to_string(lnk, self.tcx)); ln } @@ -282,7 +282,7 @@ impl<'a> IrMaps<'a> { let ln = self.add_live_node(lnk); self.live_node_map.insert(node_id, ln); - debug!("{} is node {}", ln.to_str(), node_id); + debug!("{} is node {}", ln.to_string(), node_id); } fn add_variable(&mut self, vk: VarKind) -> Variable { @@ -297,7 +297,7 @@ impl<'a> IrMaps<'a> { ImplicitRet => {} } - debug!("{} is {:?}", v.to_str(), vk); + debug!("{} is {:?}", v.to_string(), vk); v } @@ -317,7 +317,7 @@ impl<'a> IrMaps<'a> { fn variable_name(&self, var: Variable) -> String { match self.var_kinds.get(var.get()) { &Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => { - token::get_ident(nm).get().to_str() + token::get_ident(nm).get().to_string() }, &ImplicitRet => "<implicit-ret>".to_string() } @@ -675,7 +675,7 @@ impl<'a> Liveness<'a> { for var_idx in range(0u, self.ir.num_vars) { let idx = node_base_idx + var_idx; if test(idx).is_valid() { - try!(write!(wr, " {}", Variable(var_idx).to_str())); + try!(write!(wr, " {}", Variable(var_idx).to_string())); } } Ok(()) @@ -717,7 +717,7 @@ impl<'a> Liveness<'a> { self.write_vars(wr, ln, |idx| self.users.get(idx).reader); write!(wr, " writes"); self.write_vars(wr, ln, |idx| self.users.get(idx).writer); - write!(wr, " precedes {}]", self.successors.get(ln.get()).to_str()); + write!(wr, " precedes {}]", self.successors.get(ln.get()).to_string()); } str::from_utf8(wr.unwrap().as_slice()).unwrap().to_string() } @@ -766,7 +766,7 @@ impl<'a> Liveness<'a> { }); debug!("merge_from_succ(ln={}, succ={}, first_merge={}, changed={})", - ln.to_str(), self.ln_str(succ_ln), first_merge, changed); + ln.to_string(), self.ln_str(succ_ln), first_merge, changed); return changed; fn copy_if_invalid(src: LiveNode, dst: &mut LiveNode) -> bool { @@ -787,14 +787,14 @@ impl<'a> Liveness<'a> { self.users.get_mut(idx).reader = invalid_node(); self.users.get_mut(idx).writer = invalid_node(); - debug!("{} defines {} (idx={}): {}", writer.to_str(), var.to_str(), + debug!("{} defines {} (idx={}): {}", writer.to_string(), var.to_string(), idx, self.ln_str(writer)); } // Either read, write, or both depending on the acc bitset fn acc(&mut self, ln: LiveNode, var: Variable, acc: uint) { debug!("{} accesses[{:x}] {}: {}", - ln.to_str(), acc, var.to_str(), self.ln_str(ln)); + ln.to_string(), acc, var.to_string(), self.ln_str(ln)); let idx = self.idx(ln, var); let user = self.users.get_mut(idx); @@ -822,7 +822,7 @@ impl<'a> Liveness<'a> { // effectively a return---this only occurs in `for` loops, // where the body is really a closure. - debug!("compute: using id for block, {}", block_to_str(body)); + debug!("compute: using id for block, {}", block_to_string(body)); let exit_ln = self.s.exit_ln; let entry_ln: LiveNode = @@ -837,7 +837,7 @@ impl<'a> Liveness<'a> { } body.id }, - entry_ln.to_str()); + entry_ln.to_string()); entry_ln } @@ -928,7 +928,7 @@ impl<'a> Liveness<'a> { fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { - debug!("propagate_through_expr: {}", expr_to_str(expr)); + debug!("propagate_through_expr: {}", expr_to_string(expr)); match expr.node { // Interesting cases with control flow or which gen/kill @@ -942,7 +942,7 @@ impl<'a> Liveness<'a> { } ExprFnBlock(_, ref blk) | ExprProc(_, ref blk) => { - debug!("{} is an ExprFnBlock or ExprProc", expr_to_str(expr)); + debug!("{} is an ExprFnBlock or ExprProc", expr_to_string(expr)); /* The next-node for a break is the successor of the entire @@ -1314,7 +1314,7 @@ impl<'a> Liveness<'a> { first_merge = false; } debug!("propagate_through_loop: using id for loop body {} {}", - expr.id, block_to_str(body)); + expr.id, block_to_string(body)); let cond_ln = self.propagate_through_opt_expr(cond, ln); let body_ln = self.with_loop_nodes(expr.id, succ, ln, |this| { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 96716ce09e0..33ab2ed3632 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -66,7 +66,7 @@ use middle::def; use middle::ty; use middle::typeck; use util::nodemap::NodeMap; -use util::ppaux::{ty_to_str, Repr}; +use util::ppaux::{ty_to_string, Repr}; use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; @@ -217,7 +217,7 @@ pub fn deref_kind(tcx: &ty::ctxt, t: ty::t) -> deref_kind { None => { tcx.sess.bug( format!("deref_cat() invoked on non-derefable type {}", - ty_to_str(tcx, t)).as_slice()); + ty_to_string(tcx, t)).as_slice()); } } } @@ -980,7 +980,7 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> { // get the type of the *subpattern* and use that. debug!("cat_pattern: id={} pat={} cmt={}", - pat.id, pprust::pat_to_str(pat), + pat.id, pprust::pat_to_string(pat), cmt.repr(self.tcx())); op(self, cmt.clone(), pat); @@ -1105,7 +1105,7 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> { Ok(()) } - pub fn cmt_to_str(&self, cmt: &cmt_) -> String { + pub fn cmt_to_string(&self, cmt: &cmt_) -> String { match cmt.cat { cat_static_item => { "static item".to_string() @@ -1151,10 +1151,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> { "captured outer variable".to_string() } cat_discr(ref cmt, _) => { - self.cmt_to_str(&**cmt) + self.cmt_to_string(&**cmt) } cat_downcast(ref cmt) => { - self.cmt_to_str(&**cmt) + self.cmt_to_string(&**cmt) } } } @@ -1311,7 +1311,7 @@ impl Repr for InteriorKind { fn repr(&self, _tcx: &ty::ctxt) -> String { match *self { InteriorField(NamedField(fld)) => { - token::get_name(fld).get().to_str() + token::get_name(fld).get().to_string() } InteriorField(PositionalField(i)) => format!("#{:?}", i), InteriorElement(_) => "[]".to_string(), diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 76e962a3bc4..7630321bd55 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -375,7 +375,7 @@ enum FieldName { impl<'a> PrivacyVisitor<'a> { // used when debugging fn nodestr(&self, id: ast::NodeId) -> String { - self.tcx.map.node_to_str(id).to_string() + self.tcx.map.node_to_string(id).to_string() } // Determines whether the given definition is public from the point of view @@ -423,7 +423,7 @@ impl<'a> PrivacyVisitor<'a> { } debug!("privacy - local {} not public all the way down", - self.tcx.map.node_to_str(did.node)); + self.tcx.map.node_to_string(did.node)); // return quickly for things in the same module if self.parents.find(&did.node) == self.parents.find(&self.curitem) { debug!("privacy - same parent, we're done here"); diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 682dcb2b709..26bb0b62cb0 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -336,7 +336,7 @@ impl<'a> ReachableContext<'a> { .bug(format!("found unexpected thingy in worklist: {}", self.tcx .map - .node_to_str(search_item)).as_slice()) + .node_to_string(search_item)).as_slice()) } } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 3b59736e292..df4d3b7efe4 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -821,7 +821,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor, body.id={}, \ cx.parent={})", id, - visitor.sess.codemap().span_to_str(sp), + visitor.sess.codemap().span_to_string(sp), body.id, cx.parent); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index c2f4d2ff6b1..612b29afd3e 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -790,7 +790,7 @@ impl PrimitiveTypeTable { } -fn namespace_error_to_str(ns: NamespaceError) -> &'static str { +fn namespace_error_to_string(ns: NamespaceError) -> &'static str { match ns { NoError => "", ModuleError | TypeError => "type or module", @@ -1071,14 +1071,14 @@ impl<'a> Resolver<'a> { let ns = ns.unwrap(); self.resolve_error(sp, format!("duplicate definition of {} `{}`", - namespace_error_to_str(duplicate_type), + namespace_error_to_string(duplicate_type), token::get_ident(name)).as_slice()); { let r = child.span_for_namespace(ns); for sp in r.iter() { self.session.span_note(*sp, format!("first definition of {} `{}` here", - namespace_error_to_str(duplicate_type), + namespace_error_to_string(duplicate_type), token::get_ident(name)).as_slice()); } } @@ -1508,7 +1508,7 @@ impl<'a> Resolver<'a> { false, true)); debug!("(build reduced graph for item) found extern `{}`", - self.module_to_str(&*external_module)); + self.module_to_string(&*external_module)); parent.module().external_module_children.borrow_mut() .insert(name.name, external_module.clone()); self.build_reduced_graph_for_external_crate(external_module); @@ -1862,7 +1862,7 @@ impl<'a> Resolver<'a> { /// Builds the reduced graph rooted at the given external module. fn populate_external_module(&mut self, module: Rc<Module>) { debug!("(populating external module) attempting to populate {}", - self.module_to_str(&*module)); + self.module_to_string(&*module)); let def_id = match module.def_id.get() { None => { @@ -1930,7 +1930,7 @@ impl<'a> Resolver<'a> { SingleImport(target, _) => { debug!("(building import directive) building import \ directive: {}::{}", - self.idents_to_str(module_.imports.borrow().last().unwrap() + self.idents_to_string(module_.imports.borrow().last().unwrap() .module_path.as_slice()), token::get_ident(target)); @@ -2003,7 +2003,7 @@ impl<'a> Resolver<'a> { /// submodules. fn resolve_imports_for_module_subtree(&mut self, module_: Rc<Module>) { debug!("(resolving imports for module subtree) resolving {}", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); let orig_module = replace(&mut self.current_module, module_.clone()); self.resolve_imports_for_module(module_.clone()); self.current_module = orig_module; @@ -2030,7 +2030,7 @@ impl<'a> Resolver<'a> { if module.all_imports_resolved() { debug!("(resolving imports for module) all imports resolved for \ {}", - self.module_to_str(&*module)); + self.module_to_string(&*module)); return; } @@ -2047,7 +2047,7 @@ impl<'a> Resolver<'a> { None => (import_directive.span, String::new()) }; let msg = format!("unresolved import `{}`{}", - self.import_path_to_str( + self.import_path_to_string( import_directive.module_path .as_slice(), import_directive.subclass), @@ -2063,7 +2063,7 @@ impl<'a> Resolver<'a> { } } - fn idents_to_str(&self, idents: &[Ident]) -> String { + fn idents_to_string(&self, idents: &[Ident]) -> String { let mut first = true; let mut result = String::new(); for ident in idents.iter() { @@ -2077,15 +2077,15 @@ impl<'a> Resolver<'a> { result } - fn path_idents_to_str(&self, path: &Path) -> String { + fn path_idents_to_string(&self, path: &Path) -> String { let identifiers: Vec<ast::Ident> = path.segments .iter() .map(|seg| seg.identifier) .collect(); - self.idents_to_str(identifiers.as_slice()) + self.idents_to_string(identifiers.as_slice()) } - fn import_directive_subclass_to_str(&mut self, + fn import_directive_subclass_to_string(&mut self, subclass: ImportDirectiveSubclass) -> String { match subclass { @@ -2096,16 +2096,16 @@ impl<'a> Resolver<'a> { } } - fn import_path_to_str(&mut self, + fn import_path_to_string(&mut self, idents: &[Ident], subclass: ImportDirectiveSubclass) -> String { if idents.is_empty() { - self.import_directive_subclass_to_str(subclass) + self.import_directive_subclass_to_string(subclass) } else { (format!("{}::{}", - self.idents_to_str(idents), - self.import_directive_subclass_to_str( + self.idents_to_string(idents), + self.import_directive_subclass_to_string( subclass))).to_string() } } @@ -2124,8 +2124,8 @@ impl<'a> Resolver<'a> { debug!("(resolving import for module) resolving import `{}::...` in \ `{}`", - self.idents_to_str(module_path.as_slice()), - self.module_to_str(&*module_)); + self.idents_to_string(module_path.as_slice()), + self.module_to_string(&*module_)); // First, resolve the module path for the directive, if necessary. let container = if module_path.len() == 0 { @@ -2231,9 +2231,9 @@ impl<'a> Resolver<'a> { debug!("(resolving single import) resolving `{}` = `{}::{}` from \ `{}` id {}, last private {:?}", token::get_ident(target), - self.module_to_str(&*containing_module), + self.module_to_string(&*containing_module), token::get_ident(source), - self.module_to_str(module_), + self.module_to_string(module_), directive.id, lp); @@ -2420,7 +2420,7 @@ impl<'a> Resolver<'a> { if value_result.is_unbound() && type_result.is_unbound() { let msg = format!("There is no `{}` in `{}`", token::get_ident(source), - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); return Failed(Some((directive.span, msg))); } let value_used_public = value_used_reexport || value_used_public; @@ -2494,7 +2494,7 @@ impl<'a> Resolver<'a> { debug!("(resolving glob import) writing module resolution \ {:?} into `{}`", target_import_resolution.type_target.is_none(), - self.module_to_str(module_)); + self.module_to_string(module_)); if !target_import_resolution.is_public { debug!("(resolving glob import) nevermind, just kidding"); @@ -2590,9 +2590,9 @@ impl<'a> Resolver<'a> { debug!("(resolving glob import) writing resolution `{}` in `{}` \ to `{}`", - token::get_name(name).get().to_str(), - self.module_to_str(&*containing_module), - self.module_to_str(module_)); + token::get_name(name).get().to_string(), + self.module_to_string(&*containing_module), + self.module_to_string(module_)); // Merge the child item into the import resolution. if name_bindings.defined_in_public_namespace(ValueNS) { @@ -2652,7 +2652,7 @@ impl<'a> Resolver<'a> { false) { Failed(None) => { let segment_name = token::get_ident(name); - let module_name = self.module_to_str(&*search_module); + let module_name = self.module_to_string(&*search_module); let mut span = span; let msg = if "???" == module_name.as_slice() { span.hi = span.lo + Pos::from_uint(segment_name.get().len()); @@ -2660,10 +2660,10 @@ impl<'a> Resolver<'a> { match search_parent_externals(name.name, &self.current_module) { Some(module) => { - let path_str = self.idents_to_str(module_path); - let target_mod_str = self.module_to_str(&*module); + let path_str = self.idents_to_string(module_path); + let target_mod_str = self.module_to_string(&*module); let current_mod_str = - self.module_to_str(&*self.current_module); + self.module_to_string(&*self.current_module); let prefix = if target_mod_str == current_mod_str { "self::".to_string() @@ -2771,8 +2771,8 @@ impl<'a> Resolver<'a> { debug!("(resolving module path for import) processing `{}` rooted at \ `{}`", - self.idents_to_str(module_path), - self.module_to_str(&*module_)); + self.idents_to_string(module_path), + self.module_to_string(&*module_)); // Resolve the module prefix, if any. let module_prefix_result = self.resolve_module_prefix(module_.clone(), @@ -2783,7 +2783,7 @@ impl<'a> Resolver<'a> { let last_private; match module_prefix_result { Failed(None) => { - let mpath = self.idents_to_str(module_path); + let mpath = self.idents_to_string(module_path); let mpath = mpath.as_slice(); match mpath.rfind(':') { Some(idx) => { @@ -2865,7 +2865,7 @@ impl<'a> Resolver<'a> { namespace {:?} in `{}`", token::get_ident(name), namespace, - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); // The current module node is handled specially. First, check for // its immediate children. @@ -3098,7 +3098,7 @@ impl<'a> Resolver<'a> { break } debug!("(resolving module prefix) resolving `super` at {}", - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); match self.get_nearest_normal_module_parent(containing_module) { None => return Failed(None), Some(new_module) => { @@ -3109,7 +3109,7 @@ impl<'a> Resolver<'a> { } debug!("(resolving module prefix) finished resolving prefix at {}", - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); return Success(PrefixFound(containing_module, i)); } @@ -3129,7 +3129,7 @@ impl<'a> Resolver<'a> { -> ResolveResult<(Target, bool)> { debug!("(resolving name in module) resolving `{}` in `{}`", token::get_name(name).get(), - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); // First, check the direct children of the module. self.populate_module_if_necessary(&module_); @@ -3262,19 +3262,19 @@ impl<'a> Resolver<'a> { // OK. Continue. debug!("(recording exports for module subtree) recording \ exports for local module `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); } None => { // Record exports for the root module. debug!("(recording exports for module subtree) recording \ exports for root module `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); } Some(_) => { // Bail out. debug!("(recording exports for module subtree) not recording \ exports for `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); return; } } @@ -3390,7 +3390,7 @@ impl<'a> Resolver<'a> { None => { debug!("!!! (with scope) didn't find `{}` in `{}`", token::get_ident(name), - self.module_to_str(&*orig_module)); + self.module_to_string(&*orig_module)); } Some(name_bindings) => { match (*name_bindings).get_module_if_available() { @@ -3398,7 +3398,7 @@ impl<'a> Resolver<'a> { debug!("!!! (with scope) didn't find module \ for `{}` in `{}`", token::get_ident(name), - self.module_to_str(&*orig_module)); + self.module_to_string(&*orig_module)); } Some(module_) => { self.current_module = module_; @@ -3903,7 +3903,7 @@ impl<'a> Resolver<'a> { reference_type: TraitReferenceType) { match self.resolve_path(id, &trait_reference.path, TypeNS, true) { None => { - let path_str = self.path_idents_to_str(&trait_reference.path); + let path_str = self.path_idents_to_string(&trait_reference.path); let usage_str = match reference_type { TraitBoundingTypeParameter => "bound type parameter with", TraitImplementation => "implement", @@ -3922,7 +3922,7 @@ impl<'a> Resolver<'a> { (def, _) => { self.resolve_error(trait_reference.path.span, format!("`{}` is not a trait", - self.path_idents_to_str( + self.path_idents_to_string( &trait_reference.path))); // If it's a typedef, give a note @@ -3970,7 +3970,7 @@ impl<'a> Resolver<'a> { .identifier), def); debug!("(resolving struct) writing resolution for `{}` (id {})", - this.path_idents_to_str(path), + this.path_idents_to_string(path), path_id); this.record_def(path_id, (def, lp)); } @@ -4082,7 +4082,7 @@ impl<'a> Resolver<'a> { let method_name = method.ident.name; if self.method_map.borrow().find(&(method_name, did)).is_none() { - let path_str = self.path_idents_to_str(&trait_ref.path); + let path_str = self.path_idents_to_string(&trait_ref.path); self.resolve_error(method.span, format!("method `{}` is not a member of trait `{}`", token::get_name(method_name), @@ -4292,13 +4292,13 @@ impl<'a> Resolver<'a> { // Write the result into the def map. debug!("(resolving type) writing resolution for `{}` \ (id {})", - self.path_idents_to_str(path), + self.path_idents_to_string(path), path_id); self.record_def(path_id, def); } None => { let msg = format!("use of undeclared type name `{}`", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(ty.span, msg.as_slice()); } } @@ -4499,7 +4499,7 @@ impl<'a> Resolver<'a> { debug!("(resolving pattern) didn't find struct \ def: {:?}", result); let msg = format!("`{}` does not name a structure", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); } } @@ -4729,7 +4729,7 @@ impl<'a> Resolver<'a> { Some((span, msg)) => (span, msg), None => { let msg = format!("Use of undeclared module `{}`", - self.idents_to_str( + self.idents_to_string( module_path_idents.as_slice())); (path.span, msg) } @@ -4805,7 +4805,7 @@ impl<'a> Resolver<'a> { Some((span, msg)) => (span, msg), None => { let msg = format!("Use of undeclared module `::{}`", - self.idents_to_str( + self.idents_to_string( module_path_idents.as_slice())); (path.span, msg) } @@ -5010,7 +5010,7 @@ impl<'a> Resolver<'a> { match get_module(self, path.span, ident_path.as_slice()) { Some(module) => match module.children.borrow().find(&name) { Some(binding) => { - let p_str = self.path_idents_to_str(&path); + let p_str = self.path_idents_to_string(&path); match binding.def_for_namespace(ValueNS) { Some(DefStaticMethod(_, provenance, _)) => { match provenance { @@ -5032,7 +5032,7 @@ impl<'a> Resolver<'a> { let method_map = self.method_map.borrow(); match self.current_trait_ref { Some((did, ref trait_ref)) => { - let path_str = self.path_idents_to_str(&trait_ref.path); + let path_str = self.path_idents_to_string(&trait_ref.path); match method_map.find(&(name, did)) { Some(&SelfStatic) => return StaticTraitMethod(path_str), @@ -5105,7 +5105,7 @@ impl<'a> Resolver<'a> { Some(def) => { // Write the result into the def map. debug!("(resolving expr) resolved `{}`", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); // First-class methods are not supported yet; error // out here. @@ -5125,7 +5125,7 @@ impl<'a> Resolver<'a> { self.record_def(expr.id, def); } None => { - let wrong_name = self.path_idents_to_str(path); + let wrong_name = self.path_idents_to_string(path); // Be helpful if the name refers to a struct // (The pattern matching def_tys where the id is in self.structs // matches on regular structs while excluding tuple- and enum-like @@ -5221,7 +5221,7 @@ impl<'a> Resolver<'a> { debug!("(resolving expression) didn't find struct \ def: {:?}", result); let msg = format!("`{}` does not name a structure", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); } } @@ -5521,7 +5521,7 @@ impl<'a> Resolver<'a> { // /// A somewhat inefficient routine to obtain the name of a module. - fn module_to_str(&self, module: &Module) -> String { + fn module_to_string(&self, module: &Module) -> String { let mut idents = Vec::new(); fn collect_mod(idents: &mut Vec<ast::Ident>, module: &Module) { @@ -5542,14 +5542,14 @@ impl<'a> Resolver<'a> { if idents.len() == 0 { return "???".to_string(); } - self.idents_to_str(idents.move_iter().rev() + self.idents_to_string(idents.move_iter().rev() .collect::<Vec<ast::Ident>>() .as_slice()) } #[allow(dead_code)] // useful for debugging fn dump_module(&mut self, module_: Rc<Module>) { - debug!("Dump of module `{}`:", self.module_to_str(&*module_)); + debug!("Dump of module `{}`:", self.module_to_string(&*module_)); debug!("Children:"); self.populate_module_if_necessary(&module_); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 8ff5331cec2..1c85413a8d8 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -24,7 +24,7 @@ use syntax::codemap::Span; use syntax::owned_slice::OwnedSlice; use syntax::parse::token::special_idents; use syntax::parse::token; -use syntax::print::pprust::{lifetime_to_str}; +use syntax::print::pprust::{lifetime_to_string}; use syntax::visit; use syntax::visit::Visitor; use util::nodemap::NodeMap; @@ -372,7 +372,7 @@ impl<'a> LifetimeContext<'a> { } debug!("lifetime_ref={} id={} resolved to {:?}", - lifetime_to_str(lifetime_ref), + lifetime_to_string(lifetime_ref), lifetime_ref.id, def); self.named_region_map.insert(lifetime_ref.id, def); diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index 1bb5ffdccb5..d16e2bbf66b 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -51,7 +51,7 @@ use syntax::parse::token; use syntax::parse::token::{get_ident,keywords}; use syntax::visit; use syntax::visit::Visitor; -use syntax::print::pprust::{path_to_str,ty_to_str}; +use syntax::print::pprust::{path_to_string,ty_to_string}; use middle::save::span_utils::SpanUtils; use middle::save::recorder::Recorder; @@ -108,7 +108,7 @@ impl <'l> DxrVisitor<'l> { if spans.len() < path.segments.len() { error!("Mis-calculated spans for path '{}'. \ Found {} spans, expected {}. Found spans:", - path_to_str(path), spans.len(), path.segments.len()); + path_to_string(path), spans.len(), path.segments.len()); for s in spans.iter() { let loc = self.sess.codemap().lookup_char_pos(s.lo); error!(" '{}' in {}, line {}", @@ -126,7 +126,7 @@ impl <'l> DxrVisitor<'l> { let sub_path = ast::Path{span: *span, // span for the last segment global: path.global, segments: segs}; - let qualname = path_to_str(&sub_path); + let qualname = path_to_string(&sub_path); result.push((*span, qualname)); segs = sub_path.segments; } @@ -249,7 +249,7 @@ impl <'l> DxrVisitor<'l> { self.collecting = false; let span_utils = self.span; for &(id, ref p, _, _) in self.collected_paths.iter() { - let typ = ppaux::ty_to_str(&self.analysis.ty_cx, + let typ = ppaux::ty_to_string(&self.analysis.ty_cx, *self.analysis.ty_cx.node_types.borrow().get(&(id as uint))); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) @@ -257,7 +257,7 @@ impl <'l> DxrVisitor<'l> { span_utils.span_for_last_ident(p.span), id, qualname, - path_to_str(p).as_slice(), + path_to_string(p).as_slice(), typ.as_slice()); } self.collected_paths.clear(); @@ -280,7 +280,7 @@ impl <'l> DxrVisitor<'l> { match item.node { ast::ItemImpl(_, _, ty, _) => { let mut result = String::from_str("<"); - result.push_str(ty_to_str(&*ty).as_slice()); + result.push_str(ty_to_string(&*ty).as_slice()); match ty::trait_of_method(&self.analysis.ty_cx, ast_util::local_def(method.id)) { @@ -400,7 +400,7 @@ impl <'l> DxrVisitor<'l> { ast::NamedField(ident, _) => { let name = get_ident(ident); let qualname = format!("{}::{}", qualname, name); - let typ = ppaux::ty_to_str(&self.analysis.ty_cx, + let typ = ppaux::ty_to_string(&self.analysis.ty_cx, *self.analysis.ty_cx.node_types.borrow().get(&(field.node.id as uint))); match self.span.sub_span_before_token(field.span, token::COLON) { Some(sub_span) => self.fmt.field_str(field.span, @@ -452,7 +452,7 @@ impl <'l> DxrVisitor<'l> { decl: ast::P<ast::FnDecl>, ty_params: &ast::Generics, body: ast::P<ast::Block>) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Fn); self.fmt.fn_str(item.span, @@ -482,7 +482,7 @@ impl <'l> DxrVisitor<'l> { mt: ast::Mutability, expr: &ast::Expr) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); // If the variable is immutable, save the initialising expression. let value = match mt { @@ -497,7 +497,7 @@ impl <'l> DxrVisitor<'l> { get_ident(item.ident).get(), qualname.as_slice(), value.as_slice(), - ty_to_str(&*typ).as_slice(), + ty_to_string(&*typ).as_slice(), e.cur_scope); // walk type and init value @@ -510,7 +510,7 @@ impl <'l> DxrVisitor<'l> { e: DxrVisitorEnv, def: &ast::StructDef, ty_params: &ast::Generics) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); let ctor_id = match def.ctor_id { Some(node_id) => node_id, @@ -538,7 +538,7 @@ impl <'l> DxrVisitor<'l> { e: DxrVisitorEnv, enum_definition: &ast::EnumDef, ty_params: &ast::Generics) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); match self.span.sub_span_after_keyword(item.span, keywords::Enum) { Some(sub_span) => self.fmt.enum_str(item.span, Some(sub_span), @@ -639,7 +639,7 @@ impl <'l> DxrVisitor<'l> { generics: &ast::Generics, trait_refs: &Vec<ast::TraitRef>, methods: &Vec<ast::TraitMethod>) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait); self.fmt.trait_str(item.span, @@ -678,7 +678,7 @@ impl <'l> DxrVisitor<'l> { item: &ast::Item, // The module in question, represented as an item. e: DxrVisitorEnv, m: &ast::Mod) { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); let cm = self.sess.codemap(); let filename = cm.span_to_filename(m.inner); @@ -971,8 +971,8 @@ impl<'l> Visitor<DxrVisitorEnv> for DxrVisitor<'l> { self.process_trait(item, e, generics, trait_refs, methods), ast::ItemMod(ref m) => self.process_mod(item, e, m), ast::ItemTy(ty, ref ty_params) => { - let qualname = self.analysis.ty_cx.map.path_to_str(item.id); - let value = ty_to_str(&*ty); + let qualname = self.analysis.ty_cx.map.path_to_string(item.id); + let value = ty_to_string(&*ty); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); self.fmt.typedef_str(item.span, sub_span, @@ -1231,7 +1231,7 @@ impl<'l> Visitor<DxrVisitorEnv> for DxrVisitor<'l> { return } - let id = String::from_str("$").append(ex.id.to_str().as_slice()); + let id = String::from_str("$").append(ex.id.to_string().as_slice()); self.process_formals(&decl.inputs, id.as_slice(), e); // walk arg and return types @@ -1288,7 +1288,7 @@ impl<'l> Visitor<DxrVisitorEnv> for DxrVisitor<'l> { def::DefBinding(id, _) => self.fmt.variable_str(p.span, sub_span, id, - path_to_str(p).as_slice(), + path_to_string(p).as_slice(), value.as_slice(), ""), def::DefVariant(_,id,_) => self.fmt.ref_str(ref_kind, @@ -1331,7 +1331,7 @@ impl<'l> Visitor<DxrVisitorEnv> for DxrVisitor<'l> { for &(id, ref p, ref immut, _) in self.collected_paths.iter() { let value = if *immut { value.to_owned() } else { "<mutable>".to_owned() }; let types = self.analysis.ty_cx.node_types.borrow(); - let typ = ppaux::ty_to_str(&self.analysis.ty_cx, *types.get(&(id as uint))); + let typ = ppaux::ty_to_string(&self.analysis.ty_cx, *types.get(&(id as uint))); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); @@ -1339,7 +1339,7 @@ impl<'l> Visitor<DxrVisitorEnv> for DxrVisitor<'l> { self.fmt.variable_str(p.span, sub_span, id, - path_to_str(p).as_slice(), + path_to_string(p).as_slice(), value.as_slice(), typ.as_slice()); } diff --git a/src/librustc/middle/save/recorder.rs b/src/librustc/middle/save/recorder.rs index fd76d6d37d1..7869aec1683 100644 --- a/src/librustc/middle/save/recorder.rs +++ b/src/librustc/middle/save/recorder.rs @@ -252,7 +252,7 @@ impl<'a> FmtStrs<'a> { // the local case they can be overridden in one block and there is no nice way // to refer to such a scope in english, so we just hack it by appending the // variable def's node id - let qualname = String::from_str(name).append("$").append(id.to_str().as_slice()); + let qualname = String::from_str(name).append("$").append(id.to_string().as_slice()); self.check_and_record(Variable, span, sub_span, diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 11d09aa49cf..3cfd1aaee8f 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -214,7 +214,7 @@ use middle::trans::type_of; use middle::trans::debuginfo; use middle::ty; use util::common::indenter; -use util::ppaux::{Repr, vec_map_to_str}; +use util::ppaux::{Repr, vec_map_to_string}; use std; use std::collections::HashMap; @@ -409,7 +409,7 @@ fn expand_nested_bindings<'a, 'b>( bcx.to_str(), m.repr(bcx.tcx()), col, - bcx.val_to_str(val)); + bcx.val_to_string(val)); let _indenter = indenter(); m.iter().map(|br| { @@ -449,7 +449,7 @@ fn enter_match<'a, 'b>( bcx.to_str(), m.repr(bcx.tcx()), col, - bcx.val_to_str(val)); + bcx.val_to_string(val)); let _indenter = indenter(); m.iter().filter_map(|br| { @@ -485,7 +485,7 @@ fn enter_default<'a, 'b>( bcx.to_str(), m.repr(bcx.tcx()), col, - bcx.val_to_str(val)); + bcx.val_to_string(val)); let _indenter = indenter(); // Collect all of the matches that can match against anything. @@ -541,7 +541,7 @@ fn enter_opt<'a, 'b>( m.repr(bcx.tcx()), *opt, col, - bcx.val_to_str(val)); + bcx.val_to_string(val)); let _indenter = indenter(); let ctor = match opt { @@ -922,7 +922,7 @@ fn compare_values<'a>( let did = langcall(cx, None, format!("comparison of `{}`", - cx.ty_to_str(rhs_t)).as_slice(), + cx.ty_to_string(rhs_t)).as_slice(), StrEqFnLangItem); callee::trans_lang_call(cx, did, [lhs, rhs], None) } @@ -988,7 +988,7 @@ fn insert_lllocals<'a>(mut bcx: &'a Block<'a>, bindings_map: &BindingsMap, debug!("binding {:?} to {}", binding_info.id, - bcx.val_to_str(llval)); + bcx.val_to_string(llval)); bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum); if bcx.sess().opts.debuginfo == FullDebugInfo { @@ -1011,9 +1011,9 @@ fn compile_guard<'a, 'b>( -> &'b Block<'b> { debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals={})", bcx.to_str(), - bcx.expr_to_str(guard_expr), + bcx.expr_to_string(guard_expr), m.repr(bcx.tcx()), - vec_map_to_str(vals, |v| bcx.val_to_str(*v))); + vec_map_to_string(vals, |v| bcx.val_to_string(*v))); let _indenter = indenter(); let mut bcx = insert_lllocals(bcx, &data.bindings_map, None); @@ -1050,7 +1050,7 @@ fn compile_submatch<'a, 'b>( debug!("compile_submatch(bcx={}, m={}, vals={})", bcx.to_str(), m.repr(bcx.tcx()), - vec_map_to_str(vals, |v| bcx.val_to_str(*v))); + vec_map_to_string(vals, |v| bcx.val_to_string(*v))); let _indenter = indenter(); let _icx = push_ctxt("match::compile_submatch"); let mut bcx = bcx; @@ -1155,7 +1155,7 @@ fn compile_submatch_continue<'a, 'b>( debug!("options={:?}", opts); let mut kind = no_branch; let mut test_val = val; - debug!("test_val={}", bcx.val_to_str(test_val)); + debug!("test_val={}", bcx.val_to_string(test_val)); if opts.len() > 0u { match *opts.get(0) { var(_, ref repr, _) => { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 4c7db01657b..898cb036ea5 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -63,7 +63,7 @@ use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel}; use syntax::ast; use syntax::attr; use syntax::attr::IntType; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; type Hint = attr::ReprAttr; @@ -135,7 +135,7 @@ pub fn represent_node(bcx: &Block, node: ast::NodeId) -> Rc<Repr> { /// Decides how to represent a given type. pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> { - debug!("Representing: {}", ty_to_str(cx.tcx(), t)); + debug!("Representing: {}", ty_to_string(cx.tcx(), t)); match cx.adt_reprs.borrow().find(&t) { Some(repr) => return repr.clone(), None => {} diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 08cdde38c34..84b253306ff 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -71,7 +71,7 @@ use middle::trans::value::Value; use middle::ty; use middle::typeck; use util::common::indenter; -use util::ppaux::{Repr, ty_to_str}; +use util::ppaux::{Repr, ty_to_string}; use util::sha2::Sha256; use util::nodemap::NodeMap; @@ -301,7 +301,7 @@ fn require_alloc_fn(bcx: &Block, info_ty: ty::t, it: LangItem) -> ast::DefId { Ok(id) => id, Err(s) => { bcx.sess().fatal(format!("allocation of `{}` {}", - bcx.ty_to_str(info_ty), + bcx.ty_to_string(info_ty), s).as_slice()); } } @@ -706,7 +706,7 @@ pub fn iter_structural_ty<'r, let variant_cx = fcx.new_temp_block( format!("enum-iter-variant-{}", - variant.disr_val.to_str().as_slice()) + variant.disr_val.to_string().as_slice()) .as_slice()); match adt::trans_case(cx, &*repr, variant.disr_val) { _match::single_result(r) => { @@ -809,7 +809,7 @@ pub fn fail_if_zero_or_overflows<'a>( } _ => { cx.sess().bug(format!("fail-if-zero on unexpected type: {}", - ty_to_str(cx.tcx(), rhs_t)).as_slice()); + ty_to_string(cx.tcx(), rhs_t)).as_slice()); } }; let bcx = with_cond(cx, is_zero, |bcx| { @@ -903,7 +903,7 @@ pub fn invoke<'a>( debug!("invoke at ???"); } Some(id) => { - debug!("invoke at {}", bcx.tcx().map.node_to_str(id)); + debug!("invoke at {}", bcx.tcx().map.node_to_string(id)); } } @@ -1173,7 +1173,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext, if id == -1 { "".to_string() } else { - ccx.tcx.map.path_to_str(id).to_string() + ccx.tcx.map.path_to_string(id).to_string() }, id, param_substs.repr(ccx.tcx())); @@ -1474,7 +1474,7 @@ pub fn trans_fn(ccx: &CrateContext, param_substs: ¶m_substs, id: ast::NodeId, attrs: &[ast::Attribute]) { - let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_str(id).to_string()); + let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_string(id).to_string()); debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx())); let _icx = push_ctxt("trans_fn"); let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx(), id)); @@ -1527,7 +1527,7 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext, _ => ccx.sess().bug( format!("trans_enum_variant_or_tuple_like_struct: \ unexpected ctor return type {}", - ty_to_str(ccx.tcx(), ctor_ty)).as_slice()) + ty_to_string(ccx.tcx(), ctor_ty)).as_slice()) }; let arena = TypedArena::new(); @@ -2010,7 +2010,7 @@ fn exported_name(ccx: &CrateContext, id: ast::NodeId, _ => ccx.tcx.map.with_path(id, |mut path| { if attr::contains_name(attrs, "no_mangle") { // Don't mangle - path.last().unwrap().to_str() + path.last().unwrap().to_string() } else { match weak_lang_items::link_name(attrs) { Some(name) => name.get().to_string(), diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index e1c02f543bf..ce11cd24f7b 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -122,8 +122,8 @@ pub fn Invoke(cx: &Block, check_not_terminated(cx); terminate(cx, "Invoke"); debug!("Invoke({} with arguments ({}))", - cx.val_to_str(fn_), - args.iter().map(|a| cx.val_to_str(*a)).collect::<Vec<String>>().connect(", ")); + cx.val_to_string(fn_), + args.iter().map(|a| cx.val_to_string(*a)).collect::<Vec<String>>().connect(", ")); B(cx).invoke(fn_, args, then, catch, attributes) } diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index a9c1adac3d7..3a9e3e4cf9b 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -161,9 +161,9 @@ impl<'a> Builder<'a> { self.count_insn("invoke"); debug!("Invoke {} with args ({})", - self.ccx.tn.val_to_str(llfn), + self.ccx.tn.val_to_string(llfn), args.iter() - .map(|&v| self.ccx.tn.val_to_str(v)) + .map(|&v| self.ccx.tn.val_to_string(v)) .collect::<Vec<String>>() .connect(", ")); @@ -497,8 +497,8 @@ impl<'a> Builder<'a> { pub fn store(&self, val: ValueRef, ptr: ValueRef) { debug!("Store {} -> {}", - self.ccx.tn.val_to_str(val), - self.ccx.tn.val_to_str(ptr)); + self.ccx.tn.val_to_string(val), + self.ccx.tn.val_to_string(ptr)); assert!(self.llbuilder.is_not_null()); self.count_insn("store"); unsafe { @@ -508,8 +508,8 @@ impl<'a> Builder<'a> { pub fn volatile_store(&self, val: ValueRef, ptr: ValueRef) { debug!("Store {} -> {}", - self.ccx.tn.val_to_str(val), - self.ccx.tn.val_to_str(ptr)); + self.ccx.tn.val_to_string(val), + self.ccx.tn.val_to_string(ptr)); assert!(self.llbuilder.is_not_null()); self.count_insn("store.volatile"); unsafe { @@ -520,8 +520,8 @@ impl<'a> Builder<'a> { pub fn atomic_store(&self, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) { debug!("Store {} -> {}", - self.ccx.tn.val_to_str(val), - self.ccx.tn.val_to_str(ptr)); + self.ccx.tn.val_to_string(val), + self.ccx.tn.val_to_string(ptr)); self.count_insn("store.atomic"); unsafe { let ty = Type::from_ref(llvm::LLVMTypeOf(ptr)); @@ -760,7 +760,7 @@ impl<'a> Builder<'a> { if self.ccx.sess().asm_comments() { let s = format!("{} ({})", text, - self.ccx.sess().codemap().span_to_str(sp)); + self.ccx.sess().codemap().span_to_string(sp)); debug!("{}", s.as_slice()); self.add_comment(s.as_slice()); } @@ -794,11 +794,11 @@ impl<'a> Builder<'a> { else { lib::llvm::False }; let argtys = inputs.iter().map(|v| { - debug!("Asm Input Type: {:?}", self.ccx.tn.val_to_str(*v)); + debug!("Asm Input Type: {:?}", self.ccx.tn.val_to_string(*v)); val_ty(*v) }).collect::<Vec<_>>(); - debug!("Asm Output Type: {:?}", self.ccx.tn.type_to_str(output)); + debug!("Asm Output Type: {:?}", self.ccx.tn.type_to_string(output)); let fty = Type::func(argtys.as_slice(), &output); unsafe { let v = llvm::LLVMInlineAsm( @@ -812,9 +812,9 @@ impl<'a> Builder<'a> { self.count_insn("call"); debug!("Call {} with args ({})", - self.ccx.tn.val_to_str(llfn), + self.ccx.tn.val_to_string(llfn), args.iter() - .map(|&v| self.ccx.tn.val_to_str(v)) + .map(|&v| self.ccx.tn.val_to_string(v)) .collect::<Vec<String>>() .connect(", ")); diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index c5361045549..2e4a3d9fd7e 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -108,7 +108,7 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { expr.span, format!("type of callee is neither bare-fn nor closure: \ {}", - bcx.ty_to_str(datum.ty)).as_slice()); + bcx.ty_to_string(datum.ty)).as_slice()); } } } @@ -905,7 +905,7 @@ pub fn trans_arg_datum<'a>( let arg_datum_ty = arg_datum.ty; - debug!(" arg datum: {}", arg_datum.to_str(bcx.ccx())); + debug!(" arg datum: {}", arg_datum.to_string(bcx.ccx())); let mut val; if ty::type_is_bot(arg_datum_ty) { @@ -949,11 +949,11 @@ pub fn trans_arg_datum<'a>( // this could happen due to e.g. subtyping let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty); debug!("casting actual type ({}) to match formal ({})", - bcx.val_to_str(val), bcx.llty_str(llformal_arg_ty)); + bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty)); val = PointerCast(bcx, val, llformal_arg_ty); } } - debug!("--- trans_arg_datum passing {}", bcx.val_to_str(val)); + debug!("--- trans_arg_datum passing {}", bcx.val_to_string(val)); Result::new(bcx, val) } diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 0bcf94997cd..0485b100446 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -85,7 +85,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ debug!("push_ast_cleanup_scope({})", - self.ccx.tcx.map.node_to_str(id)); + self.ccx.tcx.map.node_to_string(id)); // FIXME(#2202) -- currently closure bodies have a parent // region, which messes up the assertion below, since there @@ -109,7 +109,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { id: ast::NodeId, exits: [&'a Block<'a>, ..EXIT_MAX]) { debug!("push_loop_cleanup_scope({})", - self.ccx.tcx.map.node_to_str(id)); + self.ccx.tcx.map.node_to_string(id)); assert_eq!(Some(id), self.top_ast_scope()); self.push_scope(CleanupScope::new(LoopScopeKind(id, exits))); @@ -133,7 +133,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ debug!("pop_and_trans_ast_cleanup_scope({})", - self.ccx.tcx.map.node_to_str(cleanup_scope)); + self.ccx.tcx.map.node_to_string(cleanup_scope)); assert!(self.top_scope(|s| s.kind.is_ast_with_id(cleanup_scope))); @@ -152,7 +152,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ debug!("pop_loop_cleanup_scope({})", - self.ccx.tcx.map.node_to_str(cleanup_scope)); + self.ccx.tcx.map.node_to_string(cleanup_scope)); assert!(self.top_scope(|s| s.kind.is_loop_with_id(cleanup_scope))); @@ -246,7 +246,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("schedule_drop_mem({:?}, val={}, ty={})", cleanup_scope, - self.ccx.tn.val_to_str(val), + self.ccx.tn.val_to_string(val), ty.repr(self.ccx.tcx())); self.schedule_clean(cleanup_scope, drop as Box<Cleanup>); @@ -272,7 +272,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("schedule_drop_and_zero_mem({:?}, val={}, ty={}, zero={})", cleanup_scope, - self.ccx.tn.val_to_str(val), + self.ccx.tn.val_to_string(val), ty.repr(self.ccx.tcx()), true); @@ -298,7 +298,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("schedule_drop_immediate({:?}, val={}, ty={})", cleanup_scope, - self.ccx.tn.val_to_str(val), + self.ccx.tn.val_to_string(val), ty.repr(self.ccx.tcx())); self.schedule_clean(cleanup_scope, drop as Box<Cleanup>); @@ -318,7 +318,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("schedule_free_value({:?}, val={}, heap={:?})", cleanup_scope, - self.ccx.tn.val_to_str(val), + self.ccx.tn.val_to_string(val), heap); self.schedule_clean(cleanup_scope, drop as Box<Cleanup>); @@ -358,7 +358,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.ccx.sess().bug( format!("no cleanup scope {} found", - self.ccx.tcx.map.node_to_str(cleanup_scope)).as_slice()); + self.ccx.tcx.map.node_to_string(cleanup_scope)).as_slice()); } fn schedule_clean_in_custom_scope(&self, diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index b2564936fa4..ef147eb22b5 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -27,7 +27,7 @@ use middle::trans::type_of::*; use middle::trans::type_::Type; use middle::ty; use util::ppaux::Repr; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; use arena::TypedArena; use syntax::ast; @@ -104,8 +104,8 @@ pub struct EnvValue { } impl EnvValue { - pub fn to_str(&self, ccx: &CrateContext) -> String { - format!("{}({})", self.action, self.datum.to_str(ccx)) + pub fn to_string(&self, ccx: &CrateContext) -> String { + format!("{}({})", self.action, self.datum.to_string(ccx)) } } @@ -124,7 +124,7 @@ pub fn mk_closure_tys(tcx: &ty::ctxt, } }).collect(); let cdata_ty = ty::mk_tup(tcx, bound_tys); - debug!("cdata_ty={}", ty_to_str(tcx, cdata_ty)); + debug!("cdata_ty={}", ty_to_string(tcx, cdata_ty)); return cdata_ty; } @@ -196,16 +196,16 @@ pub fn store_environment<'a>( let Result {bcx: bcx, val: llbox} = allocate_cbox(bcx, store, cdata_ty); let llbox = PointerCast(bcx, llbox, llboxptr_ty); - debug!("tuplify_box_ty = {}", ty_to_str(tcx, cbox_ty)); + debug!("tuplify_box_ty = {}", ty_to_string(tcx, cbox_ty)); // Copy expr values into boxed bindings. let mut bcx = bcx; for (i, bv) in bound_values.move_iter().enumerate() { - debug!("Copy {} into closure", bv.to_str(ccx)); + debug!("Copy {} into closure", bv.to_string(ccx)); if ccx.sess().asm_comments() { add_comment(bcx, format!("Copy {} into closure", - bv.to_str(ccx)).as_slice()); + bv.to_string(ccx)).as_slice()); } let bound_data = GEPi(bcx, llbox, [0u, abi::box_field_body, i]); diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index de5de64e346..23a391cb86d 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -196,13 +196,13 @@ impl param_substs { } } -fn param_substs_to_str(this: ¶m_substs, tcx: &ty::ctxt) -> String { +fn param_substs_to_string(this: ¶m_substs, tcx: &ty::ctxt) -> String { format!("param_substs({})", this.substs.repr(tcx)) } impl Repr for param_substs { fn repr(&self, tcx: &ty::ctxt) -> String { - param_substs_to_str(self, tcx) + param_substs_to_string(self, tcx) } } @@ -436,11 +436,11 @@ impl<'a> Block<'a> { token::get_ident(ident).get().to_string() } - pub fn node_id_to_str(&self, id: ast::NodeId) -> String { - self.tcx().map.node_to_str(id).to_string() + pub fn node_id_to_string(&self, id: ast::NodeId) -> String { + self.tcx().map.node_to_string(id).to_string() } - pub fn expr_to_str(&self, e: &ast::Expr) -> String { + pub fn expr_to_string(&self, e: &ast::Expr) -> String { e.repr(self.tcx()) } @@ -454,15 +454,15 @@ impl<'a> Block<'a> { } } - pub fn val_to_str(&self, val: ValueRef) -> String { - self.ccx().tn.val_to_str(val) + pub fn val_to_string(&self, val: ValueRef) -> String { + self.ccx().tn.val_to_string(val) } pub fn llty_str(&self, ty: Type) -> String { - self.ccx().tn.type_to_str(ty) + self.ccx().tn.type_to_string(ty) } - pub fn ty_to_str(&self, t: ty::t) -> String { + pub fn ty_to_string(&self, t: ty::t) -> String { t.repr(self.tcx()) } @@ -645,7 +645,7 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint]) let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint); debug!("const_get_elt(v={}, us={:?}, r={})", - cx.tn.val_to_str(v), us, cx.tn.val_to_str(r)); + cx.tn.val_to_string(v), us, cx.tn.val_to_string(r)); return r; } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 52a097ca6f0..c35767f99a8 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -31,7 +31,7 @@ use middle::trans::type_::Type; use middle::trans::type_of; use middle::trans::debuginfo; use middle::ty; -use util::ppaux::{Repr, ty_to_str}; +use util::ppaux::{Repr, ty_to_string}; use std::c_str::ToCStr; use std::gc::Gc; @@ -59,7 +59,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit) _ => cx.sess().span_bug(lit.span, format!("integer literal has type {} (expected int \ or uint)", - ty_to_str(cx.tcx(), lit_int_ty)).as_slice()) + ty_to_string(cx.tcx(), lit_int_ty)).as_slice()) } } ast::LitFloat(ref fs, t) => { @@ -155,14 +155,14 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool) } _ => { cx.sess().bug(format!("unexpected dereferenceable type {}", - ty_to_str(cx.tcx(), t)).as_slice()) + ty_to_string(cx.tcx(), t)).as_slice()) } }; (dv, mt.ty) } None => { cx.sess().bug(format!("can't dereference const of type {}", - ty_to_str(cx.tcx(), t)).as_slice()) + ty_to_string(cx.tcx(), t)).as_slice()) } } } @@ -285,7 +285,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef llvm::LLVMDumpValue(C_undef(llty)); } cx.sess().bug(format!("const {} of type {} has size {} instead of {}", - e.repr(cx.tcx()), ty_to_str(cx.tcx(), ety), + e.repr(cx.tcx()), ty_to_string(cx.tcx(), ety), csize, tsize).as_slice()); } (llconst, inlineable) diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index e9b1c56eb00..acc44d08d3c 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -126,8 +126,8 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, dest: expr::Dest) -> &'a Block<'a> { debug!("trans_if(bcx={}, if_id={}, cond={}, thn={:?}, dest={})", - bcx.to_str(), if_id, bcx.expr_to_str(cond), thn.id, - dest.to_str(bcx.ccx())); + bcx.to_str(), if_id, bcx.expr_to_string(cond), thn.id, + dest.to_string(bcx.ccx())); let _icx = push_ctxt("trans_if"); let mut bcx = bcx; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index b93469ad2fb..b65f5a5c7d6 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -23,7 +23,7 @@ use middle::trans::glue; use middle::trans::tvec; use middle::trans::type_of; use middle::ty; -use util::ppaux::{ty_to_str}; +use util::ppaux::{ty_to_string}; use syntax::ast; @@ -596,10 +596,10 @@ impl<K:KindOps> Datum<K> { } #[allow(dead_code)] // useful for debugging - pub fn to_str(&self, ccx: &CrateContext) -> String { + pub fn to_string(&self, ccx: &CrateContext) -> String { format!("Datum({}, {}, {:?})", - ccx.tn.val_to_str(self.val), - ty_to_str(ccx.tcx(), self.ty), + ccx.tn.val_to_string(self.val), + ty_to_string(ccx.tcx(), self.ty), self.kind) } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index f281d8e2448..9acd0487199 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -270,7 +270,7 @@ impl TypeMap { metadata: DIType) { if !self.type_to_metadata.insert(ty::type_id(type_), metadata) { cx.sess().bug(format!("Type metadata for ty::t '{}' is already in the TypeMap!", - ppaux::ty_to_str(cx.tcx(), type_)).as_slice()); + ppaux::ty_to_string(cx.tcx(), type_)).as_slice()); } } @@ -504,7 +504,7 @@ impl TypeMap { }, _ => { cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", - ppaux::ty_to_str(cx.tcx(), type_).as_slice(), + ppaux::ty_to_string(cx.tcx(), type_).as_slice(), ty::get(type_).sty).as_slice()) } }; @@ -808,7 +808,7 @@ pub fn create_global_var_metadata(cx: &CrateContext, let type_metadata = type_metadata(cx, variable_type, span); let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id)); - let var_name = token::get_ident(ident).get().to_str(); + let var_name = token::get_ident(ident).get().to_string(); let linkage_name = namespace_node.mangled_name_of_contained_item(var_name.as_slice()); let var_scope = namespace_node.scope; @@ -1056,7 +1056,7 @@ pub fn set_source_location(fcx: &FunctionContext, FunctionDebugContext(box ref function_debug_context) => { let cx = fcx.ccx; - debug!("set_source_location: {}", cx.sess().codemap().span_to_str(span)); + debug!("set_source_location: {}", cx.sess().codemap().span_to_string(span)); if function_debug_context.source_locations_enabled.get() { let loc = span_start(cx, span); @@ -1812,7 +1812,7 @@ impl RecursiveTypeDescription { type_map.find_metadata_for_type(unfinished_type).is_none() { cx.sess().bug(format!("Forward declaration of potentially recursive type \ '{}' was not found in TypeMap!", - ppaux::ty_to_str(cx.tcx(), unfinished_type)) + ppaux::ty_to_string(cx.tcx(), unfinished_type)) .as_slice()); } } @@ -2245,7 +2245,7 @@ fn describe_enum_variant(cx: &CrateContext, Some(ref names) => { names.iter() .map(|ident| { - token::get_ident(*ident).get().to_str().into_string() + token::get_ident(*ident).get().to_string().into_string() }).collect() } None => variant_info.args.iter().map(|_| "".to_string()).collect() @@ -2872,7 +2872,7 @@ fn trait_pointer_metadata(cx: &CrateContext, ty::ty_uniq(pointee_type) => pointee_type, ty::ty_rptr(_, ty::mt { ty, .. }) => ty, _ => { - let pp_type_name = ppaux::ty_to_str(cx.tcx(), trait_pointer_type); + let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_pointer_type); cx.sess().bug(format!("debuginfo: Unexpected trait-pointer type in \ trait_pointer_metadata(): {}", pp_type_name.as_slice()).as_slice()); @@ -2882,7 +2882,7 @@ fn trait_pointer_metadata(cx: &CrateContext, let def_id = match ty::get(trait_object_type).sty { ty::ty_trait(box ty::TyTrait { def_id, .. }) => def_id, _ => { - let pp_type_name = ppaux::ty_to_str(cx.tcx(), trait_object_type); + let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_object_type); cx.sess().bug(format!("debuginfo: Unexpected trait-object type in \ trait_pointer_metadata(): {}", pp_type_name.as_slice()).as_slice()); @@ -3064,7 +3064,7 @@ fn type_metadata(cx: &CrateContext, the debuginfo::TypeMap but it \ was not. (ty::t = {})", unique_type_id_str.as_slice(), - ppaux::ty_to_str(cx.tcx(), t)); + ppaux::ty_to_string(cx.tcx(), t)); cx.sess().span_bug(usage_site_span, error_message.as_slice()); } }; @@ -3079,7 +3079,7 @@ fn type_metadata(cx: &CrateContext, debuginfo::TypeMap. \ UniqueTypeId={}, ty::t={}", unique_type_id_str.as_slice(), - ppaux::ty_to_str(cx.tcx(), t)); + ppaux::ty_to_string(cx.tcx(), t)); cx.sess().span_bug(usage_site_span, error_message.as_slice()); } } @@ -3879,7 +3879,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, ty::ty_infer(_) | ty::ty_param(_) => { cx.sess().bug(format!("debuginfo: Trying to create type name for \ - unexpected type: {}", ppaux::ty_to_str(cx.tcx(), t)).as_slice()); + unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t)).as_slice()); } } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 85e85f8ab55..516c46564cd 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -75,7 +75,7 @@ use middle::trans::type_::Type; use syntax::ast; use syntax::codemap; -use syntax::print::pprust::{expr_to_str}; +use syntax::print::pprust::{expr_to_string}; use std::gc::Gc; @@ -91,9 +91,9 @@ pub enum Dest { } impl Dest { - pub fn to_str(&self, ccx: &CrateContext) -> String { + pub fn to_string(&self, ccx: &CrateContext) -> String { match *self { - SaveIn(v) => format!("SaveIn({})", ccx.tn.val_to_str(v)), + SaveIn(v) => format!("SaveIn({})", ccx.tn.val_to_string(v)), Ignore => "Ignore".to_string() } } @@ -148,7 +148,7 @@ pub fn trans<'a>(bcx: &'a Block<'a>, * the stack. */ - debug!("trans(expr={})", bcx.expr_to_str(expr)); + debug!("trans(expr={})", bcx.expr_to_string(expr)); let mut bcx = bcx; let fcx = bcx.fcx; @@ -178,7 +178,7 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, Some(adj) => { adj } }; debug!("unadjusted datum for expr {}: {}", - expr.id, datum.to_str(bcx.ccx())); + expr.id, datum.to_string(bcx.ccx())); match adjustment { AutoAddEnv(..) => { datum = unpack_datum!(bcx, add_env(bcx, expr, datum)); @@ -216,7 +216,7 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, datum = scratch.to_expr_datum(); } } - debug!("after adjustments, datum={}", datum.to_str(bcx.ccx())); + debug!("after adjustments, datum={}", datum.to_string(bcx.ccx())); return DatumBlock {bcx: bcx, datum: datum}; fn auto_slice<'a>( @@ -325,7 +325,7 @@ fn trans_unadjusted<'a>(bcx: &'a Block<'a>, let mut bcx = bcx; - debug!("trans_unadjusted(expr={})", bcx.expr_to_str(expr)); + debug!("trans_unadjusted(expr={})", bcx.expr_to_string(expr)); let _indenter = indenter(); debuginfo::set_source_location(bcx.fcx, expr.id, expr.span); @@ -545,8 +545,8 @@ fn trans_index<'a>(bcx: &'a Block<'a>, let (base, len) = base_datum.get_vec_base_and_len(bcx); - debug!("trans_index: base {}", bcx.val_to_str(base)); - debug!("trans_index: len {}", bcx.val_to_str(len)); + debug!("trans_index: base {}", bcx.val_to_string(base)); + debug!("trans_index: len {}", bcx.val_to_string(len)); let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, len); let expect = ccx.get_intrinsic(&("llvm.expect.i1")); @@ -780,7 +780,7 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>, let expr_ty = expr_ty(bcx, expr); let store = ty::ty_closure_store(expr_ty); debug!("translating block function {} with type {}", - expr_to_str(expr), expr_ty.repr(tcx)); + expr_to_string(expr), expr_ty.repr(tcx)); closure::trans_expr_fn(bcx, store, &**decl, &**body, expr.id, dest) } ast::ExprCall(ref f, ref args) => { @@ -893,7 +893,7 @@ fn trans_def_dps_unadjusted<'a>( _ => { bcx.tcx().sess.span_bug(ref_expr.span, format!( "Non-DPS def {:?} referened by {}", - def, bcx.node_id_to_str(ref_expr.id)).as_slice()); + def, bcx.node_id_to_string(ref_expr.id)).as_slice()); } } } @@ -974,7 +974,7 @@ pub fn trans_local_var<'a>(bcx: &'a Block<'a>, } }; debug!("take_local(nid={:?}, v={}, ty={})", - nid, bcx.val_to_str(datum.val), bcx.ty_to_str(datum.ty)); + nid, bcx.val_to_string(datum.val), bcx.ty_to_string(datum.ty)); datum } } @@ -1462,13 +1462,13 @@ fn trans_binary<'a>(bcx: &'a Block<'a>, debug!("trans_binary (expr {}): lhs_datum={}", expr.id, - lhs_datum.to_str(ccx)); + lhs_datum.to_string(ccx)); let lhs_ty = lhs_datum.ty; let lhs = lhs_datum.to_llscalarish(bcx); debug!("trans_binary (expr {}): rhs_datum={}", expr.id, - rhs_datum.to_str(ccx)); + rhs_datum.to_string(ccx)); let rhs_ty = rhs_datum.ty; let rhs = rhs_datum.to_llscalarish(bcx); trans_eager_binop(bcx, expr, binop_ty, op, @@ -1729,7 +1729,7 @@ fn trans_assign_op<'a>( let _icx = push_ctxt("trans_assign_op"); let mut bcx = bcx; - debug!("trans_assign_op(expr={})", bcx.expr_to_str(expr)); + debug!("trans_assign_op(expr={})", bcx.expr_to_string(expr)); // User-defined operator methods cannot be used with `+=` etc right now assert!(!bcx.tcx().method_map.borrow().contains_key(&MethodCall::expr(expr.id))); @@ -1799,7 +1799,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>, debug!("deref_once(expr={}, datum={}, method_call={})", expr.repr(bcx.tcx()), - datum.to_str(ccx), + datum.to_string(ccx), method_call); let mut bcx = bcx; @@ -1877,7 +1877,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>, }; debug!("deref_once(expr={}, method_call={}, result={})", - expr.id, method_call, r.datum.to_str(ccx)); + expr.id, method_call, r.datum.to_string(ccx)); return r; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 9d7261f8094..0b12cd3da82 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -266,8 +266,8 @@ pub fn trans_native_call<'a>( llfn={}, \ llretptr={})", callee_ty.repr(tcx), - ccx.tn.val_to_str(llfn), - ccx.tn.val_to_str(llretptr)); + ccx.tn.val_to_string(llfn), + ccx.tn.val_to_string(llretptr)); let (fn_abi, fn_sig) = match ty::get(callee_ty).sty { ty::ty_bare_fn(ref fn_ty) => (fn_ty.abi, fn_ty.sig.clone()), @@ -314,9 +314,9 @@ pub fn trans_native_call<'a>( debug!("argument {}, llarg_rust={}, rust_indirect={}, arg_ty={}", i, - ccx.tn.val_to_str(llarg_rust), + ccx.tn.val_to_string(llarg_rust), rust_indirect, - ccx.tn.type_to_str(arg_tys[i].ty)); + ccx.tn.type_to_string(arg_tys[i].ty)); // Ensure that we always have the Rust value indirectly, // because it makes bitcasting easier. @@ -330,7 +330,7 @@ pub fn trans_native_call<'a>( } debug!("llarg_rust={} (after indirection)", - ccx.tn.val_to_str(llarg_rust)); + ccx.tn.val_to_string(llarg_rust)); // Check whether we need to do any casting match arg_tys[i].cast { @@ -339,7 +339,7 @@ pub fn trans_native_call<'a>( } debug!("llarg_rust={} (after casting)", - ccx.tn.val_to_str(llarg_rust)); + ccx.tn.val_to_string(llarg_rust)); // Finally, load the value if needed for the foreign ABI let foreign_indirect = arg_tys[i].is_indirect(); @@ -355,7 +355,7 @@ pub fn trans_native_call<'a>( }; debug!("argument {}, llarg_foreign={}", - i, ccx.tn.val_to_str(llarg_foreign)); + i, ccx.tn.val_to_string(llarg_foreign)); // fill padding with undef value match arg_tys[i].pad { @@ -430,10 +430,10 @@ pub fn trans_native_call<'a>( None => fn_type.ret_ty.ty }; - debug!("llretptr={}", ccx.tn.val_to_str(llretptr)); - debug!("llforeign_retval={}", ccx.tn.val_to_str(llforeign_retval)); - debug!("llrust_ret_ty={}", ccx.tn.type_to_str(llrust_ret_ty)); - debug!("llforeign_ret_ty={}", ccx.tn.type_to_str(llforeign_ret_ty)); + debug!("llretptr={}", ccx.tn.val_to_string(llretptr)); + debug!("llforeign_retval={}", ccx.tn.val_to_string(llforeign_retval)); + debug!("llrust_ret_ty={}", ccx.tn.type_to_string(llrust_ret_ty)); + debug!("llforeign_ret_ty={}", ccx.tn.type_to_string(llforeign_ret_ty)); if llrust_ret_ty == llforeign_ret_ty { base::store_ty(bcx, llforeign_retval, llretptr, fn_sig.output) @@ -538,7 +538,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext, let llfn = base::register_fn_llvmty(ccx, sp, sym, node_id, cconv, llfn_ty); add_argument_attributes(&tys, llfn); debug!("register_rust_fn_with_foreign_abi(node_id={:?}, llfn_ty={}, llfn={})", - node_id, ccx.tn.type_to_str(llfn_ty), ccx.tn.val_to_str(llfn)); + node_id, ccx.tn.type_to_string(llfn_ty), ccx.tn.val_to_string(llfn)); llfn } @@ -583,13 +583,13 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, _ => { ccx.sess().bug(format!("build_rust_fn: extern fn {} has ty {}, \ expected a bare fn ty", - ccx.tcx.map.path_to_str(id), + ccx.tcx.map.path_to_string(id), t.repr(tcx)).as_slice()); } }; debug!("build_rust_fn: path={} id={} t={}", - ccx.tcx.map.path_to_str(id), + ccx.tcx.map.path_to_string(id), id, t.repr(tcx)); let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice()); @@ -610,8 +610,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, let t = ty::node_id_to_type(tcx, id); debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={})", - ccx.tn.val_to_str(llrustfn), - ccx.tn.val_to_str(llwrapfn), + ccx.tn.val_to_string(llrustfn), + ccx.tn.val_to_string(llwrapfn), t.repr(ccx.tcx())); // Avoid all the Rust generation stuff and just generate raw @@ -668,11 +668,11 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, match foreign_outptr { Some(llforeign_outptr) => { debug!("out pointer, foreign={}", - ccx.tn.val_to_str(llforeign_outptr)); + ccx.tn.val_to_string(llforeign_outptr)); let llrust_retptr = builder.bitcast(llforeign_outptr, llrust_ret_ty.ptr_to()); debug!("out pointer, foreign={} (casted)", - ccx.tn.val_to_str(llrust_retptr)); + ccx.tn.val_to_string(llrust_retptr)); llrust_args.push(llrust_retptr); return_alloca = None; } @@ -683,8 +683,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, allocad={}, \ llrust_ret_ty={}, \ return_ty={}", - ccx.tn.val_to_str(slot), - ccx.tn.type_to_str(llrust_ret_ty), + ccx.tn.val_to_string(slot), + ccx.tn.type_to_string(llrust_ret_ty), tys.fn_sig.output.repr(tcx)); llrust_args.push(slot); return_alloca = Some(slot); @@ -712,7 +712,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, let mut llforeign_arg = llvm::LLVMGetParam(llwrapfn, foreign_index); debug!("llforeign_arg {}{}: {}", "#", - i, ccx.tn.val_to_str(llforeign_arg)); + i, ccx.tn.val_to_string(llforeign_arg)); debug!("rust_indirect = {}, foreign_indirect = {}", rust_indirect, foreign_indirect); @@ -751,12 +751,12 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, }; debug!("llrust_arg {}{}: {}", "#", - i, ccx.tn.val_to_str(llrust_arg)); + i, ccx.tn.val_to_string(llrust_arg)); llrust_args.push(llrust_arg); } // Perform the call itself - debug!("calling llrustfn = {}, t = {}", ccx.tn.val_to_str(llrustfn), t.repr(ccx.tcx())); + debug!("calling llrustfn = {}, t = {}", ccx.tn.val_to_string(llrustfn), t.repr(ccx.tcx())); let attributes = base::get_fn_llvm_attributes(ccx, t); let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), attributes.as_slice()); @@ -876,9 +876,9 @@ fn foreign_types_for_fn_ty(ccx: &CrateContext, ret_def={}", ty.repr(ccx.tcx()), ccx.tn.types_to_str(llsig.llarg_tys.as_slice()), - ccx.tn.type_to_str(llsig.llret_ty), + ccx.tn.type_to_string(llsig.llret_ty), ccx.tn.types_to_str(fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>().as_slice()), - ccx.tn.type_to_str(fn_ty.ret_ty.ty), + ccx.tn.type_to_string(fn_ty.ret_ty.ty), ret_def); ForeignTypes { diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index d046778485c..4d9f004e3dc 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -167,11 +167,11 @@ pub fn lazily_emit_visit_glue(ccx: &CrateContext, ti: &tydesc_info) -> ValueRef match ti.visit_glue.get() { Some(visit_glue) => visit_glue, None => { - debug!("+++ lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_str(ccx.tcx(), ti.ty)); + debug!("+++ lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_string(ccx.tcx(), ti.ty)); let glue_fn = declare_generic_glue(ccx, ti.ty, llfnty, "visit"); ti.visit_glue.set(Some(glue_fn)); make_generic_glue(ccx, ti.ty, glue_fn, make_visit_glue, "visit"); - debug!("--- lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_str(ccx.tcx(), ti.ty)); + debug!("--- lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_string(ccx.tcx(), ti.ty)); glue_fn } } @@ -432,13 +432,13 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info { if ccx.sess().count_type_sizes() { println!("{}\t{}", llsize_of_real(ccx, llty), - ppaux::ty_to_str(ccx.tcx(), t)); + ppaux::ty_to_string(ccx.tcx(), t)); } let llsize = llsize_of(ccx, llty); let llalign = llalign_of(ccx, llty); let name = mangle_internal_name_by_type_and_seq(ccx, t, "tydesc"); - debug!("+++ declare_tydesc {} {}", ppaux::ty_to_str(ccx.tcx(), t), name); + debug!("+++ declare_tydesc {} {}", ppaux::ty_to_string(ccx.tcx(), t), name); let gvar = name.as_slice().with_c_str(|buf| { unsafe { llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type().to_ref(), buf) @@ -447,10 +447,10 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info { note_unique_llvm_symbol(ccx, name); let ty_name = token::intern_and_get_ident( - ppaux::ty_to_str(ccx.tcx(), t).as_slice()); + ppaux::ty_to_string(ccx.tcx(), t).as_slice()); let ty_name = C_str_slice(ccx, ty_name); - debug!("--- declare_tydesc {}", ppaux::ty_to_str(ccx.tcx(), t)); + debug!("--- declare_tydesc {}", ppaux::ty_to_string(ccx.tcx(), t)); tydesc_info { ty: t, tydesc: gvar, @@ -468,7 +468,7 @@ fn declare_generic_glue(ccx: &CrateContext, t: ty::t, llfnty: Type, ccx, t, format!("glue_{}", name).as_slice()); - debug!("{} is for type {}", fn_nm, ppaux::ty_to_str(ccx.tcx(), t)); + debug!("{} is for type {}", fn_nm, ppaux::ty_to_string(ccx.tcx(), t)); let llfn = decl_cdecl_fn(ccx, fn_nm.as_slice(), llfnty, ty::mk_nil()); note_unique_llvm_symbol(ccx, fn_nm); return llfn; diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 5022e0bf05b..28bdc6852e8 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -29,7 +29,7 @@ use middle::ty; use syntax::ast; use syntax::ast_map; use syntax::parse::token; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option<ValueRef> { let name = match token::get_ident(item.ident).get() { @@ -398,10 +398,10 @@ pub fn trans_intrinsic(ccx: &CrateContext, format!("transmute called on types with different sizes: \ {} ({} bit{}) to \ {} ({} bit{})", - ty_to_str(ccx.tcx(), in_type), + ty_to_string(ccx.tcx(), in_type), in_type_size, if in_type_size == 1 {""} else {"s"}, - ty_to_str(ccx.tcx(), out_type), + ty_to_string(ccx.tcx(), out_type), out_type_size, if out_type_size == 1 {""} else {"s"}).as_slice()); } @@ -587,14 +587,14 @@ pub fn check_intrinsics(ccx: &CrateContext) { .span_err(transmute_restriction.span, format!("transmute called on types with different sizes: \ {} ({} bit{}) to {} ({} bit{})", - ty_to_str(ccx.tcx(), transmute_restriction.from), + ty_to_string(ccx.tcx(), transmute_restriction.from), from_type_size as uint, if from_type_size == 1 { "" } else { "s" }, - ty_to_str(ccx.tcx(), transmute_restriction.to), + ty_to_string(ccx.tcx(), transmute_restriction.to), to_type_size as uint, if to_type_size == 1 { "" diff --git a/src/librustc/middle/trans/llrepr.rs b/src/librustc/middle/trans/llrepr.rs index 3cd1a59abef..f7884ca5643 100644 --- a/src/librustc/middle/trans/llrepr.rs +++ b/src/librustc/middle/trans/llrepr.rs @@ -25,13 +25,13 @@ impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] { impl LlvmRepr for Type { fn llrepr(&self, ccx: &CrateContext) -> String { - ccx.tn.type_to_str(*self) + ccx.tn.type_to_string(*self) } } impl LlvmRepr for ValueRef { fn llrepr(&self, ccx: &CrateContext) -> String { - ccx.tn.val_to_str(*self) + ccx.tn.val_to_string(*self) } } diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index ee581f75634..e50eb8f0be9 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -23,7 +23,7 @@ use middle::trans::meth; use middle::trans::type_::Type; use middle::trans::type_of::*; use middle::ty; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; use std::rc::Rc; use arena::TypedArena; @@ -98,7 +98,7 @@ impl<'a, 'b> Reflector<'a, 'b> { debug!("passing {} args:", args.len()); let mut bcx = self.bcx; for (i, a) in args.iter().enumerate() { - debug!("arg {}: {}", i, bcx.val_to_str(*a)); + debug!("arg {}: {}", i, bcx.val_to_string(*a)); } let result = unpack_result!(bcx, callee::trans_call_inner( self.bcx, None, mth_ty, @@ -129,7 +129,7 @@ impl<'a, 'b> Reflector<'a, 'b> { pub fn visit_ty(&mut self, t: ty::t) { let bcx = self.bcx; let tcx = bcx.tcx(); - debug!("reflect::visit_ty {}", ty_to_str(bcx.tcx(), t)); + debug!("reflect::visit_ty {}", ty_to_string(bcx.tcx(), t)); match ty::get(t).sty { ty::ty_bot => self.leaf("bot"), @@ -175,7 +175,7 @@ impl<'a, 'b> Reflector<'a, 'b> { ty::ty_trait(..) => { let extra = [ self.c_slice(token::intern_and_get_ident( - ty_to_str(tcx, t).as_slice())) + ty_to_string(tcx, t).as_slice())) ]; self.visit("trait", extra); } @@ -204,7 +204,7 @@ impl<'a, 'b> Reflector<'a, 'b> { ty::ty_trait(..) => { let extra = [ self.c_slice(token::intern_and_get_ident( - ty_to_str(tcx, t).as_slice())) + ty_to_string(tcx, t).as_slice())) ]; self.visit("trait", extra); } @@ -269,7 +269,7 @@ impl<'a, 'b> Reflector<'a, 'b> { let extra = (vec!( self.c_slice( - token::intern_and_get_ident(ty_to_str(tcx, + token::intern_and_get_ident(ty_to_string(tcx, t).as_slice())), self.c_bool(named_fields), self.c_uint(fields.len()) diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 19d7d6c6a00..a6e554039e7 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -29,7 +29,7 @@ use middle::trans::machine::{llsize_of, nonzero_llsize_of, llsize_of_alloc}; use middle::trans::type_::Type; use middle::trans::type_of; use middle::ty; -use util::ppaux::ty_to_str; +use util::ppaux::ty_to_string; use syntax::ast; use syntax::parse::token::InternedString; @@ -73,12 +73,12 @@ pub struct VecTypes { } impl VecTypes { - pub fn to_str(&self, ccx: &CrateContext) -> String { + pub fn to_string(&self, ccx: &CrateContext) -> String { format!("VecTypes {{unit_ty={}, llunit_ty={}, \ llunit_size={}, llunit_alloc_size={}}}", - ty_to_str(ccx.tcx(), self.unit_ty), - ccx.tn.type_to_str(self.llunit_ty), - ccx.tn.val_to_str(self.llunit_size), + ty_to_string(ccx.tcx(), self.unit_ty), + ccx.tn.type_to_string(self.llunit_ty), + ccx.tn.val_to_string(self.llunit_size), self.llunit_alloc_size) } } @@ -97,7 +97,7 @@ pub fn trans_fixed_vstore<'a>( // generate the content. debug!("trans_fixed_vstore(vstore_expr={}, dest={:?})", - bcx.expr_to_str(vstore_expr), dest.to_str(bcx.ccx())); + bcx.expr_to_string(vstore_expr), dest.to_string(bcx.ccx())); let vt = vec_types_from_expr(bcx, vstore_expr); @@ -129,7 +129,7 @@ pub fn trans_slice_vstore<'a>( let mut bcx = bcx; debug!("trans_slice_vstore(vstore_expr={}, dest={})", - bcx.expr_to_str(vstore_expr), dest.to_str(ccx)); + bcx.expr_to_string(vstore_expr), dest.to_string(ccx)); // Handle the &"..." case: match content_expr.node { @@ -150,7 +150,7 @@ pub fn trans_slice_vstore<'a>( // Handle the &[...] case: let vt = vec_types_from_expr(bcx, vstore_expr); let count = elements_required(bcx, content_expr); - debug!("vt={}, count={:?}", vt.to_str(ccx), count); + debug!("vt={}, count={:?}", vt.to_string(ccx), count); let llcount = C_uint(ccx, count); let llfixed; @@ -202,8 +202,8 @@ pub fn trans_lit_str<'a>( */ debug!("trans_lit_str(lit_expr={}, dest={})", - bcx.expr_to_str(lit_expr), - dest.to_str(bcx.ccx())); + bcx.expr_to_string(lit_expr), + dest.to_string(bcx.ccx())); match dest { Ignore => bcx, @@ -233,7 +233,7 @@ pub fn trans_uniq_vstore<'a>(bcx: &'a Block<'a>, * the array elements into them. */ - debug!("trans_uniq_vstore(vstore_expr={})", bcx.expr_to_str(vstore_expr)); + debug!("trans_uniq_vstore(vstore_expr={})", bcx.expr_to_string(vstore_expr)); let fcx = bcx.fcx; let ccx = fcx.ccx; @@ -297,7 +297,7 @@ pub fn trans_uniq_vstore<'a>(bcx: &'a Block<'a>, let dataptr = get_dataptr(bcx, val); debug!("alloc_uniq_vec() returned val={}, dataptr={}", - bcx.val_to_str(val), bcx.val_to_str(dataptr)); + bcx.val_to_string(val), bcx.val_to_string(dataptr)); let bcx = write_content(bcx, &vt, vstore_expr, content_expr, SaveIn(dataptr)); @@ -319,9 +319,9 @@ pub fn write_content<'a>( let mut bcx = bcx; debug!("write_content(vt={}, dest={}, vstore_expr={:?})", - vt.to_str(bcx.ccx()), - dest.to_str(bcx.ccx()), - bcx.expr_to_str(vstore_expr)); + vt.to_string(bcx.ccx()), + dest.to_string(bcx.ccx()), + bcx.expr_to_string(vstore_expr)); match content_expr.node { ast::ExprLit(lit) => { @@ -361,7 +361,7 @@ pub fn write_content<'a>( for (i, element) in elements.iter().enumerate() { let lleltptr = GEPi(bcx, lldest, [i]); debug!("writing index {:?} with lleltptr={:?}", - i, bcx.val_to_str(lleltptr)); + i, bcx.val_to_string(lleltptr)); bcx = expr::trans_into(bcx, &**element, SaveIn(lleltptr)); fcx.schedule_drop_mem( diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 028722071a6..50c81596edf 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -199,7 +199,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { t, t_norm.repr(cx.tcx()), t_norm, - cx.tn.type_to_str(llty)); + cx.tn.type_to_string(llty)); cx.lltypes.borrow_mut().insert(t, llty); return llty; } @@ -291,7 +291,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { debug!("--> mapped t={} {:?} to llty={}", t.repr(cx.tcx()), t, - cx.tn.type_to_str(llty)); + cx.tn.type_to_string(llty)); cx.lltypes.borrow_mut().insert(t, llty); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 282ccf1155d..f9eda70d16e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -32,8 +32,8 @@ use middle::typeck::MethodCall; use middle::ty_fold; use middle::ty_fold::{TypeFoldable,TypeFolder}; use middle; -use util::ppaux::{note_and_explain_region, bound_region_ptr_to_str}; -use util::ppaux::{trait_store_to_str, ty_to_str}; +use util::ppaux::{note_and_explain_region, bound_region_ptr_to_string}; +use util::ppaux::{trait_store_to_string, ty_to_string}; use util::ppaux::{Repr, UserString}; use util::common::{indenter}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet, FnvHashMap}; @@ -2243,8 +2243,8 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { fn type_requires(cx: &ctxt, seen: &mut Vec<DefId>, r_ty: t, ty: t) -> bool { debug!("type_requires({}, {})?", - ::util::ppaux::ty_to_str(cx, r_ty), - ::util::ppaux::ty_to_str(cx, ty)); + ::util::ppaux::ty_to_string(cx, r_ty), + ::util::ppaux::ty_to_string(cx, ty)); let r = { get(r_ty).sty == get(ty).sty || @@ -2252,8 +2252,8 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { }; debug!("type_requires({}, {})? {}", - ::util::ppaux::ty_to_str(cx, r_ty), - ::util::ppaux::ty_to_str(cx, ty), + ::util::ppaux::ty_to_string(cx, r_ty), + ::util::ppaux::ty_to_string(cx, ty), r); return r; } @@ -2261,8 +2261,8 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { fn subtypes_require(cx: &ctxt, seen: &mut Vec<DefId>, r_ty: t, ty: t) -> bool { debug!("subtypes_require({}, {})?", - ::util::ppaux::ty_to_str(cx, r_ty), - ::util::ppaux::ty_to_str(cx, ty)); + ::util::ppaux::ty_to_string(cx, r_ty), + ::util::ppaux::ty_to_string(cx, ty)); let r = match get(ty).sty { // fixed length vectors need special treatment compared to @@ -2337,8 +2337,8 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { }; debug!("subtypes_require({}, {})? {}", - ::util::ppaux::ty_to_str(cx, r_ty), - ::util::ppaux::ty_to_str(cx, ty), + ::util::ppaux::ty_to_string(cx, r_ty), + ::util::ppaux::ty_to_string(cx, ty), r); return r; @@ -2381,7 +2381,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability { fn type_structurally_recursive(cx: &ctxt, sp: Span, seen: &mut Vec<DefId>, ty: t) -> Representability { debug!("type_structurally_recursive: {}", - ::util::ppaux::ty_to_str(cx, ty)); + ::util::ppaux::ty_to_string(cx, ty)); // Compare current type to previously seen types match get(ty).sty { @@ -2441,7 +2441,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability { } debug!("is_type_representable: {}", - ::util::ppaux::ty_to_str(cx, ty)); + ::util::ppaux::ty_to_string(cx, ty)); // To avoid a stack overflow when checking an enum variant or struct that // contains a different, structurally recursive type, maintain a stack @@ -2595,7 +2595,7 @@ pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> { Some(t) => t.clone(), None => cx.sess.bug( format!("node_id_to_trait_ref: no trait ref for node `{}`", - cx.map.node_to_str(id)).as_slice()) + cx.map.node_to_string(id)).as_slice()) } } @@ -2608,7 +2608,7 @@ pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> t { Some(t) => t, None => cx.sess.bug( format!("node_id_to_type: no type for node `{}`", - cx.map.node_to_str(id)).as_slice()) + cx.map.node_to_string(id)).as_slice()) } } @@ -2842,7 +2842,7 @@ pub fn adjust_ty(cx: &ctxt, format!("the {}th autoderef failed: \ {}", i, - ty_to_str(cx, adjusted_ty)) + ty_to_string(cx, adjusted_ty)) .as_slice()); } } @@ -3220,11 +3220,11 @@ pub fn param_tys_in_type(ty: t) -> Vec<ParamTy> { rslt } -pub fn ty_sort_str(cx: &ctxt, t: t) -> String { +pub fn ty_sort_string(cx: &ctxt, t: t) -> String { match get(t).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) | ty_str => { - ::util::ppaux::ty_to_str(cx, t) + ::util::ppaux::ty_to_string(cx, t) } ty_enum(id, _) => format!("enum {}", item_path_str(cx, id)), @@ -3277,18 +3277,18 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String { terr_mismatch => "types differ".to_string(), terr_fn_style_mismatch(values) => { format!("expected {} fn but found {} fn", - values.expected.to_str(), - values.found.to_str()) + values.expected.to_string(), + values.found.to_string()) } terr_abi_mismatch(values) => { format!("expected {} fn but found {} fn", - values.expected.to_str(), - values.found.to_str()) + values.expected.to_string(), + values.found.to_string()) } terr_onceness_mismatch(values) => { format!("expected {} fn but found {} fn", - values.expected.to_str(), - values.found.to_str()) + values.expected.to_string(), + values.found.to_string()) } terr_sigil_mismatch(values) => { format!("expected {}, found {}", @@ -3344,22 +3344,22 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String { terr_regions_insufficiently_polymorphic(br, _) => { format!("expected bound lifetime parameter {}, \ but found concrete lifetime", - bound_region_ptr_to_str(cx, br)) + bound_region_ptr_to_string(cx, br)) } terr_regions_overly_polymorphic(br, _) => { format!("expected concrete lifetime, \ but found bound lifetime parameter {}", - bound_region_ptr_to_str(cx, br)) + bound_region_ptr_to_string(cx, br)) } terr_trait_stores_differ(_, ref values) => { format!("trait storage differs: expected `{}` but found `{}`", - trait_store_to_str(cx, (*values).expected), - trait_store_to_str(cx, (*values).found)) + trait_store_to_string(cx, (*values).expected), + trait_store_to_string(cx, (*values).found)) } terr_sorts(values) => { format!("expected {} but found {}", - ty_sort_str(cx, values.expected), - ty_sort_str(cx, values.found)) + ty_sort_string(cx, values.expected), + ty_sort_string(cx, values.found)) } terr_traits(values) => { format!("expected trait `{}` but found trait `{}`", @@ -3384,13 +3384,13 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String { } terr_int_mismatch(ref values) => { format!("expected `{}` but found `{}`", - values.expected.to_str(), - values.found.to_str()) + values.expected.to_string(), + values.found.to_string()) } terr_float_mismatch(ref values) => { format!("expected `{}` but found `{}`", - values.expected.to_str(), - values.found.to_str()) + values.expected.to_string(), + values.found.to_string()) } terr_variadic_mismatch(ref values) => { format!("expected {} fn but found {} function", @@ -3701,7 +3701,7 @@ pub fn substd_enum_variants(cx: &ctxt, } pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String { - with_path(cx, id, |path| ast_map::path_to_str(path)).to_string() + with_path(cx, id, |path| ast_map::path_to_string(path)).to_string() } pub enum DtorKind { @@ -3973,7 +3973,7 @@ fn each_super_struct(cx: &ctxt, mut did: ast::DefId, f: |ast::DefId|) { None => { cx.sess.bug( format!("ID not mapped to super-struct: {}", - cx.map.node_to_str(did.node)).as_slice()); + cx.map.node_to_string(did.node)).as_slice()); } } } @@ -3995,7 +3995,7 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> { _ => { cx.sess.bug( format!("ID not mapped to struct fields: {}", - cx.map.node_to_str(did.node)).as_slice()); + cx.map.node_to_string(did.node)).as_slice()); } } }); @@ -4621,7 +4621,7 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 { } impl Variance { - pub fn to_str(self) -> &'static str { + pub fn to_string(self) -> &'static str { match self { Covariant => "+", Contravariant => "-", diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 286cb536475..d565f144f36 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -66,7 +66,7 @@ use syntax::abi; use syntax::{ast, ast_util}; use syntax::codemap::Span; use syntax::owned_slice::OwnedSlice; -use syntax::print::pprust::{lifetime_to_str, path_to_str}; +use syntax::print::pprust::{lifetime_to_string, path_to_string}; pub trait AstConv { fn tcx<'a>(&'a self) -> &'a ty::ctxt; @@ -108,7 +108,7 @@ pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime) }; debug!("ast_region_to_region(lifetime={} id={}) yields {}", - lifetime_to_str(lifetime), + lifetime_to_string(lifetime), lifetime.id, r.repr(tcx)); r @@ -142,7 +142,7 @@ pub fn opt_ast_region_to_region<AC:AstConv,RS:RegionScope>( }; debug!("opt_ast_region_to_region(opt_lifetime={:?}) yields {}", - opt_lifetime.as_ref().map(|e| lifetime_to_str(e)), + opt_lifetime.as_ref().map(|e| lifetime_to_string(e)), r.repr(this.tcx())); r @@ -331,7 +331,7 @@ pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> { None => { tcx.sess.span_bug(ast_ty.span, format!("unbound path {}", - path_to_str(path)).as_slice()) + path_to_string(path)).as_slice()) } Some(&d) => d }; @@ -394,7 +394,7 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv, .sess .span_bug(ast_ty.span, format!("unbound path {}", - path_to_str(path)).as_slice()) + path_to_string(path)).as_slice()) } Some(&d) => d }; @@ -793,7 +793,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( tcx.sess .span_bug(ast_ty.span, format!("unbound path {}", - path_to_str(path)).as_slice()) + path_to_string(path)).as_slice()) } Some(&d) => d }; @@ -808,7 +808,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } match a_def { def::DefTrait(_) => { - let path_str = path_to_str(path); + let path_str = path_to_string(path); tcx.sess.span_err( ast_ty.span, format!("reference to trait `{name}` where a \ @@ -835,7 +835,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( def::DefMod(id) => { tcx.sess.span_fatal(ast_ty.span, format!("found module name used as a type: {}", - tcx.map.node_to_str(id.node)).as_slice()); + tcx.map.node_to_string(id.node)).as_slice()); } def::DefPrimTy(_) => { fail!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call"); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index a5e7db1d6fd..2232cc49657 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -399,11 +399,11 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, variant_id, substitutions, etc); } Some(&def::DefStruct(..)) | Some(&def::DefVariant(..)) => { - let name = pprust::path_to_str(path); + let name = pprust::path_to_string(path); tcx.sess.span_err(span, format!("mismatched types: expected `{}` but \ found `{}`", - fcx.infcx().ty_to_str(expected), + fcx.infcx().ty_to_string(expected), name).as_slice()); } _ => { @@ -525,9 +525,9 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { .span_err(path.span, format!("`{}` does not name the \ structure `{}`", - pprust::path_to_str(path), + pprust::path_to_string(path), fcx.infcx() - .ty_to_str(expected)).as_slice()) + .ty_to_string(expected)).as_slice()) } check_struct_pat(pcx, pat.id, pat.span, expected, path, @@ -747,7 +747,7 @@ fn check_pointer_pat(pcx: &pat_ctxt, tcx.sess.span_err( span, format!("type `{}` cannot be dereferenced", - fcx.infcx().ty_to_str(expected)).as_slice()); + fcx.infcx().ty_to_string(expected)).as_slice()); fcx.write_error(pat_id); } _ => { diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 6e44665fb3b..c1a000841a4 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -30,14 +30,14 @@ itself (note that inherent impls can only be defined in the same module as the type itself). Inherent candidates are not always derived from impls. If you have a -trait instance, such as a value of type `Box<ToStr>`, then the trait -methods (`to_str()`, in this case) are inherently associated with it. +trait instance, such as a value of type `Box<ToString>`, then the trait +methods (`to_string()`, in this case) are inherently associated with it. Another case is type parameters, in which case the methods of their bounds are inherent. Extension candidates are derived from imported traits. If I have the -trait `ToStr` imported, and I call `to_str()` on a value of type `T`, -then we will go off to find out whether there is an impl of `ToStr` +trait `ToString` imported, and I call `to_string()` on a value of type `T`, +then we will go off to find out whether there is an impl of `ToString` for `T`. These kinds of method calls are called "extension methods". They can be defined in any module, not only the one that defined `T`. Furthermore, you must import the trait to call such a method. @@ -376,7 +376,7 @@ impl<'a> LookupContext<'a> { autoderefs: uint) -> Option<Option<MethodCallee>> { debug!("search_step: self_ty={} autoderefs={}", - self.ty_to_str(self_ty), autoderefs); + self.ty_to_string(self_ty), autoderefs); match self.deref_args { check::DontDerefArgs => { @@ -508,7 +508,7 @@ impl<'a> LookupContext<'a> { did: DefId, substs: &subst::Substs) { debug!("push_inherent_candidates_from_object(did={}, substs={})", - self.did_to_str(did), + self.did_to_string(did), substs.repr(self.tcx())); let _indenter = indenter(); let tcx = self.tcx(); @@ -733,7 +733,7 @@ impl<'a> LookupContext<'a> { None => None, Some(method) => { debug!("(searching for autoderef'd method) writing \ - adjustment {:?} for {}", adjustment, self.ty_to_str( self_ty)); + adjustment {:?} for {}", adjustment, self.ty_to_string( self_ty)); match adjustment { Some((self_expr_id, adj)) => { self.fcx.write_adjustment(self_expr_id, adj); @@ -809,7 +809,7 @@ impl<'a> LookupContext<'a> { fn auto_slice_vec(&self, mt: ty::mt, autoderefs: uint) -> Option<MethodCallee> { let tcx = self.tcx(); - debug!("auto_slice_vec {}", ppaux::ty_to_str(tcx, mt.ty)); + debug!("auto_slice_vec {}", ppaux::ty_to_string(tcx, mt.ty)); // First try to borrow to a slice let entry = self.search_for_some_kind_of_autorefd_method( @@ -886,7 +886,7 @@ impl<'a> LookupContext<'a> { * `~[]` to `&[]`. */ - debug!("search_for_autosliced_method {}", ppaux::ty_to_str(self.tcx(), self_ty)); + debug!("search_for_autosliced_method {}", ppaux::ty_to_string(self.tcx(), self_ty)); let sty = ty::get(self_ty).sty.clone(); match sty { @@ -939,7 +939,7 @@ impl<'a> LookupContext<'a> { ty_infer(TyVar(_)) => { self.bug(format!("unexpected type: {}", - self.ty_to_str(self_ty)).as_slice()); + self.ty_to_string(self_ty)).as_slice()); } } } @@ -993,7 +993,7 @@ impl<'a> LookupContext<'a> { } fn search_for_method(&self, rcvr_ty: ty::t) -> Option<MethodCallee> { - debug!("search_for_method(rcvr_ty={})", self.ty_to_str(rcvr_ty)); + debug!("search_for_method(rcvr_ty={})", self.ty_to_string(rcvr_ty)); let _indenter = indenter(); // I am not sure that inherent methods should have higher @@ -1094,7 +1094,7 @@ impl<'a> LookupContext<'a> { let tcx = self.tcx(); debug!("confirm_candidate(rcvr_ty={}, candidate={})", - self.ty_to_str(rcvr_ty), + self.ty_to_string(rcvr_ty), candidate.repr(self.tcx())); self.enforce_object_limitations(candidate); @@ -1177,7 +1177,7 @@ impl<'a> LookupContext<'a> { fn_style: bare_fn_ty.fn_style, abi: bare_fn_ty.abi.clone(), }); - debug!("after replacing bound regions, fty={}", self.ty_to_str(fty)); + debug!("after replacing bound regions, fty={}", self.ty_to_string(fty)); // Before, we only checked whether self_ty could be a subtype // of rcvr_ty; now we actually make it so (this may cause @@ -1191,8 +1191,8 @@ impl<'a> LookupContext<'a> { Err(_) => { self.bug(format!( "{} was a subtype of {} but now is not?", - self.ty_to_str(rcvr_ty), - self.ty_to_str(transformed_self_ty)).as_slice()); + self.ty_to_string(rcvr_ty), + self.ty_to_string(transformed_self_ty)).as_slice()); } } @@ -1288,7 +1288,7 @@ impl<'a> LookupContext<'a> { // candidate method's `self_ty`. fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool { debug!("is_relevant(rcvr_ty={}, candidate={})", - self.ty_to_str(rcvr_ty), candidate.repr(self.tcx())); + self.ty_to_string(rcvr_ty), candidate.repr(self.tcx())); return match candidate.method_ty.explicit_self { SelfStatic => { @@ -1457,11 +1457,11 @@ impl<'a> LookupContext<'a> { self.fcx.tcx() } - fn ty_to_str(&self, t: ty::t) -> String { - self.fcx.infcx().ty_to_str(t) + fn ty_to_string(&self, t: ty::t) -> String { + self.fcx.infcx().ty_to_string(t) } - fn did_to_str(&self, did: DefId) -> String { + fn did_to_string(&self, did: DefId) -> String { ty::item_path_str(self.tcx(), did) } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 1d0c3074a4f..9f5fcb61f5f 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -397,8 +397,8 @@ impl<'a> Visitor<()> for GatherLocalsVisitor<'a> { }; self.assign(local.id, o_ty); debug!("Local variable {} is assigned type {}", - self.fcx.pat_to_str(&*local.pat), - self.fcx.infcx().ty_to_str( + self.fcx.pat_to_string(&*local.pat), + self.fcx.infcx().ty_to_string( self.fcx.inh.locals.borrow().get_copy(&local.id))); visit::walk_local(self, local, ()); } @@ -411,7 +411,7 @@ impl<'a> Visitor<()> for GatherLocalsVisitor<'a> { self.assign(p.id, None); debug!("Pattern binding {} is assigned to {}", token::get_ident(path1.node), - self.fcx.infcx().ty_to_str( + self.fcx.infcx().ty_to_string( self.fcx.inh.locals.borrow().get_copy(&p.id))); } _ => {} @@ -534,7 +534,7 @@ fn span_for_field(tcx: &ty::ctxt, field: &ty::field_ty, struct_id: ast::DefId) - let item = match tcx.map.find(struct_id.node) { Some(ast_map::NodeItem(item)) => item, None => fail!("node not in ast map: {}", struct_id.node), - _ => fail!("expected item, found {}", tcx.map.node_to_str(struct_id.node)) + _ => fail!("expected item, found {}", tcx.map.node_to_string(struct_id.node)) }; match item.node { @@ -803,7 +803,7 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt, format!( "method `{}` is not a member of trait `{}`", token::get_ident(impl_method_ty.ident), - pprust::path_to_str(&ast_trait_ref.path)).as_slice()); + pprust::path_to_string(&ast_trait_ref.path)).as_slice()); } } } @@ -870,7 +870,7 @@ fn compare_impl_method(tcx: &ty::ctxt, format!("method `{}` has a `{}` declaration in the impl, \ but not in the trait", token::get_ident(trait_m.ident), - pprust::explicit_self_to_str( + pprust::explicit_self_to_string( impl_m.explicit_self)).as_slice()); return; } @@ -880,7 +880,7 @@ fn compare_impl_method(tcx: &ty::ctxt, format!("method `{}` has a `{}` declaration in the trait, \ but not in the impl", token::get_ident(trait_m.ident), - pprust::explicit_self_to_str( + pprust::explicit_self_to_string( trait_m.explicit_self)).as_slice()); return; } @@ -1051,7 +1051,7 @@ fn compare_impl_method(tcx: &ty::ctxt, declaration", token::get_ident(trait_m.ident), i, - ppaux::trait_ref_to_str( + ppaux::trait_ref_to_string( tcx, &*impl_trait_bound)).as_slice()) } @@ -1101,8 +1101,8 @@ fn check_cast(fcx: &FnCtxt, let t_e = fcx.expr_ty(e); - debug!("t_1={}", fcx.infcx().ty_to_str(t_1)); - debug!("t_e={}", fcx.infcx().ty_to_str(t_e)); + debug!("t_1={}", fcx.infcx().ty_to_string(t_1)); + debug!("t_e={}", fcx.infcx().ty_to_string(t_e)); if ty::type_is_error(t_e) { fcx.write_error(id); @@ -1126,13 +1126,13 @@ fn check_cast(fcx: &FnCtxt, fcx.type_error_message(span, |actual| { format!("cast from nil: `{}` as `{}`", actual, - fcx.infcx().ty_to_str(t_1)) + fcx.infcx().ty_to_string(t_1)) }, t_e, None); } else if ty::type_is_nil(t_1) { fcx.type_error_message(span, |actual| { format!("cast to nil: `{}` as `{}`", actual, - fcx.infcx().ty_to_str(t_1)) + fcx.infcx().ty_to_string(t_1)) }, t_e, None); } @@ -1149,7 +1149,7 @@ fn check_cast(fcx: &FnCtxt, format!("illegal cast; cast through an \ integer first: `{}` as `{}`", actual, - fcx.infcx().ty_to_str(t_1)) + fcx.infcx().ty_to_string(t_1)) }, t_e, None); } // casts from C-like enums are allowed @@ -1217,7 +1217,7 @@ fn check_cast(fcx: &FnCtxt, fcx.type_error_message(span, |actual| { format!("non-scalar cast: `{}` as `{}`", actual, - fcx.infcx().ty_to_str(t_1)) + fcx.infcx().ty_to_string(t_1)) }, t_e, None); } @@ -1286,7 +1286,7 @@ impl<'a> FnCtxt<'a> { #[inline] pub fn write_ty(&self, node_id: ast::NodeId, ty: ty::t) { debug!("write_ty({}, {}) in fcx {}", - node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag()); + node_id, ppaux::ty_to_string(self.tcx(), ty), self.tag()); self.inh.node_types.borrow_mut().insert(node_id, ty); } @@ -1343,7 +1343,7 @@ impl<'a> FnCtxt<'a> { ast_ty_to_ty(self, self.infcx(), ast_t) } - pub fn pat_to_str(&self, pat: &ast::Pat) -> String { + pub fn pat_to_string(&self, pat: &ast::Pat) -> String { pat.repr(self.tcx()) } @@ -1363,7 +1363,7 @@ impl<'a> FnCtxt<'a> { None => { self.tcx().sess.bug( format!("no type for node {}: {} in fcx {}", - id, self.tcx().map.node_to_str(id), + id, self.tcx().map.node_to_string(id), self.tag()).as_slice()); } } @@ -1375,7 +1375,7 @@ impl<'a> FnCtxt<'a> { None => { self.tcx().sess.bug( format!("no method entry for node {}: {} in fcx {}", - id, self.tcx().map.node_to_str(id), + id, self.tcx().map.node_to_string(id), self.tag()).as_slice()); } } @@ -1842,7 +1842,7 @@ fn check_argument_types(fcx: &FnCtxt, }; debug!("check_argument_types: formal_tys={:?}", - formal_tys.iter().map(|t| fcx.infcx().ty_to_str(*t)).collect::<Vec<String>>()); + formal_tys.iter().map(|t| fcx.infcx().ty_to_string(*t)).collect::<Vec<String>>()); // Check the arguments. // We do this in a pretty awful way: first we typecheck any arguments @@ -2410,7 +2410,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, operation `{}` not \ supported for floating \ point SIMD vector `{}`", - ast_util::binop_to_str(op), + ast_util::binop_to_string(op), actual) }, lhs_t, @@ -2440,7 +2440,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, |actual| { format!("binary operation `{}` cannot be applied \ to type `{}`", - ast_util::binop_to_str(op), + ast_util::binop_to_string(op), actual) }, lhs_t, @@ -2457,7 +2457,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, operation `{}=` \ cannot be applied to \ type `{}`", - ast_util::binop_to_str(op), + ast_util::binop_to_string(op), actual) }, lhs_t, @@ -2506,7 +2506,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, trait_did, [lhs_expr, rhs], DontAutoderefReceiver, || { fcx.type_error_message(ex.span, |actual| { format!("binary operation `{}` cannot be applied to type `{}`", - ast_util::binop_to_str(op), + ast_util::binop_to_string(op), actual) }, lhs_resolved_t, None) }) @@ -2594,7 +2594,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, expected_sig); let fty_sig = fn_ty.sig.clone(); let fty = ty::mk_closure(tcx, fn_ty); - debug!("check_expr_fn fty={}", fcx.infcx().ty_to_str(fty)); + debug!("check_expr_fn fty={}", fcx.infcx().ty_to_string(fty)); fcx.write_ty(expr.id, fty); @@ -2628,7 +2628,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, autoderef(fcx, expr.span, expr_t, Some(base.id), lvalue_pref, |base_t, _| { match ty::get(base_t).sty { ty::ty_struct(base_id, ref substs) => { - debug!("struct named {}", ppaux::ty_to_str(tcx, base_t)); + debug!("struct named {}", ppaux::ty_to_string(tcx, base_t)); let fields = ty::lookup_struct_fields(tcx, base_id); lookup_field_ty(tcx, base_id, fields.as_slice(), field.node.name, &(*substs)) @@ -3386,7 +3386,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, tcx.sess .span_err(path.span, format!("`{}` does not name a structure", - pprust::path_to_str( + pprust::path_to_string( path)).as_slice()) } } @@ -3454,10 +3454,10 @@ fn check_expr_with_unifier(fcx: &FnCtxt, } debug!("type of expr({}) {} is...", expr.id, - syntax::print::pprust::expr_to_str(expr)); + syntax::print::pprust::expr_to_string(expr)); debug!("... {}, expected is {}", - ppaux::ty_to_str(tcx, fcx.expr_ty(expr)), - expected.repr(tcx)) + ppaux::ty_to_string(tcx, fcx.expr_ty(expr)), + expected.repr(tcx)); unifier(); } @@ -3792,7 +3792,7 @@ pub fn check_instantiable(tcx: &ty::ctxt, format!("this type cannot be instantiated without an \ instance of itself; consider using \ `Option<{}>`", - ppaux::ty_to_str(tcx, item_ty)).as_slice()); + ppaux::ty_to_string(tcx, item_ty)).as_slice()); false } else { true @@ -3853,7 +3853,7 @@ pub fn check_enum_variants_sized(ccx: &CrateCtxt, dynamically sized types may only \ appear as the final type in a \ variant", - ppaux::ty_to_str(ccx.tcx, + ppaux::ty_to_string(ccx.tcx, *t)).as_slice()); } } @@ -3918,7 +3918,7 @@ pub fn check_enum_variants(ccx: &CrateCtxt, match v.node.disr_expr { Some(e) => { - debug!("disr expr, checking {}", pprust::expr_to_str(&*e)); + debug!("disr expr, checking {}", pprust::expr_to_string(&*e)); let inh = blank_inherited_fields(ccx); let fcx = blank_fn_ctxt(ccx, &inh, rty, e.id); @@ -4522,7 +4522,7 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt, tps: &OwnedSlice<ast::TyParam>, ty: ty::t) { debug!("check_bounds_are_used(n_tps={}, ty={})", - tps.len(), ppaux::ty_to_str(ccx.tcx, ty)); + tps.len(), ppaux::ty_to_string(ccx.tcx, ty)); // make a vector of booleans initially false, set to true when used if tps.len() == 0u { return; } @@ -4840,7 +4840,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { fty, || { format!("intrinsic has wrong type: expected `{}`", - ppaux::ty_to_str(ccx.tcx, fty)) + ppaux::ty_to_string(ccx.tcx, fty)) }); } } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 07fb43d0d34..924934e4bcd 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -133,7 +133,7 @@ use middle::typeck::infer; use middle::typeck::MethodCall; use middle::pat_util; use util::nodemap::NodeMap; -use util::ppaux::{ty_to_str, region_to_str, Repr}; +use util::ppaux::{ty_to_string, region_to_string, Repr}; use syntax::ast; use syntax::codemap::Span; @@ -876,7 +876,7 @@ fn constrain_autoderefs(rcx: &mut Rcx, let r_deref_expr = ty::ReScope(deref_expr.id); for i in range(0u, derefs) { debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={:?}/{:?}", - rcx.fcx.infcx().ty_to_str(derefd_ty), + rcx.fcx.infcx().ty_to_string(derefd_ty), i, derefs); let method_call = MethodCall::autoderef(deref_expr.id, i); @@ -948,7 +948,7 @@ fn constrain_index(rcx: &mut Rcx, */ debug!("constrain_index(index_expr=?, indexed_ty={}", - rcx.fcx.infcx().ty_to_str(indexed_ty)); + rcx.fcx.infcx().ty_to_string(indexed_ty)); let r_index_expr = ty::ReScope(index_expr.id); match ty::get(indexed_ty).sty { @@ -984,7 +984,7 @@ fn constrain_regions_in_type_of_node( |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ ty={}, ty0={}, id={}, minimum_lifetime={:?})", - ty_to_str(tcx, ty), ty_to_str(tcx, ty0), + ty_to_string(tcx, ty), ty_to_string(tcx, ty0), id, minimum_lifetime); constrain_regions_in_type(rcx, minimum_lifetime, origin, ty); } @@ -1011,8 +1011,8 @@ fn constrain_regions_in_type( let tcx = rcx.fcx.ccx.tcx; debug!("constrain_regions_in_type(minimum_lifetime={}, ty={})", - region_to_str(tcx, "", false, minimum_lifetime), - ty_to_str(tcx, ty)); + region_to_string(tcx, "", false, minimum_lifetime), + ty_to_string(tcx, ty)); relate_nested_regions(tcx, Some(minimum_lifetime), ty, |r_sub, r_sup| { debug!("relate_nested_regions(r_sub={}, r_sup={})", @@ -1190,7 +1190,7 @@ fn link_region_from_node_type(rcx: &Rcx, let rptr_ty = rcx.resolve_node_type(id); if !ty::type_is_bot(rptr_ty) && !ty::type_is_error(rptr_ty) { let tcx = rcx.fcx.ccx.tcx; - debug!("rptr_ty={}", ty_to_str(tcx, rptr_ty)); + debug!("rptr_ty={}", ty_to_string(tcx, rptr_ty)); let r = ty::ty_region(tcx, span, rptr_ty); link_region(rcx, span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index 146b42a00ff..53e26f8696f 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -30,7 +30,7 @@ pub fn replace_late_bound_regions_in_fn_sig( let mut map = HashMap::new(); let fn_sig = { let mut f = ty_fold::RegionFolder::regions(tcx, |r| { - debug!("region r={}", r.to_str()); + debug!("region r={}", r.to_string()); match r { ty::ReLateBound(s, br) if s == fn_sig.binder_id => { *map.find_or_insert_with(br, |_| mapf(br)) @@ -153,7 +153,7 @@ pub fn relate_free_regions(tcx: &ty::ctxt, fn_sig: &ty::FnSig) { } for &t in all_tys.iter() { - debug!("relate_free_regions(t={})", ppaux::ty_to_str(tcx, t)); + debug!("relate_free_regions(t={})", ppaux::ty_to_string(tcx, t)); relate_nested_regions(tcx, None, t, |a, b| { match (&a, &b) { (&ty::ReFree(free_a), &ty::ReFree(free_b)) => { diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index bda47d99ed7..d2a1ef786bd 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -16,7 +16,7 @@ use middle::typeck::astconv::AstConv; use middle::typeck::check::{FnCtxt, impl_self_ty}; use middle::typeck::check::{structurally_resolved_type}; use middle::typeck::check::writeback; -use middle::typeck::infer::fixup_err_to_str; +use middle::typeck::infer::fixup_err_to_string; use middle::typeck::infer::{resolve_and_force_all_but_regions, resolve_type}; use middle::typeck::infer; use middle::typeck::{vtable_origin, vtable_res, vtable_param_res}; @@ -35,7 +35,7 @@ use std::collections::HashSet; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; -use syntax::print::pprust::expr_to_str; +use syntax::print::pprust::expr_to_string; use syntax::visit; use syntax::visit::Visitor; @@ -154,8 +154,8 @@ fn lookup_vtables_for_param(vcx: &VtableContext, vcx.tcx().sess.span_fatal(span, format!("failed to find an implementation of \ trait {} for {}", - vcx.infcx.trait_ref_to_str(&*trait_ref), - vcx.infcx.ty_to_str(ty)).as_slice()); + vcx.infcx.trait_ref_to_string(&*trait_ref), + vcx.infcx.ty_to_string(ty)).as_slice()); } } true @@ -205,8 +205,8 @@ fn relate_trait_refs(vcx: &VtableContext, let tcx = vcx.tcx(); tcx.sess.span_err(span, format!("expected {}, but found {} ({})", - ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref), - ppaux::trait_ref_to_str(tcx, &r_act_trait_ref), + ppaux::trait_ref_to_string(tcx, &r_exp_trait_ref), + ppaux::trait_ref_to_string(tcx, &r_act_trait_ref), ty::type_err_to_str(tcx, err)).as_slice()); } } @@ -385,8 +385,8 @@ fn search_for_vtable(vcx: &VtableContext, debug!("(checking vtable) num 2 relating trait \ ty {} to of_trait_ref {}", - vcx.infcx.trait_ref_to_str(&*trait_ref), - vcx.infcx.trait_ref_to_str(&*of_trait_ref)); + vcx.infcx.trait_ref_to_string(&*trait_ref), + vcx.infcx.trait_ref_to_string(&*of_trait_ref)); relate_trait_refs(vcx, span, of_trait_ref, trait_ref.clone()); @@ -488,7 +488,7 @@ fn fixup_ty(vcx: &VtableContext, tcx.sess.span_fatal(span, format!("cannot determine a type for this bounded type \ parameter: {}", - fixup_err_to_str(e)).as_slice()) + fixup_err_to_string(e)).as_slice()) } Err(_) => { None @@ -527,7 +527,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { } debug!("vtable: early_resolve_expr() ex with id {:?} (early: {}): {}", - ex.id, is_early, expr_to_str(ex)); + ex.id, is_early, expr_to_string(ex)); let _indent = indenter(); let cx = fcx.ccx; @@ -626,7 +626,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { ex.span, format!("can only cast an boxed pointer \ to a boxed object, not a {}", - ty::ty_sort_str(fcx.tcx(), src_ty)).as_slice()); + ty::ty_sort_string(fcx.tcx(), src_ty)).as_slice()); } _ => {} } @@ -639,7 +639,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { ex.span, format!("can only cast an &-pointer \ to an &-object, not a {}", - ty::ty_sort_str(fcx.tcx(), src_ty)).as_slice()); + ty::ty_sort_string(fcx.tcx(), src_ty)).as_slice()); } _ => {} } @@ -657,7 +657,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { let did = def.def_id(); let item_ty = ty::lookup_item_type(cx.tcx, did); debug!("early resolve expr: def {:?} {:?}, {:?}, {}", ex.id, did, def, - fcx.infcx().ty_to_str(item_ty.ty)); + fcx.infcx().ty_to_string(item_ty.ty)); debug!("early_resolve_expr: looking up vtables for type params {}", item_ty.generics.types.repr(fcx.tcx())); let vcx = fcx.vtable_context(); diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index eb43144571e..59b65fdbec7 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -31,7 +31,7 @@ use std::cell::Cell; use syntax::ast; use syntax::codemap::Span; -use syntax::print::pprust::pat_to_str; +use syntax::print::pprust::pat_to_string; use syntax::visit; use syntax::visit::Visitor; @@ -159,7 +159,7 @@ impl<'cx> Visitor<()> for WritebackCx<'cx> { self.visit_node_id(ResolvingPattern(p.span), p.id); debug!("Type for pattern binding {} (id {}) resolved to {}", - pat_to_str(p), + pat_to_string(p), p.id, ty::node_id_to_type(self.tcx(), p.id).repr(self.tcx())); @@ -403,7 +403,7 @@ impl<'cx> Resolver<'cx> { span, format!("cannot determine a type for \ this expression: {}", - infer::fixup_err_to_str(e)).as_slice()) + infer::fixup_err_to_string(e)).as_slice()) } ResolvingLocal(span) => { @@ -411,7 +411,7 @@ impl<'cx> Resolver<'cx> { span, format!("cannot determine a type for \ this local variable: {}", - infer::fixup_err_to_str(e)).as_slice()) + infer::fixup_err_to_string(e)).as_slice()) } ResolvingPattern(span) => { @@ -419,7 +419,7 @@ impl<'cx> Resolver<'cx> { span, format!("cannot determine a type for \ this pattern binding: {}", - infer::fixup_err_to_str(e)).as_slice()) + infer::fixup_err_to_string(e)).as_slice()) } ResolvingUpvar(upvar_id) => { @@ -430,8 +430,8 @@ impl<'cx> Resolver<'cx> { captured variable `{}`: {}", ty::local_var_name_str( self.tcx, - upvar_id.var_id).get().to_str(), - infer::fixup_err_to_str(e)).as_slice()); + upvar_id.var_id).get().to_string(), + infer::fixup_err_to_string(e)).as_slice()); } ResolvingImplRes(span) => { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 7b871cbe0fe..b6cdeb92aa3 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -63,7 +63,7 @@ use syntax::codemap; use syntax::owned_slice::OwnedSlice; use syntax::parse::token::special_idents; use syntax::parse::token; -use syntax::print::pprust::{path_to_str}; +use syntax::print::pprust::{path_to_string}; use syntax::visit; struct CollectItemTypesVisitor<'a> { @@ -665,7 +665,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, ccx.tcx.sess.span_fatal( ast_trait_ref.path.span, format!("`{}` is not a trait", - path_to_str(&ast_trait_ref.path)).as_slice()); + path_to_string(&ast_trait_ref.path)).as_slice()); } } } @@ -836,7 +836,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item) debug!("type of {} (id {}) is {}", token::get_ident(it.ident), it.id, - ppaux::ty_to_str(tcx, pty.ty)); + ppaux::ty_to_string(tcx, pty.ty)); ccx.tcx.tcache.borrow_mut().insert(local_def(it.id), pty.clone()); return pty; @@ -1169,7 +1169,7 @@ fn ty_generics(ccx: &CrateCtxt, format!("incompatible bounds on type parameter {}, \ bound {} does not allow unsized type", token::get_ident(ident), - ppaux::trait_ref_to_str(tcx, + ppaux::trait_ref_to_string(tcx, &*trait_ref)).as_slice()); } true diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 35661c14aeb..cdd51c4fa71 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -90,7 +90,7 @@ use syntax::codemap; use syntax::parse::token; use syntax::print::pprust; use util::ppaux::UserString; -use util::ppaux::bound_region_to_str; +use util::ppaux::bound_region_to_string; use util::ppaux::note_and_explain_region; pub trait ErrorReporting { @@ -442,7 +442,7 @@ impl<'a> ErrorReporting for InferCtxt<'a> { ty::local_var_name_str(self.tcx, upvar_id.var_id) .get() - .to_str()).as_slice()); + .to_string()).as_slice()); note_and_explain_region( self.tcx, "...the borrowed pointer is valid for ", @@ -454,7 +454,7 @@ impl<'a> ErrorReporting for InferCtxt<'a> { ty::local_var_name_str(self.tcx, upvar_id.var_id) .get() - .to_str()).as_slice(), + .to_string()).as_slice(), sup, ""); } @@ -500,7 +500,7 @@ impl<'a> ErrorReporting for InferCtxt<'a> { outlive the enclosing closure", ty::local_var_name_str(self.tcx, id).get() - .to_str()).as_slice()); + .to_string()).as_slice()); note_and_explain_region( self.tcx, "captured variable is valid for ", @@ -1046,7 +1046,7 @@ impl<'a> Rebuilder<'a> { .sess .fatal(format!( "unbound path {}", - pprust::path_to_str(path)).as_slice()) + pprust::path_to_string(path)).as_slice()) } Some(&d) => d }; @@ -1231,7 +1231,7 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> { opt_explicit_self: Option<ast::ExplicitSelf_>, generics: &ast::Generics, span: codemap::Span) { - let suggested_fn = pprust::fun_to_str(decl, fn_style, ident, + let suggested_fn = pprust::fun_to_string(decl, fn_style, ident, opt_explicit_self, generics); let msg = format!("consider using an explicit lifetime \ parameter as shown: {}", suggested_fn); @@ -1249,11 +1249,11 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> { infer::Coercion(_) => " for automatic coercion".to_string(), infer::LateBoundRegion(_, br) => { format!(" for {}in function call", - bound_region_to_str(self.tcx, "lifetime parameter ", true, br)) + bound_region_to_string(self.tcx, "lifetime parameter ", true, br)) } infer::BoundRegionInFnType(_, br) => { format!(" for {}in function type", - bound_region_to_str(self.tcx, "lifetime parameter ", true, br)) + bound_region_to_string(self.tcx, "lifetime parameter ", true, br)) } infer::EarlyBoundRegion(_, name) => { format!(" for lifetime parameter `{}", @@ -1265,7 +1265,7 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> { } infer::UpvarRegion(ref upvar_id, _) => { format!(" for capture of `{}` by closure", - ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_str()) + ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_string()) } }; @@ -1334,7 +1334,7 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> { "...so that closure can access `{}`", ty::local_var_name_str(self.tcx, upvar_id.var_id) .get() - .to_str()).as_slice()) + .to_string()).as_slice()) } infer::InfStackClosure(span) => { self.tcx.sess.span_note( @@ -1359,7 +1359,7 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> { does not outlive the enclosing closure", ty::local_var_name_str( self.tcx, - id).get().to_str()).as_slice()); + id).get().to_string()).as_slice()); } infer::IndexSlice(span) => { self.tcx.sess.span_note( @@ -1508,7 +1508,7 @@ impl LifeGiver { let mut lifetime; loop { let mut s = String::from_str("'"); - s.push_str(num_to_str(self.counter.get()).as_slice()); + s.push_str(num_to_string(self.counter.get()).as_slice()); if !self.taken.contains(&s) { lifetime = name_to_dummy_lifetime( token::str_to_ident(s.as_slice()).name); @@ -1521,7 +1521,7 @@ impl LifeGiver { return lifetime; // 0 .. 25 generates a .. z, 26 .. 51 generates aa .. zz, and so on - fn num_to_str(counter: uint) -> String { + fn num_to_string(counter: uint) -> String { let mut s = String::new(); let (n, r) = (counter/26 + 1, counter % 26); let letter: char = from_u32((r+97) as u32).unwrap(); diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index d2c27330a94..b6628c22ae6 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -26,7 +26,7 @@ use syntax::ast::{NormalFn, UnsafeFn, NodeId}; use syntax::ast::{Onceness, FnStyle}; use std::collections::HashMap; use util::common::{indenter}; -use util::ppaux::mt_to_str; +use util::ppaux::mt_to_string; use util::ppaux::Repr; pub struct Glb<'f>(pub CombineFields<'f>); // "greatest lower bound" (common subtype) @@ -50,8 +50,8 @@ impl<'f> Combine for Glb<'f> { debug!("{}.mts({}, {})", self.tag(), - mt_to_str(tcx, a), - mt_to_str(tcx, b)); + mt_to_string(tcx, a), + mt_to_string(tcx, b)); match (a.mutbl, b.mutbl) { // If one side or both is mut, then the GLB must use diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 1b3d96e474e..708eb498f84 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -39,7 +39,7 @@ use middle::typeck::infer::*; use middle::typeck::infer::combine::*; use middle::typeck::infer::glb::Glb; use middle::typeck::infer::lub::Lub; -use middle::typeck::infer::unify::{Root, UnifyKey}; +use middle::typeck::infer::unify::*; use middle::typeck::infer::sub::Sub; use util::ppaux::Repr; @@ -436,8 +436,7 @@ pub enum LatticeVarResult<K,T> { * - If the variables do not both have an upper bound, we will unify * the variables and return the unified variable, in which case the * result is a variable. This is indicated with a `VarResult` - * return. - */ + * return. */ pub fn lattice_vars<L:LatticeDir+Combine, T:LatticeValue, K:UnifyKey<Bounds<T>>>( diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 7ccffdfeb06..6a50038afe7 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -25,7 +25,7 @@ use syntax::ast::{Many, Once, NodeId}; use syntax::ast::{NormalFn, UnsafeFn}; use syntax::ast::{Onceness, FnStyle}; use syntax::ast::{MutMutable, MutImmutable}; -use util::ppaux::mt_to_str; +use util::ppaux::mt_to_string; use util::ppaux::Repr; pub struct Lub<'f>(pub CombineFields<'f>); // least-upper-bound: common supertype @@ -49,8 +49,8 @@ impl<'f> Combine for Lub<'f> { debug!("{}.mts({}, {})", self.tag(), - mt_to_str(tcx, a), - mt_to_str(tcx, b)); + mt_to_string(tcx, a), + mt_to_string(tcx, b)); if a.mutbl != b.mutbl { return Err(ty::terr_mutability) diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index b505536a59d..16e758df9db 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -44,7 +44,7 @@ use syntax::ast; use syntax::codemap; use syntax::codemap::Span; use util::common::indent; -use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str, Repr}; +use util::ppaux::{bound_region_to_string, ty_to_string, trait_ref_to_string, Repr}; pub mod doc; pub mod macros; @@ -245,7 +245,7 @@ pub enum fixup_err { region_var_bound_by_region_var(RegionVid, RegionVid) } -pub fn fixup_err_to_str(f: fixup_err) -> String { +pub fn fixup_err_to_string(f: fixup_err) -> String { match f { unresolved_int_ty(_) => { "cannot determine the type of this integer; add a suffix to \ @@ -662,19 +662,19 @@ impl<'a> InferCtxt<'a> { self.report_region_errors(&errors); // see error_reporting.rs } - pub fn ty_to_str(&self, t: ty::t) -> String { - ty_to_str(self.tcx, + pub fn ty_to_string(&self, t: ty::t) -> String { + ty_to_string(self.tcx, self.resolve_type_vars_if_possible(t)) } - pub fn tys_to_str(&self, ts: &[ty::t]) -> String { - let tstrs: Vec<String> = ts.iter().map(|t| self.ty_to_str(*t)).collect(); + pub fn tys_to_string(&self, ts: &[ty::t]) -> String { + let tstrs: Vec<String> = ts.iter().map(|t| self.ty_to_string(*t)).collect(); format!("({})", tstrs.connect(", ")) } - pub fn trait_ref_to_str(&self, t: &ty::TraitRef) -> String { + pub fn trait_ref_to_string(&self, t: &ty::TraitRef) -> String { let t = self.resolve_type_vars_in_trait_ref_if_possible(t); - trait_ref_to_str(self.tcx, &t) + trait_ref_to_string(self.tcx, &t) } pub fn resolve_type_vars_if_possible(&self, typ: ty::t) -> ty::t { @@ -707,8 +707,8 @@ impl<'a> InferCtxt<'a> { self.tcx.sess.bug( format!("resolve_type_vars_if_possible() yielded {} \ when supplied with {}", - self.ty_to_str(dummy0), - self.ty_to_str(dummy1)).as_slice()); + self.ty_to_string(dummy0), + self.ty_to_string(dummy1)).as_slice()); } } } @@ -761,7 +761,7 @@ impl<'a> InferCtxt<'a> { Some(e) => { self.tcx.sess.span_err(sp, format!("{}{}", - mk_msg(Some(self.ty_to_str(e)), actual_ty), + mk_msg(Some(self.ty_to_string(e)), actual_ty), error_str).as_slice()); } } @@ -783,7 +783,7 @@ impl<'a> InferCtxt<'a> { return; } - self.type_error_message_str(sp, |_e, a| { mk_msg(a) }, self.ty_to_str(actual_ty), err); + self.type_error_message_str(sp, |_e, a| { mk_msg(a) }, self.ty_to_string(actual_ty), err); } pub fn report_mismatched_types(&self, @@ -800,7 +800,7 @@ impl<'a> InferCtxt<'a> { // if I leave out : String, it infers &str and complains |actual: String| { format!("mismatched types: expected `{}` but found `{}`", - self.ty_to_str(resolved_expected), + self.ty_to_string(resolved_expected), actual) } } @@ -819,7 +819,7 @@ impl<'a> InferCtxt<'a> { let rvar = self.next_region_var( BoundRegionInFnType(trace.origin.span(), br)); debug!("Bound region {} maps to {:?}", - bound_region_to_str(self.tcx, "", false, br), + bound_region_to_string(self.tcx, "", false, br), rvar); rvar }); diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index adfbe9de2d5..2ae95309d41 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -56,7 +56,7 @@ use middle::typeck::infer::{unresolved_float_ty, unresolved_int_ty}; use middle::typeck::infer::{unresolved_ty}; use syntax::codemap::Span; use util::common::indent; -use util::ppaux::{Repr, ty_to_str}; +use util::ppaux::{Repr, ty_to_string}; pub static resolve_nested_tvar: uint = 0b0000000001; pub static resolve_rvar: uint = 0b0000000010; @@ -121,7 +121,7 @@ impl<'a> ResolveState<'a> { self.err = None; debug!("Resolving {} (modes={:x})", - ty_to_str(self.infcx.tcx, typ), + ty_to_string(self.infcx.tcx, typ), self.modes); // n.b. This is a hokey mess because the current fold doesn't @@ -133,8 +133,8 @@ impl<'a> ResolveState<'a> { match self.err { None => { debug!("Resolved to {} + {} (modes={:x})", - ty_to_str(self.infcx.tcx, rty), - ty_to_str(self.infcx.tcx, rty), + ty_to_string(self.infcx.tcx, rty), + ty_to_string(self.infcx.tcx, rty), self.modes); return Ok(rty); } diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 856237c4bca..44c147bfe7f 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -22,7 +22,7 @@ use middle::typeck::infer::lub::Lub; use middle::typeck::infer::then; use middle::typeck::infer::{TypeTrace, Subtype}; use util::common::{indenter}; -use util::ppaux::{bound_region_to_str, Repr}; +use util::ppaux::{bound_region_to_string, Repr}; use syntax::ast::{Onceness, FnStyle, MutImmutable, MutMutable}; @@ -176,7 +176,7 @@ impl<'f> Combine for Sub<'f> { replace_late_bound_regions_in_fn_sig(self.get_ref().infcx.tcx, b, |br| { let skol = self.get_ref().infcx.region_vars.new_skolemized(br); debug!("Bound region {} skolemized to {:?}", - bound_region_to_str(self.get_ref().infcx.tcx, "", false, br), + bound_region_to_string(self.get_ref().infcx.tcx, "", false, br), skol); skol }) diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index ff9f855c987..e66dcd118c9 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -37,7 +37,7 @@ use syntax::codemap; use syntax::codemap::{Span, CodeMap, DUMMY_SP}; use syntax::diagnostic::{Level, RenderSpan, Bug, Fatal, Error, Warning, Note}; use syntax::ast; -use util::ppaux::{ty_to_str, UserString}; +use util::ppaux::{ty_to_string, UserString}; struct Env<'a> { krate: ast::Crate, @@ -225,16 +225,16 @@ impl<'a> Env<'a> { pub fn assert_subtype(&self, a: ty::t, b: ty::t) { if !self.is_subtype(a, b) { fail!("{} is not a subtype of {}, but it should be", - self.ty_to_str(a), - self.ty_to_str(b)); + self.ty_to_string(a), + self.ty_to_string(b)); } } pub fn assert_not_subtype(&self, a: ty::t, b: ty::t) { if self.is_subtype(a, b) { fail!("{} is a subtype of {}, but it shouldn't be", - self.ty_to_str(a), - self.ty_to_str(b)); + self.ty_to_string(a), + self.ty_to_string(b)); } } @@ -243,8 +243,8 @@ impl<'a> Env<'a> { self.assert_subtype(b, a); } - pub fn ty_to_str(&self, a: ty::t) -> String { - ty_to_str(self.tcx, a) + pub fn ty_to_string(&self, a: ty::t) -> String { + ty_to_string(self.tcx, a) } pub fn t_fn(&self, @@ -328,9 +328,9 @@ impl<'a> Env<'a> { /// Checks that `GLB(t1,t2) == t_glb` pub fn check_glb(&self, t1: ty::t, t2: ty::t, t_glb: ty::t) { debug!("check_glb(t1={}, t2={}, t_glb={})", - self.ty_to_str(t1), - self.ty_to_str(t2), - self.ty_to_str(t_glb)); + self.ty_to_string(t1), + self.ty_to_string(t2), + self.ty_to_string(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { fail!("unexpected error computing LUB: {:?}", e) @@ -350,7 +350,7 @@ impl<'a> Env<'a> { match self.lub().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("unexpected success computing LUB: {}", self.ty_to_str(t)) + fail!("unexpected success computing LUB: {}", self.ty_to_string(t)) } } } @@ -360,7 +360,7 @@ impl<'a> Env<'a> { match self.glb().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("unexpected success computing GLB: {}", self.ty_to_str(t)) + fail!("unexpected success computing GLB: {}", self.ty_to_string(t)) } } } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 7b6935df420..ad6864ba487 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -276,7 +276,7 @@ pub struct CrateCtxt<'a> { // Functions that write types into the node type table pub fn write_ty_to_tcx(tcx: &ty::ctxt, node_id: ast::NodeId, ty: ty::t) { - debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_str(tcx, ty)); + debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_string(tcx, ty)); assert!(!ty::type_needs_infer(ty)); tcx.node_types.borrow_mut().insert(node_id as uint, ty); } @@ -383,14 +383,14 @@ fn check_main_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, main_span, main_t, se_ty, || { format!("main function expects type: `{}`", - ppaux::ty_to_str(ccx.tcx, se_ty)) + ppaux::ty_to_string(ccx.tcx, se_ty)) }); } _ => { tcx.sess.span_bug(main_span, format!("main has a non-function type: found \ `{}`", - ppaux::ty_to_str(tcx, + ppaux::ty_to_string(tcx, main_t)).as_slice()); } } @@ -436,7 +436,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, start_span, start_t, se_ty, || { format!("start function expects type: `{}`", - ppaux::ty_to_str(ccx.tcx, se_ty)) + ppaux::ty_to_string(ccx.tcx, se_ty)) }); } @@ -444,7 +444,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, tcx.sess.span_bug(start_span, format!("start has a non-function type: found \ `{}`", - ppaux::ty_to_str(tcx, + ppaux::ty_to_string(tcx, start_t)).as_slice()); } } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index fb3ce391d8e..8b5d16620b0 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -547,7 +547,7 @@ impl<'a> ConstraintContext<'a> { None => { self.tcx().sess.bug(format!( "no inferred index entry for {}", - self.tcx().map.node_to_str(param_id)).as_slice()); + self.tcx().map.node_to_string(param_id)).as_slice()); } } } @@ -588,8 +588,8 @@ impl<'a> ConstraintContext<'a> { let is_inferred; macro_rules! cannot_happen { () => { { fail!("invalid parent: {:s} for {:s}", - tcx.map.node_to_str(parent_id), - tcx.map.node_to_str(param_id)); + tcx.map.node_to_string(parent_id), + tcx.map.node_to_string(param_id)); } } } match parent { @@ -658,7 +658,7 @@ impl<'a> ConstraintContext<'a> { InferredIndex(index): InferredIndex, variance: VarianceTermPtr<'a>) { debug!("add_constraint(index={}, variance={})", - index, variance.to_str()); + index, variance.to_string()); self.constraints.push(Constraint { inferred: InferredIndex(index), variance: variance }); } @@ -975,7 +975,7 @@ impl<'a> SolveContext<'a> { .param_id, old_value, new_value, - term.to_str()); + term.to_string()); *self.solutions.get_mut(inferred) = new_value; changed = true; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index f228ea32ae5..542bc68ef73 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -105,7 +105,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) BrFresh(_) => "an anonymous lifetime defined on".to_string(), _ => { format!("the lifetime {} as defined on", - bound_region_ptr_to_str(cx, fr.bound_region)) + bound_region_ptr_to_string(cx, fr.bound_region)) } }; @@ -145,11 +145,11 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) } } -pub fn bound_region_ptr_to_str(cx: &ctxt, br: BoundRegion) -> String { - bound_region_to_str(cx, "", false, br) +pub fn bound_region_ptr_to_string(cx: &ctxt, br: BoundRegion) -> String { + bound_region_to_string(cx, "", false, br) } -pub fn bound_region_to_str(cx: &ctxt, +pub fn bound_region_to_string(cx: &ctxt, prefix: &str, space: bool, br: BoundRegion) -> String { let space_str = if space { " " } else { "" }; @@ -170,11 +170,11 @@ pub fn bound_region_to_str(cx: &ctxt, // In general, if you are giving a region error message, // you should use `explain_region()` or, better yet, // `note_and_explain_region()` -pub fn region_ptr_to_str(cx: &ctxt, region: Region) -> String { - region_to_str(cx, "&", true, region) +pub fn region_ptr_to_string(cx: &ctxt, region: Region) -> String { + region_to_string(cx, "&", true, region) } -pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> String { +pub fn region_to_string(cx: &ctxt, prefix: &str, space: bool, region: Region) -> String { let space_str = if space { " " } else { "" }; if cx.sess.verbose() { @@ -190,10 +190,10 @@ pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> St ty::ReEarlyBound(_, _, _, name) => { token::get_name(name).get().to_string() } - ty::ReLateBound(_, br) => bound_region_to_str(cx, prefix, space, br), - ty::ReFree(ref fr) => bound_region_to_str(cx, prefix, space, fr.bound_region), + ty::ReLateBound(_, br) => bound_region_to_string(cx, prefix, space, br), + ty::ReFree(ref fr) => bound_region_to_string(cx, prefix, space, fr.bound_region), ty::ReInfer(ReSkolemized(_, br)) => { - bound_region_to_str(cx, prefix, space, br) + bound_region_to_string(cx, prefix, space, br) } ty::ReInfer(ReVar(_)) => prefix.to_string(), ty::ReStatic => format!("{}'static{}", prefix, space_str), @@ -201,45 +201,55 @@ pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> St } } -pub fn mutability_to_str(m: ast::Mutability) -> String { +pub fn mutability_to_string(m: ast::Mutability) -> String { match m { ast::MutMutable => "mut ".to_string(), ast::MutImmutable => "".to_string(), } } -pub fn mt_to_str(cx: &ctxt, m: &mt) -> String { - format!("{}{}", mutability_to_str(m.mutbl), ty_to_str(cx, m.ty)) +pub fn mt_to_string(cx: &ctxt, m: &mt) -> String { + format!("{}{}", mutability_to_string(m.mutbl), ty_to_string(cx, m.ty)) } +#[cfg(stage0)] pub fn trait_store_to_str(cx: &ctxt, s: ty::TraitStore) -> String { + trait_store_to_string(cx, s) +} + +pub fn trait_store_to_string(cx: &ctxt, s: ty::TraitStore) -> String { match s { ty::UniqTraitStore => "Box ".to_string(), ty::RegionTraitStore(r, m) => { - format!("{}{}", region_ptr_to_str(cx, r), mutability_to_str(m)) + format!("{}{}", region_ptr_to_string(cx, r), mutability_to_string(m)) } } } -pub fn vec_map_to_str<T>(ts: &[T], f: |t: &T| -> String) -> String { +pub fn vec_map_to_string<T>(ts: &[T], f: |t: &T| -> String) -> String { let tstrs = ts.iter().map(f).collect::<Vec<String>>(); format!("[{}]", tstrs.connect(", ")) } -pub fn fn_sig_to_str(cx: &ctxt, typ: &ty::FnSig) -> String { +pub fn fn_sig_to_string(cx: &ctxt, typ: &ty::FnSig) -> String { format!("fn{}{} -> {}", typ.binder_id, typ.inputs.repr(cx), typ.output.repr(cx)) } -pub fn trait_ref_to_str(cx: &ctxt, trait_ref: &ty::TraitRef) -> String { +pub fn trait_ref_to_string(cx: &ctxt, trait_ref: &ty::TraitRef) -> String { trait_ref.user_string(cx).to_string() } +#[cfg(stage0)] pub fn ty_to_str(cx: &ctxt, typ: t) -> String { - fn fn_input_to_str(cx: &ctxt, input: ty::t) -> String { - ty_to_str(cx, input).to_string() + ty_to_string(cx, typ) +} + +pub fn ty_to_string(cx: &ctxt, typ: t) -> String { + fn fn_input_to_string(cx: &ctxt, input: ty::t) -> String { + ty_to_string(cx, input).to_string() } - fn bare_fn_to_str(cx: &ctxt, + fn bare_fn_to_string(cx: &ctxt, fn_style: ast::FnStyle, abi: abi::Abi, ident: Option<ast::Ident>, @@ -249,13 +259,13 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { match fn_style { ast::NormalFn => {} _ => { - s.push_str(fn_style.to_str().as_slice()); + s.push_str(fn_style.to_string().as_slice()); s.push_char(' '); } }; if abi != abi::Rust { - s.push_str(format!("extern {} ", abi.to_str()).as_slice()); + s.push_str(format!("extern {} ", abi.to_string()).as_slice()); }; s.push_str("fn"); @@ -268,25 +278,25 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { _ => { } } - push_sig_to_str(cx, &mut s, '(', ')', sig); + push_sig_to_string(cx, &mut s, '(', ')', sig); s } - fn closure_to_str(cx: &ctxt, cty: &ty::ClosureTy) -> String { + fn closure_to_string(cx: &ctxt, cty: &ty::ClosureTy) -> String { let mut s = String::new(); match cty.store { ty::UniqTraitStore => {} ty::RegionTraitStore(region, _) => { - s.push_str(region_to_str(cx, "", true, region).as_slice()); + s.push_str(region_to_string(cx, "", true, region).as_slice()); } } match cty.fn_style { ast::NormalFn => {} _ => { - s.push_str(cty.fn_style.to_str().as_slice()); + s.push_str(cty.fn_style.to_string().as_slice()); s.push_char(' '); } }; @@ -295,14 +305,14 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { ty::UniqTraitStore => { assert_eq!(cty.onceness, ast::Once); s.push_str("proc"); - push_sig_to_str(cx, &mut s, '(', ')', &cty.sig); + push_sig_to_string(cx, &mut s, '(', ')', &cty.sig); } ty::RegionTraitStore(..) => { match cty.onceness { ast::Many => {} ast::Once => s.push_str("once ") } - push_sig_to_str(cx, &mut s, '|', '|', &cty.sig); + push_sig_to_string(cx, &mut s, '|', '|', &cty.sig); } } @@ -314,13 +324,13 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { s } - fn push_sig_to_str(cx: &ctxt, + fn push_sig_to_string(cx: &ctxt, s: &mut String, bra: char, ket: char, sig: &ty::FnSig) { s.push_char(bra); - let strs: Vec<String> = sig.inputs.iter().map(|a| fn_input_to_str(cx, *a)).collect(); + let strs: Vec<String> = sig.inputs.iter().map(|a| fn_input_to_string(cx, *a)).collect(); s.push_str(strs.connect(", ").as_slice()); if sig.variadic { s.push_str(", ..."); @@ -332,7 +342,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { if ty::type_is_bot(sig.output) { s.push_char('!'); } else { - s.push_str(ty_to_str(cx, sig.output).as_slice()); + s.push_str(ty_to_string(cx, sig.output).as_slice()); } } } @@ -349,33 +359,33 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { ty_bot => "!".to_string(), ty_bool => "bool".to_string(), ty_char => "char".to_string(), - ty_int(t) => ast_util::int_ty_to_str(t, None).to_string(), - ty_uint(t) => ast_util::uint_ty_to_str(t, None).to_string(), - ty_float(t) => ast_util::float_ty_to_str(t).to_string(), - ty_box(typ) => format!("Gc<{}>", ty_to_str(cx, typ)), - ty_uniq(typ) => format!("Box<{}>", ty_to_str(cx, typ)), + ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(), + ty_uint(t) => ast_util::uint_ty_to_string(t, None).to_string(), + ty_float(t) => ast_util::float_ty_to_string(t).to_string(), + ty_box(typ) => format!("Gc<{}>", ty_to_string(cx, typ)), + ty_uniq(typ) => format!("Box<{}>", ty_to_string(cx, typ)), ty_ptr(ref tm) => { format!("*{} {}", match tm.mutbl { ast::MutMutable => "mut", ast::MutImmutable => "const", - }, ty_to_str(cx, tm.ty)) + }, ty_to_string(cx, tm.ty)) } ty_rptr(r, ref tm) => { - let mut buf = region_ptr_to_str(cx, r); - buf.push_str(mt_to_str(cx, tm).as_slice()); + let mut buf = region_ptr_to_string(cx, r); + buf.push_str(mt_to_string(cx, tm).as_slice()); buf } ty_tup(ref elems) => { - let strs: Vec<String> = elems.iter().map(|elem| ty_to_str(cx, *elem)).collect(); + let strs: Vec<String> = elems.iter().map(|elem| ty_to_string(cx, *elem)).collect(); format!("({})", strs.connect(",")) } ty_closure(ref f) => { - closure_to_str(cx, *f) + closure_to_string(cx, *f) } ty_bare_fn(ref f) => { - bare_fn_to_str(cx, f.fn_style, f.abi, None, &f.sig) + bare_fn_to_string(cx, f.fn_style, f.abi, None, &f.sig) } - ty_infer(infer_ty) => infer_ty.to_str(), + ty_infer(infer_ty) => infer_ty.to_string(), ty_err => "[type error]".to_string(), ty_param(ParamTy {idx: id, def_id: did, ..}) => { let ident = match cx.ty_param_defs.borrow().find(&did.node) { @@ -413,9 +423,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String { ty_vec(ref mt, sz) => { match sz { Some(n) => { - format!("[{}, .. {}]", mt_to_str(cx, mt), n) + format!("[{}, .. {}]", mt_to_string(cx, mt), n) } - None => format!("[{}]", ty_to_str(cx, mt.ty)), + None => format!("[{}]", ty_to_string(cx, mt.ty)), } } } @@ -433,7 +443,7 @@ pub fn parameterized(cx: &ctxt, subst::ErasedRegions => { } subst::NonerasedRegions(ref regions) => { for &r in regions.iter() { - let s = region_to_str(cx, "", false, r); + let s = region_to_string(cx, "", false, r); if !s.is_empty() { strs.push(s) } else { @@ -463,7 +473,7 @@ pub fn parameterized(cx: &ctxt, }; for t in tps.slice_to(tps.len() - num_defaults).iter() { - strs.push(ty_to_str(cx, *t)) + strs.push(ty_to_string(cx, *t)) } if cx.sess.verbose() { @@ -530,7 +540,7 @@ impl<T:Repr> Repr for Box<T> { } fn repr_vec<T:Repr>(tcx: &ctxt, v: &[T]) -> String { - vec_map_to_str(v, |t| t.repr(tcx)) + vec_map_to_string(v, |t| t.repr(tcx)) } impl<'a, T:Repr> Repr for &'a [T] { @@ -576,13 +586,13 @@ impl Repr for ty::RegionParameterDef { impl Repr for ty::t { fn repr(&self, tcx: &ctxt) -> String { - ty_to_str(tcx, *self) + ty_to_string(tcx, *self) } } impl Repr for ty::mt { fn repr(&self, tcx: &ctxt) -> String { - mt_to_str(tcx, self) + mt_to_string(tcx, self) } } @@ -639,25 +649,25 @@ impl Repr for ty::ParamBounds { impl Repr for ty::TraitRef { fn repr(&self, tcx: &ctxt) -> String { - trait_ref_to_str(tcx, self) + trait_ref_to_string(tcx, self) } } impl Repr for ast::Expr { fn repr(&self, _tcx: &ctxt) -> String { - format!("expr({}: {})", self.id, pprust::expr_to_str(self)) + format!("expr({}: {})", self.id, pprust::expr_to_string(self)) } } impl Repr for ast::Path { fn repr(&self, _tcx: &ctxt) -> String { - format!("path({})", pprust::path_to_str(self)) + format!("path({})", pprust::path_to_string(self)) } } impl Repr for ast::Item { fn repr(&self, tcx: &ctxt) -> String { - format!("item({})", tcx.map.node_to_str(self.id)) + format!("item({})", tcx.map.node_to_string(self.id)) } } @@ -665,13 +675,13 @@ impl Repr for ast::Stmt { fn repr(&self, _tcx: &ctxt) -> String { format!("stmt({}: {})", ast_util::stmt_id(self), - pprust::stmt_to_str(self)) + pprust::stmt_to_string(self)) } } impl Repr for ast::Pat { fn repr(&self, _tcx: &ctxt) -> String { - format!("pat({}: {})", self.id, pprust::pat_to_str(self)) + format!("pat({}: {})", self.id, pprust::pat_to_string(self)) } } @@ -787,10 +797,10 @@ impl Repr for ty::ItemVariances { impl Repr for ty::Variance { fn repr(&self, _: &ctxt) -> String { - // The first `.to_str()` returns a &'static str (it is not an implementation - // of the ToStr trait). Because of that, we need to call `.to_str()` again + // The first `.to_string()` returns a &'static str (it is not an implementation + // of the ToString trait). Because of that, we need to call `.to_string()` again // if we want to have a `String`. - self.to_str().to_str() + self.to_string().to_string() } } @@ -835,14 +845,14 @@ impl Repr for ty::BareFnTy { fn repr(&self, tcx: &ctxt) -> String { format!("BareFnTy {{fn_style: {:?}, abi: {}, sig: {}}}", self.fn_style, - self.abi.to_str(), + self.abi.to_string(), self.sig.repr(tcx)) } } impl Repr for ty::FnSig { fn repr(&self, tcx: &ctxt) -> String { - fn_sig_to_str(tcx, self) + fn_sig_to_string(tcx, self) } } @@ -892,7 +902,7 @@ impl Repr for typeck::MethodObject { impl Repr for ty::TraitStore { fn repr(&self, tcx: &ctxt) -> String { - trait_store_to_str(tcx, *self) + trait_store_to_string(tcx, *self) } } @@ -922,7 +932,7 @@ impl Repr for ty::BuiltinBounds { impl Repr for Span { fn repr(&self, tcx: &ctxt) -> String { - tcx.sess.codemap().span_to_str(*self).to_string() + tcx.sess.codemap().span_to_string(*self).to_string() } } @@ -953,7 +963,7 @@ impl UserString for ty::TraitRef { impl UserString for ty::t { fn user_string(&self, tcx: &ctxt) -> String { - ty_to_str(tcx, *self) + ty_to_string(tcx, *self) } } @@ -965,13 +975,13 @@ impl UserString for ast::Ident { impl Repr for abi::Abi { fn repr(&self, _tcx: &ctxt) -> String { - self.to_str() + self.to_string() } } impl UserString for abi::Abi { fn user_string(&self, _tcx: &ctxt) -> String { - self.to_str() + self.to_string() } } |
