seek before counting zero bytes

This commit is contained in:
Yoshiki Matsuda
2022-05-02 16:44:59 +09:00
parent 1ead92dd64
commit e11dd802c1
+2 -1
View File
@@ -40,7 +40,7 @@
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 @@ fn encode_crate_root(&mut self) -> LazyValue<CrateRoot> {
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 {