diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-09-22 23:12:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 23:12:38 +0200 |
| commit | efee13ab33572c3f8ea2eb88886d15c8a13c4d0b (patch) | |
| tree | f72425fe9604134b1329d39ed0ebc74b0b73fe3e | |
| parent | 952d6608fc9678bfc681d3bb33d7c09fdf6a69d6 (diff) | |
| parent | 09960e03194626738b3533b6c2d06a0c505117d3 (diff) | |
| download | rust-efee13ab33572c3f8ea2eb88886d15c8a13c4d0b.tar.gz rust-efee13ab33572c3f8ea2eb88886d15c8a13c4d0b.zip | |
Rollup merge of #116067 - saethlin:meta-stats-ice, r=WaffleLapkin
Open the FileEncoder file for reading and writing Maybe I just don't know `File` well enough, but the previous comment didn't make it clear enough to me that we can't use `File::create`. This one does. Fixes https://github.com/rust-lang/rust/issues/116055 r? `@WaffleLapkin`
| -rw-r--r-- | compiler/rustc_serialize/src/opaque.rs | 7 | ||||
| -rw-r--r-- | tests/ui/stats/meta-stats.rs | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 44855ae629c..55255439051 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<P: AsRef<Path>>(path: P) -> io::Result<Self> { + // File::create opens the file for writing only. When -Zmeta-stats is enabled, the metadata + // encoder 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/tests/ui/stats/meta-stats.rs b/tests/ui/stats/meta-stats.rs new file mode 100644 index 00000000000..2d38e088286 --- /dev/null +++ b/tests/ui/stats/meta-stats.rs @@ -0,0 +1,7 @@ +// build-pass +// dont-check-compiler-stderr +// compile-flags: -Zmeta-stats + +#![crate_type = "lib"] + +pub fn a() {} |
