Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix.

This commit is contained in:
Michael Woerister 2021-08-26 12:46:01 +02:00
parent dfd6306d26
commit af1b65cb18
13 changed files with 65 additions and 41 deletions

View file

@ -1626,14 +1626,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
(TypeError::Sorts(values), extra) => {
let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) {
(true, ty::Opaque(def_id, _)) => {
let pos = self
.tcx
.sess
.source_map()
.lookup_char_pos(self.tcx.def_span(*def_id).lo());
let sm = self.tcx.sess.source_map();
let pos = sm.lookup_char_pos(self.tcx.def_span(*def_id).lo());
format!(
" (opaque type at <{}:{}:{}>)",
pos.file.name.prefer_local(),
sm.filename_for_diagnostics(&pos.file.name),
pos.line,
pos.col.to_usize() + 1,
)