Struct cargo::core::compiler::fingerprint::Fingerprint

source ·
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

source

fn new() -> Fingerprint

source

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.

source

fn hash_u64(&self) -> u64

source

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.

source

fn check_filesystem( &mut self, mtime_cache: &mut HashMap<PathBuf, FileTime>, 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

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for Fingerprint

source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Serialize for Fingerprint

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer ) -> Result<(), ErrorImpl>

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where 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: 320 bytes