From e11dd802c1aa07ed61de2fdc8a7c79bae1e99f0a Mon Sep 17 00:00:00 2001 From: Yoshiki Matsuda Date: Mon, 2 May 2022 16:44:59 +0900 Subject: [PATCH] seek before counting zero bytes --- compiler/rustc_metadata/src/rmeta/encoder.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index fc069a233f3..71642305504 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -40,7 +40,7 @@ use rustc_span::{ use rustc_target::abi::VariantIdx; use std::borrow::Borrow; use std::hash::Hash; -use std::io::{Read, Write}; +use std::io::{Read, Seek, Write}; use std::iter; use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; @@ -735,6 +735,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { if tcx.sess.meta_stats() { let mut zero_bytes = 0; + self.opaque.file().seek(std::io::SeekFrom::Start(0)).unwrap(); let file = std::io::BufReader::new(self.opaque.file()); for e in file.bytes() { if e.unwrap() == 0 {