diff --git a/src/libexpr/include/nix/expr/value/context.hh b/src/libexpr/include/nix/expr/value/context.hh index 8fc948622768..5413d4062ee4 100644 --- a/src/libexpr/include/nix/expr/value/context.hh +++ b/src/libexpr/include/nix/expr/value/context.hh @@ -17,11 +17,11 @@ public: std::string_view raw; template - BadNixStringContextElem(std::string_view raw_, const Args &... args) + BadNixStringContextElem(std::string_view raw_, Args &&... args) : CloneableError("") { raw = raw_; - auto hf = HintFmt(args...); + auto hf = HintFmt(std::forward(args)...); err.msg = HintFmt("Bad String Context element: %1%: %2%", Uncolored(hf.str()), raw); } }; diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 374a39996516..e1b9eaeca4b0 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -1446,20 +1446,16 @@ void FileTransfer::download( void FileTransferError::anchor() {} template -FileTransferError::FileTransferError( - FileTransfer::Error error, std::optional response, const Args &... args) - : CloneableError(args...) +FileTransferError::FileTransferError(FileTransfer::Error error, std::optional response, Args &&... args) + : CloneableError(HintFmt(std::forward(args)...)) , error(error) , response(response) { - const auto hf = HintFmt(args...); // FIXME: Due to https://github.com/NixOS/nix/issues/3841 we don't know how // to print different messages for different verbosity levels. For now // we add some heuristics for detecting when we want to show the response. if (response && (response->size() < 1024 || response->find("") != std::string::npos)) - err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(hf.str()), chomp(*response)); - else - err.msg = hf; + err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(err.msg.str()), chomp(*response)); } } // namespace nix diff --git a/src/libstore/include/nix/store/build-result.hh b/src/libstore/include/nix/store/build-result.hh index 808fcc829eda..c68dc2f8aa63 100644 --- a/src/libstore/include/nix/store/build-result.hh +++ b/src/libstore/include/nix/store/build-result.hh @@ -82,8 +82,8 @@ public: * Delegates to the string constructor after formatting. */ template - BuildError(Status status, const Args &... args) - : CloneableError(args...) + BuildError(Status status, Args &&... args) + : CloneableError(std::forward(args)...) , status{status} { } diff --git a/src/libstore/include/nix/store/filetransfer.hh b/src/libstore/include/nix/store/filetransfer.hh index 774a4e1403b3..38f13af5d23c 100644 --- a/src/libstore/include/nix/store/filetransfer.hh +++ b/src/libstore/include/nix/store/filetransfer.hh @@ -499,7 +499,7 @@ public: std::optional response; template - FileTransferError(FileTransfer::Error error, std::optional response, const Args &... args); + FileTransferError(FileTransfer::Error error, std::optional response, Args &&... args); }; } // namespace nix diff --git a/src/libstore/include/nix/store/sqlite.hh b/src/libstore/include/nix/store/sqlite.hh index d11515b29618..72092d34791d 100644 --- a/src/libstore/include/nix/store/sqlite.hh +++ b/src/libstore/include/nix/store/sqlite.hh @@ -176,9 +176,9 @@ class SQLiteError : public CloneableError public: template - [[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, const Args &... args) + [[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, Args &&... args) { - throw_(db, HintFmt(fs, args...)); + throw_(db, HintFmt(fs, std::forward(args)...)); } SQLiteError(const char * path, const char * errMsg, int errNo, int extendedErrNo, int offset, HintFmt && hf); @@ -193,8 +193,8 @@ protected: int extendedErrNo, int offset, const std::string & fs, - const Args &... args) - : SQLiteError(path, errMsg, errNo, extendedErrNo, offset, HintFmt(fs, args...)) + Args &&... args) + : SQLiteError(path, errMsg, errNo, extendedErrNo, offset, HintFmt(fs, std::forward(args)...)) { } diff --git a/src/libstore/windows/pathlocks.cc b/src/libstore/windows/pathlocks.cc index fe0e056d7c73..659d472cef07 100644 --- a/src/libstore/windows/pathlocks.cc +++ b/src/libstore/windows/pathlocks.cc @@ -55,14 +55,14 @@ AutoCloseFD openLockFile(const std::filesystem::path & path, bool create) * Wine has incomplete file locking support, so we degrade gracefully. */ template -static bool warnOrThrowWine(DWORD lastError, const std::string & fs, const Args &... args) +static bool warnOrThrowWine(DWORD lastError, const std::string & fs, Args &&... args) { using namespace nix::windows; if (isWine()) { warn(fs + ": %s (ignored under Wine)", args..., lastError); return true; } - throw WinError(lastError, fs, args...); + throw WinError(lastError, fs, std::forward(args)...); } bool lockFile(Descriptor desc, LockType lockType, bool wait) diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc index 56172bf32b9a..d072d29e97c5 100644 --- a/src/libutil/archive.cc +++ b/src/libutil/archive.cc @@ -139,9 +139,9 @@ void dumpString(std::string_view s, Sink & sink) } template -static SerialisationError badArchive(std::string_view s, const Args &... args) +static SerialisationError badArchive(std::string_view s, Args &&... args) { - return SerialisationError("bad archive: " + s, args...); + return SerialisationError("bad archive: " + s, std::forward(args)...); } static void parseContents(CreateRegularFileSink & sink, Source & source) diff --git a/src/libutil/include/nix/util/processes.hh b/src/libutil/include/nix/util/processes.hh index bcc4374d22f8..9bef546b055b 100644 --- a/src/libutil/include/nix/util/processes.hh +++ b/src/libutil/include/nix/util/processes.hh @@ -147,8 +147,8 @@ public: int status; template - ExecError(int status, const Args &... args) - : CloneableError(args...) + ExecError(int status, Args &&... args) + : CloneableError(std::forward(args)...) , status(status) { }