@@ -195,6 +195,7 @@ use std::task::{ready, Poll};
195195use anyhow:: Context as _;
196196use cargo_util:: paths:: { self , exclude_from_backups_and_indexing} ;
197197use flate2:: read:: GzDecoder ;
198+ use semver:: VersionReq ;
198199use serde:: Deserialize ;
199200use serde:: Serialize ;
200201use tar:: Archive ;
@@ -694,6 +695,10 @@ impl<'gctx> RegistrySource<'gctx> {
694695 . open ( & path)
695696 . with_context ( || format ! ( "failed to open `{}`" , path. display( ) ) ) ?;
696697
698+ if let Err ( e) = patch_extracted_package_if_needed ( pkg, unpack_dir) {
699+ tracing:: warn!( "error patching {pkg}: {e}" ) ;
700+ }
701+
697702 let lock_meta = LockMetadata { v : 1 } ;
698703 write ! ( ok, "{}" , serde_json:: to_string( & lock_meta) . unwrap( ) ) ?;
699704
@@ -740,6 +745,20 @@ impl<'gctx> RegistrySource<'gctx> {
740745 }
741746}
742747
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 ( ) || pkg. name ( ) != "time" || !VersionReq :: parse ( "0.3.18,<0.3.35" ) . unwrap ( ) . matches ( pkg. version ( ) ) {
751+ return Ok ( ( ) ) ;
752+ }
753+
754+ let patch_path = unpack_dir. join ( "src/format_description/parse/mod.rs" ) ;
755+ let source_code = std:: fs:: read_to_string ( & patch_path) ?;
756+
757+ let patched = source_code. replace ( "<Result<Box<_>, _>>" , "<Result<Box<[_ /*patched by Cargo*/ ]>, _>>" ) ;
758+ std:: fs:: write ( & patch_path, patched) ?;
759+ Ok ( ( ) )
760+ }
761+
743762impl < ' gctx > Source for RegistrySource < ' gctx > {
744763 fn query (
745764 & mut self ,
0 commit comments