Skip to content

Commit f7f7d5e

Browse files
committed
Open the FileEncoder file for reading and writing
1 parent f73d376 commit f7f7d5e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

compiler/rustc_serialize/src/opaque.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@ pub struct FileEncoder {
3838

3939
impl FileEncoder {
4040
pub fn new<P: AsRef<Path>>(path: P) -> io::Result<Self> {
41+
// File::create opens the file for writing only. When -Zmeta-stats is enabled, the metadata
42+
// encoder rewinds the file to inspect what was written. So we need to always open the file
43+
// for reading and writing.
44+
let file = File::options().read(true).write(true).create(true).truncate(true).open(path)?;
45+
4146
Ok(FileEncoder {
4247
buf: vec![0u8; BUF_SIZE].into_boxed_slice().try_into().unwrap(),
4348
buffered: 0,
4449
flushed: 0,
45-
file: File::create(path)?,
50+
file,
4651
res: Ok(()),
4752
})
4853
}

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1854;
14-
const ROOT_ENTRY_LIMIT: usize = 865;
14+
const ROOT_ENTRY_LIMIT: usize = 867;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files

tests/ui/stats/meta-stats.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// build-pass
2+
// dont-check-compiler-stderr
3+
// compile-flags: -Zmeta-stats
4+
5+
#![crate_type = "lib"]
6+
7+
pub fn a() {}

0 commit comments

Comments
 (0)