insert dummy 4 bytes to avoid the breaking change

This commit is contained in:
Yoshiki Matsuda 2022-05-02 19:59:30 +09:00
parent e11dd802c1
commit 8d35ff16d2
2 changed files with 6 additions and 1 deletions

View File

@ -682,7 +682,7 @@ impl MetadataBlob {
}
pub(crate) fn get_rustc_version(&self) -> String {
LazyValue::<String>::from_position(NonZeroUsize::new(METADATA_HEADER.len()).unwrap())
LazyValue::<String>::from_position(NonZeroUsize::new(METADATA_HEADER.len() + 4).unwrap())
.decode(self)
}

View File

@ -2221,6 +2221,11 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: impl AsRef<Path>) {
.unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to create file encoder: {}", err)));
encoder.emit_raw_bytes(METADATA_HEADER);
// Though we had holded the root position historically in this place, we moved it to the end
// of all emitted bytes by #96544. Therefore, now these 4 bytes are just a dummy to avoid the
// breaking change.
encoder.emit_raw_bytes(&[0, 0, 0, 0]).unwrap();
let source_map_files = tcx.sess.source_map().files();
let source_file_cache = (source_map_files[0].clone(), 0);
let required_source_files = Some(GrowableBitSet::with_capacity(source_map_files.len()));