Make Promise::new_resolved unsafe

This commit is contained in:
Anthony Ramine 2017-09-22 14:08:25 +02:00
parent a69c5da208
commit 386973efeb

View file

@ -112,18 +112,16 @@ impl Promise {
} }
#[allow(unrooted_must_root, unsafe_code)] #[allow(unrooted_must_root, unsafe_code)]
pub fn new_resolved( pub unsafe fn new_resolved(
global: &GlobalScope, global: &GlobalScope,
cx: *mut JSContext, cx: *mut JSContext,
value: HandleValue, value: HandleValue,
) -> Fallible<Rc<Promise>> { ) -> Fallible<Rc<Promise>> {
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
rooted!(in(cx) let p = unsafe { CallOriginalPromiseResolve(cx, value) }); rooted!(in(cx) let p = CallOriginalPromiseResolve(cx, value));
assert!(!p.handle().is_null()); assert!(!p.handle().is_null());
unsafe {
Ok(Promise::new_with_js_promise(p.handle(), cx)) Ok(Promise::new_with_js_promise(p.handle(), cx))
} }
}
#[allow(unrooted_must_root, unsafe_code)] #[allow(unrooted_must_root, unsafe_code)]
pub unsafe fn new_rejected( pub unsafe fn new_rejected(