7878//! [`CompileKind`] (host/target) | ✓ | ✓ | ✓ | ✓
7979//! `__CARGO_DEFAULT_LIB_METADATA`[^4] | | ✓ | ✓ | ✓
8080//! `package_id` | | ✓ | ✓ | ✓
81- //! authors, description, homepage, repo | ✓ | | |
8281//! Target src path relative to ws | ✓ | | |
8382//! Target flags (test/bench/for_host/edition) | ✓ | | |
8483//! -C incremental=… flag | ✓ | | |
189188//! files to learn about environment variables that the rustc compile depends on.
190189//! Cargo then later uses this to trigger a recompile if a referenced env var
191190//! changes (even if the source didn't change).
191+ //! This also includes env vars generated from Cargo metadata like `CARGO_PKG_DESCRIPTION`.
192+ //! (See [`crate::core::manifest::ManifestMetadata`]
192193//!
193194//! #### dep-info files for build system integration.
194195//!
@@ -612,10 +613,6 @@ pub struct Fingerprint {
612613 memoized_hash : Mutex < Option < u64 > > ,
613614 /// RUSTFLAGS/RUSTDOCFLAGS environment variable value (or config value).
614615 rustflags : Vec < String > ,
615- /// Hash of some metadata from the manifest, such as "authors", or
616- /// "description", which are exposed as environment variables during
617- /// compilation.
618- metadata : u64 ,
619616 /// Hash of various config settings that change how things are compiled.
620617 config : u64 ,
621618 /// The rustc target. This is only relevant for `.json` files, otherwise
@@ -831,11 +828,12 @@ impl LocalFingerprint {
831828 & self ,
832829 mtime_cache : & mut HashMap < PathBuf , FileTime > ,
833830 checksum_cache : & mut HashMap < PathBuf , Checksum > ,
834- pkg_root : & Path ,
831+ pkg : & Package ,
835832 target_root : & Path ,
836833 cargo_exe : & Path ,
837834 gctx : & GlobalContext ,
838835 ) -> CargoResult < Option < StaleItem > > {
836+ let pkg_root = pkg. root ( ) ;
839837 match self {
840838 // We need to parse `dep_info`, learn about the crate's dependencies.
841839 //
@@ -849,6 +847,12 @@ impl LocalFingerprint {
849847 return Ok ( Some ( StaleItem :: MissingFile ( dep_info) ) ) ;
850848 } ;
851849 for ( key, previous) in info. env . iter ( ) {
850+ if let Some ( value) = pkg. manifest ( ) . metadata ( ) . env_var ( key. as_str ( ) ) {
851+ if Some ( value. as_ref ( ) ) == previous. as_deref ( ) {
852+ continue ;
853+ }
854+ }
855+
852856 let current = if key == CARGO_ENV {
853857 Some ( cargo_exe. to_str ( ) . ok_or_else ( || {
854858 format_err ! (
@@ -932,7 +936,6 @@ impl Fingerprint {
932936 local : Mutex :: new ( Vec :: new ( ) ) ,
933937 memoized_hash : Mutex :: new ( None ) ,
934938 rustflags : Vec :: new ( ) ,
935- metadata : 0 ,
936939 config : 0 ,
937940 compile_kind : 0 ,
938941 fs_status : FsStatus :: Stale ,
@@ -995,9 +998,6 @@ impl Fingerprint {
995998 new : self . rustflags . clone ( ) ,
996999 } ;
9971000 }
998- if self . metadata != old. metadata {
999- return DirtyReason :: MetadataChanged ;
1000- }
10011001 if self . config != old. config {
10021002 return DirtyReason :: ConfigSettingsChanged ;
10031003 }
@@ -1142,13 +1142,14 @@ impl Fingerprint {
11421142 & mut self ,
11431143 mtime_cache : & mut HashMap < PathBuf , FileTime > ,
11441144 checksum_cache : & mut HashMap < PathBuf , Checksum > ,
1145- pkg_root : & Path ,
1145+ pkg : & Package ,
11461146 target_root : & Path ,
11471147 cargo_exe : & Path ,
11481148 gctx : & GlobalContext ,
11491149 ) -> CargoResult < ( ) > {
11501150 assert ! ( !self . fs_status. up_to_date( ) ) ;
11511151
1152+ let pkg_root = pkg. root ( ) ;
11521153 let mut mtimes = HashMap :: new ( ) ;
11531154
11541155 // Get the `mtime` of all outputs. Optionally update their mtime
@@ -1249,7 +1250,7 @@ impl Fingerprint {
12491250 if let Some ( item) = local. find_stale_item (
12501251 mtime_cache,
12511252 checksum_cache,
1252- pkg_root ,
1253+ pkg ,
12531254 target_root,
12541255 cargo_exe,
12551256 gctx,
@@ -1279,7 +1280,6 @@ impl hash::Hash for Fingerprint {
12791280 profile,
12801281 ref deps,
12811282 ref local,
1282- metadata,
12831283 config,
12841284 compile_kind,
12851285 ref rustflags,
@@ -1294,7 +1294,6 @@ impl hash::Hash for Fingerprint {
12941294 path,
12951295 profile,
12961296 & * local,
1297- metadata,
12981297 config,
12991298 compile_kind,
13001299 rustflags,
@@ -1445,7 +1444,7 @@ fn calculate(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult
14451444 fingerprint. check_filesystem (
14461445 & mut build_runner. mtime_cache ,
14471446 & mut build_runner. checksum_cache ,
1448- unit. pkg . root ( ) ,
1447+ & unit. pkg ,
14491448 & target_root,
14501449 cargo_exe,
14511450 build_runner. bcx . gctx ,
@@ -1529,9 +1528,6 @@ fn calculate_normal(
15291528 build_runner. lto [ unit] ,
15301529 unit. pkg . manifest ( ) . lint_rustflags ( ) ,
15311530 ) ) ;
1532- // Include metadata since it is exposed as environment variables.
1533- let m = unit. pkg . manifest ( ) . metadata ( ) ;
1534- let metadata = util:: hash_u64 ( ( & m. authors , & m. description , & m. homepage , & m. repository ) ) ;
15351531 let mut config = StableHasher :: new ( ) ;
15361532 if let Some ( linker) = build_runner. compilation . target_linker ( unit. kind ) {
15371533 linker. hash ( & mut config) ;
@@ -1560,7 +1556,6 @@ fn calculate_normal(
15601556 deps,
15611557 local : Mutex :: new ( local) ,
15621558 memoized_hash : Mutex :: new ( None ) ,
1563- metadata,
15641559 config : Hasher :: finish ( & config) ,
15651560 compile_kind,
15661561 rustflags : extra_flags,
0 commit comments