Skip to content

Commit 0305ad3

Browse files
committed
refactor(toml): Pull out TomlManifest to WorkspaceConfig
1 parent c1a53f3 commit 0305ad3

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,7 @@ pub fn to_real_manifest(
520520
let workspace_config = match (original_toml.workspace.as_ref(), package.workspace.as_ref()) {
521521
(Some(toml_config), None) => {
522522
verify_lints(toml_config.lints.as_ref())?;
523-
let inheritable = InheritableFields {
524-
package: toml_config.package.clone(),
525-
dependencies: toml_config.dependencies.clone(),
526-
lints: toml_config.lints.clone(),
527-
_ws_root: package_root.to_path_buf(),
528-
};
529-
if let Some(ws_deps) = &inheritable.dependencies {
523+
if let Some(ws_deps) = &toml_config.dependencies {
530524
for (name, dep) in ws_deps {
531525
unused_dep_keys(
532526
name,
@@ -536,14 +530,7 @@ pub fn to_real_manifest(
536530
);
537531
}
538532
}
539-
let ws_root_config = WorkspaceRootConfig::new(
540-
package_root,
541-
&toml_config.members,
542-
&toml_config.default_members,
543-
&toml_config.exclude,
544-
&Some(inheritable),
545-
&toml_config.metadata,
546-
);
533+
let ws_root_config = to_workspace_config(toml_config, package_root);
547534
gctx.ws_roots
548535
.borrow_mut()
549536
.insert(package_root.to_path_buf(), ws_root_config.clone());
@@ -1246,6 +1233,27 @@ pub fn to_real_manifest(
12461233
Ok(manifest)
12471234
}
12481235

1236+
fn to_workspace_config(
1237+
resolved_toml: &manifest::TomlWorkspace,
1238+
package_root: &Path,
1239+
) -> WorkspaceRootConfig {
1240+
let inheritable = InheritableFields {
1241+
package: resolved_toml.package.clone(),
1242+
dependencies: resolved_toml.dependencies.clone(),
1243+
lints: resolved_toml.lints.clone(),
1244+
_ws_root: package_root.to_owned(),
1245+
};
1246+
let ws_root_config = WorkspaceRootConfig::new(
1247+
package_root,
1248+
&resolved_toml.members,
1249+
&resolved_toml.default_members,
1250+
&resolved_toml.exclude,
1251+
&Some(inheritable),
1252+
&resolved_toml.metadata,
1253+
);
1254+
ws_root_config
1255+
}
1256+
12491257
fn load_inheritable_fields(
12501258
gctx: &GlobalContext,
12511259
resolved_path: &Path,
@@ -1337,20 +1345,7 @@ fn to_virtual_manifest(
13371345
let workspace_config = match original_toml.workspace {
13381346
Some(ref toml_config) => {
13391347
verify_lints(toml_config.lints.as_ref())?;
1340-
let inheritable = InheritableFields {
1341-
package: toml_config.package.clone(),
1342-
dependencies: toml_config.dependencies.clone(),
1343-
lints: toml_config.lints.clone(),
1344-
_ws_root: root.to_path_buf(),
1345-
};
1346-
let ws_root_config = WorkspaceRootConfig::new(
1347-
root,
1348-
&toml_config.members,
1349-
&toml_config.default_members,
1350-
&toml_config.exclude,
1351-
&Some(inheritable),
1352-
&toml_config.metadata,
1353-
);
1348+
let ws_root_config = to_workspace_config(toml_config, root);
13541349
gctx.ws_roots
13551350
.borrow_mut()
13561351
.insert(root.to_path_buf(), ws_root_config.clone());

0 commit comments

Comments
 (0)