Skip to content

Commit

Permalink
Auto merge of #13800 - epage:u3, r=weihanglo
Browse files Browse the repository at this point in the history
fix(toml): Don't double-warn when underscore is used in workspace dep

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

Particularly, I wanted to make sure I didn't make things worse and in doing so found there was room for improvement.

### How should we test and review this PR?

### Additional information
  • Loading branch information
bors committed Apr 24, 2024
2 parents e3d42b6 + 751fd47 commit 955503e
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,6 @@ fn inner_dependency_inherit_with<'a>(
this could become a hard error in the future"
))
}
deprecated_underscore(
&dependency.default_features2,
&dependency.default_features,
"default-features",
name,
"dependency",
warnings,
);
inherit()?.get_dependency(name, package_root).map(|d| {
match d {
manifest::TomlDependency::Simple(s) => {
Expand Down
82 changes: 82 additions & 0 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,88 @@ fn default_features2_conflict() {
.run();
}

#[cargo_test]
fn workspace_default_features2() {
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["workspace_only", "dep_workspace_only", "package_only", "dep_package_only"]
[workspace.dependencies]
dep_workspace_only = { path = "dep_workspace_only", default_features = true }
dep_package_only = { path = "dep_package_only" }
"#,
)
.file(
"workspace_only/Cargo.toml",
r#"
[package]
name = "workspace_only"
version = "0.1.0"
edition = "2015"
authors = []
[dependencies]
dep_workspace_only.workspace = true
"#,
)
.file("workspace_only/src/lib.rs", "")
.file(
"dep_workspace_only/Cargo.toml",
r#"
[package]
name = "dep_workspace_only"
version = "0.1.0"
edition = "2015"
authors = []
"#,
)
.file("dep_workspace_only/src/lib.rs", "")
.file(
"package_only/Cargo.toml",
r#"
[package]
name = "package_only"
version = "0.1.0"
edition = "2015"
authors = []
[dependencies]
dep_package_only = { workspace = true, default_features = true }
"#,
)
.file("package_only/src/lib.rs", "")
.file(
"dep_package_only/Cargo.toml",
r#"
[package]
name = "dep_package_only"
version = "0.1.0"
edition = "2015"
authors = []
"#,
)
.file("dep_package_only/src/lib.rs", "")
.build();

p.cargo("check")
.with_stderr_unordered(
"\
warning: [CWD]/workspace_only/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
(in the `dep_workspace_only` dependency)
Locking 4 packages to latest compatible versions
Checking dep_package_only v0.1.0 ([CWD]/dep_package_only)
Checking dep_workspace_only v0.1.0 ([CWD]/dep_workspace_only)
Checking package_only v0.1.0 ([CWD]/package_only)
Checking workspace_only v0.1.0 ([CWD]/workspace_only)
Finished `dev` profile [unoptimized + debuginfo] target(s) in [..]s
"
)
.run();
}

#[cargo_test]
fn proc_macro2() {
let foo = project()
Expand Down

0 comments on commit 955503e

Please sign in to comment.