@@ -42,9 +42,9 @@ pub fn dep_graph_tcx_init<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
4242 }
4343
4444 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) {
4646 // 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 ) ;
4848 let work_products: Vec < SerializedWorkProduct > =
4949 RustcDecodable :: decode ( & mut work_product_decoder) . unwrap_or_else ( |e| {
5050 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>) {
7777 }
7878}
7979
80- fn load_data ( sess : & Session , path : & Path ) -> Option < Vec < u8 > > {
80+ fn load_data ( sess : & Session , path : & Path ) -> Option < ( Vec < u8 > , usize ) > {
8181 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 ) ,
8383 Ok ( None ) => {
8484 // The file either didn't exist or was produced by an incompatible
8585 // compiler version. Neither is an error.
@@ -126,8 +126,8 @@ pub fn load_prev_metadata_hashes(tcx: TyCtxt) -> DefIdMap<Fingerprint> {
126126
127127 debug ! ( "load_prev_metadata_hashes() - File: {}" , file_path. display( ) ) ;
128128
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 ,
131131 Ok ( None ) => {
132132 debug ! ( "load_prev_metadata_hashes() - File produced by incompatible \
133133 compiler version: {}", file_path. display( ) ) ;
@@ -141,7 +141,7 @@ pub fn load_prev_metadata_hashes(tcx: TyCtxt) -> DefIdMap<Fingerprint> {
141141 } ;
142142
143143 debug ! ( "load_prev_metadata_hashes() - Decoding hashes" ) ;
144- let mut decoder = Decoder :: new ( & data, 0 ) ;
144+ let mut decoder = Decoder :: new ( & data, start_pos ) ;
145145 let _ = Svh :: decode ( & mut decoder) . unwrap ( ) ;
146146 let serialized_hashes = SerializedMetadataHashes :: decode ( & mut decoder) . unwrap ( ) ;
147147
@@ -171,8 +171,8 @@ pub fn load_dep_graph(sess: &Session) -> PreviousDepGraph {
171171 return empty
172172 }
173173
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 ) ;
176176 let prev_commandline_args_hash = u64:: decode ( & mut decoder)
177177 . expect ( "Error reading commandline arg hash from cached dep-graph" ) ;
178178
@@ -184,6 +184,10 @@ pub fn load_dep_graph(sess: &Session) -> PreviousDepGraph {
184184 // We can't reuse the cache, purge it.
185185 debug ! ( "load_dep_graph_new: differing commandline arg hashes" ) ;
186186
187+ delete_all_session_dir_contents ( sess)
188+ . expect ( "Failed to delete invalidated incr. comp. session \
189+ directory contents.") ;
190+
187191 // No need to do any further work
188192 return empty
189193 }
@@ -202,8 +206,8 @@ pub fn load_query_result_cache<'sess>(sess: &'sess Session) -> OnDiskCache<'sess
202206 return OnDiskCache :: new_empty ( sess. codemap ( ) ) ;
203207 }
204208
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 )
207211 } else {
208212 OnDiskCache :: new_empty ( sess. codemap ( ) )
209213 }
0 commit comments