Skip to content

Commit e48befe

Browse files
committed
refactor(toml): Make InheritableLints::inherit_with a free function
1 parent 3047a41 commit e48befe

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ impl schema::TomlManifest {
718718
let lints = me
719719
.lints
720720
.clone()
721-
.map(|mw| mw.inherit_with(|| inherit()?.lints()))
721+
.map(|mw| lints_inherit_with(mw, || inherit()?.lints()))
722722
.transpose()?;
723723
let lints = verify_lints(lints)?;
724724
let default = schema::TomlLints::default();
@@ -1573,21 +1573,19 @@ fn field_inherit_with<'a, T>(
15731573
}
15741574
}
15751575

1576-
impl schema::InheritableLints {
1577-
fn inherit_with<'a>(
1578-
self,
1579-
get_ws_inheritable: impl FnOnce() -> CargoResult<schema::TomlLints>,
1580-
) -> CargoResult<schema::TomlLints> {
1581-
if self.workspace {
1582-
if !self.lints.is_empty() {
1583-
anyhow::bail!("cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints");
1584-
}
1585-
get_ws_inheritable().with_context(|| {
1586-
"error inheriting `lints` from workspace root manifest's `workspace.lints`"
1587-
})
1588-
} else {
1589-
Ok(self.lints)
1576+
fn lints_inherit_with(
1577+
lints: schema::InheritableLints,
1578+
get_ws_inheritable: impl FnOnce() -> CargoResult<schema::TomlLints>,
1579+
) -> CargoResult<schema::TomlLints> {
1580+
if lints.workspace {
1581+
if !lints.lints.is_empty() {
1582+
anyhow::bail!("cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints");
15901583
}
1584+
get_ws_inheritable().with_context(|| {
1585+
"error inheriting `lints` from workspace root manifest's `workspace.lints`"
1586+
})
1587+
} else {
1588+
Ok(lints.lints)
15911589
}
15921590
}
15931591

0 commit comments

Comments
 (0)