From 17d473f27754f841616c5a3f18dc63a896fa3138 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Feb 2024 10:48:57 -0800 Subject: [PATCH] Update how WIT packages are parsed Use a new `wit_parser::Resolve::push_path` API instead of a combo of `push_dir` and `UnresolvedPackage` which handles the wasm format internally and otherwise is a superset of the prior functionality. --- crates/component-macro/src/bindgen.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/component-macro/src/bindgen.rs b/crates/component-macro/src/bindgen.rs index 3613541080a0..5bfd968b3044 100644 --- a/crates/component-macro/src/bindgen.rs +++ b/crates/component-macro/src/bindgen.rs @@ -166,15 +166,9 @@ fn parse_source( let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); let mut parse = |resolve: &mut Resolve, path: &Path| -> anyhow::Result<_> { - if path.is_dir() { - let (pkg, sources) = resolve.push_dir(path)?; - files = sources; - Ok(pkg) - } else { - let pkg = UnresolvedPackage::parse_file(path)?; - files.extend(pkg.source_files().map(|s| s.to_owned())); - resolve.push(pkg) - } + let (pkg, sources) = resolve.push_path(path)?; + files.extend(sources); + Ok(pkg) }; let path_pkg = if let Some(path) = path {