File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
compiler/rustc_serialize/src Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,16 @@ pub struct FileEncoder {
3838
3939impl FileEncoder {
4040 pub fn new < P : AsRef < Path > > ( path : P ) -> io:: Result < Self > {
41+ // File::create opens the file for writing only. When -Zmeta-stats is enabled, the metadata
42+ // encoder rewinds the file to inspect what was written. So we need to always open the file
43+ // for reading and writing.
44+ let file = File :: options ( ) . read ( true ) . write ( true ) . create ( true ) . truncate ( true ) . open ( path) ?;
45+
4146 Ok ( FileEncoder {
4247 buf : vec ! [ 0u8 ; BUF_SIZE ] . into_boxed_slice ( ) . try_into ( ) . unwrap ( ) ,
4348 buffered : 0 ,
4449 flushed : 0 ,
45- file : File :: create ( path ) ? ,
50+ file,
4651 res : Ok ( ( ) ) ,
4752 } )
4853 }
Original file line number Diff line number Diff line change 1+ // build-pass
2+ // dont-check-compiler-stderr
3+ // compile-flags: -Zmeta-stats
4+
5+ #![ crate_type = "lib" ]
6+
7+ pub fn a ( ) { }
You can’t perform that action at this time.
0 commit comments