diff --git a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs index a9ab30fd8fa3..68f822aac403 100644 --- a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs +++ b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs @@ -80,7 +80,7 @@ fn for_each_constraint( let OutlivesConstraint { sup, sub, locations, category, span, .. } = constraint; let (name, arg) = match locations { Locations::All(span) => { - ("All", tcx.sess.source_map().span_to_embeddable_string(*span)) + ("All", tcx.sess.source_map().span_to_diagnostic_string(*span)) } Locations::Single(loc) => ("Single", format!("{loc:?}")), }; diff --git a/compiler/rustc_expand/src/stats.rs b/compiler/rustc_expand/src/stats.rs index 3e40632275b6..00f1c11044e0 100644 --- a/compiler/rustc_expand/src/stats.rs +++ b/compiler/rustc_expand/src/stats.rs @@ -138,10 +138,7 @@ pub(crate) fn update_macro_stats( if false { let name = ExpnKind::Macro(macro_kind, name).descr(); let crate_name = &ecx.ecfg.crate_name; - let span = ecx - .sess - .source_map() - .span_to_string(span, rustc_span::FileNameDisplayPreference::Local); + let span = ecx.sess.source_map().span_to_diagnostic_string(span); eprint!( "\ -------------------------------\n\ diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 3bdc5fdb420c..b225dd4ef60a 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -504,7 +504,7 @@ fn write_scope_tree( "{0:1$} // at {2}", indented_header, ALIGN, - tcx.sess.source_map().span_to_embeddable_string(span), + tcx.sess.source_map().span_to_diagnostic_string(span), )?; } else { writeln!(w, "{indented_header}")?; @@ -688,7 +688,7 @@ fn write_user_type_annotations( "| {:?}: user_ty: {}, span: {}, inferred_ty: {}", index.index(), annotation.user_ty, - tcx.sess.source_map().span_to_embeddable_string(annotation.span), + tcx.sess.source_map().span_to_diagnostic_string(annotation.span), with_no_trimmed_paths!(format!("{}", annotation.inferred_ty)), )?; } @@ -1420,7 +1420,7 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _location: Loca self.push("mir::ConstOperand"); self.push(&format!( "+ span: {}", - self.tcx.sess.source_map().span_to_embeddable_string(*span) + self.tcx.sess.source_map().span_to_diagnostic_string(*span) )); if let Some(user_ty) = user_ty { self.push(&format!("+ user_ty: {user_ty:?}")); @@ -1503,7 +1503,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { } fn comment(tcx: TyCtxt<'_>, SourceInfo { span, scope }: SourceInfo) -> String { - let location = tcx.sess.source_map().span_to_embeddable_string(span); + let location = tcx.sess.source_map().span_to_diagnostic_string(span); format!("scope {} at {}", scope.index(), location,) } diff --git a/compiler/rustc_monomorphize/src/util.rs b/compiler/rustc_monomorphize/src/util.rs index deb4ab433bfe..6fcb18177a14 100644 --- a/compiler/rustc_monomorphize/src/util.rs +++ b/compiler/rustc_monomorphize/src/util.rs @@ -49,7 +49,7 @@ pub(crate) fn dump_closure_profile<'tcx>(tcx: TyCtxt<'tcx>, closure_instance: In .unwrap_or_else(|e| format!("Failed {e:?}")); let closure_span = tcx.def_span(closure_def_id); - let src_file = tcx.sess.source_map().span_to_filename(closure_span); + let src_file = tcx.sess.source_map().span_to_diagnostic_string(closure_span); let line_nos = tcx .sess .source_map() @@ -57,14 +57,7 @@ pub(crate) fn dump_closure_profile<'tcx>(tcx: TyCtxt<'tcx>, closure_instance: In .map(|l| format!("{:?} {:?}", l.lines.first(), l.lines.last())) .unwrap_or_else(|e| format!("{e:?}")); - if let Err(e) = writeln!( - file, - "{}, {}, {}, {:?}", - old_size, - new_size, - src_file.prefer_local(), - line_nos - ) { + if let Err(e) = writeln!(file, "{}, {}, {}, {:?}", old_size, new_size, src_file, line_nos) { eprintln!("Error writing to file {e}") } }