@@ -443,20 +443,31 @@ panic = 'unwind'
443
443
444
444
// Prepare a workspace for cargo
445
445
let build_dir = TempDir :: new ( ) . context ( "failed to create tempdir" ) ?;
446
+ // Cargo.lock
446
447
let lock_file = build_dir. path ( ) . join ( "Cargo.lock" ) ;
447
- let manifest_file = build_dir. path ( ) . join ( "Cargo.toml" ) ;
448
- let lib_file = build_dir. path ( ) . join ( "lib.rs" ) ;
449
- fs:: copy (
450
- src_dir
451
- . parent ( )
452
- . expect ( "src_dir must have a parent" )
453
- . join ( "Cargo.lock" ) ,
454
- & lock_file,
455
- )
456
- . context ( "failed to copy lockfile from sysroot source" ) ?;
448
+ let lock_file_src = {
449
+ // Since <https://github.com/rust-lang/rust/pull/128534>, the lock file
450
+ // lives inside the src_dir.
451
+ let new_lock_file_name = src_dir. join ( "Cargo.lock" ) ;
452
+ if new_lock_file_name. exists ( ) {
453
+ new_lock_file_name
454
+ } else {
455
+ // Previously, the lock file lived one folder up.
456
+ src_dir
457
+ . parent ( )
458
+ . expect ( "src_dir must have a parent" )
459
+ . join ( "Cargo.lock" )
460
+ }
461
+ } ;
462
+ fs:: copy ( lock_file_src, & lock_file)
463
+ . context ( "failed to copy lockfile from sysroot source" ) ?;
457
464
make_writeable ( & lock_file) . context ( "failed to make lockfile writeable" ) ?;
465
+ // Cargo.toml
466
+ let manifest_file = build_dir. path ( ) . join ( "Cargo.toml" ) ;
458
467
let manifest = self . gen_manifest ( src_dir) ;
459
468
fs:: write ( & manifest_file, manifest. as_bytes ( ) ) . context ( "failed to write manifest file" ) ?;
469
+ // lib.rs
470
+ let lib_file = build_dir. path ( ) . join ( "lib.rs" ) ;
460
471
let lib = match self . config {
461
472
SysrootConfig :: NoStd => r#"#![no_std]"# ,
462
473
SysrootConfig :: WithStd { .. } => "" ,
0 commit comments