mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 21:11:44 +00:00
refactor(toml): Remove ManifestContext from dependency_inherit_with
This commit is contained in:
parent
b517320f1a
commit
21ca8ab647
|
@ -1217,7 +1217,13 @@ fn resolve_and_validate_dependencies(
|
|||
let mut deps: BTreeMap<manifest::PackageName, manifest::InheritableDependency> =
|
||||
BTreeMap::new();
|
||||
for (name_in_toml, v) in dependencies.iter() {
|
||||
let resolved = dependency_inherit_with(v.clone(), name_in_toml, inheritable, manifest_ctx)?;
|
||||
let resolved = dependency_inherit_with(
|
||||
v.clone(),
|
||||
name_in_toml,
|
||||
inheritable,
|
||||
&manifest_ctx.root,
|
||||
&mut manifest_ctx.warnings,
|
||||
)?;
|
||||
let kind_name = match kind {
|
||||
Some(k) => k.kind_table(),
|
||||
None => "dependencies",
|
||||
|
@ -1873,12 +1879,13 @@ fn dependency_inherit_with<'a>(
|
|||
dependency: manifest::InheritableDependency,
|
||||
name: &str,
|
||||
inheritable: impl FnOnce() -> CargoResult<&'a InheritableFields>,
|
||||
manifest_ctx: &mut ManifestContext<'_, '_>,
|
||||
package_root: &Path,
|
||||
warnings: &mut Vec<String>,
|
||||
) -> CargoResult<manifest::TomlDependency> {
|
||||
match dependency {
|
||||
manifest::InheritableDependency::Value(value) => Ok(value),
|
||||
manifest::InheritableDependency::Inherit(w) => {
|
||||
inner_dependency_inherit_with(w, name, inheritable, manifest_ctx).with_context(|| {
|
||||
inner_dependency_inherit_with(w, name, inheritable, package_root, warnings).with_context(|| {
|
||||
format!(
|
||||
"error inheriting `{name}` from workspace root manifest's `workspace.dependencies.{name}`",
|
||||
)
|
||||
|
@ -1891,7 +1898,8 @@ fn inner_dependency_inherit_with<'a>(
|
|||
dependency: manifest::TomlInheritedDependency,
|
||||
name: &str,
|
||||
inheritable: impl FnOnce() -> CargoResult<&'a InheritableFields>,
|
||||
manifest_ctx: &mut ManifestContext<'_, '_>,
|
||||
package_root: &Path,
|
||||
warnings: &mut Vec<String>,
|
||||
) -> CargoResult<manifest::TomlDependency> {
|
||||
fn default_features_msg(label: &str, ws_def_feat: Option<bool>, warnings: &mut Vec<String>) {
|
||||
let ws_def_feat = match ws_def_feat {
|
||||
|
@ -1906,20 +1914,13 @@ fn inner_dependency_inherit_with<'a>(
|
|||
))
|
||||
}
|
||||
if dependency.default_features.is_some() && dependency.default_features2.is_some() {
|
||||
warn_on_deprecated(
|
||||
"default-features",
|
||||
name,
|
||||
"dependency",
|
||||
manifest_ctx.warnings,
|
||||
);
|
||||
warn_on_deprecated("default-features", name, "dependency", warnings);
|
||||
}
|
||||
inheritable()?
|
||||
.get_dependency(name, manifest_ctx.root)
|
||||
.map(|d| {
|
||||
inheritable()?.get_dependency(name, package_root).map(|d| {
|
||||
match d {
|
||||
manifest::TomlDependency::Simple(s) => {
|
||||
if let Some(false) = dependency.default_features() {
|
||||
default_features_msg(name, None, &mut manifest_ctx.warnings);
|
||||
default_features_msg(name, None, warnings);
|
||||
}
|
||||
if dependency.optional.is_some()
|
||||
|| dependency.features.is_some()
|
||||
|
@ -1949,12 +1950,12 @@ fn inner_dependency_inherit_with<'a>(
|
|||
// workspace: default-features = true should ignore member
|
||||
// default-features
|
||||
(Some(false), Some(true)) => {
|
||||
default_features_msg(name, Some(true), &mut manifest_ctx.warnings);
|
||||
default_features_msg(name, Some(true), warnings);
|
||||
}
|
||||
// member: default-features = false and
|
||||
// workspace: dep = "1.0" should ignore member default-features
|
||||
(Some(false), None) => {
|
||||
default_features_msg(name, None, &mut manifest_ctx.warnings);
|
||||
default_features_msg(name, None, warnings);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue