File tree 2 files changed +13
-1
lines changed
compiler/rustc_serialize/src
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,16 @@ pub struct FileEncoder {
38
38
39
39
impl FileEncoder {
40
40
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
+
41
46
Ok ( FileEncoder {
42
47
buf : vec ! [ 0u8 ; BUF_SIZE ] . into_boxed_slice ( ) . try_into ( ) . unwrap ( ) ,
43
48
buffered : 0 ,
44
49
flushed : 0 ,
45
- file : File :: create ( path ) ? ,
50
+ file,
46
51
res : Ok ( ( ) ) ,
47
52
} )
48
53
}
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