Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8d35ff1

Browse files
committed
insert dummy 4 bytes to avoid the breaking change
1 parent e11dd80 commit 8d35ff1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl MetadataBlob {
682682
}
683683

684684
pub(crate) fn get_rustc_version(&self) -> String {
685-
LazyValue::<String>::from_position(NonZeroUsize::new(METADATA_HEADER.len()).unwrap())
685+
LazyValue::<String>::from_position(NonZeroUsize::new(METADATA_HEADER.len() + 4).unwrap())
686686
.decode(self)
687687
}
688688

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,11 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: impl AsRef<Path>) {
22212221
.unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to create file encoder: {}", err)));
22222222
encoder.emit_raw_bytes(METADATA_HEADER);
22232223

2224+
// Though we had holded the root position historically in this place, we moved it to the end
2225+
// of all emitted bytes by #96544. Therefore, now these 4 bytes are just a dummy to avoid the
2226+
// breaking change.
2227+
encoder.emit_raw_bytes(&[0, 0, 0, 0]).unwrap();
2228+
22242229
let source_map_files = tcx.sess.source_map().files();
22252230
let source_file_cache = (source_map_files[0].clone(), 0);
22262231
let required_source_files = Some(GrowableBitSet::with_capacity(source_map_files.len()));

0 commit comments

Comments
 (0)