pub struct RealFileName {
pub(crate) local: Option<InnerRealFileName>,
pub(crate) maybe_remapped: InnerRealFileName,
pub(crate) scopes: RemapPathScopeComponents,
}Expand description
A self-contained “real” filename.
It is produced by SourceMap::to_real_filename.
RealFileName represents a filename that may have been (partly) remapped
by --remap-path-prefix and -Zremap-path-scope.
It also contains an embedabble component which gives a working directory and a maybe-remapped maybe-aboslote name. This is useful for debuginfo where some formats and tools highly prefer absolute paths.
§Consistency across compiler sessions
The type-system, const-eval and other parts of the compiler rely on FileName
and by extension RealFileName to be consistent across compiler sessions.
Otherwise unsoudness (like rust-lang/rust#148328) may occur.
As such this type is self-sufficient and consistent in it’s output.
The RealFileName::path and RealFileName::embeddable_name methods
are guaranteed to always return the same output across compiler sessions.
§Usage
Creation of a RealFileName should be done using
FilePathMapping::to_real_filename.
Retrieving a path can be done in two main ways:
- by using
RealFileName::pathwith a given scope (should be preferred) - or by using
RealFileName::embeddable_namewith a given scope
Fields§
§local: Option<InnerRealFileName>The local name (always present in the original crate)
maybe_remapped: InnerRealFileNameThe maybe remapped part. Correspond to local when no remapped happened.
scopes: RemapPathScopeComponentsThe remapped scopes. Any active scope MUST use maybe_virtual
Implementations§
Source§impl RealFileName
impl RealFileName
Sourcepub fn path(&self, scope: RemapPathScopeComponents) -> &Path
pub fn path(&self, scope: RemapPathScopeComponents) -> &Path
Returns the associated path for the given remapping scope.
§Panic
Only one scope components can be given to this function.
Sourcepub fn embeddable_name(&self, scope: RemapPathScopeComponents) -> (&Path, &Path)
pub fn embeddable_name(&self, scope: RemapPathScopeComponents) -> (&Path, &Path)
Returns the working directory and embeddable path for the given remapping scope.
Useful for embedding a mostly abosolute path (modulo remapping) in the compiler outputs.
The embedabble path is not guaranteed to be an absolute path, nor is it garuenteed that the working directory part is always a prefix of embeddable path.
§Panic
Only one scope components can be given to this function.
Sourcepub fn local_path(&self) -> Option<&Path>
pub fn local_path(&self) -> Option<&Path>
Returns the path suitable for reading from the file system on the local host, if this information exists.
May not exists if the filename was imported from another crate.
Sourcepub fn into_local_path(self) -> Option<PathBuf>
pub fn into_local_path(self) -> Option<PathBuf>
Returns the path suitable for reading from the file system on the local host, if this information exists.
May not exists if the filename was imported from another crate.
Sourcepub(crate) fn was_remapped(&self) -> bool
pub(crate) fn was_remapped(&self) -> bool
Returns whenever the filename was remapped.
Sourcepub fn empty() -> RealFileName
pub fn empty() -> RealFileName
Returns an empty RealFileName
Useful as the working directory input to SourceMap::to_real_filename.
Sourcepub fn from_virtual_path(path: &Path) -> RealFileName
pub fn from_virtual_path(path: &Path) -> RealFileName
Returns a RealFileName that is completely remapped without any local components.
Only exposed for the purpose of -Zsimulate-remapped-rust-src-base.
Sourcepub fn update_for_crate_metadata(&mut self)
pub fn update_for_crate_metadata(&mut self)
Update the filename for encoding in the crate metadata.
Currently it’s about removing the local part when the filename is fully remapped.
Sourcepub(crate) fn to_string_lossy<'a>(
&'a self,
display_pref: FileNameDisplayPreference,
) -> Cow<'a, str>
pub(crate) fn to_string_lossy<'a>( &'a self, display_pref: FileNameDisplayPreference, ) -> Cow<'a, str>
Internal routine to display the filename.
Users should always use the RealFileName::path method or FileName methods instead.
Trait Implementations§
Source§impl Clone for RealFileName
impl Clone for RealFileName
Source§fn clone(&self) -> RealFileName
fn clone(&self) -> RealFileName
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RealFileName
impl Debug for RealFileName
Source§impl<__D: SpanDecoder> Decodable<__D> for RealFileName
impl<__D: SpanDecoder> Decodable<__D> for RealFileName
Source§impl<__E: SpanEncoder> Encodable<__E> for RealFileName
impl<__E: SpanEncoder> Encodable<__E> for RealFileName
Source§impl Hash for RealFileName
impl Hash for RealFileName
Source§impl Ord for RealFileName
impl Ord for RealFileName
Source§impl PartialEq for RealFileName
impl PartialEq for RealFileName
Source§impl PartialOrd for RealFileName
impl PartialOrd for RealFileName
impl Eq for RealFileName
impl StructuralPartialEq for RealFileName
Auto Trait Implementations§
impl DynSend for RealFileName
impl DynSync for RealFileName
impl Freeze for RealFileName
impl RefUnwindSafe for RealFileName
impl Send for RealFileName
impl Sync for RealFileName
impl Unpin for RealFileName
impl UnwindSafe for RealFileName
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoEither for T
impl<T> IntoEither for T
§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 more§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 more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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: 152 bytes