mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor(toml): Group workspace inheritance functions
This commit is contained in:
parent
dd8f8dc645
commit
b63e385a89
@ -1228,33 +1228,6 @@ fn to_workspace_config(
|
|||||||
ws_root_config
|
ws_root_config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_inheritable_fields(
|
|
||||||
gctx: &GlobalContext,
|
|
||||||
resolved_path: &Path,
|
|
||||||
workspace_config: &WorkspaceConfig,
|
|
||||||
) -> CargoResult<InheritableFields> {
|
|
||||||
match workspace_config {
|
|
||||||
WorkspaceConfig::Root(root) => Ok(root.inheritable().clone()),
|
|
||||||
WorkspaceConfig::Member {
|
|
||||||
root: Some(ref path_to_root),
|
|
||||||
} => {
|
|
||||||
let path = resolved_path
|
|
||||||
.parent()
|
|
||||||
.unwrap()
|
|
||||||
.join(path_to_root)
|
|
||||||
.join("Cargo.toml");
|
|
||||||
let root_path = paths::normalize_path(&path);
|
|
||||||
inheritable_from_path(gctx, root_path)
|
|
||||||
}
|
|
||||||
WorkspaceConfig::Member { root: None } => {
|
|
||||||
match find_workspace_root(&resolved_path, gctx)? {
|
|
||||||
Some(path_to_root) => inheritable_from_path(gctx, path_to_root),
|
|
||||||
None => Err(anyhow!("failed to find a workspace root")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_virtual_manifest(
|
fn to_virtual_manifest(
|
||||||
contents: String,
|
contents: String,
|
||||||
document: toml_edit::ImDocument<String>,
|
document: toml_edit::ImDocument<String>,
|
||||||
@ -1561,6 +1534,33 @@ fn unused_dep_keys(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_inheritable_fields(
|
||||||
|
gctx: &GlobalContext,
|
||||||
|
resolved_path: &Path,
|
||||||
|
workspace_config: &WorkspaceConfig,
|
||||||
|
) -> CargoResult<InheritableFields> {
|
||||||
|
match workspace_config {
|
||||||
|
WorkspaceConfig::Root(root) => Ok(root.inheritable().clone()),
|
||||||
|
WorkspaceConfig::Member {
|
||||||
|
root: Some(ref path_to_root),
|
||||||
|
} => {
|
||||||
|
let path = resolved_path
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.join(path_to_root)
|
||||||
|
.join("Cargo.toml");
|
||||||
|
let root_path = paths::normalize_path(&path);
|
||||||
|
inheritable_from_path(gctx, root_path)
|
||||||
|
}
|
||||||
|
WorkspaceConfig::Member { root: None } => {
|
||||||
|
match find_workspace_root(&resolved_path, gctx)? {
|
||||||
|
Some(path_to_root) => inheritable_from_path(gctx, path_to_root),
|
||||||
|
None => Err(anyhow!("failed to find a workspace root")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn inheritable_from_path(
|
fn inheritable_from_path(
|
||||||
gctx: &GlobalContext,
|
gctx: &GlobalContext,
|
||||||
workspace_path: PathBuf,
|
workspace_path: PathBuf,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user