refactor(toml): Make Dep's to_dependency_split a free function

This commit is contained in:
Ed Page 2023-11-30 10:43:24 -06:00
parent 8ff20c7b3c
commit 89f8f5c77a
2 changed files with 29 additions and 30 deletions

View File

@ -437,7 +437,8 @@ impl<'cfg> Workspace<'cfg> {
url, url,
deps.iter() deps.iter()
.map(|(name, dep)| { .map(|(name, dep)| {
dep.to_dependency_split( crate::util::toml::to_dependency(
dep,
name, name,
source, source,
&mut nested_paths, &mut nested_paths,

View File

@ -1694,35 +1694,33 @@ fn inner_dependency_inherit_with<'a>(
}) })
} }
impl<P: ResolveToPath + Clone> schema::TomlDependency<P> { pub(crate) fn to_dependency<P: ResolveToPath + Clone>(
pub(crate) fn to_dependency_split( dep: &schema::TomlDependency<P>,
&self, name: &str,
name: &str, source_id: SourceId,
source_id: SourceId, nested_paths: &mut Vec<PathBuf>,
nested_paths: &mut Vec<PathBuf>, config: &Config,
config: &Config, warnings: &mut Vec<String>,
warnings: &mut Vec<String>, platform: Option<Platform>,
platform: Option<Platform>, root: &Path,
root: &Path, features: &Features,
features: &Features, kind: Option<DepKind>,
kind: Option<DepKind>, ) -> CargoResult<Dependency> {
) -> CargoResult<Dependency> { dep_to_dependency(
dep_to_dependency( dep,
self, name,
name, &mut Context {
&mut Context { deps: &mut Vec::new(),
deps: &mut Vec::new(), source_id,
source_id, nested_paths,
nested_paths, config,
config, warnings,
warnings, platform,
platform, root,
root, features,
features, },
}, kind,
kind, )
)
}
} }
fn dep_to_dependency<P: ResolveToPath + Clone>( fn dep_to_dependency<P: ResolveToPath + Clone>(