Skip to content

Commit f1cfbd8

Browse files
committed
Automatically inherit workspace lints when running cargo new/init
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 64fb38c commit f1cfbd8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,18 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
820820
workspace_package_keys,
821821
)
822822
}
823+
824+
// Try to inherit the workspace lints key if it exists.
825+
if config.cli_unstable().lints
826+
&& workspace_document
827+
.get("workspace")
828+
.and_then(|workspace| workspace.get("lints"))
829+
.is_some()
830+
{
831+
let mut table = toml_edit::Table::new();
832+
table["workspace"] = toml_edit::value(true);
833+
manifest["lints"] = toml_edit::Item::Table(table);
834+
}
823835
}
824836
}
825837

0 commit comments

Comments
 (0)