Skip to content

Commit

Permalink
incr.comp.: Fix build issue in rustc_incremental if CFG_VERSION is no…
Browse files Browse the repository at this point in the history
…t set.
  • Loading branch information
michaelwoerister committed Sep 27, 2016
1 parent 1e5c253 commit 263ba92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/librustc_incremental/persist/file_format.rs
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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()
}

0 comments on commit 263ba92

Please sign in to comment.