Skip to content

Commit 3f377d3

Browse files
authored
Rollup merge of #101014 - isikkema:fix-zmeta-stats-file-encoder-no-read-perms, r=isikkema
Fix -Zmeta-stats ICE by giving `FileEncoder` file read permissions Fixes #101001 As far as I can tell, #101001 is caused because the file is being created with write-only permissions here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_serialize/src/opaque.rs#L196 but it is trying to be read here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_metadata/src/rmeta/encoder.rs#L780 This PR attempts to fix this by creating/opening the file with the same permissions as `File::create()` with the addition of read.
2 parents 14b27cf + a2cb8a4 commit 3f377d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/rustc_serialize/src/opaque.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ impl FileEncoder {
193193
// shaves an instruction off those code paths (on x86 at least).
194194
assert!(capacity <= usize::MAX - max_leb128_len());
195195

196-
let file = File::create(path)?;
196+
// Create the file for reading and writing, because some encoders do both
197+
// (e.g. the metadata encoder when -Zmeta-stats is enabled)
198+
let file = File::options().read(true).write(true).create(true).truncate(true).open(path)?;
197199

198200
Ok(FileEncoder {
199201
buf: Box::new_uninit_slice(capacity),

0 commit comments

Comments
 (0)