diff options
| author | Andy Wang <cbeuw.andy@gmail.com> | 2021-04-03 16:59:31 +0100 |
|---|---|---|
| committer | Andy Wang <cbeuw.andy@gmail.com> | 2021-05-05 15:10:50 +0100 |
| commit | 6720a370429282e071042af315d712e716d88abf (patch) | |
| tree | 2306548a63269eb78cde53e7e46ff55c4e0048c7 | |
| parent | d66506d3532848d5f52301d0c328d79673d7f551 (diff) | |
| download | rust-6720a370429282e071042af315d712e716d88abf.tar.gz rust-6720a370429282e071042af315d712e716d88abf.zip | |
Rename RealFileName::Named to LocalPath and Devirtualized to Remapped
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/expand.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/proc_macro_server.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ich/impls_syntax.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_save_analysis/src/span_utils.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 41 | ||||
| -rw-r--r-- | compiler/rustc_span/src/source_map.rs | 92 | ||||
| -rw-r--r-- | compiler/rustc_span/src/source_map/tests.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/doctest.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/json/conversions.rs | 7 |
13 files changed, 82 insertions, 132 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 59505842816..f88b05e6c8f 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1072,7 +1072,7 @@ impl<'a> ExtCtxt<'a> { // after macro expansion (that is, they are unhygienic). if !path.is_absolute() { let callsite = span.source_callsite(); - let mut result = match self.source_map().span_to_unmapped_path(callsite) { + let mut result = match self.source_map().span_to_filename(callsite) { FileName::Real(name) => name.into_local_path(), FileName::DocTest(path, _) => path, other => { diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 3347c93948c..7bb29d20e4a 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -361,7 +361,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // FIXME: Avoid visiting the crate as a `Mod` item, // make crate a first class expansion target instead. pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { - let file_path = match self.cx.source_map().span_to_unmapped_path(krate.span) { + let file_path = match self.cx.source_map().span_to_filename(krate.span) { FileName::Real(name) => name.into_local_path(), other => PathBuf::from(other.to_string()), }; diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 1ea26b4eab4..4089dc88b7b 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -725,7 +725,7 @@ fn ident_name_compatibility_hack( if let ExpnKind::Macro(_, macro_name) = orig_span.ctxt().outer_expn_data().kind { let source_map = rustc.sess.source_map(); let filename = source_map.span_to_filename(orig_span); - if let FileName::Real(RealFileName::Named(path)) = filename { + if let FileName::Real(RealFileName::LocalPath(path)) = filename { let matches_prefix = |prefix, filename| { // Check for a path that ends with 'prefix*/src/<filename>' let mut iter = path.components().rev(); @@ -788,7 +788,7 @@ fn ident_name_compatibility_hack( if macro_name == sym::tuple_from_req && matches_prefix("actix-web", "extract.rs") { let snippet = source_map.span_to_snippet(orig_span); if snippet.as_deref() == Ok("$T") { - if let FileName::Real(RealFileName::Named(macro_path)) = + if let FileName::Real(RealFileName::LocalPath(macro_path)) = source_map.span_to_filename(rustc.def_site) { if macro_path.to_string_lossy().contains("pin-project-internal-0.") { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 02e62a2cee9..2f91a72e208 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -575,7 +575,7 @@ fn write_out_deps( .iter() .filter(|fmap| fmap.is_real_file()) .filter(|fmap| !fmap.is_imported()) - .map(|fmap| escape_dep_filename(&fmap.unmapped_path.as_ref().unwrap_or(&fmap.name))) + .map(|fmap| escape_dep_filename(&fmap.name)) .collect(); if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend { @@ -587,15 +587,15 @@ fn write_out_deps( for cnum in resolver.cstore().crates_untracked() { let source = resolver.cstore().crate_source_untracked(cnum); if let Some((path, _)) = source.dylib { - let file_name = FileName::Real(RealFileName::Named(path)); + let file_name = FileName::Real(RealFileName::LocalPath(path)); files.push(escape_dep_filename(&file_name)); } if let Some((path, _)) = source.rlib { - let file_name = FileName::Real(RealFileName::Named(path)); + let file_name = FileName::Real(RealFileName::LocalPath(path)); files.push(escape_dep_filename(&file_name)); } if let Some((path, _)) = source.rmeta { - let file_name = FileName::Real(RealFileName::Named(path)); + let file_name = FileName::Real(RealFileName::LocalPath(path)); files.push(escape_dep_filename(&file_name)); } } diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 2ade1bb4f95..74325c62ed3 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1635,9 +1635,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { if let Some(virtual_dir) = virtual_rust_source_base_dir { if let Some(real_dir) = &sess.opts.real_rust_source_base_dir { if let rustc_span::FileName::Real(old_name) = name { - if let rustc_span::RealFileName::Named(one_path) = old_name { - if let Ok(rest) = one_path.strip_prefix(virtual_dir) { - let virtual_name = one_path.clone(); + if let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } = + old_name + { + if let Ok(rest) = virtual_name.strip_prefix(virtual_dir) { + let virtual_name = virtual_name.clone(); // The std library crates are in // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates @@ -1673,7 +1675,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { virtual_name.display(), new_path.display(), ); - let new_name = rustc_span::RealFileName::Devirtualized { + let new_name = rustc_span::RealFileName::Remapped { local_path: new_path, virtual_name, }; @@ -1694,7 +1696,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { // containing the information we need. let rustc_span::SourceFile { mut name, - name_was_remapped, src_hash, start_pos, end_pos, @@ -1709,8 +1710,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { // If this file's path has been remapped to `/rustc/$hash`, // we might be able to reverse that (also see comments above, // on `try_to_translate_virtual_to_real`). - // FIXME(eddyb) we could check `name_was_remapped` here, - // but in practice it seems to be always `false`. try_to_translate_virtual_to_real(&mut name); let source_length = (end_pos - start_pos).to_usize(); @@ -1735,7 +1734,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { let local_version = sess.source_map().new_imported_source_file( name, - name_was_remapped, src_hash, name_hash, source_length, diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index e8f02b8e66f..fbae2278f1e 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -28,9 +28,12 @@ use rustc_middle::ty::codec::TyEncoder; use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt}; use rustc_serialize::{opaque, Encodable, Encoder}; use rustc_session::config::CrateType; -use rustc_span::hygiene::{ExpnDataEncodeMode, HygieneEncodeContext, MacroKind}; use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{self, ExternalSource, FileName, SourceFile, Span, SyntaxContext}; +use rustc_span::{ + hygiene::{ExpnDataEncodeMode, HygieneEncodeContext, MacroKind}, + RealFileName, +}; use rustc_target::abi::VariantIdx; use std::hash::Hash; use std::num::NonZeroUsize; @@ -485,18 +488,22 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { }) .map(|(_, source_file)| { let mut adapted = match source_file.name { - // This path of this SourceFile has been modified by - // path-remapping, so we use it verbatim (and avoid - // cloning the whole map in the process). - _ if source_file.name_was_remapped => source_file.clone(), - - // Otherwise expand all paths to absolute paths because - // any relative paths are potentially relative to a - // wrong directory. FileName::Real(ref name) => { - let name = name.stable_name(); + // Expand all local paths to absolute paths because + // any relative paths are potentially relative to a + // wrong directory. let mut adapted = (**source_file).clone(); - adapted.name = Path::new(&working_dir).join(name).into(); + adapted.name = match name { + RealFileName::LocalPath(local_path) => { + Path::new(&working_dir).join(local_path).into() + } + RealFileName::Remapped { local_path, virtual_name } => { + FileName::Real(RealFileName::Remapped { + local_path: Path::new(&working_dir).join(local_path), + virtual_name: virtual_name.clone(), + }) + } + }; adapted.name_hash = { let mut hasher: StableHasher = StableHasher::new(); adapted.name.hash(&mut hasher); diff --git a/compiler/rustc_middle/src/ich/impls_syntax.rs b/compiler/rustc_middle/src/ich/impls_syntax.rs index b93b25d6b5c..2d8f661ef59 100644 --- a/compiler/rustc_middle/src/ich/impls_syntax.rs +++ b/compiler/rustc_middle/src/ich/impls_syntax.rs @@ -61,8 +61,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile { let SourceFile { name: _, // We hash the smaller name_hash instead of this name_hash, - name_was_remapped, - unmapped_path: _, cnum, // Do not hash the source as it is not encoded src: _, @@ -77,7 +75,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile { } = *self; (name_hash as u64).hash_stable(hcx, hasher); - name_was_remapped.hash_stable(hcx, hasher); src_hash.hash_stable(hcx, hasher); diff --git a/compiler/rustc_save_analysis/src/span_utils.rs b/compiler/rustc_save_analysis/src/span_utils.rs index edcd4925773..5e16a427f3f 100644 --- a/compiler/rustc_save_analysis/src/span_utils.rs +++ b/compiler/rustc_save_analysis/src/span_utils.rs @@ -16,8 +16,7 @@ impl<'a> SpanUtils<'a> { pub fn make_filename_string(&self, file: &SourceFile) -> String { match &file.name { - FileName::Real(name) if !file.name_was_remapped => { - let path = name.local_path(); + FileName::Real(RealFileName::LocalPath(path)) => { if path.is_absolute() { self.sess .source_map() @@ -30,8 +29,11 @@ impl<'a> SpanUtils<'a> { self.sess.working_dir.0.join(&path).display().to_string() } } - // If the file name is already remapped, we assume the user + // If the file name was remapped, we assume the user // configured it the way they wanted to, so use that directly + FileName::Real(RealFileName::Remapped { local_path: _, virtual_name }) => { + virtual_name.display().to_string() + } filename => filename.to_string(), } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d30236ec3ec..44617b5aa00 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -113,17 +113,16 @@ pub fn with_default_session_globals<R>(f: impl FnOnce() -> R) -> R { // deserialization. scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals); -// FIXME: Perhaps this should not implement Rustc{Decodable, Encodable} -// // FIXME: We should use this enum or something like it to get rid of the // use of magic `/rust/1.x/...` paths across the board. #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] #[derive(HashStable_Generic, Decodable, Encodable)] pub enum RealFileName { - Named(PathBuf), - /// For de-virtualized paths (namely paths into libstd that have been mapped - /// to the appropriate spot on the local host's file system), - Devirtualized { + LocalPath(PathBuf), + /// For remapped paths (namely paths into libstd that have been mapped + /// to the appropriate spot on the local host's file system, and local file + /// system paths that have been remapped with `FilePathMapping`), + Remapped { /// `local_path` is the (host-dependent) local path to the file. local_path: PathBuf, /// `virtual_name` is the stable path rustc will store internally within @@ -137,8 +136,8 @@ impl RealFileName { /// Avoid embedding this in build artifacts; see `stable_name()` for that. pub fn local_path(&self) -> &Path { match self { - RealFileName::Named(p) - | RealFileName::Devirtualized { local_path: p, virtual_name: _ } => &p, + RealFileName::LocalPath(p) + | RealFileName::Remapped { local_path: p, virtual_name: _ } => &p, } } @@ -146,19 +145,19 @@ impl RealFileName { /// Avoid embedding this in build artifacts; see `stable_name()` for that. pub fn into_local_path(self) -> PathBuf { match self { - RealFileName::Named(p) - | RealFileName::Devirtualized { local_path: p, virtual_name: _ } => p, + RealFileName::LocalPath(p) + | RealFileName::Remapped { local_path: p, virtual_name: _ } => p, } } /// Returns the path suitable for embedding into build artifacts. Note that - /// a virtualized path will not correspond to a valid file system path; see + /// a remapped path will not correspond to a valid file system path; see /// `local_path()` for something that is more likely to return paths into the /// local host file system. pub fn stable_name(&self) -> &Path { match self { - RealFileName::Named(p) - | RealFileName::Devirtualized { local_path: _, virtual_name: p } => &p, + RealFileName::LocalPath(p) + | RealFileName::Remapped { local_path: _, virtual_name: p } => &p, } } } @@ -214,7 +213,7 @@ impl std::fmt::Display for FileName { impl From<PathBuf> for FileName { fn from(p: PathBuf) -> Self { assert!(!p.to_string_lossy().ends_with('>')); - FileName::Real(RealFileName::Named(p)) + FileName::Real(RealFileName::LocalPath(p)) } } @@ -1124,11 +1123,6 @@ pub struct SourceFile { /// originate from files has names between angle brackets by convention /// (e.g., `<anon>`). pub name: FileName, - /// `true` if the `name` field above has been modified by `--remap-path-prefix`. - pub name_was_remapped: bool, - /// The unmapped path of the file that the source came from. - /// Set to `None` if the `SourceFile` was imported from an external crate. - pub unmapped_path: Option<FileName>, /// The complete source code. pub src: Option<Lrc<String>>, /// The source code's hash. @@ -1158,7 +1152,6 @@ impl<S: Encoder> Encodable<S> for SourceFile { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_struct("SourceFile", 8, |s| { s.emit_struct_field("name", 0, |s| self.name.encode(s))?; - s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?; s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?; s.emit_struct_field("start_pos", 3, |s| self.start_pos.encode(s))?; s.emit_struct_field("end_pos", 4, |s| self.end_pos.encode(s))?; @@ -1233,8 +1226,6 @@ impl<D: Decoder> Decodable<D> for SourceFile { fn decode(d: &mut D) -> Result<SourceFile, D::Error> { d.read_struct("SourceFile", 8, |d| { let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?; - let name_was_remapped: bool = - d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?; let src_hash: SourceFileHash = d.read_struct_field("src_hash", 2, |d| Decodable::decode(d))?; let start_pos: BytePos = @@ -1278,8 +1269,6 @@ impl<D: Decoder> Decodable<D> for SourceFile { let cnum: CrateNum = d.read_struct_field("cnum", 10, |d| Decodable::decode(d))?; Ok(SourceFile { name, - name_was_remapped, - unmapped_path: None, start_pos, end_pos, src: None, @@ -1307,8 +1296,6 @@ impl fmt::Debug for SourceFile { impl SourceFile { pub fn new( name: FileName, - name_was_remapped: bool, - unmapped_path: FileName, mut src: String, start_pos: BytePos, hash_kind: SourceFileHashAlgorithm, @@ -1330,8 +1317,6 @@ impl SourceFile { SourceFile { name, - name_was_remapped, - unmapped_path: Some(unmapped_path), src: Some(Lrc::new(src)), src_hash, external_src: Lock::new(ExternalSource::Unneeded), diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index f612d1425b9..03be11f828b 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -15,11 +15,11 @@ pub use crate::*; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::{AtomicU32, Lrc, MappedReadGuard, ReadGuard, RwLock}; -use std::cmp; -use std::convert::TryFrom; use std::hash::Hash; use std::path::{Path, PathBuf}; use std::sync::atomic::Ordering; +use std::{clone::Clone, cmp}; +use std::{convert::TryFrom, unreachable}; use std::fs; use std::io; @@ -127,30 +127,16 @@ pub struct StableSourceFileId(u128); // StableSourceFileId, perhaps built atop source_file.name_hash. impl StableSourceFileId { pub fn new(source_file: &SourceFile) -> StableSourceFileId { - StableSourceFileId::new_from_pieces( - &source_file.name, - source_file.name_was_remapped, - source_file.unmapped_path.as_ref(), - ) + StableSourceFileId::new_from_name(&source_file.name) } - fn new_from_pieces( - name: &FileName, - name_was_remapped: bool, - unmapped_path: Option<&FileName>, - ) -> StableSourceFileId { + fn new_from_name(name: &FileName) -> StableSourceFileId { let mut hasher = StableHasher::new(); - if let FileName::Real(real_name) = name { - // rust-lang/rust#70924: Use the stable (virtualized) name when - // available. (We do not want artifacts from transient file system - // paths for libstd to leak into our build artifacts.) - real_name.stable_name().hash(&mut hasher) - } else { - name.hash(&mut hasher); - } - name_was_remapped.hash(&mut hasher); - unmapped_path.hash(&mut hasher); + // If name was remapped, we need to take both the local path + // and stablised path into account, in case two different paths were + // mapped to the same + name.hash(&mut hasher); StableSourceFileId(hasher.finish()) } @@ -283,35 +269,15 @@ impl SourceMap { fn try_new_source_file( &self, - mut filename: FileName, + filename: FileName, src: String, ) -> Result<Lrc<SourceFile>, OffsetOverflowError> { - // The path is used to determine the directory for loading submodules and - // include files, so it must be before remapping. // Note that filename may not be a valid path, eg it may be `<anon>` etc, // but this is okay because the directory determined by `path.pop()` will // be empty, so the working directory will be used. - let unmapped_path = filename.clone(); - - let was_remapped; - if let FileName::Real(real_filename) = &mut filename { - match real_filename { - RealFileName::Named(path_to_be_remapped) - | RealFileName::Devirtualized { - local_path: path_to_be_remapped, - virtual_name: _, - } => { - let mapped = self.path_mapping.map_prefix(path_to_be_remapped.clone()); - was_remapped = mapped.1; - *path_to_be_remapped = mapped.0; - } - } - } else { - was_remapped = false; - } + let (filename, _) = self.path_mapping.map_filename_prefix(&filename); - let file_id = - StableSourceFileId::new_from_pieces(&filename, was_remapped, Some(&unmapped_path)); + let file_id = StableSourceFileId::new_from_name(&filename); let lrc_sf = match self.source_file_by_stable_id(file_id) { Some(lrc_sf) => lrc_sf, @@ -320,8 +286,6 @@ impl SourceMap { let source_file = Lrc::new(SourceFile::new( filename, - was_remapped, - unmapped_path, src, Pos::from_usize(start_pos), self.hash_kind, @@ -345,7 +309,6 @@ impl SourceMap { pub fn new_imported_source_file( &self, filename: FileName, - name_was_remapped: bool, src_hash: SourceFileHash, name_hash: u128, source_len: usize, @@ -382,8 +345,6 @@ impl SourceMap { let source_file = Lrc::new(SourceFile { name: filename, - name_was_remapped, - unmapped_path: None, src: None, src_hash, external_src: Lock::new(ExternalSource::Foreign { @@ -474,14 +435,6 @@ impl SourceMap { self.lookup_char_pos(sp.lo()).file.name.clone() } - pub fn span_to_unmapped_path(&self, sp: Span) -> FileName { - self.lookup_char_pos(sp.lo()) - .file - .unmapped_path - .clone() - .expect("`SourceMap::span_to_unmapped_path` called for imported `SourceFile`?") - } - pub fn is_multiline(&self, sp: Span) -> bool { let lo = self.lookup_char_pos(sp.lo()); let hi = self.lookup_char_pos(sp.hi()); @@ -1046,9 +999,26 @@ impl FilePathMapping { fn map_filename_prefix(&self, file: &FileName) -> (FileName, bool) { match file { FileName::Real(realfile) => { - let path = realfile.local_path(); - let (path, mapped) = self.map_prefix(path.to_path_buf()); - (FileName::Real(RealFileName::Named(path)), mapped) + // If the file is the Name variant with only local_path, then clearly we want to map that + // to a virtual_name + // If the file is already remapped, then we want to map virtual_name further + // but we leave local_path alone + let path = realfile.stable_name(); + let (mapped_path, mapped) = self.map_prefix(path.to_path_buf()); + if mapped { + let mapped_realfile = match realfile { + RealFileName::LocalPath(local_path) + | RealFileName::Remapped { local_path, virtual_name: _ } => { + RealFileName::Remapped { + local_path: local_path.clone(), + virtual_name: mapped_path, + } + } + }; + (FileName::Real(mapped_realfile), mapped) + } else { + unreachable!("attempted to remap an already remapped filename"); + } } other => (other.clone(), false), } diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs index 7d814f1d82c..ee87ef0b5e5 100644 --- a/compiler/rustc_span/src/source_map/tests.rs +++ b/compiler/rustc_span/src/source_map/tests.rs @@ -229,7 +229,6 @@ fn t10() { let SourceFile { name, - name_was_remapped, src_hash, start_pos, end_pos, @@ -243,7 +242,6 @@ fn t10() { let imported_src_file = sm.new_imported_source_file( name, - name_was_remapped, src_hash, name_hash, (end_pos - start_pos).to_usize(), diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 466d1b65406..9b945cd42cf 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -883,8 +883,6 @@ impl Tester for Collector { self.compiling_test_count.fetch_add(1, Ordering::SeqCst); } - // FIXME(#44940): if doctests ever support path remapping, then this filename - // needs to be the result of `SourceMap::span_to_unmapped_path`. let path = match &filename { FileName::Real(path) => path.local_path().to_path_buf(), _ => PathBuf::from(r"doctest.rs"), diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 8ca6342462f..88e369e1bab 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -66,12 +66,7 @@ impl JsonRenderer<'_> { let hi = span.hi(self.sess()); let lo = span.lo(self.sess()); Some(Span { - filename: match name { - rustc_span::RealFileName::Named(path) => path, - rustc_span::RealFileName::Devirtualized { local_path, virtual_name: _ } => { - local_path - } - }, + filename: name.into_local_path(), begin: (lo.line, lo.col.to_usize()), end: (hi.line, hi.col.to_usize()), }) |
