pub struct Fingerprint {Show 15 fields
rustc: u64,
features: String,
declared_features: String,
target: u64,
profile: u64,
path: u64,
deps: Vec<DepFingerprint>,
local: Mutex<Vec<LocalFingerprint>>,
memoized_hash: Mutex<Option<u64>>,
rustflags: Vec<String>,
metadata: u64,
config: u64,
compile_kind: u64,
fs_status: FsStatus,
outputs: Vec<PathBuf>,
}
Expand description
A fingerprint can be considered to be a “short string” representing the state of a world for a package.
If a fingerprint ever changes, then the package itself needs to be
recompiled. Inputs to the fingerprint include source code modifications,
compiler flags, compiler version, etc. This structure is not simply a
String
due to the fact that some fingerprints cannot be calculated lazily.
Path sources, for example, use the mtime of the corresponding dep-info file
as a fingerprint (all source files must be modified before this mtime).
This dep-info file is not generated, however, until after the crate is
compiled. As a result, this structure can be thought of as a fingerprint
to-be. The actual value can be calculated via hash_u64()
, but the operation
may fail as some files may not have been generated.
Note that dependencies are taken into account for fingerprints because rustc
requires that whenever an upstream crate is recompiled that all downstream
dependents are also recompiled. This is typically tracked through
DependencyQueue
, but it also needs to be retained here because Cargo can
be interrupted while executing, losing the state of the DependencyQueue
graph.
Fields§
§rustc: u64
Hash of the version of rustc
used.
features: String
Sorted list of cfg features enabled.
declared_features: String
Sorted list of all the declared cfg features.
target: u64
Hash of the Target
struct, including the target name,
package-relative source path, edition, etc.
profile: u64
Hash of the Profile
, CompileMode
, and any extra flags passed via
cargo rustc
or cargo rustdoc
.
path: u64
Hash of the path to the base source file. This is relative to the workspace root for path members, or absolute for other sources.
deps: Vec<DepFingerprint>
Fingerprints of dependencies.
local: Mutex<Vec<LocalFingerprint>>
Information about the inputs that affect this Unit (such as source file mtimes or build script environment variables).
memoized_hash: Mutex<Option<u64>>
Cached hash of the Fingerprint
struct. Used to improve performance
for hashing.
rustflags: Vec<String>
RUSTFLAGS/RUSTDOCFLAGS environment variable value (or config value).
metadata: u64
Hash of some metadata from the manifest, such as “authors”, or “description”, which are exposed as environment variables during compilation.
config: u64
Hash of various config settings that change how things are compiled.
compile_kind: u64
The rustc target. This is only relevant for .json
files, otherwise
the metadata hash segregates the units.
fs_status: FsStatus
Description of whether the filesystem status for this unit is up to date or should be considered stale.
outputs: Vec<PathBuf>
Files, relative to target_root
, that are produced by the step that
this Fingerprint
represents. This is used to detect when the whole
fingerprint is out of date if this is missing, or if previous
fingerprints output files are regenerated and look newer than this one.
Implementations§
source§impl Fingerprint
impl Fingerprint
fn new() -> Fingerprint
sourcepub fn clear_memoized(&self)
pub fn clear_memoized(&self)
For performance reasons fingerprints will memoize their own hash, but
there’s also internal mutability with its local
field which can
change, for example with build scripts, during a build.
This method can be used to bust all memoized hashes just before a build to ensure that after a build completes everything is up-to-date.
fn hash_u64(&self) -> u64
sourcefn compare(&self, old: &Fingerprint) -> DirtyReason
fn compare(&self, old: &Fingerprint) -> DirtyReason
Compares this fingerprint with an old version which was previously serialized to filesystem.
The purpose of this is exclusively to produce a diagnostic message
DirtyReason
, indicating why we’re recompiling something.
sourcefn check_filesystem(
&mut self,
mtime_cache: &mut HashMap<PathBuf, FileTime>,
checksum_cache: &mut HashMap<PathBuf, Checksum>,
pkg_root: &Path,
target_root: &Path,
cargo_exe: &Path,
gctx: &GlobalContext,
) -> CargoResult<()>
fn check_filesystem( &mut self, mtime_cache: &mut HashMap<PathBuf, FileTime>, checksum_cache: &mut HashMap<PathBuf, Checksum>, pkg_root: &Path, target_root: &Path, cargo_exe: &Path, gctx: &GlobalContext, ) -> CargoResult<()>
Dynamically inspect the local filesystem to update the fs_status
field
of this Fingerprint
.
This function is used just after a Fingerprint
is constructed to check
the local state of the filesystem and propagate any dirtiness from
dependencies up to this unit as well. This function assumes that the
unit starts out as FsStatus::Stale
and then it will optionally switch
it to UpToDate
if it can.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Fingerprint
impl<'de> Deserialize<'de> for Fingerprint
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Hash for Fingerprint
impl Hash for Fingerprint
Auto Trait Implementations§
impl !Freeze for Fingerprint
impl RefUnwindSafe for Fingerprint
impl Send for Fingerprint
impl Sync for Fingerprint
impl Unpin for Fingerprint
impl UnwindSafe for Fingerprint
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
§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> Pointable for T
impl<T> Pointable for T
source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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: 328 bytes