1
Fork 0

Add a footer in FileEncoder and check for it in MemDecoder

This commit is contained in:
Ben Kimock 2024-05-03 21:17:57 -04:00
parent 39e02f1bd1
commit 95150d7246
16 changed files with 115 additions and 52 deletions

View file

@ -195,6 +195,7 @@ pub enum CodegenErrors {
EmptyVersionNumber,
EncodingVersionMismatch { version_array: String, rlink_version: u32 },
RustcVersionMismatch { rustc_version: String },
CorruptFile,
}
pub fn provide(providers: &mut Providers) {
@ -265,7 +266,9 @@ impl CodegenResults {
});
}
let mut decoder = MemDecoder::new(&data[4..], 0);
let Some(mut decoder) = MemDecoder::new(&data[4..], 0) else {
return Err(CodegenErrors::CorruptFile);
};
let rustc_version = decoder.read_str();
if rustc_version != sess.cfg_version {
return Err(CodegenErrors::RustcVersionMismatch {