[libcxx-commits] [libcxx] [libc++] mark `std::expected` as `nodiscard` (PR #130820)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 26 10:00:20 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 03eb8258406b9684c44debc873f038a8779a8a09 c71ba3284b9725a446868c4cefe680e653c6269d --extensions h,cpp -- libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp libcxx/include/__expected/expected.h libcxx/test/libcxx/utilities/expected/expected.expected/and_then.mandates.verify.cpp libcxx/test/libcxx/utilities/expected/expected.expected/or_else.mandates.verify.cpp libcxx/test/libcxx/utilities/expected/expected.void/and_then.mandates.verify.cpp libcxx/test/libcxx/utilities/expected/expected.void/or_else.mandates.verify.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp
index 5c3263ec53..bbf8010452 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp
@@ -14,18 +14,14 @@
 
 #include <expected>
 
-std::expected<int, int> returns_expected() {
-  return std::expected<int, int>(5);
-}
+std::expected<int, int> returns_expected() { return std::expected<int, int>(5); }
 
-std::expected<void, int> returns_expected_void() {
-  return std::expected<void, int>();
-}
+std::expected<void, int> returns_expected_void() { return std::expected<void, int>(); }
 
 void test() {
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   returns_expected();
-  
+
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   returns_expected_void();
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/130820


More information about the libcxx-commits mailing list