Skip to content

Commit

Permalink
Don't fail parsing on @feature and @SInCE gates.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvk committed Aug 27, 2024
1 parent bcb2087 commit 4f6efdc
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 103 deletions.
120 changes: 62 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ warg-crypto = "0.7.0"
warg-protocol = "0.7.0"
warg-server = "0.7.0"
wasi-preview1-component-adapter-provider = "23.0.1"
wasm-metadata = "0.208.1"
wasm-metadata = "0.215.0"
wasm-pkg-client = { git = "https://github.com/bytecodealliance/wasm-pkg-tools.git", rev = "c48006aa1bcff1e69f4f8fc6689249b314985ab1" }
wasmparser = "0.208.1"
wasmprinter = "0.208.1"
wasmparser = "0.215.0"
wasmprinter = "0.215.0"
wat = "1.208.1"
which = "6.0.1"
wit-bindgen-core = "0.25.0"
wit-bindgen-rust = "0.25.0"
wit-component = "0.208.1"
wit-parser = "0.208.1"
wit-bindgen-core = "0.30.0"
wit-bindgen-rust = "0.30.0"
wit-component = "0.215.0"
wit-parser = "0.215.0"

[profile.release]
panic = "abort"
Expand Down
20 changes: 12 additions & 8 deletions crates/core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use wasm_pkg_client::{
Client, Config, ContentDigest, Error as WasmPkgError, PackageRef, Release, VersionInfo,
};
use wit_component::DecodedWasm;
use wit_parser::{PackageId, PackageName, Resolve, UnresolvedPackage, WorldId};
use wit_parser::{PackageId, PackageName, Resolve, UnresolvedPackageGroup, WorldId};

use crate::{
lock::{LockFileResolver, LockedPackageVersion},
Expand Down Expand Up @@ -315,7 +315,7 @@ impl DependencyResolution {
{
return Ok(DecodedDependency::Wit {
resolution: self,
package: UnresolvedPackage::parse_dir(path).with_context(|| {
package: UnresolvedPackageGroup::parse_dir(path).with_context(|| {
format!("failed to parse dependency `{path}`", path = path.display())
})?,
});
Expand Down Expand Up @@ -354,9 +354,9 @@ impl DependencyResolution {
if &bytes[0..4] != b"\0asm" {
return Ok(DecodedDependency::Wit {
resolution: self,
package: UnresolvedPackage::parse(
package: UnresolvedPackageGroup::parse(
// This is fake, but it's needed for the parser to work.
self.name().to_string().as_ref(),
self.name().to_string(),
std::str::from_utf8(&bytes).with_context(|| {
format!(
"dependency `{name}` is not UTF-8 encoded",
Expand Down Expand Up @@ -386,7 +386,7 @@ pub enum DecodedDependency<'a> {
/// The resolution related to the decoded dependency.
resolution: &'a DependencyResolution,
/// The unresolved WIT package.
package: UnresolvedPackage,
package: UnresolvedPackageGroup,
},
/// The dependency decoded from a Wasm file.
Wasm {
Expand All @@ -406,8 +406,12 @@ impl<'a> DecodedDependency<'a> {
match self {
Self::Wit { package, .. } => {
let mut resolve = Resolve::new();
let source_files = package.source_files().map(Path::to_path_buf).collect();
let pkg = resolve.push(package)?;
let source_files = package
.source_map
.source_files()
.map(Path::to_path_buf)
.collect();
let pkg = resolve.push_group(package)?;
Ok((resolve, pkg, source_files))
}
Self::Wasm { decoded, .. } => match decoded {
Expand All @@ -423,7 +427,7 @@ impl<'a> DecodedDependency<'a> {
/// Gets the package name of the decoded dependency.
pub fn package_name(&self) -> &PackageName {
match self {
Self::Wit { package, .. } => &package.name,
Self::Wit { package, .. } => &package.main.name,
Self::Wasm { decoded, .. } => &decoded.resolve().packages[decoded.package()].name,
}
}
Expand Down
Loading

0 comments on commit 4f6efdc

Please sign in to comment.