diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index d61415f1f..4494fad45 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -105,6 +105,10 @@ impl TomlManifest { pub fn features(&self) -> Option<&BTreeMap>> { self.features.as_ref() } + + pub fn resolved_lints(&self) -> Result, UnresolvedError> { + self.lints.as_ref().map(|l| l.resolved()).transpose() + } } #[derive(Debug, Deserialize, Serialize, Clone)] @@ -1378,6 +1382,16 @@ pub struct InheritableLints { pub lints: TomlLints, } +impl InheritableLints { + pub fn resolved(&self) -> Result<&TomlLints, UnresolvedError> { + if self.workspace { + Err(UnresolvedError) + } else { + Ok(&self.lints) + } + } +} + fn is_false(b: &bool) -> bool { !b } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 5880e0d5f..14007b28f 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -668,6 +668,11 @@ pub fn to_real_manifest( metadata: original_package.metadata.clone(), _invalid_cargo_features: Default::default(), }; + let resolved_lints = original_toml + .lints + .clone() + .map(|value| lints_inherit_with(value, || inherit()?.lints())) + .transpose()?; let rust_version = resolved_package .resolved_rust_version() @@ -865,14 +870,9 @@ pub fn to_real_manifest( &inherit_cell, )?; - let lints = original_toml - .lints - .clone() - .map(|mw| lints_inherit_with(mw, || inherit()?.lints())) - .transpose()?; - verify_lints(lints.as_ref(), gctx, manifest_ctx.warnings)?; + verify_lints(resolved_lints.as_ref(), gctx, manifest_ctx.warnings)?; let default = manifest::TomlLints::default(); - let rustflags = lints_to_rustflags(lints.as_ref().unwrap_or(&default)); + let rustflags = lints_to_rustflags(resolved_lints.as_ref().unwrap_or(&default)); let mut target: BTreeMap = BTreeMap::new(); for (name, platform) in original_toml.target.iter().flatten() { @@ -1128,7 +1128,7 @@ pub fn to_real_manifest( .badges .as_ref() .map(|_| manifest::InheritableField::Value(metadata.badges.clone())), - lints: lints.map(|lints| manifest::InheritableLints { + lints: resolved_lints.map(|lints| manifest::InheritableLints { workspace: false, lints, }),