Skip to content

Commit 6c23346

Browse files
committed
fix(lints): Prevent inheritance from bring exposed for published packages
1 parent 27d3e3d commit 6c23346

File tree

4 files changed

+124
-215
lines changed

4 files changed

+124
-215
lines changed

src/cargo/core/workspace.rs

+5-56
Original file line numberDiff line numberDiff line change
@@ -1149,25 +1149,11 @@ impl<'gctx> Workspace<'gctx> {
11491149
}
11501150

11511151
pub fn emit_warnings(&self) -> CargoResult<()> {
1152-
let ws_lints = self
1153-
.root_maybe()
1154-
.workspace_config()
1155-
.inheritable()
1156-
.and_then(|i| i.lints().ok())
1157-
.unwrap_or_default();
1158-
1159-
let ws_cargo_lints = ws_lints
1160-
.get("cargo")
1161-
.cloned()
1162-
.unwrap_or_default()
1163-
.into_iter()
1164-
.collect();
1165-
11661152
for (path, maybe_pkg) in &self.packages.packages {
11671153
let path = path.join("Cargo.toml");
11681154
if let MaybePackage::Package(pkg) = maybe_pkg {
11691155
if self.gctx.cli_unstable().cargo_lints {
1170-
self.emit_lints(pkg, &path, &ws_cargo_lints)?
1156+
self.emit_lints(pkg, &path)?
11711157
}
11721158
}
11731159
let warnings = match maybe_pkg {
@@ -1195,12 +1181,7 @@ impl<'gctx> Workspace<'gctx> {
11951181
Ok(())
11961182
}
11971183

1198-
pub fn emit_lints(
1199-
&self,
1200-
pkg: &Package,
1201-
path: &Path,
1202-
ws_cargo_lints: &manifest::TomlToolLints,
1203-
) -> CargoResult<()> {
1184+
pub fn emit_lints(&self, pkg: &Package, path: &Path) -> CargoResult<()> {
12041185
let mut error_count = 0;
12051186
let toml_lints = pkg
12061187
.manifest()
@@ -1214,16 +1195,6 @@ impl<'gctx> Workspace<'gctx> {
12141195
.cloned()
12151196
.unwrap_or(manifest::TomlToolLints::default());
12161197

1217-
// We should only be using workspace lints if the `[lints]` table is
1218-
// present in the manifest, and `workspace` is set to `true`
1219-
let ws_cargo_lints = pkg
1220-
.manifest()
1221-
.resolved_toml()
1222-
.lints
1223-
.as_ref()
1224-
.is_some_and(|l| l.workspace)
1225-
.then(|| ws_cargo_lints);
1226-
12271198
let ws_contents = match self.root_maybe() {
12281199
MaybePackage::Package(pkg) => pkg.manifest().contents(),
12291200
MaybePackage::Virtual(v) => v.contents(),
@@ -1238,36 +1209,14 @@ impl<'gctx> Workspace<'gctx> {
12381209
pkg,
12391210
&path,
12401211
&cargo_lints,
1241-
ws_cargo_lints,
12421212
ws_contents,
12431213
ws_document,
12441214
self.root_manifest(),
12451215
self.gctx,
12461216
)?;
1247-
check_im_a_teapot(
1248-
pkg,
1249-
&path,
1250-
&cargo_lints,
1251-
ws_cargo_lints,
1252-
&mut error_count,
1253-
self.gctx,
1254-
)?;
1255-
check_implicit_features(
1256-
pkg,
1257-
&path,
1258-
&cargo_lints,
1259-
ws_cargo_lints,
1260-
&mut error_count,
1261-
self.gctx,
1262-
)?;
1263-
unused_dependencies(
1264-
pkg,
1265-
&path,
1266-
&cargo_lints,
1267-
ws_cargo_lints,
1268-
&mut error_count,
1269-
self.gctx,
1270-
)?;
1217+
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
1218+
check_implicit_features(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
1219+
unused_dependencies(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
12711220
if error_count > 0 {
12721221
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
12731222
"encountered {error_count} errors(s) while running lints"

0 commit comments

Comments
 (0)