From 163060f4df919faebf38cd333261d9e46490962f Mon Sep 17 00:00:00 2001 From: Qyriad Date: Thu, 1 Jan 2026 15:24:32 +0100 Subject: [PATCH] fix Wdefaulted-function-deleted in Pos/Origin This warning was only showing up in newer Nixpkgs but presumably technically applies either way. Change-Id: I9606c8ebc599538789d502a8af3388346a6a6964 --- lix/libutil/position.hh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lix/libutil/position.hh b/lix/libutil/position.hh index 966e7f84c..3159c468c 100644 --- a/lix/libutil/position.hh +++ b/lix/libutil/position.hh @@ -7,6 +7,7 @@ #include #include +#include #include "lix/libutil/source-path.hh" @@ -50,6 +51,40 @@ struct Pos } std::optional getSource() const; + + constexpr friend bool operator==(Origin const & lhs, Origin const & rhs) + { + // clang-format: off + return std::visit(overloaded { + [&](std::monostate const &, std::monostate const &) { + return true; + }, + [&](Stdin const & lStdin, Stdin const & rStdin) { + // NOTE: comparing the `ref<>`s, not their contents. + return lStdin.source == rStdin.source; + }, + [&](String const & lStr, String const & rStr) { + // NOTE: comparing the `ref<>`s, not their contents. + return lStr.source == rStr.source; + }, + [&](CheckedSourcePath const & lPath, CheckedSourcePath const & rPath) { + return lPath == rPath; + }, + [](Hidden const & lHidden, Hidden const & rHidden) { + // NOTE(Qyriad): Pos::Hidden is an empty class with a default `operator==`, + // so we believe this will always be true. We forward the comparison anyway + // 1) because we could be wrong, and 2) so if `Hidden`'s behavior changes + // this part doesn't accidentally become incorrect. + return lHidden == rHidden; + }, + [](auto const &, auto const &) { + // This means lhs and rhs were different types, in which case we never + // consider them equal. + return false; + }, + }, lhs, rhs); + // clang-format: on + } }; Origin origin = std::monostate();