Skip to content
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
13 changes: 13 additions & 0 deletions src/skeleton/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ pub(super) fn manifests<P: AsRef<Path>>(

let mut intermediate = toml::Value::try_from(parsed)?;

// Remove [lints] - they can cause compilation failures on the dummy source files
// generated by `cargo chef cook` (e.g. `missing_docs = "deny"`).
if let Some(table) = intermediate.as_table_mut() {
table.remove("lints");
}
// Remove [workspace.lints] for the same reason.
if let Some(workspace) = intermediate
.get_mut("workspace")
.and_then(|w| w.as_table_mut())
{
workspace.remove("lints");
}

// Specifically, toml gives no guarantees to the ordering of the auto binaries
// in its results. We will manually sort these to ensure that the output
// manifest will match.
Expand Down
60 changes: 60 additions & 0 deletions tests/skeletons/tests/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,63 @@ edition = "2018"
);
}
}

#[test]
pub fn lints_are_removed_from_all_manifests() {
// Arrange - workspace with [workspace.lints] and member with [lints] workspace = true
// See https://github.com/LukeMathWalker/cargo-chef/issues/343
let project = CargoWorkspace::new()
.manifest(
".",
r#"
[workspace]
members = [
"crate_a",
]

[workspace.lints.rust]
missing_docs = "deny"
"#,
)
.lib_package(
"crate_a",
r#"
[package]
name = "crate_a"
version = "0.1.0"
edition = "2021"

[lints]
workspace = true

[dependencies]
"#,
)
.build();

// Act
let skeleton = Skeleton::derive(project.path(), None).unwrap();

// Assert - lints should be stripped from all manifests
for manifest in &skeleton.manifests {
let parsed: toml::Value = toml::from_str(&manifest.contents).unwrap();

// No top-level [lints]
assert!(
parsed.get("lints").is_none(),
"Expected [lints] to be removed from manifest at {:?}, but found: {:?}",
manifest.relative_path,
parsed.get("lints")
);

// No [workspace.lints]
if let Some(workspace) = parsed.get("workspace") {
assert!(
workspace.get("lints").is_none(),
"Expected [workspace.lints] to be removed from manifest at {:?}, but found: {:?}",
manifest.relative_path,
workspace.get("lints")
);
}
}
}