File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
compiler/rustc_codegen_ssa/src Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -276,24 +276,22 @@ impl CodegenResults {
276276 ) -> Result < ( Self , OutputFilenames ) , CodegenErrors > {
277277 // The Decodable machinery is not used here because it panics if the input data is invalid
278278 // and because its internal representation may change.
279- if ! data. starts_with ( RLINK_MAGIC ) {
279+ let Some ( data) = data . strip_prefix ( RLINK_MAGIC ) else {
280280 return Err ( CodegenErrors :: WrongFileType ) ;
281- }
282- let data = & data [ RLINK_MAGIC . len ( ) .. ] ;
283- if data. len ( ) < 4 {
281+ } ;
282+
283+ let Some ( ( & version_array , data) ) = data . split_first_chunk ( ) else {
284284 return Err ( CodegenErrors :: EmptyVersionNumber ) ;
285- }
285+ } ;
286286
287- let mut version_array: [ u8 ; 4 ] = Default :: default ( ) ;
288- version_array. copy_from_slice ( & data[ ..4 ] ) ;
289287 if u32:: from_be_bytes ( version_array) != RLINK_VERSION {
290288 return Err ( CodegenErrors :: EncodingVersionMismatch {
291289 version_array : String :: from_utf8_lossy ( & version_array) . to_string ( ) ,
292290 rlink_version : RLINK_VERSION ,
293291 } ) ;
294292 }
295293
296- let Ok ( mut decoder) = MemDecoder :: new ( & data[ 4 .. ] , 0 ) else {
294+ let Ok ( mut decoder) = MemDecoder :: new ( data, 0 ) else {
297295 return Err ( CodegenErrors :: CorruptFile ) ;
298296 } ;
299297 let rustc_version = decoder. read_str ( ) ;
You can’t perform that action at this time.
0 commit comments