Truly independent web browser
Meta: Keep clippy quiet about three shapes of the Rust bindings
Aliaksandr Kalenik9da0466ca634
diff --git a/Meta/Generators/libweb_bindings/rust_bindings.py b/Meta/Generators/libweb_bindings/rust_bindings.pyindex b45d453eb90..9dd2d73ec76 100644--- a/Meta/Generators/libweb_bindings/rust_bindings.py+++ b/Meta/Generators/libweb_bindings/rust_bindings.py@@ -614,11 +614,15 @@ def write_this_implementation(out: TextIO, context: GenerationContext, interfacewhile ancestor.name != interface.name:next_ancestor = context.interfaces[ancestor.parent_name]next_path = "Implementation" if next_ancestor.name == interface.name else rust_interface_path(next_ancestor)- steps += f" let object = <{rust_interface_path(ancestor)} as Inherits<{next_path}>>::parent(object);\n"+ step = f"<{rust_interface_path(ancestor)} as Inherits<{next_path}>>::parent(object)"+ # NB: The last step is the value of the arm.+ if next_ancestor.name == interface.name:+ steps += f" {step}\n"+ else:+ steps += f" let object = {step};\n"ancestor = next_ancestorarms += f""" Self::{other.name}(object) => {{-{steps} object- }}+{steps} }}"""choices += f""" if let Some(object) = implementation_if::<{path}>(object) {{return Ok((Receiver::{other.name}(object), cx));@@ -697,16 +701,26 @@ def write_rust_operation(steps.write(" drop(type_error_realm_scope);\n")arguments = "".join(f", {rust_local_name(parameter.name)}" for parameter in operation.parameters)returns_promise = is_promise_type(operation.return_type) and not operation.return_type.nullable- if returns_promise:- conversion = "result.to_js(&cx)"+ call = f"Implementation::{overload.method}(&implementation, &mut cx{arguments})"+ if operation.return_type.name == "undefined" and not operation.return_type.nullable:+ # NB: An operation that returns nothing has no result to name, and the conversion of nothing is undefined.+ steps.write(+ f""" {call}+ .map_err(|exception| exception.throw(vm))?;+ Ok(Value::UNDEFINED)+"""+ )else:- conversion = rust_to_js_value(operation.return_type, "result", "&cx", context, what)- steps.write(- f""" let result = Implementation::{overload.method}(&implementation, &mut cx{arguments})+ if returns_promise:+ conversion = "result.to_js(&cx)"+ else:+ conversion = rust_to_js_value(operation.return_type, "result", "&cx", context, what)+ steps.write(+ f""" let result = {call}.map_err(|exception| exception.throw(vm))?;{conversion}"""- )+ )out.write(f"\n fn {function}(vm: &Vm) -> ThrowCompletionOr<Value> {{\n")if returns_promise:diff --git a/Meta/Generators/libweb_bindings/rust_overloads.py b/Meta/Generators/libweb_bindings/rust_overloads.pyindex 1fb616d2367..db4a652c2fa 100644--- a/Meta/Generators/libweb_bindings/rust_overloads.py+++ b/Meta/Generators/libweb_bindings/rust_overloads.py@@ -284,6 +284,17 @@ def write_resolution_at_distinguishing_index(if {step.argument_test} {{return {selections[0][1]};}}+"""+ )+ continue+ if len(selections) == 1:+ condition, call = selections[0]+ condition = f"({condition})" if "||" in condition else condition+ out.write(+ f""" // {step.description}+ if {step.argument_test} && {condition} {{+ return {call};+ }}""")continue