Skip to content

Commit

Permalink
Open the FileEncoder file for reading and writing
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Sep 22, 2023
1 parent f73d376 commit c3c226a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ pub struct FileEncoder {

impl FileEncoder {
pub fn new<P: AsRef<Path>>(path: P) -> io::Result<Self> {
// File::create opens the file for writing only. When -Zmeta-stats is enabled, the metadata
// rewinds the file to inspect what was written. So we need to always open the file for
// reading and writing.
let file = File::options().read(true).write(true).create(true).truncate(true).open(path)?;

Ok(FileEncoder {
buf: vec![0u8; BUF_SIZE].into_boxed_slice().try_into().unwrap(),
buffered: 0,
flushed: 0,
file: File::create(path)?,
file,
res: Ok(()),
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: usize = 1854;
const ROOT_ENTRY_LIMIT: usize = 865;
const ROOT_ENTRY_LIMIT: usize = 867;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/meta-stats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// build-pass
// dont-check-compiler-stderr
// compile-flags: -Zmeta-stats

#![crate_type = "lib"]

pub fn a() {}

0 comments on commit c3c226a

Please sign in to comment.