Skip to content
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

[beta-1.81] Revert "fix: Ensure dep/feature activates the dependency on 2024" #14366

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn resolve_toml(
});
resolved_toml.package = Some(resolved_package);

resolved_toml.features = resolve_features(original_toml.features.as_ref(), edition)?;
resolved_toml.features = resolve_features(original_toml.features.as_ref())?;

resolved_toml.lib = targets::resolve_lib(
original_toml.lib.as_ref(),
Expand Down Expand Up @@ -691,34 +691,11 @@ fn default_readme_from_package_root(package_root: &Path) -> Option<String> {
#[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 {
let Some(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));
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))
}

Expand Down
6 changes: 6 additions & 0 deletions tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ fn basic() {
assert_eq!(p.glob(deps_dir.join("*.dylib")).count(), 0);
}

#[allow(unused_attributes)]
#[ignore = "to unblock beta-1.81 backport"]
#[cargo_test(build_std_real)]
fn cross_custom() {
let p = project()
Expand Down Expand Up @@ -176,6 +178,8 @@ fn cross_custom() {
.run();
}

#[allow(unused_attributes)]
#[ignore = "to unblock beta-1.81 backport"]
#[cargo_test(build_std_real)]
fn custom_test_framework() {
let p = project()
Expand Down Expand Up @@ -237,6 +241,8 @@ fn custom_test_framework() {
// Fixing rust-lang/rust#117839.
// on macOS it never gets remapped.
// Might be a separate issue, so only run on Linux.
#[allow(unused_attributes)]
#[ignore = "to unblock beta-1.81 backport"]
#[cargo_test(build_std_real)]
#[cfg(target_os = "linux")]
fn remap_path_scope() {
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6576,7 +6576,7 @@ fn user_specific_cfgs_are_filtered_out() {
)
.build();

p.cargo("rustc -- --cfg debug_assertions --cfg proc_macro -Aunknown_lints -Aunexpected_builtin_cfgs")
p.cargo("rustc -- --cfg debug_assertions --cfg proc_macro -Aunknown_lints -Aexplicit_builtin_cfgs_in_flags")
.run();
p.process(&p.bin("foo")).run();
}
Expand Down
32 changes: 11 additions & 21 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,27 +1890,17 @@ fn strong_dep_feature_edition2024() {

p.cargo("metadata")
.masquerade_as_nightly_cargo(&["edition2024"])
.with_stdout_data(
str![[r#"
{
"metadata": null,
"packages": [
{
"features": {
"optional_dep": [
"optional_dep/foo",
"dep:optional_dep"
]
},
"name": "foo",
"...": "{...}"
}
],
"...": "{...}"
}
"#]]
.json(),
)
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] feature `optional_dep` includes `optional_dep/foo`, but `optional_dep` is not a dependency
--> Cargo.toml:9:32
|
9 | optional_dep = ["optional_dep/foo"]
| ^^^^^^^^^^^^^^^^^^^^
|
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`

"#]])
.run();
}

Expand Down