Change the name of wit-bindgen's host implementation traits. (#5890)
* Change the name of wit-bindgen's host implementation traits. Instead of naming the host implementation trait something like `wasi_filesystem::WasiFilesystem`, name it `wasi_filesystem::Host`, and avoid using the identifier `Host` in other places. This fixes a collision when generating bindings for the current wasi-clock API, which contains an interface `wall-clock` which contains a type `wall-clock`, which created a naming collision on the name `WallClock`. * Update tests to use the new trait name. * Fix one more. * Add the new test interface to the simple-wasi world.
This commit is contained in:
@@ -368,6 +368,7 @@ pub trait RustGenerator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate `name` to a Rust `snake_case` identifier.
|
||||
pub fn to_rust_ident(name: &str) -> String {
|
||||
match name {
|
||||
// Escape Rust keywords.
|
||||
@@ -425,3 +426,13 @@ pub fn to_rust_ident(name: &str) -> String {
|
||||
s => s.to_snake_case(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate `name` to a Rust `UpperCamelCase` identifier.
|
||||
pub fn to_rust_upper_camel_case(name: &str) -> String {
|
||||
match name {
|
||||
// We use `Host` as the name of the trait for host implementations
|
||||
// to fill in, so rename it if "Host" is used as a regular identifier.
|
||||
"host" => "Host_".into(),
|
||||
s => s.to_upper_camel_case(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user