File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,17 @@ impl SourceId {
204
204
SourceId :: new ( SourceKind :: Path , url, None )
205
205
}
206
206
207
+ /// Creates a `SourceId` from a filesystem path.
208
+ ///
209
+ /// `path`: an absolute path.
210
+ pub fn for_manifest_path ( manifest_path : & Path ) -> CargoResult < SourceId > {
211
+ if crate :: util:: toml:: is_embedded ( manifest_path) {
212
+ Self :: for_path ( manifest_path)
213
+ } else {
214
+ Self :: for_path ( manifest_path. parent ( ) . unwrap ( ) )
215
+ }
216
+ }
217
+
207
218
/// Creates a `SourceId` from a Git reference.
208
219
pub fn for_git ( url : & Url , reference : GitReference ) -> CargoResult < SourceId > {
209
220
SourceId :: new ( SourceKind :: Git ( reference) , url. clone ( ) , None )
Original file line number Diff line number Diff line change @@ -1817,11 +1817,7 @@ impl<'gctx> Packages<'gctx> {
1817
1817
match self . packages . entry ( manifest_path. to_path_buf ( ) ) {
1818
1818
Entry :: Occupied ( e) => Ok ( e. into_mut ( ) ) ,
1819
1819
Entry :: Vacant ( v) => {
1820
- let source_id = if crate :: util:: toml:: is_embedded ( manifest_path) {
1821
- SourceId :: for_path ( manifest_path) ?
1822
- } else {
1823
- SourceId :: for_path ( manifest_path. parent ( ) . unwrap ( ) ) ?
1824
- } ;
1820
+ let source_id = SourceId :: for_manifest_path ( manifest_path) ?;
1825
1821
let manifest = read_manifest ( manifest_path, source_id, self . gctx ) ?;
1826
1822
Ok ( v. insert ( match manifest {
1827
1823
EitherManifest :: Real ( manifest) => {
You can’t perform that action at this time.
0 commit comments