diff options
| author | Michael Howell <michael@notriddle.com> | 2022-09-20 10:12:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-20 10:12:57 -0700 |
| commit | 3f377d3f9670b28abb8b52b3e69b8d76f2eb2c42 (patch) | |
| tree | 89ebc21ba6b6546d288043af4d883d91d6af3772 /compiler/rustc_serialize/src | |
| parent | 14b27cfd11be4285d61415015d0d38e42d401ae3 (diff) | |
| parent | a2cb8a49498c9eab1cf5617135e7de0b3013843b (diff) | |
| download | rust-3f377d3f9670b28abb8b52b3e69b8d76f2eb2c42.tar.gz rust-3f377d3f9670b28abb8b52b3e69b8d76f2eb2c42.zip | |
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.
Diffstat (limited to 'compiler/rustc_serialize/src')
| -rw-r--r-- | compiler/rustc_serialize/src/opaque.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 5c17ef6ace2..f35cc08f4fb 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -193,7 +193,9 @@ impl FileEncoder { // shaves an instruction off those code paths (on x86 at least). assert!(capacity <= usize::MAX - max_leb128_len()); - let file = File::create(path)?; + // Create the file for reading and writing, because some encoders do both + // (e.g. the metadata encoder when -Zmeta-stats is enabled) + let file = File::options().read(true).write(true).create(true).truncate(true).open(path)?; Ok(FileEncoder { buf: Box::new_uninit_slice(capacity), |
