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 @@ -297,24 +297,22 @@ impl CodegenResults {
297
297
) -> Result < ( Self , OutputFilenames ) , CodegenErrors > {
298
298
// The Decodable machinery is not used here because it panics if the input data is invalid
299
299
// and because its internal representation may change.
300
- if ! data. starts_with ( RLINK_MAGIC ) {
300
+ let Some ( data) = data . strip_prefix ( RLINK_MAGIC ) else {
301
301
return Err ( CodegenErrors :: WrongFileType ) ;
302
- }
303
- let data = & data [ RLINK_MAGIC . len ( ) .. ] ;
304
- if data. len ( ) < 4 {
302
+ } ;
303
+
304
+ let Some ( ( & version_array , data) ) = data . split_first_chunk ( ) else {
305
305
return Err ( CodegenErrors :: EmptyVersionNumber ) ;
306
- }
306
+ } ;
307
307
308
- let mut version_array: [ u8 ; 4 ] = Default :: default ( ) ;
309
- version_array. copy_from_slice ( & data[ ..4 ] ) ;
310
308
if u32:: from_be_bytes ( version_array) != RLINK_VERSION {
311
309
return Err ( CodegenErrors :: EncodingVersionMismatch {
312
310
version_array : String :: from_utf8_lossy ( & version_array) . to_string ( ) ,
313
311
rlink_version : RLINK_VERSION ,
314
312
} ) ;
315
313
}
316
314
317
- let Ok ( mut decoder) = MemDecoder :: new ( & data[ 4 .. ] , 0 ) else {
315
+ let Ok ( mut decoder) = MemDecoder :: new ( data, 0 ) else {
318
316
return Err ( CodegenErrors :: CorruptFile ) ;
319
317
} ;
320
318
let rustc_version = decoder. read_str ( ) ;
You can’t perform that action at this time.
0 commit comments