pub struct Fingerprint {
Show 14 fields rustc: u64, 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.

§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§

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.

Compares this fingerprint with an old version which was previously serialized to filesystem.

The purpose of this is exclusively to produce a diagnostic message indicating why we’re recompiling something. This function always returns an error, it will never return success.

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§

Deserialize this value from the given Serde deserializer. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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: 296 bytes