summaryrefslogtreecommitdiff
path: root/js/src/builtin/Promise.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/builtin/Promise.cpp')
-rw-r--r--js/src/builtin/Promise.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
index 7d4c232f2e..8755025ed0 100644
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -311,7 +311,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
elements().setElementNeedsWrapping = needsWrapping;
}
- MOZ_MUST_USE bool pushUndefined(JSContext* cx) {
+ [[nodiscard]] bool pushUndefined(JSContext* cx) {
// Helper for the AutoCompartment we need to work with |array|. We mostly do this
// for performance; we could go ahead and do the define via a cross-
// compartment proxy instead...
@@ -335,7 +335,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
// Promise.all/allSettled/any function, which isn't necessarily the same
// compartment as unwrappedArray as explained in NewPromiseCombinatorElements.
// So before storing |val| we may need to enter unwrappedArray's compartment.
- MOZ_MUST_USE bool setElement(JSContext* cx, uint32_t index, HandleValue val) {
+ [[nodiscard]] bool setElement(JSContext* cx, uint32_t index, HandleValue val) {
// The index is guaranteed to be initialized to `undefined`.
MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined());
@@ -560,7 +560,7 @@ MaybeGetAndClearException(JSContext* cx, MutableHandleValue rval)
return GetAndClearException(cx, rval);
}
-static MOZ_MUST_USE bool RunResolutionFunction(JSContext *cx, HandleObject resolutionFun,
+[[nodiscard]] static bool RunResolutionFunction(JSContext *cx, HandleObject resolutionFun,
HandleValue result, ResolutionMode mode,
HandleObject promiseObj);
@@ -778,7 +778,7 @@ static bool ResolvePromiseFunction(JSContext* cx, unsigned argc, Value* vp);
static bool RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp);
// ES2016, 25.4.1.3.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CreateResolvingFunctions(JSContext* cx, HandleObject promise,
MutableHandleObject resolveFn,
MutableHandleObject rejectFn)
@@ -823,11 +823,11 @@ IsSettledMaybeWrappedPromise(JSObject* promise)
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason);
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason);
// ES2016, 25.4.1.3.1.
@@ -874,15 +874,15 @@ RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj,
+[[nodiscard]] static bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj,
HandleValue value_);
-static MOZ_MUST_USE bool EnqueuePromiseResolveThenableJob(JSContext* cx,
+[[nodiscard]] static bool EnqueuePromiseResolveThenableJob(JSContext* cx,
HandleValue promiseToResolve,
HandleValue thenable,
HandleValue thenVal);
-static MOZ_MUST_USE bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx,
+[[nodiscard]] static bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx,
HandleObject promiseToResolve,
HandleObject thenable);
@@ -891,7 +891,7 @@ static bool Promise_then_impl(JSContext* cx, HandleValue promiseVal, HandleValue
HandleValue onRejected, MutableHandleValue rval, bool rvalUsed);
// ES2016, 25.4.1.3.2, steps 6-13.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ResolvePromiseInternal(JSContext* cx, HandleObject promise, HandleValue resolutionVal)
{
assertSameCompartment(cx, promise, resolutionVal);
@@ -1024,7 +1024,7 @@ static bool PromiseReactionJob(JSContext* cx, unsigned argc, Value* vp);
* targetState - The PromiseState this reaction job targets. This decides
* whether the onFulfilled or onRejected handler is called.
*/
-MOZ_MUST_USE static bool
+[[nodiscard]] static bool
EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
HandleValue handlerArg_, JS::PromiseState targetState)
{
@@ -1130,11 +1130,11 @@ EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
return cx->runtime()->enqueuePromiseJob(cx, job, promise, global);
}
-static MOZ_MUST_USE bool TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal,
+[[nodiscard]] static bool TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal,
JS::PromiseState state, HandleValue valueOrReason);
// ES2016, Commoned-out implementation of 25.4.1.4. and 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueOrReason,
JS::PromiseState state)
{
@@ -1177,14 +1177,14 @@ ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueO
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason)
{
return ResolvePromise(cx, promise, reason, JS::PromiseState::Rejected);
}
// ES2016, 25.4.1.4.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue value_)
{
Rooted<PromiseObject*> promise(cx);
@@ -1210,7 +1210,7 @@ FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue v
static bool GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp);
static bool PromiseConstructor(JSContext* cx, unsigned argc, Value* vp);
-static MOZ_MUST_USE PromiseObject* CreatePromiseObjectInternal(JSContext* cx,
+[[nodiscard]] static PromiseObject* CreatePromiseObjectInternal(JSContext* cx,
HandleObject proto = nullptr,
bool protoIsWrapped = false,
bool informDebugger = true);
@@ -1220,7 +1220,7 @@ enum GetCapabilitiesExecutorSlots {
GetCapabilitiesExecutorSlots_Reject
};
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
{
Rooted<PromiseObject*> promise(cx, CreatePromiseObjectInternal(cx));
@@ -1231,7 +1231,7 @@ CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
return promise;
}
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject resolve,
MutableHandleObject reject)
{
@@ -1258,7 +1258,7 @@ CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject r
}
// ES2016, 25.4.1.5.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
NewPromiseCapability(JSContext* cx, HandleObject C, MutableHandle<PromiseCapability> capability,
bool canOmitResolutionFunctions)
{
@@ -1369,7 +1369,7 @@ GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp)
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason_)
{
Rooted<PromiseObject*> promise(cx);
@@ -1410,7 +1410,7 @@ RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue re
}
// ES2016, 25.4.1.8.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseState state,
HandleValue valueOrReason)
{
@@ -1440,7 +1440,7 @@ TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseStat
// Implements PromiseReactionJob optimized for the case when the reaction
// handler is one of the default resolving functions as created by the
// CreateResolvingFunctions abstract operation.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1485,7 +1485,7 @@ DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*>
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1513,7 +1513,7 @@ AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> re
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1723,7 +1723,7 @@ PromiseResolveThenableJob(JSContext* cx, unsigned argc, Value* vp)
return Call(cx, rejectVal, UndefinedHandleValue, rval, &rval);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve);
@@ -1785,7 +1785,7 @@ PromiseResolveBuiltinThenableJob(JSContext* cx, unsigned argc, Value* vp)
* thenable_ - The thenable to resolve the Promise with.
* thenVal - The `then` function to invoke with the `thenable` as the receiver.
*/
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_,
HandleValue thenable_, HandleValue thenVal)
{
@@ -1847,7 +1847,7 @@ EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_,
* promiseToResolve - The promise to resolve, obviously.
* thenable - The thenable to resolve the Promise with.
*/
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToResolve,
HandleObject thenable)
{
@@ -1869,11 +1869,11 @@ EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToRes
return cx->runtime()->enqueuePromiseJob(cx, job, promiseToResolve, incumbentGlobal);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction);
@@ -1947,7 +1947,7 @@ ClearResolutionFunctionSlots(JSFunction* resolutionFun)
}
// ES2016, 25.4.3.1. steps 3-7.
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseObjectInternal(JSContext* cx, HandleObject proto /* = nullptr */,
bool protoIsWrapped /* = false */, bool informDebugger /* = true */)
{
@@ -2175,19 +2175,19 @@ class MOZ_STACK_CLASS PromiseForOfIterator : public JS::ForOfIterator {
}
};
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAllSettled(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAny(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseRace(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
@@ -2204,7 +2204,7 @@ enum class CombinatorKind { All, AllSettled, Any, Race };
// https://tc39.es/proposal-promise-any/
//
// Promise.any ( iterable )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CommonPromiseCombinator(JSContext* cx, CallArgs& args, CombinatorKind mode)
{
HandleValue iterable = args.get(0);
@@ -2340,11 +2340,11 @@ static bool Promise_static_all(JSContext* cx, unsigned argc, Value* vp) {
return CommonPromiseCombinator(cx, args, CombinatorKind::All);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability);
@@ -2356,7 +2356,7 @@ static JSFunction* NewPromiseCombinatorElementFunction(
static bool PromiseAllResolveElementFunction(JSContext* cx, unsigned argc, Value* vp);
// Unforgeable version of ES2016, 25.4.4.1.
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
{
#ifdef DEBUG
@@ -2476,7 +2476,7 @@ js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
return resultCapability.promise();
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue result,
ResolutionMode mode, HandleObject promiseObj)
{
@@ -2528,7 +2528,7 @@ RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue res
return RejectPromiseInternal(cx, promise, result);
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode);
@@ -2544,7 +2544,7 @@ IsPromiseSpecies(JSContext* cx, JSFunction* species);
// https://tc39.es/proposal-promise-any/
// Runtime Semantics: PerformPromiseAny, steps 6-8.
template <typename T>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
HandleObject resultPromise, HandleValue promiseResolve, bool* done,
bool resolveReturnsUndefined, T getResolveAndReject)
@@ -2810,7 +2810,7 @@ CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, Ha
// Create the elements for the Promise combinators Promise.all and
// Promise.allSettled.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapability,
MutableHandle<PromiseCombinatorElements> elements)
{
@@ -2862,7 +2862,7 @@ NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapa
}
// Retrieve the combinator elements from the data holder.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
GetPromiseCombinatorElements(JSContext* cx, Handle<PromiseCombinatorDataHolder*> data,
MutableHandle<PromiseCombinatorElements> elements)
{
@@ -2947,7 +2947,7 @@ PromiseCombinatorElementFunctionAlreadyCalled(const CallArgs& args,
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.1.1 PerformPromiseAll (iteratorRecord, constructor, resultCapability)
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{
@@ -3083,7 +3083,7 @@ Promise_static_race(JSContext* cx, unsigned argc, Value* vp)
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.3.1 PerformPromiseRace (iteratorRecord, constructor, resultCapability)
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseRace(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{
@@ -3138,7 +3138,7 @@ static bool Promise_static_allSettled(JSContext* cx, unsigned argc, Value* vp) {
// 25.6.4.2 Promise.allSettled ( iterable )
//
// PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
-static MOZ_MUST_USE bool PerformPromiseAllSettled(
+[[nodiscard]] static bool PerformPromiseAllSettled(
JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) {
*done = false;
@@ -3349,7 +3349,7 @@ static void ThrowAggregateError(JSContext* cx,
// https://tc39.es/proposal-promise-any/
//
// PerformPromiseAny ( iteratorRecord, constructor, resultCapability )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAny(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{
@@ -3553,7 +3553,7 @@ ThrowAggregateError(JSContext* cx, Handle<PromiseCombinatorElements> errors, Han
// 25.6.4.4 Promise.reject ( r )
// 25.6.4.5 Promise.resolve ( x )
// 25.6.4.5.1 PromiseResolve ( C, x )
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode)
{
@@ -3610,7 +3610,7 @@ CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue ar
return capability.promise();
}
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value)
{
RootedValue C(cx, ObjectValue(*constructor));
@@ -3789,7 +3789,7 @@ PromiseThenNewPromiseCapability(JSContext* cx, HandleObject promiseObj,
}
// ES2016, 25.4.5.3., steps 3-5.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue onFulfilled, HandleValue onRejected,
MutableHandleObject dependent, CreateDependentPromise createDependent)
@@ -3813,7 +3813,7 @@ js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve)
{
@@ -3870,7 +3870,7 @@ OriginalPromiseThenBuiltin(JSContext* cx, HandleValue promiseVal, HandleValue on
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise)
{
// Not much we can do about uncatchable exceptions, just bail.
@@ -3880,7 +3880,7 @@ js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise)
return PromiseObject::reject(cx, promise, exn);
}
-static MOZ_MUST_USE bool PerformPromiseThenWithReaction(JSContext* cx,
+[[nodiscard]] static bool PerformPromiseThenWithReaction(JSContext* cx,
Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction);
@@ -3888,7 +3888,7 @@ static MOZ_MUST_USE bool PerformPromiseThenWithReaction(JSContext* cx,
// js/src/builtin/AsyncFunction.cpp, to call Promise internal functions.
// ES 2018 draft 14.6.11 and 14.7.14 step 1.
-MOZ_MUST_USE PromiseObject*
+[[nodiscard]] PromiseObject*
js::CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal)
{
// Step 1.
@@ -3909,7 +3909,7 @@ js::IsPromiseForAsync(JSObject* promise)
}
// ES 2018 draft 25.5.5.2 steps 3.f, 3.g.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise)
{
// Step 3.f.
@@ -3925,7 +3925,7 @@ js::AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise)
}
// ES 2018 draft 25.5.5.2 steps 3.d-e, 3.g.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{
// Steps 3.d-e.
@@ -3939,7 +3939,7 @@ js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, H
// Helper function that performs the equivalent steps as
// Async Iteration proposal 4.1 Await steps 2-3, 6-9 or similar.
template <typename T>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
HandleValue onFulfilled, HandleValue onRejected, T extraStep)
{
@@ -3972,7 +3972,7 @@ InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
}
// ES 2018 draft 25.5.5.3 steps 2-10.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{
// Steps 4-5.
@@ -3987,7 +3987,7 @@ js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, Hand
}
// Async Iteration proposal 4.1 Await steps 2-9.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value)
{
@@ -4146,13 +4146,13 @@ enum class ResumeNextKind {
Enqueue, Reject, Resolve
};
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind, HandleValue valueOrException = UndefinedHandleValue,
bool done = false);
// Async Iteration proposal 11.4.3.3.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value, bool done)
{
@@ -4160,7 +4160,7 @@ js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenO
}
// Async Iteration proposal 11.4.3.4.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue exception)
{
@@ -4168,7 +4168,7 @@ js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
}
// Async Iteration proposal 11.4.3.5.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind,
HandleValue valueOrException_ /* = UndefinedHandleValue */,
@@ -4349,7 +4349,7 @@ AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
}
// Async Iteration proposal 11.4.3.6.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal,
CompletionKind completionKind, HandleValue completionValue,
MutableHandleValue result)
@@ -4540,7 +4540,7 @@ Promise_then(JSContext* cx, unsigned argc, Value* vp)
}
// ES2016, 25.4.5.3.1.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability)
{
@@ -4567,7 +4567,7 @@ PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue on
return PerformPromiseThenWithReaction(cx, promise, reaction);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability)
@@ -4593,7 +4593,7 @@ PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> pr
return PerformPromiseThenWithReaction(cx, promise, reaction);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction)
{
@@ -4637,7 +4637,7 @@ PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction)
{
@@ -4705,7 +4705,7 @@ AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise)
{