mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
script: Take away Fallible from new_resolved and new_rejected (#35473)
* script: Take away Fallible from new_resolved and new_rejected Both Promise::new_resolved and new_rejected only return `Ok`. We don't need them to be fallible. Simply return `Rc<Promise>`, instead of `Fallible<Rc<Promise>>`. Also, clean up relevant code. Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> * script: pull_algorithm becomes infallible The method pull_algorithm only returns `Some(Ok(_))`, which means it is infallible. Clean up the returned type. Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> * script: generic_initialize becomes infallible The method generic_initialize only returns `Ok(())`, which means it is infallible. Clean up the returned type. Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
parent
3421185737
commit
b4f48c561b
9 changed files with 23 additions and 44 deletions
|
@ -31,7 +31,7 @@ use js::rust::wrappers::{
|
|||
use js::rust::{HandleObject, HandleValue, MutableHandleObject, Runtime};
|
||||
|
||||
use crate::dom::bindings::conversions::root_from_object;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, DomObject, MutDomObject, Reflector};
|
||||
use crate::dom::bindings::settings_stack::AutoEntryScript;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
@ -153,14 +153,14 @@ impl Promise {
|
|||
global: &GlobalScope,
|
||||
cx: SafeJSContext,
|
||||
value: impl ToJSValConvertible,
|
||||
) -> Fallible<Rc<Promise>> {
|
||||
) -> Rc<Promise> {
|
||||
let _ac = JSAutoRealm::new(*cx, global.reflector().get_jsobject().get());
|
||||
unsafe {
|
||||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
value.to_jsval(*cx, rval.handle_mut());
|
||||
rooted!(in(*cx) let p = CallOriginalPromiseResolve(*cx, rval.handle()));
|
||||
assert!(!p.handle().is_null());
|
||||
Ok(Promise::new_with_js_promise(p.handle(), cx))
|
||||
Promise::new_with_js_promise(p.handle(), cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,14 +170,14 @@ impl Promise {
|
|||
global: &GlobalScope,
|
||||
cx: SafeJSContext,
|
||||
value: impl ToJSValConvertible,
|
||||
) -> Fallible<Rc<Promise>> {
|
||||
) -> Rc<Promise> {
|
||||
let _ac = JSAutoRealm::new(*cx, global.reflector().get_jsobject().get());
|
||||
unsafe {
|
||||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
value.to_jsval(*cx, rval.handle_mut());
|
||||
rooted!(in(*cx) let p = CallOriginalPromiseReject(*cx, rval.handle()));
|
||||
assert!(!p.handle().is_null());
|
||||
Ok(Promise::new_with_js_promise(p.handle(), cx))
|
||||
Promise::new_with_js_promise(p.handle(), cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue