Skip to content

Commit 3787309

Browse files
committed
Auto merge of #10209 - jonhoo:pub-manifest-from-str, r=alexcrichton
Add function for parsing already-read manifest This makes the function formerly known as `do_read_manifest` public under the name `read_manifest_from_str` so that Cargo-as-a-library users can parse a manifest without re-reading a `Cargo.toml` file they have already read from disk themselves.
2 parents fcef612 + 7e160e5 commit 3787309

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,20 @@ pub fn read_manifest(
5252
);
5353
let contents = paths::read(path).map_err(|err| ManifestError::new(err, path.into()))?;
5454

55-
do_read_manifest(&contents, path, source_id, config)
55+
read_manifest_from_str(&contents, path, source_id, config)
5656
.with_context(|| format!("failed to parse manifest at `{}`", path.display()))
5757
.map_err(|err| ManifestError::new(err, path.into()))
5858
}
5959

60-
fn do_read_manifest(
60+
/// Parse an already-loaded `Cargo.toml` as a Cargo manifest.
61+
///
62+
/// This could result in a real or virtual manifest being returned.
63+
///
64+
/// A list of nested paths is also returned, one for each path dependency
65+
/// within the manifest. For virtual manifests, these paths can only
66+
/// come from patched or replaced dependencies. These paths are not
67+
/// canonicalized.
68+
pub fn read_manifest_from_str(
6169
contents: &str,
6270
manifest_file: &Path,
6371
source_id: SourceId,

0 commit comments

Comments
 (0)