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

Fix the exports key for packages-with-versions #677

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 4 additions & 14 deletions crates/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,24 +296,14 @@ impl WorldGenerator for RustWasm {
id: InterfaceId,
_files: &mut Files,
) -> Result<()> {
let (pkg, inner_name) = match name {
WorldKey::Name(name) => (None, name),
let inner_name = match name {
WorldKey::Name(name) => name,
WorldKey::Interface(id) => {
let interface = &resolve.interfaces[*id];
(
Some(&resolve.packages[interface.package.unwrap()].name),
interface.name.as_ref().unwrap(),
)
interface.name.as_ref().unwrap()
}
};
let path = format!(
"{}{inner_name}",
if let Some(pkg) = pkg {
format!("{}:{}/", pkg.namespace, pkg.name)
} else {
String::new()
}
);
let path = resolve.id_of(id).unwrap_or(inner_name.to_string());
let mut gen = self.interface(Identifier::Interface(id, name), None, resolve, false);
let (snake, pkg) = gen.start_append_submodule(name);
gen.types(id);
Expand Down
30 changes: 29 additions & 1 deletion crates/rust/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ mod symbol_does_not_conflict {
bar: func() -> string
}


world foo {
export foo1
export foo2
Expand Down Expand Up @@ -272,3 +271,32 @@ mod owned_resource_deref_mut {
}
}
}

mod package_with_versions {
wit_bindgen::generate!({
inline: "
package my:[email protected]

interface foo {
resource bar {
constructor()
}
}

world baz {
export foo
}
",
exports: {
"my:inline/[email protected]/bar": Resource
}
});

pub struct Resource;

impl exports::my::inline::foo::GuestBar for Resource {
fn new() -> Self {
loop {}
}
}
}
Loading