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

fix(toml)!: Disallow [lints] in virtual workspaces #13155

Merged
merged 2 commits into from
Dec 11, 2023
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
3 changes: 3 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,9 @@ fn to_virtual_manifest(
if me.badges.is_some() {
bail!("this virtual manifest specifies a [badges] section, which is not allowed");
}
if me.lints.is_some() {
bail!("this virtual manifest specifies a [lints] section, which is not allowed");
}

let mut nested_paths = Vec::new();
let mut warnings = Vec::new();
Expand Down
1 change: 1 addition & 0 deletions src/cargo/util_schemas/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct TomlManifest {
pub workspace: Option<TomlWorkspace>,
pub badges: Option<InheritableBtreeMap>,
pub lints: Option<InheritableLints>,
// when adding new fields, be sure to check whether `to_virtual_manifest` should disallow them
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder we have a way to catch this automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way to catch this would be to put it in the design of the structs.

The problem is this doesn't align well with serde to say "these fields depend on this other field being present". We'd likely have to do stuff like what we do with workspace inheritance where we deserialize twice between two structures and pick the more appropriate one. Bleh. This isn't why I haven't done a bigger fix yet.

}

impl TomlManifest {
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,7 @@ fn ws_err_unused() {
"[features]",
"[target]",
"[badges]",
"[lints]",
] {
let p = project()
.file(
Expand Down