Skip to content

Commit 2f02462

Browse files
committed
Move users of span_to_embeddable_string to span_to_diagnostic_string
This is done in order to simplify the filename overhaul and those places don't need to the embeddable path anyway.
1 parent b593ab4 commit 2f02462

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

compiler/rustc_borrowck/src/region_infer/dump_mir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8080
let OutlivesConstraint { sup, sub, locations, category, span, .. } = constraint;
8181
let (name, arg) = match locations {
8282
Locations::All(span) => {
83-
("All", tcx.sess.source_map().span_to_embeddable_string(*span))
83+
("All", tcx.sess.source_map().span_to_diagnostic_string(*span))
8484
}
8585
Locations::Single(loc) => ("Single", format!("{loc:?}")),
8686
};

compiler/rustc_expand/src/stats.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ pub(crate) fn update_macro_stats(
138138
if false {
139139
let name = ExpnKind::Macro(macro_kind, name).descr();
140140
let crate_name = &ecx.ecfg.crate_name;
141-
let span = ecx
142-
.sess
143-
.source_map()
144-
.span_to_string(span, rustc_span::FileNameDisplayPreference::Local);
141+
let span = ecx.sess.source_map().span_to_diagnostic_string(span);
145142
eprint!(
146143
"\
147144
-------------------------------\n\

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ fn write_scope_tree(
504504
"{0:1$} // at {2}",
505505
indented_header,
506506
ALIGN,
507-
tcx.sess.source_map().span_to_embeddable_string(span),
507+
tcx.sess.source_map().span_to_diagnostic_string(span),
508508
)?;
509509
} else {
510510
writeln!(w, "{indented_header}")?;
@@ -688,7 +688,7 @@ fn write_user_type_annotations(
688688
"| {:?}: user_ty: {}, span: {}, inferred_ty: {}",
689689
index.index(),
690690
annotation.user_ty,
691-
tcx.sess.source_map().span_to_embeddable_string(annotation.span),
691+
tcx.sess.source_map().span_to_diagnostic_string(annotation.span),
692692
with_no_trimmed_paths!(format!("{}", annotation.inferred_ty)),
693693
)?;
694694
}
@@ -1420,7 +1420,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
14201420
self.push("mir::ConstOperand");
14211421
self.push(&format!(
14221422
"+ span: {}",
1423-
self.tcx.sess.source_map().span_to_embeddable_string(*span)
1423+
self.tcx.sess.source_map().span_to_diagnostic_string(*span)
14241424
));
14251425
if let Some(user_ty) = user_ty {
14261426
self.push(&format!("+ user_ty: {user_ty:?}"));
@@ -1503,7 +1503,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
15031503
}
15041504

15051505
fn comment(tcx: TyCtxt<'_>, SourceInfo { span, scope }: SourceInfo) -> String {
1506-
let location = tcx.sess.source_map().span_to_embeddable_string(span);
1506+
let location = tcx.sess.source_map().span_to_diagnostic_string(span);
15071507
format!("scope {} at {}", scope.index(), location,)
15081508
}
15091509

compiler/rustc_monomorphize/src/util.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,15 @@ pub(crate) fn dump_closure_profile<'tcx>(tcx: TyCtxt<'tcx>, closure_instance: In
4949
.unwrap_or_else(|e| format!("Failed {e:?}"));
5050

5151
let closure_span = tcx.def_span(closure_def_id);
52-
let src_file = tcx.sess.source_map().span_to_filename(closure_span);
52+
let src_file = tcx.sess.source_map().span_to_diagnostic_string(closure_span);
5353
let line_nos = tcx
5454
.sess
5555
.source_map()
5656
.span_to_lines(closure_span)
5757
.map(|l| format!("{:?} {:?}", l.lines.first(), l.lines.last()))
5858
.unwrap_or_else(|e| format!("{e:?}"));
5959

60-
if let Err(e) = writeln!(
61-
file,
62-
"{}, {}, {}, {:?}",
63-
old_size,
64-
new_size,
65-
src_file.prefer_local(),
66-
line_nos
67-
) {
60+
if let Err(e) = writeln!(file, "{}, {}, {}, {:?}", old_size, new_size, src_file, line_nos) {
6861
eprintln!("Error writing to file {e}")
6962
}
7063
}

0 commit comments

Comments
 (0)