@@ -13,6 +13,15 @@ use crate::core::compiler::{CompileMode, CompileTarget, CrateType, FileType, Uni
13
13
use crate :: core:: { Target , TargetKind , Workspace } ;
14
14
use crate :: util:: { self , CargoResult , StableHasher } ;
15
15
16
+ /// This is a generic version number that can be changed to make
17
+ /// backwards-incompatible changes to any file structures in the output
18
+ /// directory. For example, the fingerprint files or the build-script
19
+ /// output files. Normally cargo updates ship with rustc updates which will
20
+ /// cause a new hash due to the rustc version changing, but this allows
21
+ /// cargo to be extra careful to deal with different versions of cargo that
22
+ /// use the same rustc version.
23
+ const METADATA_VERSION : u8 = 2 ;
24
+
16
25
/// The `Metadata` is a hash used to make unique file names for each unit in a
17
26
/// build. It is also use for symbol mangling.
18
27
///
@@ -162,7 +171,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
162
171
/// Used for the metadata when `metadata` returns `None`.
163
172
pub fn target_short_hash ( & self , unit : & Unit ) -> String {
164
173
let hashable = unit. pkg . package_id ( ) . stable_hash ( self . ws . root ( ) ) ;
165
- util:: short_hash ( & hashable)
174
+ util:: short_hash ( & ( METADATA_VERSION , hashable) )
166
175
}
167
176
168
177
/// Returns the directory where the artifacts for the given unit are
@@ -483,14 +492,7 @@ fn compute_metadata(
483
492
}
484
493
let mut hasher = StableHasher :: new ( ) ;
485
494
486
- // This is a generic version number that can be changed to make
487
- // backwards-incompatible changes to any file structures in the output
488
- // directory. For example, the fingerprint files or the build-script
489
- // output files. Normally cargo updates ship with rustc updates which will
490
- // cause a new hash due to the rustc version changing, but this allows
491
- // cargo to be extra careful to deal with different versions of cargo that
492
- // use the same rustc version.
493
- 2 . hash ( & mut hasher) ;
495
+ METADATA_VERSION . hash ( & mut hasher) ;
494
496
495
497
// Unique metadata per (name, source, version) triple. This'll allow us
496
498
// to pull crates from anywhere without worrying about conflicts.
0 commit comments