Skip to content

Commit 751fd66

Browse files
authored
Handle interface names that collide with Rust keywords. (#508)
Use `to_rust_ident` for interface names, and add a test for a world and interface with names that collide with Rust keywords. Fixes #507.
1 parent 62a6233 commit 751fd66

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

crates/gen-guest-rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl InterfaceGenerator<'_> {
373373

374374
fn finish_append_submodule(mut self, name: &str) {
375375
let module = self.finish();
376-
let snake = name.to_snake_case();
376+
let snake = to_rust_ident(name);
377377
uwriteln!(
378378
self.gen.src,
379379
"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default world trait {
2+
import continue: interface {
3+
break: func()
4+
}
5+
6+
export match: interface {
7+
return: func()
8+
}
9+
}

0 commit comments

Comments
 (0)