@@ -42,9 +42,9 @@ pub fn dep_graph_tcx_init<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
42
42
}
43
43
44
44
let work_products_path = work_products_path ( tcx. sess ) ;
45
- if let Some ( work_products_data) = load_data ( tcx. sess , & work_products_path) {
45
+ if let Some ( ( work_products_data, start_pos ) ) = load_data ( tcx. sess , & work_products_path) {
46
46
// Decode the list of work_products
47
- let mut work_product_decoder = Decoder :: new ( & work_products_data[ ..] , 0 ) ;
47
+ let mut work_product_decoder = Decoder :: new ( & work_products_data[ ..] , start_pos ) ;
48
48
let work_products: Vec < SerializedWorkProduct > =
49
49
RustcDecodable :: decode ( & mut work_product_decoder) . unwrap_or_else ( |e| {
50
50
let msg = format ! ( "Error decoding `work-products` from incremental \
@@ -77,9 +77,9 @@ pub fn dep_graph_tcx_init<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
77
77
}
78
78
}
79
79
80
- fn load_data ( sess : & Session , path : & Path ) -> Option < Vec < u8 > > {
80
+ fn load_data ( sess : & Session , path : & Path ) -> Option < ( Vec < u8 > , usize ) > {
81
81
match file_format:: read_file ( sess, path) {
82
- Ok ( Some ( data ) ) => return Some ( data ) ,
82
+ Ok ( Some ( data_and_pos ) ) => return Some ( data_and_pos ) ,
83
83
Ok ( None ) => {
84
84
// The file either didn't exist or was produced by an incompatible
85
85
// compiler version. Neither is an error.
@@ -126,8 +126,8 @@ pub fn load_prev_metadata_hashes(tcx: TyCtxt) -> DefIdMap<Fingerprint> {
126
126
127
127
debug ! ( "load_prev_metadata_hashes() - File: {}" , file_path. display( ) ) ;
128
128
129
- let data = match file_format:: read_file ( tcx. sess , & file_path) {
130
- Ok ( Some ( data ) ) => data ,
129
+ let ( data, start_pos ) = match file_format:: read_file ( tcx. sess , & file_path) {
130
+ Ok ( Some ( data_and_pos ) ) => data_and_pos ,
131
131
Ok ( None ) => {
132
132
debug ! ( "load_prev_metadata_hashes() - File produced by incompatible \
133
133
compiler version: {}", file_path. display( ) ) ;
@@ -141,7 +141,7 @@ pub fn load_prev_metadata_hashes(tcx: TyCtxt) -> DefIdMap<Fingerprint> {
141
141
} ;
142
142
143
143
debug ! ( "load_prev_metadata_hashes() - Decoding hashes" ) ;
144
- let mut decoder = Decoder :: new ( & data, 0 ) ;
144
+ let mut decoder = Decoder :: new ( & data, start_pos ) ;
145
145
let _ = Svh :: decode ( & mut decoder) . unwrap ( ) ;
146
146
let serialized_hashes = SerializedMetadataHashes :: decode ( & mut decoder) . unwrap ( ) ;
147
147
@@ -171,8 +171,8 @@ pub fn load_dep_graph(sess: &Session) -> PreviousDepGraph {
171
171
return empty
172
172
}
173
173
174
- if let Some ( bytes) = load_data ( sess, & dep_graph_path ( sess) ) {
175
- let mut decoder = Decoder :: new ( & bytes, 0 ) ;
174
+ if let Some ( ( bytes, start_pos ) ) = load_data ( sess, & dep_graph_path ( sess) ) {
175
+ let mut decoder = Decoder :: new ( & bytes, start_pos ) ;
176
176
let prev_commandline_args_hash = u64:: decode ( & mut decoder)
177
177
. expect ( "Error reading commandline arg hash from cached dep-graph" ) ;
178
178
@@ -184,6 +184,10 @@ pub fn load_dep_graph(sess: &Session) -> PreviousDepGraph {
184
184
// We can't reuse the cache, purge it.
185
185
debug ! ( "load_dep_graph_new: differing commandline arg hashes" ) ;
186
186
187
+ delete_all_session_dir_contents ( sess)
188
+ . expect ( "Failed to delete invalidated incr. comp. session \
189
+ directory contents.") ;
190
+
187
191
// No need to do any further work
188
192
return empty
189
193
}
@@ -202,8 +206,8 @@ pub fn load_query_result_cache<'sess>(sess: &'sess Session) -> OnDiskCache<'sess
202
206
return OnDiskCache :: new_empty ( sess. codemap ( ) ) ;
203
207
}
204
208
205
- if let Some ( bytes) = load_data ( sess, & query_cache_path ( sess) ) {
206
- OnDiskCache :: new ( sess, & bytes[ ..] )
209
+ if let Some ( ( bytes, start_pos ) ) = load_data ( sess, & query_cache_path ( sess) ) {
210
+ OnDiskCache :: new ( sess, & bytes[ ..] , start_pos )
207
211
} else {
208
212
OnDiskCache :: new_empty ( sess. codemap ( ) )
209
213
}
0 commit comments