2929// - Awaiter: `or_unwind` (&, const&, &&), `or_unwind_owning`
3030// - Context: `result` coroutine, `now_task` coroutine
3131// - Inner type: `void`, `int` and refs, `string`, `unique_ptr` and refs
32- // - Result-like container: `result`, `value_only_result`, `non_value_result `
32+ // - Result-like container: `result`, `value_only_result`, `error_or_stopped `
3333// - States: value, error, stopped
3434
3535#if FOLLY_HAS_RESULT
@@ -90,7 +90,8 @@ consteval void checkAwaitResumeType() {
9090 decltype (std::declval<Awaitable>().await_resume ())>);
9191}
9292
93- // Check `await_resume()` types for rvalue-only types (e.g. `non_value_result`).
93+ // Check `await_resume()` types for rvalue-only types (e.g.
94+ // `error_or_stopped`).
9495template <typename ResultT, typename RvalueT, typename OwningT>
9596consteval void checkRvalueAwaitResumeTypes () {
9697 checkAwaitResumeType<RvalueT, decltype (or_unwind (FOLLY_DECLVAL (ResultT)))>();
@@ -150,9 +151,9 @@ ResultT makeResultWithValue(MakeInner&& makeInner) {
150151 }
151152}
152153
153- // An empty `non_value_result ` made from an empty `exception_wrapper`.
154- inline non_value_result emptyNonValue () {
155- return non_value_result ::make_legacy_error_or_cancellation_slow (
154+ // An empty `error_or_stopped ` made from an empty `exception_wrapper`.
155+ inline error_or_stopped emptyErrorOrStopped () {
156+ return error_or_stopped ::make_legacy_error_or_cancellation_slow (
156157 detail::result_private_t {}, exception_wrapper{});
157158}
158159
@@ -170,16 +171,17 @@ void forEachOrUnwindVariant(MakeResult makeResult, Check&& check) {
170171 check (tag_t <Context>{}, or_unwind (std::as_const (val)));
171172 // Lvalue refs must NOT mutate the original (error is copied, not moved).
172173 // Users don't expect `co_await or_unwind(r)` to mutate `r`.
173- if constexpr (requires { val.non_value (); }) {
174- EXPECT_TRUE (hasValue || (emptyNonValue () != val.non_value ()));
174+ if constexpr (requires { val.error_or_stopped (); }) {
175+ EXPECT_TRUE (
176+ hasValue || (emptyErrorOrStopped () != val.error_or_stopped ()));
175177 }
176178 }
177179 check (tag_t <Context>{}, or_unwind_owning (makeResult ()));
178180 // By rvalue ref -- error SHOULD be moved out.
179181 check (tag_t <Context>{}, or_unwind (std::move (val)));
180- if constexpr (requires { val.non_value (); }) {
182+ if constexpr (requires { val.error_or_stopped (); }) {
181183 // NOLINTNEXTLINE(bugprone-use-after-move)
182- EXPECT_TRUE (hasValue || (emptyNonValue () == val.non_value ()));
184+ EXPECT_TRUE (hasValue || (emptyErrorOrStopped () == val.error_or_stopped ()));
183185 }
184186}
185187
@@ -220,19 +222,19 @@ struct CheckExtractRef {
220222 }
221223};
222224
223- // Test non-value propagation across all applicable variants.
224- template <typename MakeNonValue , typename Verify>
225- void testNonValue (MakeNonValue makeNonValue , Verify verify) {
225+ // Test error-or-stopped propagation across all applicable variants.
226+ template <typename MakeErrorOrStopped , typename Verify>
227+ void testErrorOrStopped (MakeErrorOrStopped makeErrorOrStopped , Verify verify) {
226228 forEachOrUnwindVariant<InResult>(
227- makeNonValue , [&](tag_t <InResult>, auto && awaitable) {
229+ makeErrorOrStopped , [&](tag_t <InResult>, auto && awaitable) {
228230 auto out = InResult::run ([&]() -> InResult::Coro<void > {
229231 (void )co_await must_use_immediately_unsafe_mover (
230232 static_cast <decltype (awaitable)>(awaitable))();
231233 });
232234 verify (out);
233235 });
234236 forEachOrUnwindVariant<InTask>(
235- makeNonValue , [&](tag_t <InTask>, auto && awaitable) {
237+ makeErrorOrStopped , [&](tag_t <InTask>, auto && awaitable) {
236238 auto out = InTask::run ([&]() -> InTask::Coro<void > {
237239 (void )co_await must_use_immediately_unsafe_mover (
238240 static_cast <decltype (awaitable)>(awaitable))();
@@ -242,18 +244,18 @@ void testNonValue(MakeNonValue makeNonValue, Verify verify) {
242244}
243245
244246template <typename ... Makes>
245- void testNonValueErrors (Makes... makes) {
247+ void testErrorOrStoppedErrors (Makes... makes) {
246248 auto verify = [](auto & out) {
247249 EXPECT_TRUE (!out.has_value () && !out.has_stopped ());
248250 EXPECT_NE (nullptr , get_exception<std::runtime_error>(out));
249251 };
250- (testNonValue (makes, verify), ...);
252+ (testErrorOrStopped (makes, verify), ...);
251253}
252254
253255template <typename ... Makes>
254- void testNonValueStopped (Makes... makes) {
256+ void testErrorOrStoppedStopped (Makes... makes) {
255257 auto verify = [](auto & out) { EXPECT_TRUE (out.has_stopped ()); };
256- (testNonValue (makes, verify), ...);
258+ (testErrorOrStopped (makes, verify), ...);
257259}
258260
259261// Test all `or_unwind...` flavors in both `result` and `now_task` coros.
@@ -278,12 +280,12 @@ void testOrUnwind(MakeInner makeInner, const CheckValue& checkValue) {
278280 forEachOrUnwindVariant<InTask>(makeRes, checkValue);
279281 }
280282
281- // Propagate error/stopped, for result types with `.non_value ()`
282- if constexpr (requires { FOLLY_DECLVAL (ResultT).non_value (); }) {
283- testNonValueErrors ([&] {
284- return ResultT{non_value_result {std::runtime_error{" err" }}};
283+ // Propagate error/stopped, for result types with `.error_or_stopped ()`
284+ if constexpr (requires { FOLLY_DECLVAL (ResultT).error_or_stopped (); }) {
285+ testErrorOrStoppedErrors ([&] {
286+ return ResultT{error_or_stopped {std::runtime_error{" err" }}};
285287 });
286- testNonValueStopped ([&] { return ResultT{stopped_result}; });
288+ testErrorOrStoppedStopped ([&] { return ResultT{stopped_result}; });
287289 }
288290}
289291
@@ -339,16 +341,16 @@ TEST(OrUnwind, valueOnlyResult) {
339341 testOrUnwindVaryingInnerType<value_only_result>();
340342}
341343
342- // Test `or_unwind...` overloads for `non_value_result ` & `stopped_result_t`
343- TEST (OrUnwind, nonValueResult ) {
344- checkRvalueAwaitResumeTypes<non_value_result , void , void >();
344+ // Test `or_unwind...` overloads for `error_or_stopped ` & `stopped_result_t`
345+ TEST (OrUnwind, errorOrStoppedResult ) {
346+ checkRvalueAwaitResumeTypes<error_or_stopped , void , void >();
345347 checkRvalueAwaitResumeTypes<stopped_result_t , void , void >();
346348
347- testNonValueErrors ([] {
348- return non_value_result {std::runtime_error{" err" }};
349+ testErrorOrStoppedErrors ([] {
350+ return error_or_stopped {std::runtime_error{" err" }};
349351 });
350- testNonValueStopped (
351- [] { return non_value_result {stopped_result}; },
352+ testErrorOrStoppedStopped (
353+ [] { return error_or_stopped {stopped_result}; },
352354 [] { return stopped_result; });
353355}
354356
0 commit comments