@@ -195,6 +195,7 @@ use std::task::{ready, Poll};
195
195
use anyhow:: Context as _;
196
196
use cargo_util:: paths:: { self , exclude_from_backups_and_indexing} ;
197
197
use flate2:: read:: GzDecoder ;
198
+ use semver:: VersionReq ;
198
199
use serde:: Deserialize ;
199
200
use serde:: Serialize ;
200
201
use tar:: Archive ;
@@ -694,6 +695,10 @@ impl<'gctx> RegistrySource<'gctx> {
694
695
. open ( & path)
695
696
. with_context ( || format ! ( "failed to open `{}`" , path. display( ) ) ) ?;
696
697
698
+ if let Err ( e) = patch_extracted_package_if_needed ( pkg, unpack_dir) {
699
+ tracing:: warn!( "error patching {pkg}: {e}" ) ;
700
+ }
701
+
697
702
let lock_meta = LockMetadata { v : 1 } ;
698
703
write ! ( ok, "{}" , serde_json:: to_string( & lock_meta) . unwrap( ) ) ?;
699
704
@@ -740,6 +745,28 @@ impl<'gctx> RegistrySource<'gctx> {
740
745
}
741
746
}
742
747
748
+ /// Workaround for <https://github.com/rust-lang/rust/issues/127343> in the `time` crate
749
+ fn patch_extracted_package_if_needed ( pkg : PackageId , unpack_dir : & Path ) -> CargoResult < ( ) > {
750
+ if !pkg. source_id ( ) . is_crates_io ( )
751
+ || pkg. name ( ) != "time"
752
+ || !VersionReq :: parse ( "0.3.18,<0.3.35" )
753
+ . unwrap ( )
754
+ . matches ( pkg. version ( ) )
755
+ {
756
+ return Ok ( ( ) ) ;
757
+ }
758
+
759
+ let patch_path = unpack_dir. join ( "src/format_description/parse/mod.rs" ) ;
760
+ let source_code = std:: fs:: read_to_string ( & patch_path) ?;
761
+
762
+ let patched = source_code. replace (
763
+ "<Result<Box<_>, _>>" ,
764
+ "<Result<Box<[_ /*patched by Cargo*/ ]>, _>>" ,
765
+ ) ;
766
+ std:: fs:: write ( & patch_path, patched) ?;
767
+ Ok ( ( ) )
768
+ }
769
+
743
770
impl < ' gctx > Source for RegistrySource < ' gctx > {
744
771
fn query (
745
772
& mut self ,
0 commit comments