about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2016-09-26 22:26:10 -0400
committerMichael Woerister <michaelwoerister@posteo.net>2016-09-26 22:26:10 -0400
commit263ba920457c9f0ef20d7cb60578d91672eed20e (patch)
treea21eff5e5d719f00e88655a49059732c79895d80 /src
parent1e5c253aa1b0a9f6c753773e3efb7142cfc81638 (diff)
incr.comp.: Fix build issue in rustc_incremental if CFG_VERSION is not set.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_incremental/persist/file_format.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc_incremental/persist/file_format.rs b/src/librustc_incremental/persist/file_format.rs
index 274e05255b9..7c2b69e762b 100644
--- a/src/librustc_incremental/persist/file_format.rs
+++ b/src/librustc_incremental/persist/file_format.rs
@@ -35,7 +35,7 @@ const HEADER_FORMAT_VERSION: u16 = 0;
 /// A version string that hopefully is always different for compiler versions
 /// with different encodings of incremental compilation artifacts. Contains
 /// the git commit hash.
-const RUSTC_VERSION: &'static str = env!("CFG_VERSION");
+const RUSTC_VERSION: Option<&'static str> = option_env!("CFG_VERSION");
 
 pub fn write_file_header<W: io::Write>(stream: &mut W) -> io::Result<()> {
     stream.write_all(FILE_MAGIC)?;
@@ -98,7 +98,7 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
         buffer.resize(rustc_version_str_len, 0);
         file.read_exact(&mut buffer[..])?;
 
-        if &buffer[..] != RUSTC_VERSION.as_bytes() {
+        if &buffer[..] != rustc_version().as_bytes() {
             return Ok(None);
         }
     }
@@ -116,5 +116,7 @@ fn rustc_version() -> String {
         }
     }
 
-    RUSTC_VERSION.to_string()
+    RUSTC_VERSION.expect("Cannot use rustc without explicit version for \
+                          incremental compilation")
+                 .to_string()
 }