-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo in Rust 1.66 changed location for source cache #11487
Comments
I believe the order of enum variants matters. By moving Maybe we should release at least a new patch version of cargo crate. |
I don't think that's true. At least from a basic test on the playground, the hash of the first variant changes if a second variant is added. |
It seems that single-variant enum has got a special treatment. The result of #![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
enum E { A, }
#[automatically_derived]
impl ::core::hash::Hash for E {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
} For #![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
enum E { A, B, }
#[automatically_derived]
impl ::core::hash::Hash for E {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_tag = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_tag, state)
}
} It looks like, for enum containing 2 or more variants, the hash value of each variant is computed from |
@rust-lang/cargo Does anyone feel like this regression is worth pushing for a point release? Or maybe just backporting a fix to 1.67 and leave 1.66 as an outlier? Or just leave it as-is and let newer versions use the new hash. To summarize: If someone uses |
I believe this also applies to any registry that isn't crates.io for what it's worth. |
Can you provide an example for that? In my testing, it doesn't seem to be affected. AFAIK, the hash only changed for |
Ohh, you're right, forgot about those being earlier variants in the enum! In that case I'm in favor of closing this as a wontfix. Only a point release would actually help the misalignment between binary and library, and that doesn't feel worth it. |
OK, I'm going to go ahead and close this as wontfix. #11501 added a test to check for regressions in the future. In the future it might be worthwhile to investigate a more reliable and stable approach to hashing. |
Problem
In Rust 1.66.0, Cargo appears to be using a different hash for computing directory names in
$CARGO_HOME/src/
. This means that the cache from <=1.65.0 is no longer re-used. Furthermore, for anyone using Cargo as a library, if the version used as a library doesn't match the one used by the binary, they'll use different cache directories, causing everything to be extracted (and downloaded?) twice.It doesn't appear to affect crates.io — not quite sure why. Do we hard-code its registry name somewhere perhaps?
Steps
Possible Solution(s)
The cause of this was #11209, which added a new variant to
SourceKind
, which in turn affects the derivedimpl Hash for SourceKind
. ThatHash
impl is taken into account inimpl Hash for SourceId
here:cargo/src/cargo/core/source/source_id.rs
Line 565 in 8607003
which in turn is used to generate a
SourceId
's "short name" here:cargo/src/cargo/sources/registry/mod.rs
Lines 549 to 553 in 8607003
I'm not 100% sure where crates.io diverges so it doesn't go through the same path, but it's definitely intentional given this test. I suspect it's because the crates.io
SourceId
is constructed specially:cargo/src/cargo/core/source/source_id.rs
Line 219 in 8607003
Notes
No response
Version
The text was updated successfully, but these errors were encountered: