Struct rustc_span::source_map::StableSourceFileId
source · pub struct StableSourceFileId {
pub file_name_hash: Hash64,
pub cnum: CrateNum,
}
Expand description
This is a SourceFile identifier that is used to correlate source files between subsequent compilation sessions (which is something we need to do during incremental compilation).
The StableSourceFileId also contains the CrateNum of the crate the source file was originally parsed for. This way we get two separate entries in the SourceMap if the same file is part of both the local and an upstream crate. Trying to only have one entry for both cases is problematic because at the point where we discover that there’s a local use of the file in addition to the upstream one, we might already have made decisions based on the assumption that it’s an upstream file. Treating the two files as different has no real downsides.
Fields§
§file_name_hash: Hash64
A hash of the source file’s FileName
. This is hash so that it’s size
is more predictable than if we included the actual FileName
value.
cnum: CrateNum
The CrateNum
of the crate this source file was originally parsed for.
We cannot include this information in the hash because at the time
of hashing we don’t have the context to map from the CrateNum
’s numeric
value to a StableCrateId
.
Implementations§
source§impl StableSourceFileId
impl StableSourceFileId
pub fn new(source_file: &SourceFile) -> StableSourceFileId
fn new_from_name(name: &FileName, cnum: CrateNum) -> StableSourceFileId
Trait Implementations§
source§impl Clone for StableSourceFileId
impl Clone for StableSourceFileId
source§fn clone(&self) -> StableSourceFileId
fn clone(&self) -> StableSourceFileId
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StableSourceFileId
impl Debug for StableSourceFileId
source§impl<__D: Decoder> Decodable<__D> for StableSourceFileId
impl<__D: Decoder> Decodable<__D> for StableSourceFileId
source§impl<__E: Encoder> Encodable<__E> for StableSourceFileId
impl<__E: Encoder> Encodable<__E> for StableSourceFileId
source§impl Hash for StableSourceFileId
impl Hash for StableSourceFileId
source§impl PartialEq<StableSourceFileId> for StableSourceFileId
impl PartialEq<StableSourceFileId> for StableSourceFileId
source§fn eq(&self, other: &StableSourceFileId) -> bool
fn eq(&self, other: &StableSourceFileId) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for StableSourceFileId
impl Eq for StableSourceFileId
impl StructuralEq for StableSourceFileId
impl StructuralPartialEq for StableSourceFileId
Auto Trait Implementations§
impl RefUnwindSafe for StableSourceFileId
impl Send for StableSourceFileId
impl Sync for StableSourceFileId
impl Unpin for StableSourceFileId
impl UnwindSafe for StableSourceFileId
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
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: 16 bytes