diff options
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 3 | ||||
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 11 |
2 files changed, 7 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 6b23e485e25..7e80e6c9969 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3953,7 +3953,8 @@ class CGUnionConversionStruct(CGThing): method = CGWrapper( CGIndenter(CGList(conversions, "\n\n")), pre="unsafe fn from_jsval(cx: *mut JSContext,\n" - " value: HandleValue, _option: ())" + " value: HandleValue,\n" + " _option: ())\n" " -> Result<ConversionResult<%s>, ()> {\n" % self.type, post="\n}") return CGWrapper( diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 3ac26b0f97b..113a9d279d5 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -104,15 +104,14 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> { type Config = (); - unsafe fn from_jsval(cx: *mut JSContext, + unsafe fn from_jsval(_cx: *mut JSContext, value: HandleValue, _config: Self::Config) -> Result<ConversionResult<Root<T>>, ()> { - let result = root_from_handlevalue(value); - if let Err(()) = result { - throw_type_error(cx, "value is not an object"); - } - result.map(ConversionResult::Success) + Ok(match root_from_handlevalue(value) { + Ok(result) => ConversionResult::Success(result), + Err(()) => ConversionResult::Failure("value is not an object".into()), + }) } } |