Skip to content

Commit 080f747

Browse files
committed
refactor: Consolidate to SourceId::from_manifest_path
1 parent 5a35140 commit 080f747

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/cargo/core/workspace.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'gctx> Workspace<'gctx> {
447447
BTreeMap<String, BTreeMap<String, TomlDependency<ConfigRelativePath>>>,
448448
> = self.gctx.get("patch")?;
449449

450-
let source = SourceId::for_path(self.root())?;
450+
let source = SourceId::for_manifest_path(self.root_manifest())?;
451451

452452
let mut warnings = Vec::new();
453453

@@ -1144,7 +1144,7 @@ impl<'gctx> Workspace<'gctx> {
11441144
if let Some(p) = loaded.get(manifest_path).cloned() {
11451145
return Ok(p);
11461146
}
1147-
let source_id = SourceId::for_path(manifest_path.parent().unwrap())?;
1147+
let source_id = SourceId::for_manifest_path(manifest_path)?;
11481148
let package = ops::read_package(manifest_path, source_id, self.gctx)?;
11491149
loaded.insert(manifest_path.to_path_buf(), package.clone());
11501150
Ok(package)
@@ -1975,8 +1975,7 @@ pub fn find_workspace_root(
19751975
gctx: &GlobalContext,
19761976
) -> CargoResult<Option<PathBuf>> {
19771977
find_workspace_root_with_loader(manifest_path, gctx, |self_path| {
1978-
let key = self_path.parent().unwrap();
1979-
let source_id = SourceId::for_path(key)?;
1978+
let source_id = SourceId::for_manifest_path(self_path)?;
19801979
let manifest = read_manifest(self_path, source_id, gctx)?;
19811980
Ok(manifest
19821981
.workspace_config()

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ fn inheritable_from_path(
946946
return Ok(ws_root.inheritable().clone());
947947
};
948948

949-
let source_id = SourceId::for_path(workspace_path_root)?;
949+
let source_id = SourceId::for_manifest_path(&workspace_path)?;
950950
let man = read_manifest(&workspace_path, source_id, gctx)?;
951951
match man.workspace_config() {
952952
WorkspaceConfig::Root(root) => {

0 commit comments

Comments
 (0)