Skip to content

Commit 263ba92

Browse files
incr.comp.: Fix build issue in rustc_incremental if CFG_VERSION is not set.
1 parent 1e5c253 commit 263ba92

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustc_incremental/persist/file_format.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const HEADER_FORMAT_VERSION: u16 = 0;
3535
/// A version string that hopefully is always different for compiler versions
3636
/// with different encodings of incremental compilation artifacts. Contains
3737
/// the git commit hash.
38-
const RUSTC_VERSION: &'static str = env!("CFG_VERSION");
38+
const RUSTC_VERSION: Option<&'static str> = option_env!("CFG_VERSION");
3939

4040
pub fn write_file_header<W: io::Write>(stream: &mut W) -> io::Result<()> {
4141
stream.write_all(FILE_MAGIC)?;
@@ -98,7 +98,7 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
9898
buffer.resize(rustc_version_str_len, 0);
9999
file.read_exact(&mut buffer[..])?;
100100

101-
if &buffer[..] != RUSTC_VERSION.as_bytes() {
101+
if &buffer[..] != rustc_version().as_bytes() {
102102
return Ok(None);
103103
}
104104
}
@@ -116,5 +116,7 @@ fn rustc_version() -> String {
116116
}
117117
}
118118

119-
RUSTC_VERSION.to_string()
119+
RUSTC_VERSION.expect("Cannot use rustc without explicit version for \
120+
incremental compilation")
121+
.to_string()
120122
}

0 commit comments

Comments
 (0)