@@ -17,7 +17,7 @@ use rustc_index::vec::{Idx, IndexVec};
1717use rustc_query_system:: dep_graph:: DepContext ;
1818use rustc_query_system:: query:: QueryContext ;
1919use rustc_serialize:: {
20- opaque:: { self , FileEncodeResult , FileEncoder } ,
20+ opaque:: { self , FileEncodeResult , FileEncoder , IntEncodedWithFixedSize } ,
2121 Decodable , Decoder , Encodable , Encoder ,
2222} ;
2323use rustc_session:: { CrateDisambiguator , Session } ;
@@ -1180,42 +1180,6 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx, FileEncoder>> for [u8] {
11801180 }
11811181}
11821182
1183- // An integer that will always encode to 8 bytes.
1184- struct IntEncodedWithFixedSize ( u64 ) ;
1185-
1186- impl IntEncodedWithFixedSize {
1187- pub const ENCODED_SIZE : usize = 8 ;
1188- }
1189-
1190- impl < E : OpaqueEncoder > Encodable < E > for IntEncodedWithFixedSize {
1191- fn encode ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
1192- let start_pos = e. position ( ) ;
1193- for i in 0 ..IntEncodedWithFixedSize :: ENCODED_SIZE {
1194- ( ( self . 0 >> ( i * 8 ) ) as u8 ) . encode ( e) ?;
1195- }
1196- let end_pos = e. position ( ) ;
1197- assert_eq ! ( ( end_pos - start_pos) , IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
1198- Ok ( ( ) )
1199- }
1200- }
1201-
1202- impl < ' a > Decodable < opaque:: Decoder < ' a > > for IntEncodedWithFixedSize {
1203- fn decode ( decoder : & mut opaque:: Decoder < ' a > ) -> Result < IntEncodedWithFixedSize , String > {
1204- let mut value: u64 = 0 ;
1205- let start_pos = decoder. position ( ) ;
1206-
1207- for i in 0 ..IntEncodedWithFixedSize :: ENCODED_SIZE {
1208- let byte: u8 = Decodable :: decode ( decoder) ?;
1209- value |= ( byte as u64 ) << ( i * 8 ) ;
1210- }
1211-
1212- let end_pos = decoder. position ( ) ;
1213- assert_eq ! ( ( end_pos - start_pos) , IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
1214-
1215- Ok ( IntEncodedWithFixedSize ( value) )
1216- }
1217- }
1218-
12191183pub fn encode_query_results < ' a , ' tcx , CTX , Q > (
12201184 tcx : CTX ,
12211185 encoder : & mut CacheEncoder < ' a , ' tcx , FileEncoder > ,
0 commit comments