diff options
author | Thomas Lively <tlively@google.com> | 2024-11-15 16:18:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 13:18:29 -0800 |
commit | 368c1edf2a6182dcde7a91e6facbf3dbdd6c7456 (patch) | |
tree | 048eb337ab186d3548a3b4460de39e513e5da4a6 /src/support | |
parent | ce1a2b480ae89e65b4d94e1bb3332c5980e2479f (diff) | |
download | binaryen-368c1edf2a6182dcde7a91e6facbf3dbdd6c7456.tar.gz binaryen-368c1edf2a6182dcde7a91e6facbf3dbdd6c7456.tar.bz2 binaryen-368c1edf2a6182dcde7a91e6facbf3dbdd6c7456.zip |
Mark Result and MaybeResult [[nodiscard]] (#7083)
Since these types may be carrying errors that need to be handled or
propagated, it is always an error not to use them in some way. Adding
the [[nodiscard]] attribute caused the compiler to find a few instances
where we were incorrectly ignoring results. Fix these places.
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/result.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/support/result.h b/src/support/result.h index ab71d3a53..7cd360d53 100644 --- a/src/support/result.h +++ b/src/support/result.h @@ -40,7 +40,7 @@ struct Err { } // Represent a result of type T or an error message. -template<typename T = Ok> struct Result { +template<typename T = Ok> struct [[nodiscard]] Result { std::variant<T, Err> val; Result(Result<T>& other) = default; @@ -56,7 +56,7 @@ template<typename T = Ok> struct Result { }; // Represent an optional result of type T or an error message. -template<typename T = Ok> struct MaybeResult { +template<typename T = Ok> struct [[nodiscard]] MaybeResult { std::variant<T, None, Err> val; MaybeResult() : val(None{}) {} |