From 6a5a77a968898fac76df3cdf3c5b661be10e2f22 Mon Sep 17 00:00:00 2001 From: Kallyn Gowdy Date: Mon, 22 Jun 2020 14:07:51 -0400 Subject: [PATCH] Fix building with --feature js_backtrace - mozjs::jsapi::CapturedJSStack::as_string() (https://doc.servo.org/mozjs/rust/struct.CapturedJSStack.html#method.as_string) was updated to accept a second parameter which specifies which Stacktrace format to use. The default has been specified to preserve the (presumably) original behavior. - The related code has also been placed in an unsafe block since the capture_stack macro calling the unsafe mozjs::jsapi::CapturedJSStack::new() function. Seems that this commit (https://github.com/servo/servo/commit/0703a1ad6d736796d467f5a028e5ab3c6d876268) forgot this part. --- components/script/dom/bindings/error.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index f678611423b..79cc8fbd869 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -23,6 +23,8 @@ use js::jsapi::ExceptionStackBehavior; use js::jsapi::JSContext; use js::jsapi::JS_ClearPendingException; use js::jsapi::JS_IsExceptionPending; +#[cfg(feature = "js_backtrace")] +use js::jsapi::StackFormat as JSStackFormat; use js::jsval::UndefinedValue; use js::rust::wrappers::JS_ErrorFromException; use js::rust::wrappers::JS_GetPendingException; @@ -108,9 +110,9 @@ pub type ErrorResult = Fallible<()>; /// Set a pending exception for the given `result` on `cx`. pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) { #[cfg(feature = "js_backtrace")] - { + unsafe { capture_stack!(in(*cx) let stack); - let js_stack = stack.and_then(|s| s.as_string(None)); + let js_stack = stack.and_then(|s| s.as_string(None, JSStackFormat::Default)); let rust_stack = Backtrace::new(); LAST_EXCEPTION_BACKTRACE.with(|backtrace| { *backtrace.borrow_mut() = Some((js_stack, format!("{:?}", rust_stack)));