-
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
fix: Ensure dep/feature activates the dependency on 2024 #14221
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -291,7 +291,7 @@ fn resolve_toml( | |||||||||||||||||||||||||||||||||||||
dev_dependencies2: None, | ||||||||||||||||||||||||||||||||||||||
build_dependencies: None, | ||||||||||||||||||||||||||||||||||||||
build_dependencies2: None, | ||||||||||||||||||||||||||||||||||||||
features: original_toml.features.clone(), | ||||||||||||||||||||||||||||||||||||||
features: None, | ||||||||||||||||||||||||||||||||||||||
target: None, | ||||||||||||||||||||||||||||||||||||||
replace: original_toml.replace.clone(), | ||||||||||||||||||||||||||||||||||||||
patch: original_toml.patch.clone(), | ||||||||||||||||||||||||||||||||||||||
|
@@ -322,6 +322,8 @@ fn resolve_toml( | |||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||
resolved_toml.package = Some(resolved_package); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
resolved_toml.features = resolve_features(original_toml.features.as_ref(), edition)?; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
resolved_toml.lib = targets::resolve_lib( | ||||||||||||||||||||||||||||||||||||||
original_toml.lib.as_ref(), | ||||||||||||||||||||||||||||||||||||||
package_root, | ||||||||||||||||||||||||||||||||||||||
|
@@ -686,6 +688,40 @@ fn default_readme_from_package_root(package_root: &Path) -> Option<String> { | |||||||||||||||||||||||||||||||||||||
None | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
#[tracing::instrument(skip_all)] | ||||||||||||||||||||||||||||||||||||||
fn resolve_features( | ||||||||||||||||||||||||||||||||||||||
original_features: Option<&BTreeMap<manifest::FeatureName, Vec<String>>>, | ||||||||||||||||||||||||||||||||||||||
edition: Edition, | ||||||||||||||||||||||||||||||||||||||
) -> CargoResult<Option<BTreeMap<manifest::FeatureName, Vec<String>>>> { | ||||||||||||||||||||||||||||||||||||||
let Some(mut resolved_features) = original_features.cloned() else { | ||||||||||||||||||||||||||||||||||||||
return Ok(None); | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if Edition::Edition2024 <= edition { | ||||||||||||||||||||||||||||||||||||||
for activations in resolved_features.values_mut() { | ||||||||||||||||||||||||||||||||||||||
let mut deps = Vec::new(); | ||||||||||||||||||||||||||||||||||||||
for feature_value in activations.iter() { | ||||||||||||||||||||||||||||||||||||||
let feature_value = FeatureValue::new(InternedString::new(feature_value)); | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this PR chose the approach:
I forgot if we had a conclusion somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #14016 (comment)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we choose to do it here instead of in cargo/src/cargo/util/toml/mod.rs Lines 1442 to 1459 in 471287f
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want everything to be normalized on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By doing it here, we get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Doesn't this fail if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ran into this as well, see #14283. :) |
||||||||||||||||||||||||||||||||||||||
let FeatureValue::DepFeature { | ||||||||||||||||||||||||||||||||||||||
dep_name, | ||||||||||||||||||||||||||||||||||||||
dep_feature: _, | ||||||||||||||||||||||||||||||||||||||
weak: false, | ||||||||||||||||||||||||||||||||||||||
} = feature_value | ||||||||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
let dep = FeatureValue::Dep { dep_name }.to_string(); | ||||||||||||||||||||||||||||||||||||||
if !activations.contains(&dep) { | ||||||||||||||||||||||||||||||||||||||
deps.push(dep); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
activations.extend(deps); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Ok(Some(resolved_features)) | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
#[tracing::instrument(skip_all)] | ||||||||||||||||||||||||||||||||||||||
fn resolve_dependencies<'a>( | ||||||||||||||||||||||||||||||||||||||
gctx: &GlobalContext, | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand you like Yoda style more, but forgot the reason.
Anyway, this is not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually really dislike Yoda style for equality checks. For these checks, I prefer number line order (the lower value is always on the left, so
<
and<=
are only ever used and not>
or>=
)