]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_serialize/src/opaque.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / compiler / rustc_serialize / src / opaque.rs
index 5c17ef6ace2d50344173bf9a41de8502aec971bc..f35cc08f4fbfe61eb663c4f53bfd0b0ff8021424 100644 (file)
@@ -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),