1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-07-31 03:51:56 +00:00

Make to_idl_type infallible

This commit makes the `to_idl_type` infallible, returning a new enum
variant, `UnknownInterface`, in the one location that we still return
`None`. By making this infallible we can ensure that expansion of unions
which have unknown types still generate methods for all the variants
which we actually have all the methods for!
This commit is contained in:
Alex Crichton
2018-11-07 10:37:43 -08:00
parent ac6a230d83
commit 176eedc63b
3 changed files with 66 additions and 78 deletions
crates/webidl/src

@@ -336,7 +336,7 @@ impl<'src> FirstPassRecord<'src> {
) -> Option<backend::ast::ImportFunction> {
let kind = backend::ast::OperationKind::Getter(Some(raw_ident(name)));
let kind = self.import_function_kind(self_name, is_static, kind);
let ret = ty.to_idl_type(self)?;
let ret = ty.to_idl_type(self);
self.create_one_function(
&name,
&snake_case_ident(name),
@@ -366,7 +366,7 @@ impl<'src> FirstPassRecord<'src> {
) -> Option<backend::ast::ImportFunction> {
let kind = backend::ast::OperationKind::Setter(Some(raw_ident(name)));
let kind = self.import_function_kind(self_name, is_static, kind);
let field_ty = field_ty.to_idl_type(self)?;
let field_ty = field_ty.to_idl_type(self);
self.create_one_function(
&name,
&format!("set_{}", name).to_snake_case(),
@@ -431,10 +431,7 @@ impl<'src> FirstPassRecord<'src> {
);
signatures.push((signature, idl_args.clone()));
}
match arg.ty.to_idl_type(self) {
Some(t) => idl_args.push(t),
None => continue 'outer,
}
idl_args.push(arg.ty.to_idl_type(self));
}
signatures.push((signature, idl_args));
}
@@ -517,10 +514,7 @@ impl<'src> FirstPassRecord<'src> {
// TODO: overloads probably never change return types, so we should
// do this much earlier to avoid all the above work if
// possible.
let ret_ty = match signature.orig.ret.to_idl_type(self) {
Some(ty) => ty,
None => continue,
};
let ret_ty = signature.orig.ret.to_idl_type(self);
let mut rust_name = snake_case_ident(name);
let mut first = true;