File tree 1 file changed +6
-8
lines changed
compiler/rustc_codegen_ssa/src
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -276,24 +276,22 @@ impl CodegenResults {
276
276
) -> Result < ( Self , OutputFilenames ) , CodegenErrors > {
277
277
// The Decodable machinery is not used here because it panics if the input data is invalid
278
278
// and because its internal representation may change.
279
- if ! data. starts_with ( RLINK_MAGIC ) {
279
+ let Some ( data) = data . strip_prefix ( RLINK_MAGIC ) else {
280
280
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 {
284
284
return Err ( CodegenErrors :: EmptyVersionNumber ) ;
285
- }
285
+ } ;
286
286
287
- let mut version_array: [ u8 ; 4 ] = Default :: default ( ) ;
288
- version_array. copy_from_slice ( & data[ ..4 ] ) ;
289
287
if u32:: from_be_bytes ( version_array) != RLINK_VERSION {
290
288
return Err ( CodegenErrors :: EncodingVersionMismatch {
291
289
version_array : String :: from_utf8_lossy ( & version_array) . to_string ( ) ,
292
290
rlink_version : RLINK_VERSION ,
293
291
} ) ;
294
292
}
295
293
296
- let Ok ( mut decoder) = MemDecoder :: new ( & data[ 4 .. ] , 0 ) else {
294
+ let Ok ( mut decoder) = MemDecoder :: new ( data, 0 ) else {
297
295
return Err ( CodegenErrors :: CorruptFile ) ;
298
296
} ;
299
297
let rustc_version = decoder. read_str ( ) ;
You can’t perform that action at this time.
0 commit comments