summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-05-08 04:12:38 -0500
committerjyn <github@jyn.dev>2023-05-17 23:54:21 -0500
commitd5f2b8e5c65b0406254b990296793f664c1926a0 (patch)
tree7245f2f921a806ae8fc6dad29d543af26ab0f452 /compiler/rustc_span/src
parent0dddad0dc5d614f799d7e04de4895e7a7418eccb (diff)
downloadrust-d5f2b8e5c65b0406254b990296793f664c1926a0.tar.gz
rust-d5f2b8e5c65b0406254b990296793f664c1926a0.zip
Only depend on CFG_VERSION in rustc_interface
this avoids having to rebuild the whole compiler on each commit when
`omit-git-hash = false`.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/def_id.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index 8c58b52a5dc..f65a6aa4fb2 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -146,7 +146,12 @@ pub struct StableCrateId(pub(crate) Hash64);
 impl StableCrateId {
     /// Computes the stable ID for a crate with the given name and
     /// `-Cmetadata` arguments.
-    pub fn new(crate_name: Symbol, is_exe: bool, mut metadata: Vec<String>) -> StableCrateId {
+    pub fn new(
+        crate_name: Symbol,
+        is_exe: bool,
+        mut metadata: Vec<String>,
+        cfg_version: &'static str,
+    ) -> StableCrateId {
         let mut hasher = StableHasher::new();
         // We must hash the string text of the crate name, not the id, as the id is not stable
         // across builds.
@@ -180,7 +185,7 @@ impl StableCrateId {
         if let Some(val) = std::env::var_os("RUSTC_FORCE_RUSTC_VERSION") {
             hasher.write(val.to_string_lossy().into_owned().as_bytes())
         } else {
-            hasher.write(option_env!("CFG_VERSION").unwrap_or("unknown version").as_bytes());
+            hasher.write(cfg_version.as_bytes())
         }
 
         StableCrateId(hasher.finish())