diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 44855ae629c13..86bb542ef170a 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -38,11 +38,16 @@ pub struct FileEncoder { impl FileEncoder { pub fn new>(path: P) -> io::Result { + // 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(()), }) } diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 2b828e58d5418..7e24793adee0e 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -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 diff --git a/tests/ui/meta-stats.rs b/tests/ui/meta-stats.rs new file mode 100644 index 0000000000000..2d38e0882866d --- /dev/null +++ b/tests/ui/meta-stats.rs @@ -0,0 +1,7 @@ +// build-pass +// dont-check-compiler-stderr +// compile-flags: -Zmeta-stats + +#![crate_type = "lib"] + +pub fn a() {}