Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail parsing on @feature and @since gates. #329

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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"
20 changes: 12 additions & 8 deletions crates/core/src/registry.rs
Original file line number Diff line number Diff line change
@@ -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},
@@ -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())
})?,
});
@@ -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",
@@ -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 {
@@ -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 {
@@ -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,
}
}
Loading