Skip to content

Commit 3cb3130

Browse files
committed
refactor(toml): Group inheritance code
1 parent 1ed0efc commit 3cb3130

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,24 @@ impl<T> schema::InheritableField<T> {
15761576
}
15771577
}
15781578

1579+
impl schema::InheritableLints {
1580+
fn inherit_with<'a>(
1581+
self,
1582+
get_ws_inheritable: impl FnOnce() -> CargoResult<schema::TomlLints>,
1583+
) -> CargoResult<schema::TomlLints> {
1584+
if self.workspace {
1585+
if !self.lints.is_empty() {
1586+
anyhow::bail!("cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints");
1587+
}
1588+
get_ws_inheritable().with_context(|| {
1589+
"error inheriting `lints` from workspace root manifest's `workspace.lints`"
1590+
})
1591+
} else {
1592+
Ok(self.lints)
1593+
}
1594+
}
1595+
}
1596+
15791597
impl schema::InheritableDependency {
15801598
fn inherit_with<'a>(
15811599
self,
@@ -2141,24 +2159,6 @@ fn validate_profile_override(profile: &schema::TomlProfile, which: &str) -> Carg
21412159
Ok(())
21422160
}
21432161

2144-
impl schema::InheritableLints {
2145-
fn inherit_with<'a>(
2146-
self,
2147-
get_ws_inheritable: impl FnOnce() -> CargoResult<schema::TomlLints>,
2148-
) -> CargoResult<schema::TomlLints> {
2149-
if self.workspace {
2150-
if !self.lints.is_empty() {
2151-
anyhow::bail!("cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints");
2152-
}
2153-
get_ws_inheritable().with_context(|| {
2154-
"error inheriting `lints` from workspace root manifest's `workspace.lints`"
2155-
})
2156-
} else {
2157-
Ok(self.lints)
2158-
}
2159-
}
2160-
}
2161-
21622162
pub trait ResolveToPath {
21632163
fn resolve(&self, config: &Config) -> PathBuf;
21642164
}

0 commit comments

Comments
 (0)