Struct rustc_span::source_map::FilePathMapping
source · pub struct FilePathMapping {
mapping: Vec<(PathBuf, PathBuf)>,
filename_display_for_diagnostics: FileNameDisplayPreference,
}
Fields§
§mapping: Vec<(PathBuf, PathBuf)>
§filename_display_for_diagnostics: FileNameDisplayPreference
Implementations§
source§impl FilePathMapping
impl FilePathMapping
pub fn empty() -> FilePathMapping
pub fn new( mapping: Vec<(PathBuf, PathBuf)>, filename_display_for_diagnostics: FileNameDisplayPreference, ) -> FilePathMapping
sourcepub fn map_prefix<'a>(
&'a self,
path: impl Into<Cow<'a, Path>>,
) -> (Cow<'a, Path>, bool)
pub fn map_prefix<'a>( &'a self, path: impl Into<Cow<'a, Path>>, ) -> (Cow<'a, Path>, bool)
Applies any path prefix substitution as defined by the mapping. The return value is the remapped path and a boolean indicating whether the path was affected by the mapping.
fn map_filename_prefix(&self, file: &FileName) -> (FileName, bool)
sourcepub fn to_real_filename<'a>(
&self,
local_path: impl Into<Cow<'a, Path>>,
) -> RealFileName
pub fn to_real_filename<'a>( &self, local_path: impl Into<Cow<'a, Path>>, ) -> RealFileName
Applies any path prefix substitution as defined by the mapping. The return value is the local path with a “virtual path” representing the remapped part if any remapping was performed.
sourcepub fn to_embeddable_absolute_path(
&self,
file_path: RealFileName,
working_directory: &RealFileName,
) -> RealFileName
pub fn to_embeddable_absolute_path( &self, file_path: RealFileName, working_directory: &RealFileName, ) -> RealFileName
Expand a relative path to an absolute path with remapping taken into account. Use this when absolute paths are required (e.g. debuginfo or crate metadata).
The resulting RealFileName
will have its local_path
portion erased if
possible (i.e. if there’s also a remapped path).
sourcepub fn to_local_embeddable_absolute_path(
&self,
file_path: RealFileName,
working_directory: &RealFileName,
) -> RealFileName
pub fn to_local_embeddable_absolute_path( &self, file_path: RealFileName, working_directory: &RealFileName, ) -> RealFileName
Expand a relative path to an absolute path without remapping taken into account.
The resulting RealFileName
will have its virtual_path
portion erased if
possible (i.e. if there’s also a remapped path).
sourcefn reverse_map_prefix_heuristically(&self, path: &Path) -> Option<PathBuf>
fn reverse_map_prefix_heuristically(&self, path: &Path) -> Option<PathBuf>
Attempts to (heuristically) reverse a prefix mapping.
Returns Some
if there is exactly one mapping where the “to” part is
a prefix of path
and has at least one non-empty
Normal
component. The component
restriction exists to avoid reverse mapping overly generic paths like
/
or .
).
This is a heuristic and not guaranteed to return the actual original path! Do not rely on the result unless you have other means to verify that the mapping is correct (e.g. by checking the file content hash).
Trait Implementations§
source§impl Clone for FilePathMapping
impl Clone for FilePathMapping
source§fn clone(&self) -> FilePathMapping
fn clone(&self) -> FilePathMapping
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl DynSend for FilePathMapping
impl DynSync for FilePathMapping
impl Freeze for FilePathMapping
impl RefUnwindSafe for FilePathMapping
impl Send for FilePathMapping
impl Sync for FilePathMapping
impl Unpin for FilePathMapping
impl UnwindSafe for FilePathMapping
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes