@@ -105,22 +105,21 @@ impl AbsoluteBytePos {
105105
106106impl < ' sess > OnDiskCache < ' sess > {
107107 /// Creates a new OnDiskCache instance from the serialized data in `data`.
108- pub fn new ( sess : & ' sess Session , data : Vec < u8 > , start_pos : usize ) -> OnDiskCache < ' sess > {
108+ pub fn new ( sess : & ' sess Session , data : Vec < u8 > ) -> OnDiskCache < ' sess > {
109109 debug_assert ! ( sess. opts. incremental. is_some( ) ) ;
110110
111111 // Wrapping in a scope so we can borrow `data`
112112 let footer: Footer = {
113- let mut decoder = opaque:: Decoder :: new ( & data[ ..] , start_pos) ;
114-
115113 // Decode the *position* of the footer which can be found in the
116114 // last 8 bytes of the file.
117- decoder. set_position ( data. len ( ) - IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
115+ let mut decoder = opaque:: Decoder :: new (
116+ & data, data. len ( ) - IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
118117 let query_result_index_pos = IntEncodedWithFixedSize :: decode ( & mut decoder)
119118 . expect ( "Error while trying to decode query result index position." )
120119 . 0 as usize ;
121120
122121 // Decoder the file footer which contains all the lookup tables, etc.
123- decoder. set_position ( query_result_index_pos) ;
122+ decoder = opaque :: Decoder :: new ( & data , query_result_index_pos) ;
124123 decode_tagged ( & mut decoder, TAG_FILE_FOOTER )
125124 . expect ( "Error while trying to decode query result index position." )
126125 } ;
@@ -540,7 +539,7 @@ impl<'a, 'tcx: 'a, 'x> ty_codec::TyDecoder<'a, 'tcx> for CacheDecoder<'a, 'tcx,
540539
541540 #[ inline]
542541 fn peek_byte ( & self ) -> u8 {
543- self . opaque . data [ self . opaque . position ( ) ]
542+ self . opaque . data ( ) [ 0 ]
544543 }
545544
546545 fn cached_ty_for_shorthand < F > ( & mut self ,
@@ -569,9 +568,9 @@ impl<'a, 'tcx: 'a, 'x> ty_codec::TyDecoder<'a, 'tcx> for CacheDecoder<'a, 'tcx,
569568 fn with_position < F , R > ( & mut self , pos : usize , f : F ) -> R
570569 where F : FnOnce ( & mut Self ) -> R
571570 {
572- debug_assert ! ( pos < self . opaque. data . len( ) ) ;
571+ debug_assert ! ( pos < self . opaque. original_data . len( ) ) ;
573572
574- let new_opaque = opaque:: Decoder :: new ( self . opaque . data , pos) ;
573+ let new_opaque = opaque:: Decoder :: new ( & self . opaque . original_data , pos) ;
575574 let old_opaque = mem:: replace ( & mut self . opaque , new_opaque) ;
576575 let r = f ( self ) ;
577576 self . opaque = old_opaque;
0 commit comments