A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.StableSourceFileId.html below:

StableSourceFileId in rustc_span - Rust

Struct StableSourceFileIdSource
pub struct StableSourceFileId(pub(crate) Hash128);
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).

It is a hash value (so we can efficiently consume it when stable-hashing spans) that consists of the FileName and the StableCrateId of the crate the source file is from. The crate id is needed because sometimes the FileName is not unique within the crate graph (think src/lib.rs, for example).

The way the crate-id part is handled is a bit special: source files of the local crate are hashed as (filename, None), while source files from upstream crates have a hash of (filename, Some(stable_crate_id)). This is because SourceFiles for the local crate are allocated very early in the compilation process when the StableCrateId is not yet known. If, due to some refactoring of the compiler, the StableCrateId of the local crate were to become available, it would be better to uniformly make this a hash of (filename, stable_crate_id).

When SourceFiles are exported in crate metadata, the StableSourceFileId is updated to incorporate the StableCrateId of the exporting crate.

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4